shithub: freetype+ttf2subf

Download patch

ref: e3d6e94853c8ffddb9b0c0e21395cd11568d6704
parent: 6f8c6229969d552d1e16f936027b1816785da222
author: David Turner <[email protected]>
date: Tue Sep 26 12:58:21 EDT 2006

CHANGES BETWEEN 2.2.1 and 2.2.2

  I. IMPORTANT BUG FIXES

    - Various integer overflows have been fixed.

    - PFB fonts with MacOS resource fork weren't  handled correctly on
      non-MacOS platforms.

    - The PCF font loarder has been seriously hardened against malformed
      font files.

  II. IMPORTANT CHANGES

    - the unpatented hinter is now part of the default build of the
      library, and we added code to automatically support "tricky"
      fonts that need it.

      what this means is that FreeType should "just work" with certain
      Asian fonts, like MingLiu, which cannot properly load without a
      bytecode interpreter, but fortunately do not use any of the
      patented bytecode opcodes.

      Note that the API didn't change, so you can still force
      unpatented hinting with a special parameter to FT_Open_Face
      as well.

      if you're an embedded systems developer, you might want to
      *disable* the feature to save code space by undefining
      TT_CONFIG_OPTION_UNPATENTED_HINTING in ftoption.h.

    - LCD-optimized rendering is now disabled in all default builds
      of the library, mainly due to patent reasons. For more information
      see:

      http://lists.gnu.org/archive/html/freetype/2006-09/msg00064.html

      a new configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING has
      been introduced in ftoption.h; manually define it in this file
      if you want to re-enable the feature.

      the change only affects the implementation, not the FreeType API.
      This means that clients don't need to be modified, because the
      library still generates LCD decimated bitmaps, but with the added
      constraint that R=G=B on each triplet.

   - Some computation bugs in the TrueType bytecode interpreter were found,
     which allow us to get rid of very subtle and rare differences we had
     with the Windows renderer.

  III. MISCELLANEOUS

    - TrueType glyph loading is now about 25% faster.

    - the anti-aliased rasterizer has been optimized and is now 15% to 25%
      percent faster than the previous one, depending on content

    - the Type 1 loader has been improved; as an example, it now skips
      over top-level dictionaries properly

======================================================================

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,18 @@
         horizontal and vertical hinting for the purpose of debugging
         the auto-fitter
 
+        * include/freetype/config/ftoption.h, devel/ftoption.h:
+        introducing the new FT_CONFIG_OPTION_SUBPIXEL_RENDERING to
+        control wether we want to compile LCD-optimized rendering code
+        (à la ClearType) or not. The macro *must* be disabled in default
+        builds of the library for patent reasons.
+
+        * src/smooth/ftsmooth.c: disabling LCD-specific rendering when
+        FT_CONFIG_OPTION_SUBPIXEL_RENDERING isn't defined at compile
+        time. This only changes the content of the rendered glyph to
+        match the one of normal gray-level rendering, hence clients
+        should not need to be modified.
+
 2006-09-18  Garrick Meeker  <[email protected]>
 
 	* src/base/ftmac.c (FT_New_Face_From_FOND): Fall back to SFNT if
--- a/devel/ftoption.h
+++ b/devel/ftoption.h
@@ -77,6 +77,26 @@
 
   /*************************************************************************/
   /*                                                                       */
+  /* uncomment the line below if you want to active sub-pixel rendering    */
+  /* (a.k.a. LCD rendering, or ClearType) in this build of the library.    */
+  /*                                                                       */
+  /* Note that this feature is covered by several Microsoft patents        */
+  /* and should not be activated in any default build of the library.      */
+  /*                                                                       */
+  /* This macro has no impact on the FreeType API, only on its             */
+  /* _implementation_. For example, using FT_RENDER_MODE_LCD when calling  */
+  /* FT_Render_Glyph will still generate a bitmap that is 3 times          */
+  /* larger than the original size, The difference will be that each       */
+  /* triplet of subpixels will have R=G=B.                                 */
+  /*                                                                       */
+  /* This is done to allow FreeType clients to run unmodified, forcing    */
+  /* them to display normal gray-level anti-aliased glyphs.                */
+  /*                                                                       */
+/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
+
+
+  /*************************************************************************/
+  /*                                                                       */
   /* Many compilers provide a non-ANSI 64-bit data type that can be used   */
   /* by FreeType to speed up some computations.  However, this will create */
   /* some problems when compiling the library in strict ANSI mode.         */
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -1,3 +1,69 @@
+CHANGES BETWEEN 2.2.2 and 2.2.1
+
+  I. IMPORTANT BUG FIXES
+
+    - The PCF font loarder has been seriously hardened against malformed
+      font files.
+
+    - various memory leaks have been found and squashed
+
+  II. IMPORTANT CHANGES
+
+    - the unpatented hinter is now part of the default build of the
+      library, and we added code to automatically support "tricky"
+      fonts that need it.
+
+      what this means is that FreeType should "just work" with certain
+      Asian fonts, like MingLiU, which cannot properly load without a
+      bytecode interpreter, but fortunately do not use any of the
+      patented bytecode opcodes. We detect these fonts by name, so
+      report any font file that doesn't seem to work with this,
+      and we'll do what we can to support it in a next release.
+
+      Note that the API didn't change, so you can still force
+      unpatented hinting with a special parameter to FT_Open_Face
+      as well. This might be useful, for example, a PDF reader
+      might present a user option to activate it to deal with certain
+      "tricky" embedded fonts which cannot be clearly identified.
+
+      if you're an embedded systems developer, you might want to
+      *disable* the feature to save code space by undefining
+      TT_CONFIG_OPTION_UNPATENTED_HINTING in ftoption.h.
+
+    - LCD-optimized rendering is now DISABLED in all default builds
+      of the library, mainly due to PATENTS. For more information
+      see:
+
+      http://lists.gnu.org/archive/html/freetype/2006-09/msg00064.html
+
+      a new configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING has
+      been introduced in ftoption.h; manually define it in this file
+      if you want to re-enable the feature.
+
+      the change only affects the implementation, not the FreeType API.
+      This means that clients don't need to be modified, because the
+      library still generates LCD decimated bitmaps, but with the added
+      constraint that R=G=B on each triplet.
+
+      the displayed result should be equal to normal anti-aliased
+      rendering.
+
+   - Some computation bugs in the TrueType bytecode interpreter were found,
+     which allow us to get rid of very subtle and rare differences we had
+     with the Windows renderer.
+
+  III. MISCELLANEOUS
+
+    - TrueType glyph loading is now about 25% faster.
+
+    - the anti-aliased rasterizer has been optimized and is now 15% to 25%
+      percent faster than the previous one, depending on content
+
+    - the Type 1 loader has been improved; as an example, it now skips
+      over top-level dictionaries properly
+
+======================================================================
+
 CHANGES BETWEEN 2.2.1 and 2.2
 
   I. IMPORTANT BUG FIXES
