shithub: freetype+ttf2subf

Download patch

ref: 576fc2c06e9b34db235b18cc8ae20c3ce789fb65
parent: e547a656a5b24d6bab178fc8864263e57b31ec95
author: Werner Lemberg <[email protected]>
date: Tue Mar 1 22:52:36 EST 2011

Add AF_CONFIG_OPTION_USE_WARPER to control the autofit warper.

* devel/ftoption.h, include/freetype/config/ftoption.h
(AF_CONFIG_OPTION_USE_WARPER): New macro.
* src/autofit/aftypes.h (AF_USE_WARPER): Remove.

* src/autofit/*: s/AF_USE_WARPER/AF_CONFIG_OPTION_USE_WARPER/.

* src/autofit/afwarp.c [!AF_CONFIG_OPTION_USE_WARPER]: Replace dummy
variable assignment with a typedef.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2011-02-27  Werner Lemberg  <[email protected]>
+
+	Add AF_CONFIG_OPTION_USE_WARPER to control the autofit warper.
+
+	* devel/ftoption.h, include/freetype/config/ftoption.h
+	(AF_CONFIG_OPTION_USE_WARPER): New macro.
+	* src/autofit/aftypes.h (AF_USE_WARPER): Remove.
+
+	* src/autofit/*: s/AF_USE_WARPER/AF_CONFIG_OPTION_USE_WARPER/.
+
+	* src/autofit/afwarp.c [!AF_CONFIG_OPTION_USE_WARPER]: Replace dummy
+	variable assignment with a typedef.
+
 2011-02-26  Werner Lemberg  <[email protected]>
 
 	[autofit] Slight simplifications.
--- a/devel/ftoption.h
+++ b/devel/ftoption.h
@@ -4,8 +4,7 @@
 /*                                                                         */
 /*    User-selectable configuration macros (specification only).           */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,   */
-/*            2010 by                                                      */
+/*  Copyright 1996-2011 by                                                 */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -691,6 +690,19 @@
   /* Compile autofit module with Indic script support.                     */
   /*                                                                       */
 #define AF_CONFIG_OPTION_INDIC
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* Compile autofit module with warp hinting.  The idea of the warping    */
+  /* code is to slightly scale and shift a glyph within a single dimension */
+  /* so that as much of its segments are aligned (more or less) on the     */
+  /* grid.  To find out the optimal scaling and shifting value, various    */
+  /* parameter combinations are tried and scored.                          */
+  /*                                                                       */
+  /* This experimental option is only active if the render mode is         */
+  /* FT_RENDER_MODE_LIGHT.                                                 */
+  /*                                                                       */
+#define AF_CONFIG_OPTION_USE_WARPER
 
   /* */
 
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -4,8 +4,7 @@
 /*                                                                         */
 /*    User-selectable configuration macros (specification only).           */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,   */
-/*            2010 by                                                      */
+/*  Copyright 1996-2011 by                                                 */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -691,6 +690,19 @@
   /* Compile autofit module with Indic script support.                     */
   /*                                                                       */
 #define AF_CONFIG_OPTION_INDIC
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* Compile autofit module with warp hinting.  The idea of the warping    */
+  /* code is to slightly scale and shift a glyph within a single dimension */
+  /* so that as much of its segments are aligned (more or less) on the     */
+  /* grid.  To find out the optimal scaling and shifting value, various    */
+  /* parameter combinations are tried and scored.                          */
+  /*                                                                       */
+  /* This experimental option is only active if the render mode is         */
+  /* FT_RENDER_MODE_LIGHT.                                                 */
+  /*                                                                       */
+/* #define AF_CONFIG_OPTION_USE_WARPER */
 
   /* */
 
--- a/src/autofit/afcjk.c
+++ b/src/autofit/afcjk.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter hinting routines for CJK script (body).                  */
 /*                                                                         */
-/*  Copyright 2006, 2007, 2008, 2009, 2010 by                              */
+/*  Copyright 2006-2011 by                                                 */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -32,7 +32,7 @@
 #include "aferrors.h"
 
 
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
 #include "afwarp.h"
 #endif
 
@@ -623,7 +623,7 @@
     /* compute flags depending on render mode, etc. */
     mode = metrics->root.scaler.render_mode;
 
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
     if ( mode == FT_RENDER_MODE_LCD || mode == FT_RENDER_MODE_LCD_V )
       metrics->root.scaler.render_mode = mode = FT_RENDER_MODE_NORMAL;
 #endif
@@ -1397,7 +1397,7 @@
            ( dim == AF_DIMENSION_VERT && AF_HINTS_DO_VERTICAL( hints ) )   )
       {
 
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
         if ( dim == AF_DIMENSION_HORZ                                  &&
              metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL )
         {
@@ -1410,7 +1410,7 @@
           af_glyph_hints_scale_dim( hints, dim, scale, delta );
           continue;
         }
-#endif /* AF_USE_WARPER */
+#endif /* AF_CONFIG_OPTION_USE_WARPER */
 
         af_cjk_hint_edges( hints, (AF_Dimension)dim );
         af_cjk_align_edge_points( hints, (AF_Dimension)dim );
--- a/src/autofit/afhints.c
+++ b/src/autofit/afhints.c
@@ -1150,7 +1150,7 @@
   }
 
 
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
 
   /* Apply (small) warp scale and warp delta for given dimension. */
 
