[XeTeX] chess fonts with xelatex

Jonathan Kew jonathan_kew at sil.org
Sun Jan 13 20:35:45 CET 2008


On 13 Jan 2008, at 3:06 pm, Ulrike Fischer wrote:

> Am Sat, 12 Jan 2008 23:56:20 +0000 schrieb Jonathan Kew:
>
>> On 12 Jan 2008, at 2:58 pm, Ulrike Fischer wrote:
>>
>>> I was now wondering if I could add some support for ttf chess fonts
>>> installed in the normal (windows) fonts folder. To be able to do it
>>> I must somehow reencode the fonts.
>>>
>>> Unicode can not be used as chess fonts are highly unstandard. Most
>>> chars don't have a unicode number. Also the different authors of the
>>> fonts did put the chars quite randomly in the character table and
>>> also used various glyphs name.
>>
>> There are chess pieces encoded at U+2654 onwards, but yes, I expect
>> various chess fonts have additional idiosyncratic glyphs that may not
>> have Unicode values. And old chess fonts probably don't use the
>> Unicode encoding even for the basic symbols.
>
> The chess pieces encoded in Unicode are only the ones of the
> "figurine" set, which are used to print the notation of a game. But
> chessfss deals also with the chars for boards and the so-called
> informator symbols (for comments).
>
>
>
>>
>>> So in the psfonts.map almost every font has its own encoding vector:
>>>
>>> chess-pirat-lsf ChessFigurinePirat " ChessPiratFigEncoding
>>> ReEncodeFont " <chess-pirat-fig.enc <chess-pirat-fig-raw.pfb
>>>
>>> How could such reencoding be done with XeTeX if the fonts are in the
>>> system font folder?
>>
>> I suppose it should be possible to use the font-mapping mechanism
>> (like the tex-text mapping that's commonly used with Latin-script
>> fonts).
>
> I already looked a bit at the font-mapping. As far as I understand
> it, I would have to add the mapping command to the .fd-files. Which
> means that I would have to define new encodings (like the
> eu-Encoding) solely for the use with XeTeX and maintain a lot of
> additional .fd-files and additional code to switch between the
> encoding. I do find this quite complicated. Also, I don't think that
> the fd-files are the right place for informations specific to an
> engine (like xetex) or a system (like the decision if a ttf-font or
> a pfb-font, a free font or a professional one is used). With
> pdflatex/dvips you can add such informations through the
> psfonts.map: There you can decide if you want to use the mf-version
> of the ec-fonts or the cm-super-fonts, if you want to use the
> urw-version of times or a professional one.
>
> Isn't there anywhere a file similar to the psfonts.map where you can
> define "font aliases" but which is specific to XeTeX so that is
> don't mess up dvips and pdflatex? Or a command like the pdfmapfile
> of pdflatex?

Those maps aren't used by xetex itself, but by the output driver.  
xdvipdfmx uses the same maps as dvipdfmx (see dvipdfmx.cfg), which in  
a typical configuration also uses dvipdfm.map. It also supports a  
\special{...} form of the \pdfmapfile and \pdfmapline commands from  
pdftex. However, all this applies to fonts that are used via TFM  
files; none of it applies to fonts used "directly" without TFM data.  
The driver map files, as I see it, exist primarily to relate TFM  
names (which are all TeX knows) to physical fonts that can be  
rendered to an output device (PFB or other files); they may *also*  
deal with re-encoding, but only in the context of this TFM-to-output  
font association. When XeTeX uses a TTF (or other) font directly from  
the system's installed font collection, the entire TFM business is  
bypassed.

>
>
>> You could write mappings for each font to map some standard
>> character encoding (preferably Unicode!) to the font-specific codes
>> needed.
>
> The mappings to a standard encoding (and the standard itself)
> already exist: That's the main part of enpassant/chessfss. I only
> have to find a way to tell XeLaTex to use them even for fonts which
> are not installed in the texmf-tree.

The only way I can think of is the font-mapping mechanism with font- 
specific mappings that (or, I suppose, distinct "encodings" for each  
different chess font, and then define the various commands to access  
the appropriate character codes from that encoding).

As I think about it, though, I'd suggest that the font-mapping  
feature *does* provide a "font aliases" feature within xetex. When  
you say

   \font\x = "My Special Chess Font:mapping=mychess"

to load an installed font, that's an "alias" for "My Special Chess  
Font", but allows you to effectively re-encode it by applying a  
character mapping.

I don't know how chessfss works internally, but if it's at all like  
NFSS, it ought to be possible to load fonts similarly to how fontspec  
does it for text fonts. And that allows them to be loaded with custom  
font-mappings, with no need for .fd files, etc. Can't you have

   \setchessfont[Mapping=mychess]{My Special Chess Font}

just like fontspec's \setmainfont, etc.? Then all you need is the  
appropriate mapping from your standard internal encoding to each  
chess font's private encoding.

> And if in some future Unicode
> encodes the chars needed I'm quite willing to adapt my standard.

If there are characters needed for chess notation that aren't yet  
encoded in Unicode, you could do the chess community a huge service  
by submitting a proposal to add these to the Standard. That's the  
best way forward towards standardized encoding and interoperable data  
and fonts, not only within the TeX world but outside it as well.

JK



More information about the XeTeX mailing list