[bdf] Postpone font ascent and descent handling.

* src/bdf/bdflib.c (bdf_parse_start_, bdf_add_property_): Delay handling
of the font ascent and descent until...
* src/bdf/bdfdrivr.c (BDF_Face_Init): ... handles all other properties.
master
Alexei Podtelezhnikov 1 month ago
parent c33da8fbbd
commit c0a7839e7d
  1. 32
      src/bdf/bdfdrivr.c
  2. 52
      src/bdf/bdflib.c

@ -439,19 +439,25 @@ THE SOFTWARE.
long value;
/* sanity checks */
if ( font->font_ascent > 0x7FFF || font->font_ascent < -0x7FFF )
{
font->font_ascent = font->font_ascent < 0 ? -0x7FFF : 0x7FFF;
FT_TRACE0(( "BDF_Face_Init: clamping font ascent to value %ld\n",
font->font_ascent ));
}
if ( font->font_descent > 0x7FFF || font->font_descent < -0x7FFF )
{
font->font_descent = font->font_descent < 0 ? -0x7FFF : 0x7FFF;
FT_TRACE0(( "BDF_Face_Init: clamping font descent to value %ld\n",
font->font_descent ));
}
prop = bdf_get_font_property( font, "FONT_ASCENT" );
if ( prop )
font->font_ascent = prop->value.l;
else
font->font_ascent = font->bbx.ascent;
if ( font->font_ascent > 0x7FFF )
font->font_ascent = 0x7FFF;
else if ( font->font_ascent < 0 )
font->font_ascent = 0;
prop = bdf_get_font_property( font, "FONT_DESCENT" );
if ( prop )
font->font_descent = prop->value.l;
else
font->font_descent = font->bbx.descent;
if ( font->font_descent > 0x7FFF )
font->font_descent = 0x7FFF;
else if ( font->font_descent < 0 )
font->font_descent = 0;
bsize->height = (FT_Short)( font->font_ascent + font->font_descent );

@ -51,9 +51,6 @@
#define FT_COMPONENT bdflib
#define BUFSIZE 128
/**************************************************************************
*
* Builtin BDF font properties.
@ -866,10 +863,6 @@
/* spacing. */
if ( _bdf_strncmp( name, "DEFAULT_CHAR", 12 ) == 0 )
font->default_char = fp->value.ul;
else if ( _bdf_strncmp( name, "FONT_ASCENT", 11 ) == 0 )
font->font_ascent = fp->value.l;
else if ( _bdf_strncmp( name, "FONT_DESCENT", 12 ) == 0 )
font->font_descent = fp->value.l;
else if ( _bdf_strncmp( name, "SPACING", 7 ) == 0 )
{
if ( !fp->value.atom )
@ -1605,11 +1598,7 @@
/* Check for the CHARS field */
if ( _bdf_strncmp( line, "CHARS", 5 ) == 0 )
{
char nbuf[BUFSIZE];
/* Check the header for completeness before leaving. */
/* Check the header for completeness before parsing glyphs. */
if ( !( p->flags & BDF_FONT_NAME_ ) )
{
/* Missing the FONT field. */
@ -1617,7 +1606,6 @@
error = FT_THROW( Missing_Font_Field );
goto Exit;
}
if ( !( p->flags & BDF_SIZE_ ) )
{
/* Missing the SIZE field. */
@ -1625,7 +1613,6 @@
error = FT_THROW( Missing_Size_Field );
goto Exit;
}
if ( !( p->flags & BDF_FONT_BBX_ ) )
{
/* Missing the FONTBOUNDINGBOX field. */
@ -1634,43 +1621,6 @@
goto Exit;
}
/* Reserve space for artificial FONT_ASCENT or FONT_DESCENT. */
if ( font->props_size == 0 )
{
if ( FT_NEW_ARRAY( font->props, 2 ) )
goto Exit;
font->props_size = 2;
}
/* If the FONT_ASCENT or FONT_DESCENT properties have not been */
/* encountered yet, then make sure they are added as properties and */
/* make sure they are set from the font bounding box info. */
/* */
/* This is *always* done regardless of the options, because X11 */
/* requires these two fields to compile fonts. */
if ( bdf_get_font_property( font, "FONT_ASCENT" ) == 0 )
{
font->font_ascent = font->bbx.ascent;
ft_snprintf( nbuf, BUFSIZE, "%hd", font->bbx.ascent );
error = bdf_add_property_( font, "FONT_ASCENT", nbuf, lineno );
if ( error )
goto Exit;
FT_TRACE2(( "bdf_parse_start_: " ACMSG1, font->bbx.ascent ));
}
if ( bdf_get_font_property( font, "FONT_DESCENT" ) == 0 )
{
font->font_descent = font->bbx.descent;
ft_snprintf( nbuf, BUFSIZE, "%hd", font->bbx.descent );
error = bdf_add_property_( font, "FONT_DESCENT", nbuf, lineno );
if ( error )
goto Exit;
FT_TRACE2(( "bdf_parse_start_: " ACMSG2, font->bbx.descent ));
}
line = bdf_strtok_( line, ' ' );
p->cnt = font->glyphs_size = bdf_atoul_( line );

Loading…
Cancel
Save