From 778a7e6a36912303d9cb8b16b7aceacf3572d325 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 19 Jul 2013 14:28:28 +0200 Subject: [PATCH] [sfnt] `sbix' fix-ups. * src/sfnt/sfobjs.c (sfnt_load_face): Apple's `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. * src/sfnt/ttsbit.c (tt_face_load_strike_metrics) [TT_SBIT_TABLE_TYPE_SBIX]: Return metrics in 26.6 units. (tt_face_load_sbix_image): Typo. --- ChangeLog | 13 +++++++++++++ src/sfnt/sfobjs.c | 11 ++++++++++- src/sfnt/ttsbit.c | 10 +++++----- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4fa89e6c8..f525b2d66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2013-07-18 Behdad Esfahbod + + [sfnt] `sbix' fix-ups. + + * src/sfnt/sfobjs.c (sfnt_load_face): Apple's `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. + + * src/sfnt/ttsbit.c (tt_face_load_strike_metrics) + [TT_SBIT_TABLE_TYPE_SBIX]: Return metrics in 26.6 units. + (tt_face_load_sbix_image): Typo. + 2013-07-18 Behdad Esfahbod [sfnt] Add support for Apple's `sbix' color bitmap table. diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index f975e71c3..f94518ac2 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -555,6 +555,7 @@ #endif FT_Bool has_outline; FT_Bool is_apple_sbit; + FT_Bool is_apple_sbix; FT_Bool ignore_preferred_family = FALSE; FT_Bool ignore_preferred_subfamily = FALSE; @@ -608,6 +609,14 @@ #endif 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 */ @@ -619,7 +628,7 @@ /* load the font header (`head' table) if this isn't an Apple */ /* sbit font file */ - if ( !is_apple_sbit ) + if ( !is_apple_sbit || is_apple_sbix ) { LOAD_( head ); if ( error ) diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c index 2fc0ef154..c147251f1 100644 --- a/src/sfnt/ttsbit.c +++ b/src/sfnt/ttsbit.c @@ -286,12 +286,12 @@ metrics->x_ppem = ppem; metrics->y_ppem = ppem; - metrics->ascender = ppem * hori->Ascender / upem; - metrics->descender = ppem * hori->Descender / upem; + metrics->ascender = ppem * hori->Ascender * 64 / upem; + metrics->descender = ppem * hori->Descender * 64 / upem; metrics->height = ppem * ( hori->Ascender - hori->Descender + - hori->Line_Gap ) / upem; - metrics->max_advance = ppem * hori->advance_Width_Max / upem; + hori->Line_Gap ) * 64 / upem; + metrics->max_advance = ppem * hori->advance_Width_Max * 64 / upem; return error; } @@ -1322,7 +1322,7 @@ metrics->horiBearingX = originOffsetX; metrics->horiBearingY = -originOffsetY + metrics->height; metrics->horiAdvance = aadvance * face->root.size->metrics.x_ppem / - face->root.units_per_EM; + face->header.Units_Per_EM; } return error;