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

R (Chandra) Chandrasekhar chyavana at gmail.com
Fri Jan 29 08:47:30 CET 2010


Jonathan Kew wrote:
> On 29 Jan 2010, at 06:42, R (Chandra) Chandrasekhar wrote:
>> 1. How might I find out if a chosen font does indeed provide this
>> symbol? I am on Kubuntu 9.10 and have kcharselect and gucharmap,
>> but do not know of an efficient way of finding this out. Are there
>> any utilities to do this efficiently?
> 
> I'll leave this for someone familiar with utilities available on
> Kubuntu. (To examine an individual font, you could open it with
> FontForge, or you could write a small xetex file using the
> \iffontchar primitive to check for the existence of the character.
> But I wouldn't consider that an efficient approach to finding
> suitable fonts, that's just checking them at random until you find
> one that works.)

I stumbled upon this website from a Google search and it seems to list 
font support for a block as a percentage:

http://www.fileformat.info/info/unicode/block/miscellaneous_symbols/fontsupport.htm

and

http://www.fileformat.info/info/unicode/block/dingbats/fontsupport.htm

This might be an interim solution and has given me DejaVu Sans as a good 
choice for either symbol.

>> 2. Once I have found a font supporting the desired symbol, how
>> might I invoke this symbol in a .tex file to be processed by
>> XeLaTeX? I am thinking along the lines of:
>> 
>> \newfontfamily{\myfont}[Script=????]{Font????}
> 
> No need for [Script=....]; this doesn't require a script-specific
> shaping engine.
> 
>> \newcommand{\pentagram}{\myfont ★}
> 
> You'll want to add braces for grouping, as in
> 
> \newcommand{\pentagram}{{\myfont ★}}
> 
> so that the font change doesn't stay in effect for the following
> text.
> 
> JK

Thank you JK. I have now tried the command out with DejaVu Sans and I 
have gotten what I was after :-)

Chandra


More information about the XeTeX mailing list