shithub: freetype+ttf2subf

Download patch

ref: ee3778d3d766ed1f645496bd5962d9a89958114b
parent: f3abecb61595c813413d2f3ca4997de69b7b8e6c
author: Werner Lemberg <[email protected]>
date: Mon Feb 3 06:16:47 EST 2014

[cff] Fix Savannah bug #41363.

* src/cff/cf2ft.c (cf2_checkTransform): Convert assertion into
parameter check.
(cf2_decoder_parse_charstrings): Call `cf2_checkTransform' only if
we are scaling the outline.
(cf2_getPpemY): Remove problematic assertion.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2014-02-03  Werner Lemberg  <[email protected]>
+
+	[cff] Fix Savannah bug #41363.
+
+	* src/cff/cf2ft.c (cf2_checkTransform): Convert assertion into
+	parameter check.
+	(cf2_decoder_parse_charstrings): Call `cf2_checkTransform' only if
+	we are scaling the outline.
+	(cf2_getPpemY): Remove problematic assertion.
+
 2014-01-26  Werner Lemberg  <[email protected]>
 
 	[autofit] Introduce two more slots for standard characters.
--- a/src/cff/cf2ft.c
+++ b/src/cff/cf2ft.c
@@ -61,7 +61,9 @@
 
     FT_ASSERT( unitsPerEm > 0 );
 
-    FT_ASSERT( transform->a > 0 && transform->d > 0 );
+    if ( transform->a <= 0 || transform->d <= 0 )
+      return FT_THROW( Invalid_Size_Handle );
+
     FT_ASSERT( transform->b == 0 && transform->c == 0 );
     FT_ASSERT( transform->tx == 0 && transform->ty == 0 );
 
@@ -357,9 +359,12 @@
       /* also get units per em to validate scale */
       font->unitsPerEm = (CF2_Int)cf2_getUnitsPerEm( decoder );
 
-      error2 = cf2_checkTransform( &transform, font->unitsPerEm );
-      if ( error2 )
-        return error2;
+      if ( scaled )
+      {
+        error2 = cf2_checkTransform( &transform, font->unitsPerEm );
+        if ( error2 )
+          return error2;
+      }
 
       error2 = cf2_getGlyphOutline( font, &buf, &transform, &glyphWidth );
       if ( error2 )
@@ -389,8 +394,16 @@
     FT_ASSERT( decoder                          &&
                decoder->builder.face            &&
                decoder->builder.face->root.size );
-    FT_ASSERT( decoder->builder.face->root.size->metrics.y_ppem );
 
+    /*
+     * Note that `y_ppem' can be zero if there wasn't a call to
+     * `FT_Set_Char_Size' or something similar.  However, this isn't a
+     * problem since we come to this place in the code only if
+     * FT_LOAD_NO_SCALE is set (the other case gets caught by
+     * `cf2_checkTransform').  The ppem value is needed to compute the stem
+     * darkening, which is disabled for getting the unscaled outline.
+     *
+     */
     return cf2_intToFixed(
              decoder->builder.face->root.size->metrics.y_ppem );
   }