freetype-devel
[Top][All Lists]
Advanced

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

[Devel] PCF bitmap bounding box patch (was: pcfdriver.c memory leak)


From: Detlef Würkner
Subject: [Devel] PCF bitmap bounding box patch (was: pcfdriver.c memory leak)
Date: Wed, 06 Feb 2002 15:13:06 +0100

address@hidden (David Turner) wrote:

> Francesco Zappa Nardelli a écrit :
> > 
> > This patch looks good to me.  Can somebody commit it?
> >
> 
> Done, as well as the patch managing the "AVERAGE_WIDTH"
> property.. _Please_ test..

Sorry, found some fonts with negative AVERAGE_WIDTH...
This version uses the global bounding box of the PCF bitmap
font if possible, thanks to George Williams for the hint with
the accelerator table. The XFree86 base fonts all have usable
sizes with it, hopefully its now foolproof enough...
----8<----
--- freetype2-current/src/pcf/pcfread.c.ori     Wed Feb  6 13:55:26 2002
+++ freetype2-current/src/pcf/pcfread.c Wed Feb  6 13:59:13 2002
@@ -908,7 +908,6 @@
     {
       FT_Face       root = FT_FACE( face );
       PCF_Property  prop;
-      int           size_set = 0;
 
 
       root->num_faces = 1;
@@ -967,57 +966,56 @@
       if ( ALLOC_ARRAY( root->available_sizes, 1, FT_Bitmap_Size ) )
         goto Bail;
 
-      prop = pcf_find_property( face, "PIXEL_SIZE" );
-      if ( prop != NULL )
+      if ( face->accel.maxbounds.characterWidth > 0 )
+        root->available_sizes->width = face->accel.maxbounds.characterWidth;
+      else
       {
-        root->available_sizes->height = 
-        root->available_sizes->width  = (FT_Short)( prop->value.integer );
-        
-        prop = pcf_find_property( face, "AVERAGE_WIDTH" );
-        if ( prop != NULL )
-          root->available_sizes->width = (FT_Short)( prop->value.integer / 10 
);
-        
-        size_set = 1;
+        prop = find_property( face, "AVERAGE_WIDTH" );
+        if ( ( prop != NULL ) && ( prop->value.integer > 0 ) )
+          root->available_sizes->width =
+            (FT_Short)( prop->value.integer / 10 );
       }
-      else 
+
+      if ( ( face->accel.maxbounds.ascent > 0 ) &&
+           ( face->accel.maxbounds.descent >= 0 ) )
+        root->available_sizes->height =
+          face->accel.maxbounds.ascent + face->accel.maxbounds.descent;
+      else
       {
-        prop = pcf_find_property( face, "POINT_SIZE" );
+        prop = find_property( face, "PIXEL_SIZE" );
         if ( prop != NULL )
+          root->available_sizes->height = (FT_Short)( prop->value.integer );
+        else 
         {
-          PCF_Property  xres, yres, avgw;
-
+          prop = find_property( face, "POINT_SIZE" );
+          if ( prop != NULL )
+          {
+            PCF_Property  yres;
 
-          xres = pcf_find_property( face, "RESOLUTION_X" );
-          yres = pcf_find_property( face, "RESOLUTION_Y" );
-          avgw = pcf_find_property( face, "AVERAGE_WIDTH" );
 
-          if ( ( yres != NULL ) && ( ( xres != NULL ) || ( avgw == NULL ) ) )
-          {
-            root->available_sizes->height =
-              (FT_Short)( prop->value.integer *  
-                          yres->value.integer / 720 ); 
-
-            if ( avgw != NULL )
-              root->available_sizes->width =
-                (FT_Short)( avgw->value.integer / 10 );
-            else
-              root->available_sizes->width =
+            yres = find_property( face, "RESOLUTION_Y" );
+            if ( yres != NULL )
+              root->available_sizes->height =
                 (FT_Short)( prop->value.integer *  
-                            xres->value.integer / 720 );
-                  
-            size_set = 1;
+                            yres->value.integer / 720 ); 
           }
         }
       }
 
-      if (size_set == 0 )
+      if ( root->available_sizes->width == 0 )
       {
+        if ( root->available_sizes->height == 0 )
+        {
 #if 0
-        printf( "PCF Warning: Pixel Size undefined, assuming 12\n");
+           printf( "PCF Warning: Pixel Size undefined, assuming 12\n");
 #endif
-        root->available_sizes->width  = 12;
-        root->available_sizes->height = 12;
+           root->available_sizes->width  = 12;
+        }
+        else
+           root->available_sizes->width = root->available_sizes->height;
       }
+      if ( root->available_sizes->height == 0 )
+         root->available_sizes->height = root->available_sizes->width;
 
       /* XXX: charmaps.  For now, report unicode for Unicode and Latin 1 */
       root->charmaps     = &face->charmap_handle;
----8<----

Ciao, Detlef
-- 
_ // address@hidden
\X/  Detlef Wuerkner, Langgoens/Germany



reply via email to

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