Commit 21c32b08d5dfb015b49f0fa245dd264aaedba4a0

Behdad Esfahbod 2013-07-25T21:53:18

Add FT_FACE_FLAG_COLOR and FT_HAS_COLOR. Also disambiguate Google's color bitmap tables. * include/freetype/freetype.h (FT_FACE_FLAG_COLOR, FT_HAS_COLOR): New macros. * include/freetype/internal/tttypes.h (TT_SbitTableType): Add TT_SBIT_TABLE_TYPE_CBLC. * src/sfnt/sfobjs.c (sfnt_load_face): Handle FT_FACE_FLAG_COLOR. * src/sfnt/ttsbit.c (tt_face_load_sbit, tt_face_load_strike_metrics, tt_face_load_sbit_image): Handle TT_SBIT_TABLE_TYPE_CBLC.

diff --git a/ChangeLog b/ChangeLog
index aab1597..c15bda3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2013-07-25  Behdad Esfahbod  <behdad@google.com>
+
+	Add FT_FACE_FLAG_COLOR and FT_HAS_COLOR.
+
+	Also disambiguate Google's color bitmap tables.
+
+	* include/freetype/freetype.h (FT_FACE_FLAG_COLOR, FT_HAS_COLOR):
+	New macros.
+
+	* include/freetype/internal/tttypes.h (TT_SbitTableType): Add
+	TT_SBIT_TABLE_TYPE_CBLC.
+
+	* src/sfnt/sfobjs.c (sfnt_load_face): Handle FT_FACE_FLAG_COLOR.
+
+	* src/sfnt/ttsbit.c (tt_face_load_sbit,
+	tt_face_load_strike_metrics, tt_face_load_sbit_image): Handle
+	TT_SBIT_TABLE_TYPE_CBLC.
+
 2013-07-24  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
 
 	[sfnt] Fix for `make multi' target.
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index aa48977..6bbd840 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -98,7 +98,10 @@ FT_BEGIN_HEADER
   /*    FT_FACE_FLAG_FIXED_WIDTH                                           */
   /*    FT_FACE_FLAG_HORIZONTAL                                            */
   /*    FT_FACE_FLAG_VERTICAL                                              */
+  /*    FT_FACE_FLAG_COLOR                                                 */
   /*    FT_FACE_FLAG_SFNT                                                  */
+  /*    FT_FACE_FLAG_CID_KEYED                                             */
+  /*    FT_FACE_FLAG_TRICKY                                                */
   /*    FT_FACE_FLAG_KERNING                                               */
   /*    FT_FACE_FLAG_MULTIPLE_MASTERS                                      */
   /*    FT_FACE_FLAG_GLYPH_NAMES                                           */
@@ -1076,6 +1079,10 @@ FT_BEGIN_HEADER
   /*      Currently, there are about a dozen TrueType fonts in the list of */
   /*      tricky fonts; they are hard-coded in file `ttobjs.c'.            */
   /*                                                                       */
+  /*    FT_FACE_FLAG_COLOR ::                                              */
+  /*      Set if the font has color glyph tables.  To access color glyphs  */
+  /*      use @FT_LOAD_COLOR.                                              */
+  /*                                                                       */
 #define FT_FACE_FLAG_SCALABLE          ( 1L <<  0 )
 #define FT_FACE_FLAG_FIXED_SIZES       ( 1L <<  1 )
 #define FT_FACE_FLAG_FIXED_WIDTH       ( 1L <<  2 )
@@ -1090,6 +1097,7 @@ FT_BEGIN_HEADER
 #define FT_FACE_FLAG_HINTER            ( 1L << 11 )
 #define FT_FACE_FLAG_CID_KEYED         ( 1L << 12 )
 #define FT_FACE_FLAG_TRICKY            ( 1L << 13 )
