diff options
author | Werner Lemberg <wl@gnu.org> | 2022-02-07 06:55:54 +0100 |
---|---|---|
committer | Werner Lemberg <wl@gnu.org> | 2022-03-25 06:37:41 +0000 |
commit | ac4c1ebf7edb3c142c5c4ad9b3345d95325750fd (patch) | |
tree | 97a8db7f4cee075015dc9963507cd9bfdfabb0ca /src/sfnt | |
parent | 907715a6a214001db7504983f6cf2a48e8b33053 (diff) | |
download | freetype2-ac4c1ebf7edb3c142c5c4ad9b3345d95325750fd.tar.gz |
[truetype] Fix 'sbix' table handling.
* src/sfnt/ttsbit.c (tt_face_load_sbix_image): Correct calculation of
'metrics->horiBearingY'.
Set vertical metrics.
* src/sfnt/sfobjs.c (sfnt_load_face): Adjust setting of `FT_FACE_FLAG_SBIX`.
Handle metrics of fonts with 'sbix' table.
* src/truetype/ttgload.c (TT_Load_Glyph): For 'sbix' embedded bitmaps, apply
bbox offset and bearing values of the corresponding glyph in the 'glyf'
table if it exists and has a contour.
* src/truetype/ttobjs.c (tt_face_init): Handle font with 'sbix' table.
Fixes issue #998.
Diffstat (limited to 'src/sfnt')
-rw-r--r-- | src/sfnt/sfobjs.c | 19 | ||||
-rw-r--r-- | src/sfnt/ttsbit.c | 21 |
2 files changed, 27 insertions, 13 deletions
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index 008962b2f..614ff68de 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -851,12 +851,6 @@ is_apple_sbit = 0; is_apple_sbix = !face->goto_table( face, TTAG_sbix, stream, 0 ); - /* Apple 'sbix' color bitmaps are rendered scaled and then the 'glyf' - * outline rendered on top. We don't support that yet, so just ignore - * the 'glyf' outline and advertise it as a bitmap-only font. */ - if ( is_apple_sbix ) - has_outline = FALSE; - /* if this font doesn't contain outlines, we try to load */ /* a `bhed' table */ if ( !has_outline && sfnt->load_bhed ) @@ -1059,10 +1053,12 @@ if ( has_outline == TRUE ) { - flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */ - - if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX ) - flags |= FT_FACE_FLAG_SBIX; /* and 'sbix' bitmaps */ + /* by default (and for backward compatibility) we handle */ + /* fonts with an 'sbix' table as bitmap-only */ + if ( is_apple_sbix ) + flags |= FT_FACE_FLAG_SBIX; /* with 'sbix' bitmaps */ + else + flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */ } /* The sfnt driver only supports bitmap fonts natively, thus we */ @@ -1286,7 +1282,8 @@ * * Set up metrics. */ - if ( FT_IS_SCALABLE( root ) ) + if ( FT_IS_SCALABLE( root ) || + FT_HAS_SBIX( root ) ) { /* XXX What about if outline header is missing */ /* (e.g. sfnt wrapped bitmap)? */ diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c index 179e9cc55..0ab602632 100644 --- a/src/sfnt/ttsbit.c +++ b/src/sfnt/ttsbit.c @@ -1580,17 +1580,34 @@ if ( !error ) { - FT_Short abearing; + FT_Short abearing; /* not used here */ FT_UShort aadvance; tt_face_get_metrics( face, FALSE, glyph_index, &abearing, &aadvance ); metrics->horiBearingX = (FT_Short)originOffsetX; - metrics->horiBearingY = (FT_Short)( -originOffsetY + metrics->height ); + metrics->vertBearingX = (FT_Short)originOffsetX; + + metrics->horiBearingY = (FT_Short)( originOffsetY + metrics->height ); + metrics->vertBearingY = (FT_Short)originOffsetY; + metrics->horiAdvance = (FT_UShort)( aadvance * face->root.size->metrics.x_ppem / face->header.Units_Per_EM ); + + if ( face->vertical_info ) + tt_face_get_metrics( face, TRUE, glyph_index, &abearing, &aadvance ); + else if ( face->os2.version != 0xFFFFU ) + aadvance = (FT_UShort)FT_ABS( face->os2.sTypoAscender - + face->os2.sTypoDescender ); + else + aadvance = (FT_UShort)FT_ABS( face->horizontal.Ascender - + face->horizontal.Descender ); + + metrics->vertAdvance = (FT_UShort)( aadvance * + face->root.size->metrics.x_ppem / + face->header.Units_Per_EM ); } return error; |