[lltx] Reencode chessfonts with luaoftload
Khaled Hosny
khaledhosny at eglug.org
Mon Oct 25 13:07:29 CEST 2010
On Mon, Oct 25, 2010 at 11:51:45AM +0200, Ulrike Fischer wrote:
> Hello,
>
> I'm currently a bit playing around with the idea to add some support
> in the chessfss package for system fonts.
>
> Chess fonts are highly unstandard. The different authors of the
> fonts did put the chars quite randomly in the character table and
> also used various glyphs name. 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
>
> So to be able to use ttf-fonts etc directly I must reencode the
> fonts (without changing the original fonts).
>
> I was able to substitute glyphs with a .fea-file:
>
> feature renc {
> substitute K by c140;
> } renc;
>
>
> and use this in this way:
>
> \documentclass{article}
>
> \usepackage{luaotfload}
>
> \begin{document}
> \font\test={name:Chess Figurine Pirat}
> \test \fbox{K}
>
> \font\test={name:Chess Figurine
> Pirat:featurefile=testsubs.fea;+renc}
> \test \fbox{K}
> \end{document}
>
> Before continuing on this way I have some questions:
>
> 1. Is using a .fea-file to reencode a font the right idea?
That is not reencoding per se, just glyph substitution, so it depends on
what you want to achieve. If you are substituting from "K" glyph that
does not exist in the font, then the substitution code will be ignored
(feature files operate on glyphs not code points). If chess symbols are
supported by Unicode, then one possible solution is to actually reencode
the fonts while processed by LuaTeX so that using proper Unicode code
points will always work, but this is not trivial (well, I don't know how
to do it, actually, but it is doable since Hans is doing a similar trick
in his virtual Unicode math fonts).
> 2. Which name should I use for the feature? Is "renc" ok or can this
> give trouble somewhere?
AFAIK, there are no limitations on the tag name, but an unused 4 char
tag make sure it does not interfere with other font features (it need
not to be 4 chars though).
> 3. The pirat font (http://www.enpassant.dk/chess/downl/pirat.zip)
> used above shows already some on the problems of the project: The
> font seems to have a text font as base. To get slots for the chess
> symbols it has moved some of the chars backward. Now the king (glyph
> name c140) is on position 140, the position of å, the å is on
> position 229 (Å), luaotfload seems to haved realized this, the
> temp-lua-file of the font contains c140={ 229, 140 } and my
> substituation rule gets me an "å" instead of the King I want. How
> can I correct to rule?
There is something odd with the fonts, it seems to have the same glyph
referenced in multiple slots, for example the king is on c162 too, so
using that instead of c140 seems to work (you have to delete the cached
font, since luaotload don't regenerate the cache when the feature is
changed).
> 4. Can I somehow tell luaotfload to always regenerate the
> temp-font.lua files during my tests?
Not here, it actually does not regenerate them when it should.
> 5. Is there some code around which generates like (nfssfont.tex) a
> neat font table of a ttf-font?
I need one, if you found any (to make tables for XITS and other fonts).
> 6. The font Alfonso
> (http://www.enpassant.dk/chess/downl/alfonso.zip) gives an error
> message. Probably the font is faulty somehow (I wouldn't be
> surprised) but perhaps it also indicates a hidden bug, so I'm
> mentioning it:
Looks like a deeper (may be engine bug), the font is using an unusual
trick resulting on glyphs not assigned there Unicode code point by
luatex.
--
Khaled Hosny
Arabic localiser and member of Arabeyes.org team
Free font developer
More information about the lualatex-dev
mailing list