Commit 2429dc3d7c209a35d2026fa9f864e0ba785cf697

Werner Lemberg 2013-06-03T12:41:58

Add CFF_CONFIG_OPTION_OLD_ENGINE configuration option. This controls whether the old FreeType CFF engine gets compiled into FreeType. It is now disabled by default. * devel/ftoption.h, include/freetype/config/ftoption.h (CFF_CONFIG_OPTION_OLD_ENGINE): New macro. * src/cff/cffdrivr.c (cff_property_set), src/cff/cffgload.c (CFF_Operator, cff_argument_counts, cff_builder_add_point, cff_operator_seac, cff_decoder_parse_charstrings, cff_slot_load), src/cff/cffgload.h, src/cff/cffobjs.c (cff_driver_init): Use CFF_CONFIG_OPTION_OLD_ENGINE to guard the affected code. * docs/CHANGES: Updated.

diff --git a/ChangeLog b/ChangeLog
index 85e9d40..d10c8f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2013-06-03  Werner Lemberg  <wl@gnu.org>
+
+	Add CFF_CONFIG_OPTION_OLD_ENGINE configuration option.
+
+	This controls whether the old FreeType CFF engine gets compiled into
+	FreeType.  It is now disabled by default.
+
+	* devel/ftoption.h, include/freetype/config/ftoption.h
+	(CFF_CONFIG_OPTION_OLD_ENGINE): New macro.
+
+	* src/cff/cffdrivr.c (cff_property_set), src/cff/cffgload.c
+	(CFF_Operator, cff_argument_counts, cff_builder_add_point,
+	cff_operator_seac, cff_decoder_parse_charstrings, cff_slot_load),
+	src/cff/cffgload.h, src/cff/cffobjs.c (cff_driver_init): Use
+	CFF_CONFIG_OPTION_OLD_ENGINE to guard the affected code.
+
+	* docs/CHANGES: Updated.
+
 2013-06-02  Werner Lemberg  <wl@gnu.org>
 
 	Fix PNG library handling.
diff --git a/devel/ftoption.h b/devel/ftoption.h
index 0696018..ccb2321 100644
--- a/devel/ftoption.h
+++ b/devel/ftoption.h
@@ -752,6 +752,25 @@ FT_BEGIN_HEADER
   /*************************************************************************/
   /*************************************************************************/
   /****                                                                 ****/
+  /****         C F F   D R I V E R    C O N F I G U R A T I O N        ****/
+  /****                                                                 ****/
+  /*************************************************************************/
+  /*************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* CFF_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe CFF       */
+  /* engine gets compiled into FreeType.  If defined, it is possible to    */
+  /* switch between the two engines using the `hinting-engine' property of */
+  /* the cff driver module.                                                */
+  /*                                                                       */
+/* #define CFF_CONFIG_OPTION_OLD_ENGINE */
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /****                                                                 ****/
   /****    A U T O F I T   M O D U L E    C O N F I G U R A T I O N     ****/
   /****                                                                 ****/
   /*************************************************************************/
diff --git a/docs/CHANGES b/docs/CHANGES
index 2636796..4b6d523 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -21,11 +21,42 @@ CHANGES BETWEEN 2.4.12 and 2.5
       Note that  color bitmaps  are converted  to grayscale  if client
       didn't ask for color.
 
+    - As  announced in  the  previous release,  the  old FreeType  CFF
+      engine  is now  disabled by  default.  It  can be  conditionally
+      compiled     by     defining     the     configuration     macro
+      CFF_CONFIG_OPTION_OLD_ENGINE.
+
     - As announced in the previous release,  all code related to macro
       FT_CONFIG_OPTION_OLD_INTERNALS  has been removed,  thus becoming
       obsolete.
 
 
