shithub: freetype+ttf2subf

Download patch

ref: 0a5315d141e698253603170595c655132d9baff2
parent: ab10ffcdd55f289fc0d335cf752acbf68edff172
author: Werner Lemberg <[email protected]>
date: Thu Apr 27 09:02:24 EDT 2017

Introduce AF_CONFIG_OPTION_TT_SIZE_METRICS configuration option.

* include/freetype/config/ftoption.h
(AF_CONFIG_OPTION_TT_SIZE_METRICS): New option, commented out by
default.

* src/autofit/afloader.c (af_loader_load_glyph): Use
AF_CONFIG_OPTION_TT_SIZE_METRICS to guard the corresponding code.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2017-04-27  Werner Lemberg  <[email protected]>
+
+	Introduce AF_CONFIG_OPTION_TT_SIZE_METRICS configuration option.
+
+	* include/freetype/config/ftoption.h
+	(AF_CONFIG_OPTION_TT_SIZE_METRICS): New option, commented out by
+	default.
+
+	* src/autofit/afloader.c (af_loader_load_glyph): Use
+	AF_CONFIG_OPTION_TT_SIZE_METRICS to guard the corresponding code.
+
 2017-04-26  Werner Lemberg  <[email protected]>
 
 	* include/freetype/freetype.h (FT_Render_Mode): Fix order.
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -886,7 +886,9 @@
 
   /*************************************************************************/
   /*                                                                       */
-  /* Compile autofit module with Indic script support.                     */
+  /* Compile autofit module with fallback Indic script support, covering   */
+  /* some scripts that the `latin' submodule of the autofit module doesn't */
+  /* (yet) handle.                                                         */
   /*                                                                       */
 #define AF_CONFIG_OPTION_INDIC
 
@@ -904,6 +906,22 @@
   /* information; by default it is switched off).                          */
   /*                                                                       */
 #define AF_CONFIG_OPTION_USE_WARPER
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* Use TrueType-like size metrics for `light' auto-hinting.  This option */
+  /* exists mainly for backwards compatibility with GNU/Linux              */
+  /* distributions like Fedora that did not un-patch the following change  */
+  /* (which was present in FreeType between versions 2.4.6 and 2.7.1,      */
+  /* inclusive).                                                           */
+  /*                                                                       */
+  /*   2011-07-16  Steven Chu  <[email protected]>                    */
+  /*                                                                       */
+  /*     [truetype] Fix metrics on size request for scalable fonts.        */
+  /*                                                                       */
+  /* This problematic commit is now reverted (more or less).               */
+  /*                                                                       */
+/* #define AF_CONFIG_OPTION_TT_SIZE_METRICS */
 
   /* */
 
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -2933,27 +2933,34 @@
    *     rendering.  For monochrome output, use @FT_LOAD_TARGET_MONO
    *     instead.
    *
-   *   FT_LOAD_TARGET_LIGHT ::
-   *     A lighter hinting algorithm for gray-level modes.  Many generated
+   *   FT_LOAD_TARGET_SLIGHT ::
+   *     A slight hinting algorithm for gray-level modes.  Many generated
    *     glyphs are fuzzier but better resemble their original shape.  This
    *     is achieved by snapping glyphs to the pixel grid only vertically
-   *     (Y-axis), as is done by Microsoft's ClearType and Adobe's
-   *     proprietary font renderer.  This preserves inter-glyph spacing in
+   *     (Y-axis), as is done by FreeType's new CFF engine or Microsoft's
+   *     ClearType font renderer.  This preserves inter-glyph spacing in
    *     horizontal text.  The snapping is done either by the native font
    *     driver, if the driver itself and the font support it, or by the
    *     auto-hinter.
    *
-   *     Use this hinting mode if you mainly need integer advance widths
-   *     and want to avoid sub-pixel rendering.
+   *     Advance widths are not rounded to integer values; instead, metrics
+   *     are based on linearly scaled values.  In particular this implies
+   *     that you have to apply sub-pixel rendering.
    *
-   *   FT_LOAD_TARGET_SLIGHT ::
-   *     This is similar to @FT_LOAD_TARGET_LIGHT with a main difference:
-   *     Advance widths are not rounded to integer values; instead, the
-   *     linearly scaled values are used.  In particular this implies that
-   *     you have to apply sub-pixel rendering.
+   *   FT_LOAD_TARGET_LIGHT ::
+   *     This is similar to @FT_LOAD_TARGET_SLIGHT with a main difference:
+   *     It uses integer advance widths.
    *
-   *     In general, this mode yields better results than
-   *     @FT_LOAD_TARGET_LIGHT.
+   *     If configuration option AF_CONFIG_OPTION_TT_SIZE_METRICS is active,
+   *     TrueType-like metrics are used to make this mode behave similarly
+   *     as in unpatched FreeType versions between 2.4.6 and 2.7.1
+   *     (inclusive).
+   *
+   *     This hinting mode is deprecated.  In general,
+   *     @FT_LOAD_TARGET_SLIGHT always yields better results; additionally,
+   *     FT_LOAD_TARGET_LIGHT suffers from backwards compatibility issues
+   *     (see the documentation of AF_CONFIG_OPTION_TT_SIZE_METRICS in
+   *     `ftoption.h' for more details).
    *
    *   FT_LOAD_TARGET_MONO ::
    *     Strong hinting algorithm that should only be used for monochrome
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -252,6 +252,7 @@
       size_internal->autohint_mode    = FT_LOAD_TARGET_MODE( load_flags );
       size_internal->autohint_metrics = size->metrics;
 
+#ifdef AF_CONFIG_OPTION_TT_SIZE_METRICS
       if ( size_internal->autohint_mode != FT_RENDER_MODE_SLIGHT )
       {
         FT_Size_Metrics*  size_metrics = &size_internal->autohint_metrics;
@@ -278,6 +279,7 @@
                                       FT_MulFix( face->max_advance_width,
                                                  size_metrics->x_scale ) );
       }
+#endif /* AF_CONFIG_OPTION_TT_SIZE_METRICS */
     }
 
     /*