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

Peter Baker psb6m at virginia.edu
Thu Feb 4 22:54:41 CET 2010

Thanks to François Charette and Michiel Kamermans for sharing their 
code. I'll look forward to studying their examples and learning 
something from them.

Meanwhile, I've updated my own script. It can't read font files as fast 
as François's, but thanks to FontForge's support for many formats of 
outline font, it's pretty universal. It's happy to index TTF, OTF, TTC, 
PFB and PFA fonts. If the installed version of FontForge is recent 
enough (built Sept. 2009 or later), it will supply Unicode encodings for 
PFB and PFA fonts when possible; and of course you can search by glyph 
name as well. Once an index is built, a search takes 1 to 4 seconds 
(depending largely on whether the index is compressed).

It's got an option to exclude a font from a search or from an indexing 
operation (so Chris doesn't have to index the Unifont over and over!); 
it will also delete fonts from the index.

Indexes for the new version are much smaller than for the old. Any 
operation on the index (aside from just reading it) causes it to be 
updated to the new, smaller format. Convert the index without doing 
anything else by running

fontswith --build-index --exclude=*

It's here: http://faculty.virginia.edu/OldEnglish/fontswith/fontswith.zip


François Charette wrote:
> Hello all,
> Sorry to chime in so late in the discussion, but I just realized I've 
> written a similar tool some time ago, in Perl. It does not rely on 
> fontforge, but it is based on the CPAN module Font::TTF (which also 
> works with OTF) by Martin Hosken of SIL. It does not perform indexing, 
> but it is nevertheless quite fast, even with a relatively large 
> collection of fonts. It should also work on all platforms, including 
> Windows.
> Here is a sample output on my Linux system:
> $ time fontcheck.pl 2605
> Looking in 409 system fonts ...
> The glyph ★ (0x2605) is available in the following fonts:
> Bitstream Cyberbit Roman
> DejaVu Sans Bold
> DejaVu Sans Bold Oblique
> DejaVu Sans Book
> DejaVu Sans Condensed Bold
> DejaVu Sans Condensed Bold Oblique
> DejaVu Sans Condensed Book
> DejaVu Sans Condensed Oblique
> DejaVu Sans Mono Bold
> DejaVu Sans Mono Book
> DejaVu Sans Oblique
> FreeMono Medium
> FreeSerif Bold
> FreeSerif Medium
> Linux Biolinum Bold
> Linux Biolinum O Bold
> Linux Biolinum O Regular
> Linux Biolinum Regular
> Linux Libertine Bold
> Linux Libertine Bold Italic
> Linux Libertine C Regular
> Linux Libertine Italic
> Linux Libertine O Bold
> Linux Libertine O Bold Italic
> Linux Libertine O C Regular
> Linux Libertine O Italic
> Linux Libertine O Regular
> Linux Libertine Regular
> Lucida Sans Regular
> TITUS Cyberbit Basic Regular
> real 0m2.470s
> user 0m2.390s
> sys 0m0.073s
> I've attached the script, in case someone is interested in using or 
> modifying it. Note that you may have to change the paths where fonts 
> are located on your system. Currently these are set to 
> /usr/share/fonts and $HOME/.fonts (lines 38-39).
> Best,
> FC
> ------------------------------------------------------------------------
> --------------------------------------------------
> Subscriptions, Archive, and List information, etc.:
>   http://tug.org/mailman/listinfo/xetex

More information about the XeTeX mailing list