[truetype] Fix advance of empty glyphs in bitmap fonts (#53393).

* src/truetype/ttgload.c (TT_Load_Glyph): Apply scaling to metrics
for empty bitmaps.
This commit is contained in:
Ben Wagner 2018-03-23 06:07:24 +01:00 committed by Werner Lemberg
parent af89e445f8
commit 43d4852ec6
2 changed files with 26 additions and 13 deletions

View File

@ -1,3 +1,10 @@
2018-03-23 Ben Wagner <bungeman@google.com>
[truetype] Fix advance of empty glyphs in bitmap fonts (#53393).
* src/truetype/ttgload.c (TT_Load_Glyph): Apply scaling to metrics
for empty bitmaps.
2018-03-22 Werner Lemberg <wl@gnu.org>
Remove `ftlcdfil.c' and `ftfntfmt.c' from build files (#53415).

View File

@ -2709,6 +2709,10 @@
( load_flags & FT_LOAD_NO_BITMAP ) == 0 &&
IS_DEFAULT_INSTANCE )
{
FT_Fixed x_scale = size->root.metrics.x_scale;
FT_Fixed y_scale = size->root.metrics.y_scale;
error = load_sbit_image( size, glyph, glyph_index, load_flags );
if ( FT_ERR_EQ( error, Missing_Bitmap ) )
{
@ -2716,9 +2720,13 @@
/* if we have a bitmap-only font, return an empty glyph */
if ( !FT_IS_SCALABLE( glyph->face ) )
{
TT_Face face = (TT_Face)glyph->face;
FT_Short left_bearing = 0, top_bearing = 0;
FT_UShort advance_width = 0, advance_height = 0;
TT_Face face = (TT_Face)glyph->face;
FT_Short left_bearing = 0;
FT_Short top_bearing = 0;
FT_UShort advance_width = 0;
FT_UShort advance_height = 0;
/* to return an empty glyph, however, we need metrics data */
@ -2744,13 +2752,13 @@
glyph->metrics.width = 0;
glyph->metrics.height = 0;
glyph->metrics.horiBearingX = left_bearing;
glyph->metrics.horiBearingX = FT_MulFix( left_bearing, x_scale );
glyph->metrics.horiBearingY = 0;
glyph->metrics.horiAdvance = advance_width;
glyph->metrics.horiAdvance = FT_MulFix( advance_width, x_scale );
glyph->metrics.vertBearingX = 0;
glyph->metrics.vertBearingY = top_bearing;
glyph->metrics.vertAdvance = advance_height;
glyph->metrics.vertBearingY = FT_MulFix( top_bearing, y_scale );
glyph->metrics.vertAdvance = FT_MulFix( advance_height, y_scale );
glyph->format = FT_GLYPH_FORMAT_BITMAP;
glyph->bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
@ -2781,13 +2789,11 @@
/* sanity checks: if `xxxAdvance' in the sbit metric */
/* structure isn't set, use `linearXXXAdvance' */
if ( !glyph->metrics.horiAdvance && glyph->linearHoriAdvance )
glyph->metrics.horiAdvance =
FT_MulFix( glyph->linearHoriAdvance,
size->metrics->x_scale );
glyph->metrics.horiAdvance = FT_MulFix( glyph->linearHoriAdvance,
x_scale );
if ( !glyph->metrics.vertAdvance && glyph->linearVertAdvance )
glyph->metrics.vertAdvance =
FT_MulFix( glyph->linearVertAdvance,
size->metrics->y_scale );
glyph->metrics.vertAdvance = FT_MulFix( glyph->linearVertAdvance,
y_scale );
}
return FT_Err_Ok;