[XeTeX] Finding out if a font supports a particular Unicode character and using it

Peter Baker psb6m at virginia.edu
Mon Feb 1 14:11:25 CET 2010


Chris Jones wrote:
> I maintain a debian squeeze system on another partition so I can find
> out what I'm in for when "testing" becomes "stable". Let me check the
> version of fontforge on that system and run a test to see if it make a
> difference.
>   
Here are a couple of other tests:

Open unifont.ttf in the FontForge GUI and see what happens. Does it 
freeze the machine?

Try this minimal Python script (make sure not to lose the spacing):

import fontforge
import sys

try:
    f = fontforge.open(sys.argv[1])
except Exception:
    sys.stderr.write("Couldn't open " + sys.argv[1] + "\n")
else:
    try:
        gly = f['A']
    except TypeError:
        sys.stdout.write("This font doesn't contain the letter A\n")
    else:
        sys.stdout.write("This font contains the letter A\n")
    f.close()

> Also, I checked my ~/.fontswith/ directory and found a fontswith.index
> file in there and quickly browsing it confirmed that your script had
> successfully indexed GNU/unifont at some point. 
>
> I ran a quick test that quickly revealed the following:
>
> | $ fontswith ~/.fontswith/fontswith.index U+5D0
> | These fonts contain the glyph U+05D0:
> | unifont: ./unifont.ttf
>
> So it looks like the indexing did work at some point.
>
>   
That was probably from an earlier version: the current version uses 
bzip2 to compress the index. If you use bzip2 to make 
~/.fontswith/fontswith.index.bz2, then fontswith will see it and use it 
automatically. Or use the -n or --no-bz2 option to automatically use the 
uncompressed index. If you type fontswith -h you'll get some additional 
usage info.

Peter



More information about the XeTeX mailing list