+  II. MISCELLANEOUS
+
+    - The  property API  (`FT_Property_Get' and  `FT_Property_Set') is
+      now declared as stable.
+
+    - `ftview' has been updated to support color embedded bitmaps; it
+      can be toggled on and off with key `c'.
+
+    - It  is now  possible  to  control the  version  of the  TrueType
+      hinting engine  using the new `interpreter-version'  property of
+      the  `truetype' module:  Versions 35  and 38  (the default)  are
+      supported,  which  roughly  corresponds to  disable  and  enable
+      subpixel hinting support, respectively.
+
+      In  both  `ftview'  and  `ftdiff',  switching  between  the  two
+      versions  can be  done  with  key `H'.   In  the `ftbench'  demo
+      program, command line option `-H'  has been extended to activate
+      the non-default interpreter version.
+
+    - Another round of TrueType subpixel hinting fixes.
+
+    - The `apinames' tool can now create an import file for NetWare.
+
+    - 64bit compilation of the new CFF engine was buggy.
+
+
 ======================================================================
 
 CHANGES BETWEEN 2.4.11 and 2.4.12
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index d2254bb..d162780 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -752,6 +752,25 @@ FT_BEGIN_HEADER
   /*************************************************************************/
   /*************************************************************************/
   /****                                                                 ****/
+  /****         C F F   D R I V E R    C O N F I G U R A T I O N        ****/
+  /****                                                                 ****/
+  /*************************************************************************/
+  /*************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* CFF_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe CFF       */
+  /* engine gets compiled into FreeType.  If defined, it is possible to    */
+  /* switch between the two engines using the `hinting-engine' property of */
+  /* the cff driver module.                                                */
+  /*                                                                       */
+#define CFF_CONFIG_OPTION_OLD_ENGINE
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /****                                                                 ****/
   /****    A U T O F I T   M O D U L E    C O N F I G U R A T I O N     ****/
   /****                                                                 ****/
   /*************************************************************************/
diff --git a/include/freetype/ftcffdrv.h b/include/freetype/ftcffdrv.h
index 07ae54d..ccbcbcc 100644
--- a/include/freetype/ftcffdrv.h
+++ b/include/freetype/ftcffdrv.h
@@ -61,11 +61,12 @@ FT_BEGIN_HEADER
    *
    * @description:
    *   Thanks to Adobe, which contributed a new hinting (and parsing)
-   *   engine, an application can select between `freetype' and `adobe'.
+   *   engine, an application can select between `freetype' and `adobe' if
+   *   compiled with CFF_CONFIG_OPTION_OLD_ENGINE.  If this configuration
+   *   macro isn't defined, `hinting-engine' does nothing.
    *
-   *   Right now, the default engine is `freetype'.  However, this will
-   *   change: After a certain time of intensive testing it is planned to
-   *   make `adobe' the default due to its superior rendering results.
+   *   The default engine is `freetype' if CFF_CONFIG_OPTION_OLD_ENGINE is
+   *   defined, and `adobe' otherwise.
    *
    *   The following example code demonstrates how to select Adobe's hinting
    *   engine (omitting the error handling).
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 0bbbed0..c8ca96b 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -38,6 +38,7 @@
 #include FT_SERVICE_XFREE86_NAME_H
 #include FT_SERVICE_GLYPH_DICT_H
 #include FT_SERVICE_PROPERTIES_H
+#include FT_CFF_DRIVER_H
 
 
   /*************************************************************************/
@@ -590,7 +591,12 @@
       FT_UInt*  hinting_engine = (FT_UInt*)value;
 
 
-      driver->hinting_engine = *hinting_engine;
+#ifndef CFF_CONFIG_OPTION_OLD_ENGINE
+      if ( *hinting_engine != FT_CFF_HINTING_ADOBE )
+        error = FT_ERR( Unimplemented_Feature );
+      else
+#endif
+        driver->hinting_engine = *hinting_engine;
 
       return error;
     }
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 4b6f417..1904ca0 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -41,6 +41,8 @@
 #define FT_COMPONENT  trace_cffgload
 
 
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+
   typedef enum  CFF_Operator_
   {
     cff_op_unknown = 0,
@@ -211,6 +213,8 @@
     2  /* setcurrentpoint */
   };
 
+#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
+
 
   /*************************************************************************/
   /*************************************************************************/
