[Fontconfig] Re: fc-glyphname bug

James Cloos cloos at jhcloos.com
Wed Mar 7 10:13:56 PST 2007


Here is my propsed patch to fix the infinite loop and then to add
glyphlist.txt back into the generated fcglyphname.h.

It can be pulled (as two commits) from:

git://people.freedesktop.org/~cloos/fontconfig.git

(also via http://, ssh:// or ~cloos/fontconfig.git on annarchy.)

First:

,----
| commit 8b7624793de2b1a7ddf75fe338861495d694f68c
| Author: James Cloos <cloos at jhcloos.com>
| Date:   Wed Mar 7 12:36:28 2007 -0500
| 
|     Prevent infinite loop
|     
|         fc-glyphname/fc-glyphname.c:insert() could
|         enter an infinite loop if the 3rd arg was
|         an integer multiple of rehash.
|     
|         Prevent the infinite loop by incrementing
|         i by 1 in the while{} whenever r is 0.
| 
| diff --git a/fc-glyphname/fc-glyphname.c b/fc-glyphname/fc-glyphname.c
| index faaa63b..a0e18e7 100644
| --- a/fc-glyphname/fc-glyphname.c
| +++ b/fc-glyphname/fc-glyphname.c
| @@ -207,7 +207,7 @@ insert (FcGlyphName *gn, FcGlyphName **table, FcChar32 h)
|      while (table[i])
|      {
|         if (!r) r = (int) (h % rehash);
| -       i += r;
| +       i += r ? r : 1;
|         if (i >= hash)
|             i -= hash;
|      }
`----

and then:

,----
| commit b63d40d0a1782dec43a8080d580a01d585e71aea
| Author: James Cloos <cloos at jhcloos.com>
| Date:   Wed Mar 7 12:39:29 2007 -0500
| 
|     Include (Adobe) glyphlist.txt into generated fcglyphname.h
|     
|         Last commit fixed the infinite loop that prevented
|         the inclusion of glyphlist.txt into the genereted
|         fcglyphname.h file.
|     
|         So now include it.
| 
| diff --git a/fc-glyphname/Makefile.am b/fc-glyphname/Makefile.am
| index 063ba00..709e11b 100644
| --- a/fc-glyphname/Makefile.am
| +++ b/fc-glyphname/Makefile.am
| @@ -38,8 +38,8 @@ noinst_HEADERS=$(TARG)
|  
|  noinst_MANS=fc-glyphname.man
|  
| -GLYPHNAME=zapfdingbats.txt
| -SGLYPHNAME=${top_srcdir}/fc-glyphname/zapfdingbats.txt
| +GLYPHNAME=zapfdingbats.txt glyphlist.txt
| +SGLYPHNAME=${top_srcdir}/fc-glyphname/zapfdingbats.txt ${top_srcdir}/fc-glyphname/glyphlist.txt
|  
|  EXTRA_DIST=$(TMPL) $(GLYPHNAME)
|  
| 
| 
`----

Together these get around the bug I was seeing with caching the urw
Symbol clone, by ensuring that FC_GLYPHNAME_MAXLEN is larger than
the length of the glyphnames in Standard Symbols L.

That said, should FC_GLYPHNAME_MAXLEN be only as long as the longest
name processed by fc-glyphname when fc is built?  Or should it be long
enough to handle any valid PostScript glyph name?  (Which is 127
according to the PLRM.)

-JimC
-- 
James Cloos <cloos at jhcloos.com>         OpenPGP: 1024D/ED7DAEA6


More information about the Fontconfig mailing list