>From fe1c90c79a6070bda504c150aedfce63e75053f6 Mon Sep 17 00:00:00 2001
From: Behdad Esfahbod
Date: Mon, 22 Jul 2013 13:46:05 -0400
Subject: [PATCH] Add FT_FACE_FLAG_COLOR and FT_HAS_COLOR
---
include/freetype/freetype.h | 20 ++++++++++++++++++++
include/freetype/internal/tttypes.h | 4 ++--
src/sfnt/sfobjs.c | 4 ++++
src/sfnt/ttsbit.c | 18 ++++++++++++------
4 files changed, 38 insertions(+), 8 deletions(-)
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index aa48977..e6be760 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -1076,6 +1076,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 +1094,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 +1279,21 @@ 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 )
+
+
+
/*************************************************************************/
/* */
/* */
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];
--
1.8.3