shithub: freetype+ttf2subf

Download patch

ref: 7d017ba810d0b29a941f83188ac39cf3c8d52a48
parent: f0898b9259d4b3b99a1e720924683730dd36d3db
author: Werner Lemberg <[email protected]>
date: Tue Sep 5 11:28:21 EDT 2017

[bdf] Fix size and resolution handling.

* src/bdf/bdfdrivr.c (BDF_Face_Init): Use `SIZE' values if
`POINT_SIZE', `RESOLUTION_X', or `RESOLUTION_Y' properties are
missing.

* docs/CHANGES: Document it.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2017-09-05  Werner Lemberg  <[email protected]>
+
+	[bdf] Fix size and resolution handling.
+
+	* src/bdf/bdfdrivr.c (BDF_Face_Init): Use `SIZE' values if
+	`POINT_SIZE', `RESOLUTION_X', or `RESOLUTION_Y' properties are
+	missing.
+
+	* docs/CHANGES: Document it.
+
 2017-08-25  Alexei Podtelezhnikov  <[email protected]>
 
 	Swap `ALLOC_MULT' arguments (#51833).
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -48,6 +48,12 @@
     - FreeType  now synthesizes  a  missing Unicode  cmap for  (older)
       TrueType fonts also if glyph names are available.
 
+    - FreeType  has  improved  handling   of  BDF  fonts  without  the
+      `POINT_SIZE', `RESOLUTION_X', or  `RESOLUTION_Y' properties; the
+      library now  uses the values of  the `SIZE' keyword if  they are
+      missing.   Previously,   `SIZE'  was  completely   ignored,  and
+      FreeType used heuristic values instead.
+
 
 ======================================================================
 
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -437,6 +437,7 @@
       {
         FT_Bitmap_Size*  bsize = bdfface->available_sizes;
         FT_Short         resolution_x = 0, resolution_y = 0;
+        long             value;
 
 
         FT_ZERO( bsize );
@@ -500,6 +501,17 @@
                                      64 * 7200,
                                      72270L );
         }
+        else if ( font->point_size )
+        {
+          if ( font->point_size > 0x7FFF )
+          {
+            bsize->size = 0x7FFF;
+            FT_TRACE0(( "BDF_Face_Init: clamping point size to value %d\n",
+                        bsize->size ));
+          }
+          else
+            bsize->size = (FT_Pos)font->point_size << 6;
+        }
         else
         {
           /* this is a heuristical value */
@@ -525,12 +537,16 @@
 
         prop = bdf_get_font_property( font, "RESOLUTION_X" );
         if ( prop )
+          value = prop->value.l;
+        else
+          value = (long)font->resolution_x;
+        if ( value )
         {
 #ifdef FT_DEBUG_LEVEL_TRACE
-          if ( prop->value.l < 0 )
+          if ( value < 0 )
             FT_TRACE0(( "BDF_Face_Init: negative X resolution\n" ));
 #endif
-          if ( prop->value.l > 0x7FFF || prop->value.l < -0x7FFF )
+          if ( value > 0x7FFF || value < -0x7FFF )
           {
             resolution_x = 0x7FFF;
             FT_TRACE0(( "BDF_Face_Init: clamping X resolution to value %d\n",
@@ -537,17 +553,21 @@
                         resolution_x ));
           }
           else
-            resolution_x = FT_ABS( (FT_Short)prop->value.l );
+            resolution_x = FT_ABS( (FT_Short)value );
         }
 
         prop = bdf_get_font_property( font, "RESOLUTION_Y" );
         if ( prop )
+          value = prop->value.l;
+        else
+          value = (long)font->resolution_y;
+        if ( value )
         {
 #ifdef FT_DEBUG_LEVEL_TRACE
-          if ( prop->value.l < 0 )
+          if ( value < 0 )
             FT_TRACE0(( "BDF_Face_Init: negative Y resolution\n" ));
 #endif
-          if ( prop->value.l > 0x7FFF || prop->value.l < -0x7FFF )
+          if ( value > 0x7FFF || value < -0x7FFF )
           {
             resolution_y = 0x7FFF;
             FT_TRACE0(( "BDF_Face_Init: clamping Y resolution to value %d\n",
@@ -554,7 +574,7 @@
                         resolution_y ));
           }
           else
-            resolution_y = FT_ABS( (FT_Short)prop->value.l );
+            resolution_y = FT_ABS( (FT_Short)value );
         }
 
         if ( bsize->y_ppem == 0 )