Commit 7d3dfcd4a5255a7b00bcf0dbabb85b245bedb581

Jonathan Kew 2017-12-17T08:19:51

Fix incorrect advance width scaling (#52683). * src/base/ftadvance.c (FT_Get_Advances): Always respect the FT_LOAD_NO_SCALE flag if present.

diff --git a/ChangeLog b/ChangeLog
index 78be02a..82830ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-12-17  Jonathan Kew  <jfkthame@gmail.com>
+
+	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  <apodtele@gmail.com>
 
 	* builds/windows/vc2010/freetype.vcxproj: AfterBuild copy.
diff --git a/src/base/ftadvanc.c b/src/base/ftadvanc.c
index 1557607..d066142 100644
--- 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,16 +155,17 @@
       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 );
       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;