freetype-devel
[Top][All Lists]
Advanced

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

Bugs in in freetype2


From: Tor Lillqvist
Subject: Bugs in in freetype2
Date: Wed, 7 Jun 2000 03:48:07 +0300 (EETDST)

Hi,

I noticed a bug in the src/sfnt/ttcmap.c:code_to_index4() function in
freetype2. It worked very strangely. I found this while hacking on
the gimp-freetype plug-in to work also for non-ASCII characters.

The bug is that the calculation of index1 uses segCount, which the
loop decrements. However, if we jump directly to Found: (when the
charCode is found in the cached last segment), segCount is wrong.

Suggested patch below. segCount no longer is decremented in the loop,
instead pointer arithmetic is used at Found:. Also, the check for
match in the cached last segment is made using a clearer expression,
at least to my eyes ;-)

(I will leave for 3 weeks vacation tomorrow, no use mailing be before
July.)

Index: src/sfnt/ttcmap.c
===================================================================
RCS file: /cvsroot/freetype2/src/sfnt/ttcmap.c,v
retrieving revision 1.9
diff -u -2 -r1.9 ttcmap.c
--- ttcmap.c    2000/06/07 00:00:08     1.9
+++ ttcmap.c    2000/06/07 08:41:51
@@ -453,9 +453,8 @@
     /* check against the last segment */
     seg4 = cmap4->last_segment;
-    if ( (TT_ULong)(charCode       - seg4->startCount) <
-         (TT_ULong)(seg4->endCount - seg4->startCount) )
+    if ( charCode >= seg4->startCount && charCode <= seg4->endCount )
       goto Found;
 
-    for ( seg4 = cmap4->segments; seg4 < limit; seg4++, segCount-- )
+    for ( seg4 = cmap4->segments; seg4 < limit; seg4++ )
     {
       /* the ranges are sorted in increasing order.  If we are out of */
@@ -481,6 +480,7 @@
       /* otherwise, we must use the glyphIdArray to do it */
       index1 = seg4->idRangeOffset / 2
-               + ( charCode - seg4->startCount )
-               - segCount;
+              + ( charCode - seg4->startCount )
+              + ( seg4 - cmap4->segments )
+              - segCount;
 
       if ( index1 < cmap4->numGlyphId       &&



Another problem with freetype2 is that the makefile rules to recognize
gcc don't work if $(CC) also contains some options (-mno-cygwin
-fnative-struct in my case). Suggested fix:

Index: demos/graph/win32/rules.mk
===================================================================
RCS file: /cvsroot/freetype2/demos/graph/win32/rules.mk,v
retrieving revision 1.3
diff -u -2 -r1.3 rules.mk
--- rules.mk    2000/05/12 15:01:16     1.3
+++ rules.mk    2000/06/07 08:41:51
@@ -27,5 +27,5 @@
 # Now update COMPILE_GRAPH_LIB according to the compiler used on Win32
 #
-ifeq ($(CC),gcc)   # test for GCC
+ifeq ($(firstword $(CC)),gcc)   # test for GCC
 LINK              = $(CC) $T$@ $< $(FTLIB)
 COMMON_LINK       = $(LINK) $(COMMON_OBJ)


Cheers,
--tml




reply via email to

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