freetype-devel
[Top][All Lists]
Advanced

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

[Devel] Fix for PFR glyph index problem


From: Detlef Würkner
Subject: [Devel] Fix for PFR glyph index problem
Date: Sun, 16 Jun 2002 10:45:32 +0200

I wrote:

> A zero returncode from FT_Get_Char_Index() is supposed to indicate
> an error. The current PCF and BDF drivers return zero for the first
> glyph which fails with e.g. the glyph cache code. To avoid that I
> changed the BDF and PCF drivers to work like the FNT driver: return
> index+1 instead of index when asked for it, use index-1 instead of
> index for glyph loading.

The same problem could be found in the PFR driver, it was not possible
to get the first glyph via the glyph cache. The fix:

----8<----
--- freetype2-current/src/pfr/pfrcmap.c.ori     Sat Apr 20 05:38:33 2002
+++ freetype2-current/src/pfr/pfrcmap.c Sun Jun 16 08:30:47 2002
@@ -71,7 +71,7 @@
       gchar = cmap->chars + mid;
 
       if ( gchar->char_code == char_code )
-        return mid;
+        return mid + 1;
 
       if ( gchar->char_code < char_code )
         min = mid + 1;
@@ -107,7 +107,10 @@
         {
           result = mid;
           if ( result != 0 )
+          {
+            result++;
             goto Exit;
+          }
 
           char_code++;
           goto Restart;
@@ -127,7 +130,10 @@
         gchar  = cmap->chars + min;
         result = min;
         if ( result != 0 )
+        {
+          result++;
           char_code = gchar->char_code;
+        }
       }
     }
 
--- freetype2-current/src/pfr/pfrobjs.c.ori     Sun Apr 28 10:25:55 2002
+++ freetype2-current/src/pfr/pfrobjs.c Sat Jun 15 13:34:16 2002
@@ -217,14 +217,17 @@
   {
     FT_Error     error;
     PFR_Face     face    = (PFR_Face)slot->root.face;
-    PFR_Char     gchar   = face->phy_font.chars + gindex;
+    PFR_Char     gchar;
     FT_Outline*  outline = &slot->root.outline;
     FT_ULong     gps_offset;
 
+    if (gindex > 0)
+      gindex--;
 
     /* check that the glyph index is correct */
     FT_ASSERT( gindex < face->phy_font.num_chars );
 
+    gchar               = face->phy_font.chars + gindex;
     slot->root.format   = ft_glyph_format_outline;
     outline->n_points   = 0;
     outline->n_contours = 0;
----8<----

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



reply via email to

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