Commit 778a7e6a36912303d9cb8b16b7aceacf3572d325

Behdad Esfahbod 2013-07-19T14:28:28

[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.

diff --git a/ChangeLog b/ChangeLog
index 4fa89e6..f525b2d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2013-07-18  Behdad Esfahbod  <behdad@google.com>
 
+	[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  <behdad@google.com>
+
 	[sfnt] Add support for Apple's `sbix' color bitmap table.
 
 	* include/freetype/internal/tttypes.h (TT_SBit_MetricsRec): Widen
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index f975e71..f94518a 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 2fc0ef1..c147251 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;