freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master cb7a512: [pcf] Improve `FT_ABS' fix from 2015-09-17 (


From: Werner LEMBERG
Subject: [freetype2] master cb7a512: [pcf] Improve `FT_ABS' fix from 2015-09-17 (#45999).
Date: Sat, 19 Sep 2015 05:58:15 +0000

branch: master
commit cb7a5122e15d3013bd51cfedc8e5d723b6e2e33c
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    [pcf] Improve `FT_ABS' fix from 2015-09-17 (#45999).
    
    * src/pcf/pcfread.c (pcf_load_font): Do first the cast to FT_Short,
    then take the absolute value.
    Also apply FT_ABS to `height'.
---
 ChangeLog         |    8 ++++++++
 src/pcf/pcfread.c |   19 ++++++++++++-------
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 511c8cc..6d41da6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2015-09-19  Werner Lemberg  <address@hidden>
+
+       [pcf] Improve `FT_ABS' fix from 2015-09-17 (#45999).
+
+       * src/pcf/pcfread.c (pcf_load_font): Do first the cast to FT_Short,
+       then take the absolute value.
+       Also apply FT_ABS to `height'.
+
 2015-09-17  Werner Lemberg  <address@hidden>
 
        [type42] Fix memory leak (#45989).
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index 9d8d794..afa1480 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -1272,13 +1272,18 @@ THE SOFTWARE.
 
         FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) );
 
+        /* for simplicity, we take absolute values of integer properties */
+
 #if 0
         bsize->height = face->accel.maxbounds.ascent << 6;
 #endif
-        bsize->height = (FT_Short)( face->accel.fontAscent +
-                                    face->accel.fontDescent );
 
-        /* for simplicity, we take absolute values of integer properties */
+#ifdef FT_DEBUG_LEVEL_TRACE
+        if ( face->accel.fontAscent + face->accel.fontDescent < 0 )
+          FT_TRACE0(( "pcf_load_font: negative height\n" ));
+#endif
+        bsize->height = FT_ABS( (FT_Short)( face->accel.fontAscent +
+                                            face->accel.fontDescent ) );
 
         prop = pcf_find_property( face, "AVERAGE_WIDTH" );
         if ( prop )
@@ -1287,7 +1292,7 @@ THE SOFTWARE.
           if ( prop->value.l < 0 )
             FT_TRACE0(( "pcf_load_font: negative average width\n" ));
 #endif
-          bsize->width = (FT_Short)( ( FT_ABS( prop->value.l ) + 5 ) / 10 );
+          bsize->width = FT_ABS( (FT_Short)( ( prop->value.l ) + 5 ) / 10 );
         }
         else
           bsize->width = (FT_Short)FT_MulDiv( bsize->height, 2, 3 );
@@ -1312,7 +1317,7 @@ THE SOFTWARE.
           if ( prop->value.l < 0 )
             FT_TRACE0(( "pcf_load_font: negative pixel size\n" ));
 #endif
-          bsize->y_ppem = (FT_Short)FT_ABS( prop->value.l ) << 6;
+          bsize->y_ppem = FT_ABS( (FT_Short)prop->value.l ) << 6;
         }
 
         prop = pcf_find_property( face, "RESOLUTION_X" );
@@ -1322,7 +1327,7 @@ THE SOFTWARE.
           if ( prop->value.l < 0 )
             FT_TRACE0(( "pcf_load_font: negative X resolution\n" ));
 #endif
-          resolution_x = (FT_Short)FT_ABS( prop->value.l );
+          resolution_x = FT_ABS( (FT_Short)prop->value.l );
         }
 
         prop = pcf_find_property( face, "RESOLUTION_Y" );
@@ -1332,7 +1337,7 @@ THE SOFTWARE.
           if ( prop->value.l < 0 )
             FT_TRACE0(( "pcf_load_font: negative Y resolution\n" ));
 #endif
-          resolution_y = (FT_Short)FT_ABS( prop->value.l );
+          resolution_y = FT_ABS( (FT_Short)prop->value.l );
         }
 
         if ( bsize->y_ppem == 0 )



reply via email to

[Prev in Thread] Current Thread [Next in Thread]