[bdf] Use flags instead of options.
* src/bdf/bdf.h (bdf_options_t): Removed. (BDF_KEEP_COMMENTS, BDF_KEEP_UNENCODED, BDF_CORRECT_METRICS): Updated to avoid collisions with the other parsing flags. * src/bdf/bdfdrivr.c (BDF_Face_Init): Use default flags explicitly. * src/bdf/bdflib.c (bdf_load_font): Use flags as an argument to initialize the parser. (bdf_set_fedault_spacing_): Default to BDF_PROPORTIONAL explicitly. (bdf_parse_*_): Updated.
This commit is contained in:
parent
a05c22103d
commit
a3c68e3b48
|
@ -57,39 +57,13 @@ FT_BEGIN_HEADER
|
|||
*/
|
||||
|
||||
|
||||
#define BDF_CORRECT_METRICS 0x01 /* Correct invalid metrics when loading. */
|
||||
#define BDF_KEEP_COMMENTS 0x02 /* Preserve the font comments. */
|
||||
#define BDF_KEEP_UNENCODED 0x04 /* Keep the unencoded glyphs. */
|
||||
#define BDF_PROPORTIONAL 0x08 /* Font has proportional spacing. */
|
||||
#define BDF_MONOWIDTH 0x10 /* Font has mono width. */
|
||||
#define BDF_CHARCELL 0x20 /* Font has charcell spacing. */
|
||||
#define BDF_CORRECT_METRICS 0x1000 /* Correct metrics when loading. */
|
||||
#define BDF_KEEP_COMMENTS 0x2000 /* Preserve the font comments. */
|
||||
#define BDF_KEEP_UNENCODED 0x4000 /* Keep the unencoded glyphs. */
|
||||
|
||||
#define BDF_ALL_SPACING ( BDF_PROPORTIONAL | \
|
||||
BDF_MONOWIDTH | \
|
||||
BDF_CHARCELL )
|
||||
|
||||
#define BDF_DEFAULT_LOAD_OPTIONS ( BDF_CORRECT_METRICS | \
|
||||
BDF_KEEP_COMMENTS | \
|
||||
BDF_KEEP_UNENCODED | \
|
||||
BDF_PROPORTIONAL )
|
||||
|
||||
|
||||
typedef struct bdf_options_t_
|
||||
{
|
||||
int correct_metrics;
|
||||
int keep_unencoded;
|
||||
int keep_comments;
|
||||
int font_spacing;
|
||||
|
||||
} bdf_options_t;
|
||||
|
||||
|
||||
/* Callback function type for unknown configuration options. */
|
||||
typedef int
|
||||
(*bdf_options_callback_t)( bdf_options_t* opts,
|
||||
char** params,
|
||||
unsigned long nparams,
|
||||
void* client_data );
|
||||
#define BDF_PROPORTIONAL 0x08 /* Font has proportional spacing. */
|
||||
#define BDF_MONOWIDTH 0x10 /* Font has mono width. */
|
||||
#define BDF_CHARCELL 0x20 /* Font has charcell spacing. */
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
|
@ -233,7 +207,7 @@ FT_BEGIN_HEADER
|
|||
FT_LOCAL( FT_Error )
|
||||
bdf_load_font( FT_Stream stream,
|
||||
FT_Memory memory,
|
||||
bdf_options_t* opts,
|
||||
unsigned long flags,
|
||||
bdf_font_t* *font );
|
||||
|
||||
FT_LOCAL( void )
|
||||
|
|
|
@ -349,7 +349,6 @@ THE SOFTWARE.
|
|||
FT_Memory memory = FT_FACE_MEMORY( face );
|
||||
|
||||
bdf_font_t* font = NULL;
|
||||
bdf_options_t options;
|
||||
|
||||
FT_UNUSED( num_params );
|
||||
FT_UNUSED( params );
|
||||
|
@ -360,12 +359,8 @@ THE SOFTWARE.
|
|||
if ( FT_STREAM_SEEK( 0 ) )
|
||||
goto Exit;
|
||||
|
||||
options.correct_metrics = 1; /* FZ XXX: options semantics */
|
||||
options.keep_unencoded = 1;
|
||||
options.keep_comments = 0;
|
||||
options.font_spacing = BDF_PROPORTIONAL;
|
||||
|
||||
error = bdf_load_font( stream, memory, &options, &font );
|
||||
error = bdf_load_font( stream, memory,
|
||||
BDF_CORRECT_METRICS | BDF_KEEP_UNENCODED, &font );
|
||||
if ( FT_ERR_EQ( error, Missing_Startfont_Field ) )
|
||||
{
|
||||
FT_TRACE2(( " not a BDF file\n" ));
|
||||
|
|
|
@ -54,22 +54,6 @@
|
|||
#define BUFSIZE 128
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Default BDF font options.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
static const bdf_options_t bdf_opts_ =
|
||||
{
|
||||
1, /* Correct metrics. */
|
||||
1, /* Preserve unencoded glyphs. */
|
||||
0, /* Preserve comments. */
|
||||
BDF_PROPORTIONAL /* Default spacing. */
|
||||
};
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Builtin BDF font properties.
|
||||
|
@ -270,7 +254,6 @@
|
|||
|
||||
bdf_glyph_t* glyph;
|
||||
bdf_font_t* font;
|
||||
bdf_options_t* opts;
|
||||
|
||||
bdf_list_t_ list;
|
||||
|
||||
|
@ -954,11 +937,10 @@
|
|||
}
|
||||
|
||||
|
||||
/* Set the spacing from the font name if it exists, or set it to the */
|
||||
/* default specified in the options. */
|
||||
/* Set the spacing from the font name if it exists, */
|
||||
/* or use default */
|
||||
static FT_Error
|
||||
bdf_set_default_spacing_( bdf_font_t* font,
|
||||
bdf_options_t* opts,
|
||||
unsigned long lineno )
|
||||
{
|
||||
size_t len;
|
||||
|
@ -980,7 +962,7 @@
|
|||
|
||||
bdf_list_init_( &list, memory );
|
||||
|
||||
font->spacing = opts->font_spacing;
|
||||
font->spacing = BDF_PROPORTIONAL; /* default */
|
||||
|
||||
len = ft_strlen( font->name ) + 1;
|
||||
/* Limit ourselves to 256 characters in the font name. */
|
||||
|
@ -1356,7 +1338,7 @@
|
|||
/* Check for a comment. */
|
||||
if ( _bdf_strncmp( line, "COMMENT", 7 ) == 0 )
|
||||
{
|
||||
if ( p->opts->keep_comments )
|
||||
if ( p->flags & BDF_KEEP_COMMENTS )
|
||||
{
|
||||
linelen -= 7;
|
||||
|
||||
|
@ -1408,9 +1390,9 @@
|
|||
|
||||
/* Check whether a glyph is being scanned but should be */
|
||||
/* ignored because it is an unencoded glyph. */
|
||||
if ( ( p->flags & BDF_GLYPH_ ) &&
|
||||
p->glyph_enc == -1 &&
|
||||
p->opts->keep_unencoded == 0 )
|
||||
if ( p->flags & BDF_GLYPH_ &&
|
||||
p->glyph_enc == -1 &&
|
||||
!( p->flags & BDF_KEEP_UNENCODED ) )
|
||||
goto Exit;
|
||||
|
||||
/* Check for the STARTCHAR field. */
|
||||
|
@ -1500,7 +1482,7 @@
|
|||
glyph->name = p->glyph_name;
|
||||
glyph->encoding = (unsigned long)p->glyph_enc;
|
||||
}
|
||||
else if ( p->opts->keep_unencoded )
|
||||
else if ( p->flags & BDF_KEEP_UNENCODED )
|
||||
{
|
||||
/* Allocate the next unencoded glyph. */
|
||||
if ( font->unencoded_used == font->unencoded_size )
|
||||
|
@ -1617,7 +1599,7 @@
|
|||
|
||||
/* If the BDF_CORRECT_METRICS flag is set, then adjust the SWIDTH */
|
||||
/* value if necessary. */
|
||||
if ( p->opts->correct_metrics )
|
||||
if ( p->flags & BDF_CORRECT_METRICS )
|
||||
{
|
||||
/* Determine the point size of the glyph. */
|
||||
unsigned short sw = (unsigned short)FT_MulDiv(
|
||||
|
@ -1788,7 +1770,7 @@
|
|||
/* comments before the STARTFONT line for some reason. */
|
||||
if ( _bdf_strncmp( line, "COMMENT", 7 ) == 0 )
|
||||
{
|
||||
if ( p->opts->keep_comments && p->font )
|
||||
if ( p->flags & BDF_KEEP_COMMENTS && p->font )
|
||||
{
|
||||
linelen -= 7;
|
||||
|
||||
|
@ -1842,7 +1824,7 @@
|
|||
error = ft_hash_str_init( p->font->internal, memory );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
p->font->spacing = p->opts->font_spacing;
|
||||
p->font->spacing = BDF_PROPORTIONAL;
|
||||
p->font->default_char = ~0UL;
|
||||
|
||||
goto Exit;
|
||||
|
@ -1945,7 +1927,7 @@
|
|||
|
||||
/* If the font name is an XLFD name, set the spacing to the one in */
|
||||
/* the font name. If there is no spacing fall back on the default. */
|
||||
error = bdf_set_default_spacing_( font, p->opts, lineno );
|
||||
error = bdf_set_default_spacing_( font, lineno );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
|
@ -2096,7 +2078,7 @@
|
|||
FT_LOCAL_DEF( FT_Error )
|
||||
bdf_load_font( FT_Stream stream,
|
||||
FT_Memory memory,
|
||||
bdf_options_t* opts,
|
||||
unsigned long flags,
|
||||
bdf_font_t* *font )
|
||||
{
|
||||
unsigned long lineno = 0; /* make compiler happy */
|
||||
|
@ -2108,7 +2090,7 @@
|
|||
if ( FT_NEW( p ) )
|
||||
goto Exit;
|
||||
|
||||
p->opts = (bdf_options_t*)( opts ? opts : &bdf_opts_ );
|
||||
p->flags = flags; /* comments, metrics, unencoded */
|
||||
p->minlb = 32767;
|
||||
p->size = stream->size;
|
||||
p->memory = memory; /* only during font creation */
|
||||
|
@ -2138,7 +2120,7 @@
|
|||
|
||||
/* Once the font has been loaded, adjust the overall font metrics if */
|
||||
/* necessary. */
|
||||
if ( p->opts->correct_metrics != 0 &&
|
||||
if ( p->flags & BDF_CORRECT_METRICS &&
|
||||
( p->font->glyphs_used > 0 || p->font->unencoded_used > 0 ) )
|
||||
{
|
||||
if ( p->maxrb - p->minlb != p->font->bbx.width )
|
||||
|
|
Loading…
Reference in New Issue