@@ -485,22 +489,24 @@
 
     if ( builder->load_points )
     {
-      CFF_Driver  driver  = (CFF_Driver)FT_FACE_DRIVER( builder->face );
-
       FT_Vector*  point   = outline->points + outline->n_points;
       FT_Byte*    control = (FT_Byte*)outline->tags + outline->n_points;
 
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+      CFF_Driver  driver  = (CFF_Driver)FT_FACE_DRIVER( builder->face );
 
-      if ( driver->hinting_engine == FT_CFF_HINTING_ADOBE )
+
+      if ( driver->hinting_engine == FT_CFF_HINTING_FREETYPE )
       {
-        /* cf2_decoder_parse_charstrings uses 16.16 coordinates */
-        point->x = x >> 10;
-        point->y = y >> 10;
+        point->x = x >> 16;
+        point->y = y >> 16;
       }
       else
+#endif
       {
-        point->x = x >> 16;
-        point->y = y >> 16;
+        /* cf2_decoder_parse_charstrings uses 16.16 coordinates */
+        point->x = x >> 10;
+        point->y = y >> 10;
       }
       *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC );
     }
@@ -722,6 +728,8 @@
   }
 
 
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+
   static FT_Error
   cff_operator_seac( CFF_Decoder*  decoder,
                      FT_Pos        asb,
@@ -2518,6 +2526,8 @@
     return FT_THROW( Stack_Overflow );
   }
 
+#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
+
 
   /*************************************************************************/
   /*************************************************************************/
@@ -2794,7 +2804,10 @@
     glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;  /* by default */
 
     {
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
       CFF_Driver  driver = (CFF_Driver)FT_FACE_DRIVER( face );
+#endif
+
 
       FT_Byte*  charstring;
       FT_ULong  charstring_len;
@@ -2819,20 +2832,27 @@
       if ( error )
         goto Glyph_Build_Finished;
 
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
       /* choose which CFF renderer to use */
-      if ( driver->hinting_engine == FT_CFF_HINTING_ADOBE )
-        error = cf2_decoder_parse_charstrings( &decoder,
+      if ( driver->hinting_engine == FT_CFF_HINTING_FREETYPE )
+        error = cff_decoder_parse_charstrings( &decoder,
                                                charstring,
                                                charstring_len );
-
-      /* Adobe's engine uses 16.16 numbers everywhere;              */
-      /* as a consequence, glyphs larger than 2000ppem get rejected */
-      if ( FT_ERR_EQ( error, Glyph_Too_Big )                 ||
-           driver->hinting_engine == FT_CFF_HINTING_FREETYPE )
-        error = cff_decoder_parse_charstrings( &decoder,
+      else
+#endif
+      {
+        error = cf2_decoder_parse_charstrings( &decoder,
                                                charstring,
                                                charstring_len );
 
+        /* Adobe's engine uses 16.16 numbers everywhere;              */
+        /* as a consequence, glyphs larger than 2000ppem get rejected */
+        if ( FT_ERR_EQ( error, Glyph_Too_Big ) )
+        {
+          /* XXX to be implemented */
+        }
+      }
+
       cff_free_glyph_data( face, &charstring, charstring_len );
 
       if ( error )
diff --git a/src/cff/cffgload.h b/src/cff/cffgload.h
index 11b389e..41df7db 100644
--- a/src/cff/cffgload.h
+++ b/src/cff/cffgload.h
@@ -218,10 +218,12 @@ FT_BEGIN_HEADER
 
 #endif /* 0 */
 
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
   FT_LOCAL( FT_Error )
   cff_decoder_parse_charstrings( CFF_Decoder*  decoder,
                                  FT_Byte*      charstring_base,
                                  FT_ULong      charstring_len );
+#endif
 
   FT_LOCAL( FT_Error )
   cff_slot_load( CFF_GlyphSlot  glyph,
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index ebcf189..90a9a33 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -1056,7 +1056,11 @@
 
 
     /* set default property values */
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
     driver->hinting_engine    = FT_CFF_HINTING_FREETYPE;
+#else
+    driver->hinting_engine    = FT_CFF_HINTING_ADOBE;
+#endif
     driver->no_stem_darkening = FALSE;
 
     return FT_Err_Ok;