freetype-devel
[Top][All Lists]
Advanced

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

[Devel] Fix for type1 custom encoding glyph index problem


From: Detlef Würkner
Subject: [Devel] Fix for type1 custom encoding glyph index problem
Date: Mon, 17 Jun 2002 21:33:19 +0200

address@hidden (Anthony Fok) wrote:

> I wonder if it is related to the same changes in FreeType 2.1.1: After
> upgrading FreeType 2.1.1, Nautilus is no longer able to display
> anti-aliased fonts under the icons.  It appears that librsvg1
> (SAX-based renderer library for SVG files) is responsible for calling
> FreeType to render the fonts; it works with TrueType fonts, but not
> with Type 1 fonts: it would display "no glyph loaded for character
> '%c'" instead. Not sure why, and a simple recompile didn't seem to fix
> the problem. Perhaps the Type1 driver has the same problem of getting
> the first glyph via the glyph cache too?

Hm - the index returned by the type1 driver is an index into the encoding
array which IMHO can only be zero if the font has a custom encoding which
assigns a code to index 0, never seen that.

But I've found that the type1 custom encoding cmap support had an error,
it returned the wrong glyph indices for type1 fonts with custom encoding
array of 256 entries when the first entry in the encoding array was not 0
(cmap->indices starts at 0 not at cmap->first). I hope this does not
break something else:

----8<----
--- freetype2-current/src/psaux/t1cmap.c.ori    Sun Apr 14 00:54:31 2002
+++ freetype2-current/src/psaux/t1cmap.c        Mon Jun 17 18:43:41 2002
@@ -197,12 +197,11 @@
                              FT_UInt32      char_code )
   {
     FT_UInt    result = 0;
-    FT_UInt32  idx;
 
 
-    idx = (FT_UInt32)( char_code - cmap->first );
-    if ( idx < cmap->count )
-      result = cmap->indices[idx];
+    if ( ( char_code >= cmap->first )                  &&
+         ( char_code < ( cmap->first + cmap->count ) ) )
+      result = cmap->indices[char_code];
 
     return result;
   }
@@ -214,7 +213,6 @@
   {
     FT_UInt    result = 0;
     FT_UInt32  char_code = *pchar_code;
-    FT_UInt32  idx;
 
 
     ++char_code;
@@ -222,10 +220,9 @@
     if ( char_code < cmap->first )
       char_code = cmap->first;
 
-    idx = (FT_UInt32)( char_code - cmap->first );
-    for ( ; idx < cmap->count; idx++, char_code++ )
+    for ( ; char_code < ( cmap->first + cmap->count ); char_code++ )
     {
-      result = cmap->indices[idx];
+      result = cmap->indices[char_code];
       if ( result != 0 )
         goto Exit;
     }
----8<----

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



reply via email to

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