@@ -491,7 +557,7 @@
 
   III. MISCELLANEOUS
 
-    - Wolfgang Domr�se contributed support files for building FreeType
+    - Wolfgang Domr�e contributed support files for building FreeType
       on the Atari using the PureC compiler.  Note that the Atari is a
       16bit platform.
 
@@ -1075,7 +1141,7 @@
       to use the following text in your documentation:
 
       """
-        Portions of this software are copyright � 1996-2002 The
+        Portions of this software are copyright  1996-2002 The
         FreeType Project (www.freetype.org).  All rights reserved.
       """
 
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -77,6 +77,25 @@
 
   /*************************************************************************/
   /*                                                                       */
+  /* uncomment the line below if you want to active sub-pixel rendering    */
+  /* (a.k.a. LCD rendering, or ClearType) in this build of the library.    */
+  /*                                                                       */
+  /* Note that this feature is covered by several Microsoft patents        */
+  /* and should not be activated in any default build of the library.      */
+  /*                                                                       */
+  /* This macro has no impact on the FreeType API, only on its             */
+  /* _implementation_. For example, using FT_RENDER_MODE_LCD when calling  */
+  /* FT_Render_Glyph will still generate a bitmap that is 3 times          */
+  /* larger than the original size, The difference will be that each       */
+  /* triplet of subpixels will have R=G=B.                                 */
+  /*                                                                       */
+  /* This is done to allow FreeType clients to run unmodified, forcing    */
+  /* them to display normal gray-level anti-aliased glyphs.                */
+  /*                                                                       */
+/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
+
+  /*************************************************************************/
+  /*                                                                       */
   /* Many compilers provide a non-ANSI 64-bit data type that can be used   */
   /* by FreeType to speed up some computations.  However, this will create */
   /* some problems when compiling the library in strict ANSI mode.         */
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -105,7 +105,7 @@
     FT_Error     error;
     FT_Outline*  outline = NULL;
     FT_BBox      cbox;
-    FT_UInt      width, height, pitch;
+    FT_UInt      width, height, height_org, width_org, pitch;
     FT_Bitmap*   bitmap;
     FT_Memory    memory;
 
@@ -142,6 +142,9 @@
     bitmap = &slot->bitmap;
     memory = render->root.memory;
 
+    width_org  = width;
+    height_org = height;
+
     /* release old bitmap buffer */
     if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
     {
@@ -179,6 +182,7 @@
     params.source = outline;
     params.flags  = FT_RASTER_FLAG_AA;
 
+#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
     /* implode outline if needed */
     {
       FT_Int      n;
@@ -211,6 +215,55 @@
         for ( vec = outline->points, n = 0; n < outline->n_points; n++, vec++ )
           vec->y /= vmul;
     }
+#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
+    /* render outline into bitmap */
+    error = render->raster_render( render->raster, &params );
+
+    /* expand it horizontally */
+    if ( hmul > 1 )
+    {
+      FT_Byte*  line = bitmap->buffer + (height - height_org)*pitch;
+      FT_UInt   hh;
+
+      for ( hh = height_org; hh > 0; hh--, line += pitch )
+      {
+        FT_UInt   xx;
+        FT_Byte*  end = line + width;
+
+        for ( xx = width_org; xx > 0; xx-- )
+        {
+          FT_UInt  pixel = line[xx-1];
+          FT_UInt  count = hmul;
+
+          for ( count = hmul; count > 0; count-- )
+            end[-count] = (FT_Byte)pixel;
+
+          end -= hmul;
+        }
+      }
+    }
+
+    /* expand it vertically */
+    if ( vmul > 1 )
+    {
+      FT_Byte*    read  = bitmap->buffer + (height-height_org)*pitch;
+      FT_Byte*    write = bitmap->buffer;
+      FT_UInt     hh;
+
+      for ( hh = height_org; hh > 0; hh-- )
+      {
+        FT_UInt  count = vmul;
+
+        for ( count = vmul; count > 0; count-- )
+        {
+          memcpy( write, read, pitch );
+          write += pitch;
+        }
+        read += pitch;
+      }
+    }
+
+#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
 
     FT_Outline_Translate( outline, cbox.xMin, cbox.yMin );