shithub: freetype+ttf2subf

Download patch

ref: 7d3dfcd4a5255a7b00bcf0dbabb85b245bedb581
parent: d019097bd20319023ed4e7241973016098387992
author: Jonathan Kew <[email protected]>
date: Sun Dec 17 03:19:51 EST 2017

Fix incorrect advance width scaling (#52683).

* src/base/ftadvance.c (FT_Get_Advances): Always respect the
FT_LOAD_NO_SCALE flag if present.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-12-17  Jonathan Kew  <[email protected]>
+
+	Fix incorrect advance width scaling (#52683).
+
+	* src/base/ftadvance.c (FT_Get_Advances): Always respect the
+	FT_LOAD_NO_SCALE flag if present.
+
 2017-12-16  Alexei Podtelezhnikov  <[email protected]>
 
 	* builds/windows/vc2010/freetype.vcxproj: AfterBuild copy.
--- a/src/base/ftadvanc.c
+++ b/src/base/ftadvanc.c
@@ -116,9 +116,12 @@
                    FT_Int32   flags,
                    FT_Fixed  *padvances )
   {
+    FT_Error  error = FT_Err_Ok;
+
     FT_Face_GetAdvancesFunc  func;
-    FT_UInt                  num, end, nn;
-    FT_Error                 error = FT_Err_Ok;
+
+    FT_UInt  num, end, nn;
+    FT_Int   factor;
 
 
     if ( !face )
@@ -152,6 +155,7 @@
       return FT_THROW( Unimplemented_Feature );
 
     flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY;
+    factor = ( flags & FT_LOAD_NO_SCALE ) ? 1 : 1024;
     for ( nn = 0; nn < count; nn++ )
     {
       error = FT_Load_Glyph( face, start + nn, flags );
@@ -158,10 +162,10 @@
       if ( error )
         break;
 
-      /* scale from 26.6 to 16.16 */
+      /* scale from 26.6 to 16.16, unless NO_SCALE was requested */
       padvances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT )
-                      ? face->glyph->advance.y * 1024
-                      : face->glyph->advance.x * 1024;
+                      ? face->glyph->advance.y * factor
+                      : face->glyph->advance.x * factor;
     }
 
     return error;