+#define FT_FACE_FLAG_COLOR             ( 1L << 14 )
 
 
   /*************************************************************************
@@ -1274,6 +1282,20 @@ FT_BEGIN_HEADER
           ( face->face_flags & FT_FACE_FLAG_TRICKY )
 
 
+  /*************************************************************************
+   *
+   * @macro:
+   *   FT_HAS_COLOR( face )
+   *
+   * @description:
+   *   A macro that returns true whenever a face object contains
+   *   tables for color glyphs.
+   *
+   */
+#define FT_HAS_COLOR( face ) \
+          ( face->face_flags & FT_FACE_FLAG_COLOR )
+
+
   /*************************************************************************/
   /*                                                                       */
   /* <Const>                                                               */
diff --git a/include/freetype/internal/tttypes.h b/include/freetype/internal/tttypes.h
index 999e455..5709522 100644
--- a/include/freetype/internal/tttypes.h
+++ b/include/freetype/internal/tttypes.h
@@ -983,8 +983,8 @@ FT_BEGIN_HEADER
   {
     TT_SBIT_TABLE_TYPE_NONE = 0,
     TT_SBIT_TABLE_TYPE_EBLC, /* `EBLC' (Microsoft), */
-                             /* `bloc' (Apple), or  */
-                             /* `CBLC' (Google)     */
+                             /* `bloc' (Apple)      */
+    TT_SBIT_TABLE_TYPE_CBLC, /* `CBLC' (Google)     */
     TT_SBIT_TABLE_TYPE_SBIX, /* `sbix' (Apple)      */
 
     /* do not remove */
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index f94518a..412cc8e 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -812,6 +812,10 @@
       /*                                                                   */
       /* Compute face flags.                                               */
       /*                                                                   */
+      if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_CBLC ||
+           face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX )
+        flags |= FT_FACE_FLAG_COLOR;      /* color glyphs */
+
       if ( has_outline == TRUE )
         flags |= FT_FACE_FLAG_SCALABLE;   /* scalable outlines */
 
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index 74992c5..7d56851 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -55,14 +55,17 @@
     face->sbit_table_type  = TT_SBIT_TABLE_TYPE_NONE;
     face->sbit_num_strikes = 0;
 
-    /* this table is optional */
     error = face->goto_table( face, TTAG_CBLC, stream, &table_size );
-    if ( error )
-      error = face->goto_table( face, TTAG_EBLC, stream, &table_size );
-    if ( error )
-      error = face->goto_table( face, TTAG_bloc, stream, &table_size );
     if ( !error )
-      face->sbit_table_type = TT_SBIT_TABLE_TYPE_EBLC;
+      face->sbit_table_type = TT_SBIT_TABLE_TYPE_CBLC;
+    else
+    {
+      error = face->goto_table( face, TTAG_EBLC, stream, &table_size );
+      if ( error )
+        error = face->goto_table( face, TTAG_bloc, stream, &table_size );
+      if ( !error )
+        face->sbit_table_type = TT_SBIT_TABLE_TYPE_EBLC;
+    }
 
     if ( error )
     {
@@ -83,6 +86,7 @@
     switch ( (FT_UInt)face->sbit_table_type )
     {
     case TT_SBIT_TABLE_TYPE_EBLC:
+    case TT_SBIT_TABLE_TYPE_CBLC:
       {
         FT_Byte*  p;
         FT_Fixed  version;
@@ -227,6 +231,7 @@
     switch ( (FT_UInt)face->sbit_table_type )
     {
     case TT_SBIT_TABLE_TYPE_EBLC:
+    case TT_SBIT_TABLE_TYPE_CBLC:
       {
         FT_Byte*  strike;
 
@@ -1343,6 +1348,7 @@
     switch ( (FT_UInt)face->sbit_table_type )
     {
     case TT_SBIT_TABLE_TYPE_EBLC:
+    case TT_SBIT_TABLE_TYPE_CBLC:
       {
         TT_SBitDecoderRec  decoder[1];