shithub: freetype+ttf2subf

Download patch

ref: 2429dc3d7c209a35d2026fa9f864e0ba785cf697
parent: f9cceeb4e314656403e183ec9ddf181819fac808
author: Werner Lemberg <[email protected]>
date: Mon Jun 3 08:41:58 EDT 2013

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.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2013-06-03  Werner Lemberg  <[email protected]>
+
+	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  <[email protected]>
 
 	Fix PNG library handling.
--- a/devel/ftoption.h
+++ b/devel/ftoption.h
@@ -752,6 +752,25 @@
   /*************************************************************************/
   /*************************************************************************/
   /****                                                                 ****/
+  /****         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     ****/
   /****                                                                 ****/
   /*************************************************************************/
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -21,9 +21,40 @@
       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.
 
 
 ======================================================================
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -752,6 +752,25 @@
   /*************************************************************************/
   /*************************************************************************/
   /****                                                                 ****/
+  /****         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     ****/
   /****                                                                 ****/
   /*************************************************************************/
--- a/include/freetype/ftcffdrv.h
+++ b/include/freetype/ftcffdrv.h
@@ -61,11 +61,12 @@
    *
    * @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).
--- 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;
     }
--- 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,7 +213,9 @@
     2  /* setcurrentpoint */
   };
 
+#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
 
+
   /*************************************************************************/
   /*************************************************************************/
   /*************************************************************************/
@@ -485,23 +489,25 @@
 
     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 )
       {
+        point->x = x >> 16;
+        point->y = y >> 16;
+      }
+      else
+#endif
+      {
         /* cf2_decoder_parse_charstrings uses 16.16 coordinates */
         point->x = x >> 10;
         point->y = y >> 10;
       }
-      else
-      {
-        point->x = x >> 16;
-        point->y = y >> 16;
-      }
       *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,7 +2526,9 @@
     return FT_THROW( Stack_Overflow );
   }
 
+#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
 
+
   /*************************************************************************/
   /*************************************************************************/
   /*************************************************************************/
@@ -2794,8 +2804,11 @@
     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,19 +2832,26 @@
       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 );
 
--- a/src/cff/cffgload.h
+++ b/src/cff/cffgload.h
@@ -218,10 +218,12 @@
 
 #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,
--- 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;