From 5e094c6fb2ddd6e8901a5679e2cbb8fa476a38ee Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Mon, 10 Jun 2013 14:59:21 +0200 Subject: [PATCH] [truetype] Improve handling of broken sbit advance widths. * src/truetype/ttgload.c (TT_Load_Glyph): Use the glyph's (scaled) `linearHoriAdvance' if the sbit's `horiAdvance' value is zero. Cf. font `Fixedsys Excelsior' v3.01 (FSEX300.ttf), glyph A, 16ppem. --- ChangeLog | 9 +++++++++ src/truetype/ttgload.c | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index d9edc2ad0..9968449e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2013-06-10 Werner Lemberg + + [truetype] Improve handling of broken sbit advance widths. + + * src/truetype/ttgload.c (TT_Load_Glyph): Use the glyph's (scaled) + `linearHoriAdvance' if the sbit's `horiAdvance' value is zero. + + Cf. font `Fixedsys Excelsior' v3.01 (FSEX300.ttf), glyph A, 16ppem. + 2013-06-10 Werner Lemberg [sfnt] Improve embedded bitmap tracing. diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index bd2478b54..f640a6c78 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -2224,6 +2224,13 @@ glyph->linearHoriAdvance = loader.linear; glyph->linearVertAdvance = loader.top_bearing + loader.bbox.yMax - loader.vadvance; + + /* sanity check: if `horiAdvance' in the sbit metric */ + /* structure isn't set, use `linearHoriAdvance' */ + if ( !glyph->metrics.horiAdvance && glyph->linearHoriAdvance ) + glyph->metrics.horiAdvance = + FT_MulFix( glyph->linearHoriAdvance, + size->root.metrics.x_scale ); } return FT_Err_Ok;