shithub: freetype+ttf2subf

Download patch

ref: 265ade8e807819e6a3f93671df1382c56ba50f85
parent: d57f227121ef8e31872a5e7cfe2d10a46c81db46
author: Hin-Tak Leung <[email protected]>
date: Sat Sep 26 10:51:30 EDT 2015

Add new FT_LOAD_COMPUTE_METRICS load flag.

* include/freetype/freetype.h (FT_LOAD_COMPUTE_METRICS): New macro.
* src/truetype/ttgload.c (compute_glyph_metrics): Usage.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-09-26  Hin-Tak Leung  <[email protected]>
+
+	Add new FT_LOAD_COMPUTE_METRICS load flag.
+
+	* include/freetype/freetype.h (FT_LOAD_COMPUTE_METRICS): New macro.
+	* src/truetype/ttgload.c (compute_glyph_metrics): Usage.
+
 2015-09-26  Werner Lemberg  <[email protected]>
 
 	* src/base/ftobjs.c (Mac_Read_sfnt_Resource): Add cast.
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -2743,6 +2743,16 @@
    *     bitmaps transparently.  Those bitmaps will be in the
    *     @FT_PIXEL_MODE_GRAY format.
    *
+   *   FT_LOAD_COMPUTE_METRICS ::
+   *     This flag sets computing glyph metrics without the use of bundled
+   *     metrics tables (for example, the `hdmx' table in TrueType fonts).
+   *     Well-behaving fonts have optimized bundled metrics and these should
+   *     be used.  This flag is mainly used by font validating or font
+   *     editing applications, which need to ignore, verify, or edit those
+   *     tables.
+   *
+   *     Currently, this flag is only implemented for TrueType fonts.
+   *
    *   FT_LOAD_CROP_BITMAP ::
    *     Ignored.  Deprecated.
    *
@@ -2788,6 +2798,7 @@
 #define FT_LOAD_NO_AUTOHINT                  ( 1L << 15 )
   /* Bits 16..19 are used by `FT_LOAD_TARGET_' */
 #define FT_LOAD_COLOR                        ( 1L << 20 )
+#define FT_LOAD_COMPUTE_METRICS              ( 1L << 21 )
 
   /* */
 
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -1936,8 +1936,10 @@
     glyph->metrics.horiAdvance  = loader->pp2.x - loader->pp1.x;
 
     /* adjust advance width to the value contained in the hdmx table */
-    if ( !face->postscript.isFixedPitch  &&
-         IS_HINTED( loader->load_flags ) )
+    /* unless FT_LOAD_COMPUTE_METRICS is set                         */
+    if ( !face->postscript.isFixedPitch                    &&
+         IS_HINTED( loader->load_flags )                   &&
+         !( loader->load_flags & FT_LOAD_COMPUTE_METRICS ) )
     {
       FT_Byte*  widthp;