@@ -1177,6 +1177,6 @@
     }
   }
 
-#endif /* AF_USE_WARPER */
+#endif /* AF_CONFIG_OPTION_USE_WARPER */
 
 /* END */
--- a/src/autofit/afhints.h
+++ b/src/autofit/afhints.h
@@ -440,7 +440,7 @@
   af_glyph_hints_align_weak_points( AF_GlyphHints  hints,
                                     AF_Dimension   dim );
 
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
   FT_LOCAL( void )
   af_glyph_hints_scale_dim( AF_GlyphHints  hints,
                             AF_Dimension   dim,
--- a/src/autofit/afindic.c
+++ b/src/autofit/afindic.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter hinting routines for Indic scripts (body).               */
 /*                                                                         */
-/*  Copyright 2007 by                                                      */
+/*  Copyright 2007, 2011 by                                                */
 /*  Rahul Bhalerao <[email protected]>, <[email protected]>.    */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -27,7 +27,7 @@
 #include "afcjk.h"
 
 
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
 #include "afwarp.h"
 #endif
 
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -23,7 +23,7 @@
 #include "aferrors.h"
 
 
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
 #include "afwarp.h"
 #endif
 
@@ -1428,7 +1428,7 @@
     /* compute flags depending on render mode, etc. */
     mode = metrics->root.scaler.render_mode;
 
-#if 0 /* #ifdef AF_USE_WARPER */
+#if 0 /* #ifdef AF_CONFIG_OPTION_USE_WARPER */
     if ( mode == FT_RENDER_MODE_LCD || mode == FT_RENDER_MODE_LCD_V )
     {
       metrics->root.scaler.render_mode = mode = FT_RENDER_MODE_NORMAL;
@@ -2174,7 +2174,7 @@
       goto Exit;
 
     /* analyze glyph outline */
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
     if ( metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT ||
          AF_HINTS_DO_HORIZONTAL( hints )                          )
 #else
@@ -2198,7 +2198,7 @@
     /* grid-fit the outline */
     for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
     {
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
       if ( dim == AF_DIMENSION_HORZ                                 &&
            metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT )
       {
--- a/src/autofit/aflatin2.c
+++ b/src/autofit/aflatin2.c
@@ -23,7 +23,7 @@
 #include "aferrors.h"
 
 
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
 #include "afwarp.h"
 #endif
 
@@ -1472,7 +1472,7 @@
     /* compute flags depending on render mode, etc. */
     mode = metrics->root.scaler.render_mode;
 
-#if 0 /* #ifdef AF_USE_WARPER */
+#if 0 /* #ifdef AF_CONFIG_OPTION_USE_WARPER */
     if ( mode == FT_RENDER_MODE_LCD || mode == FT_RENDER_MODE_LCD_V )
     {
       metrics->root.scaler.render_mode = mode = FT_RENDER_MODE_NORMAL;
@@ -2269,7 +2269,7 @@
       goto Exit;
 
     /* analyze glyph outline */
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
     if ( metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT ||
          AF_HINTS_DO_HORIZONTAL( hints ) )
 #else
@@ -2293,7 +2293,7 @@
     /* grid-fit the outline */
     for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
     {
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
       if ( ( dim == AF_DIMENSION_HORZ &&
              metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT ) )
       {
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -53,7 +53,6 @@
   /*************************************************************************/
   /*************************************************************************/
 
-#define xxAF_USE_WARPER  /* only define to use warp hinting */
 #define xxAF_DEBUG
 
 #ifdef AF_DEBUG
--- a/src/autofit/afwarp.c
+++ b/src/autofit/afwarp.c
@@ -25,7 +25,7 @@
 
 #include "afwarp.h"
 
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
 
   /* The weights cover the range 0/64 - 63/64 of a pixel.  Obviously, */
   /* values around a half pixel (which means exactly between two grid */
@@ -354,10 +354,11 @@
     }
   }
 
-#else /* !AF_USE_WARPER */
+#else /* !AF_CONFIG_OPTION_USE_WARPER */
 
-  char  af_warper_dummy = 0;  /* make compiler happy */
+  /* ANSI C doesn't like empty source files */
+  typedef int  _af_warp_dummy;
 
-#endif /* !AF_USE_WARPER */
+#endif /* !AF_CONFIG_OPTION_USE_WARPER */
 
 /* END */
--- a/src/autofit/autofit.c
+++ b/src/autofit/autofit.c
@@ -34,7 +34,7 @@
 #include "afloader.c"
 #include "afmodule.c"
 
-#ifdef AF_USE_WARPER
+#ifdef AF_CONFIG_OPTION_USE_WARPER
 #include "afwarp.c"
 #endif