From: Christian Stapfer on
Here's an interesting little problem: I am given a master.ttf font file and
a subset file subset.ttf of that font, and I am asked to map indices of all
the glyphs in subset.ttf to the corresponding indices in master.ttf. The
subset font file is the result of a pipeline of 3 tools (pdflatex, Adobe
Reader, and the Microsoft XPS Document Writer).
The resulting document format (XAML) holds indices into subset.ttf, and in
order to display that document with reference to master.ttf, I need to do
this mapping of indices: subset -> master.
(Carrying subset.ttf along with the XAML code is not an option, I think,
because I need to be able to support copy and paste of small snippets from
that document through a shared whiteboard.)

I have tried to parse the two font files to the point of having the x- and
y-coordinate points of the outlines of glyphs handy. But, unfortunately,
subset.ttf has been processed in a way that makes it very difficult to
compare its glyph outlines with the outlines of glyphs in master.ttf.

So my next best idea is to draw the various glyphs as, 16x16 B/W images,
say, and use the 16*16 bits (that is, 16 ints or 8 longs) that result from
this as a sufficiently precise description of the glyph to do the necessary
comparisons.

PIL would be great for this, except for one "little" problem: I need to be
able to draw glyphs based on their index, not based on their character code.

Any ideas to get around that limitation of PIL's drawing primitives?

Thanks in advance,
Christian

From: Christian Stapfer on
"Christian Stapfer" <nobody(a)nowhere.nil> schrieb im Newsbeitrag
news:b7256$4bf516e1$544ba447$20752(a)news.hispeed.ch...
> Here's an interesting little problem: I am given a master.ttf font file
> and a subset file subset.ttf of that font, and I am asked to map indices
> of all the glyphs in subset.ttf to the corresponding indices in
> master.ttf. The subset font file is the result of a pipeline of 3 tools
> (pdflatex, Adobe Reader, and the Microsoft XPS Document Writer).

<snip/>

> So my next best idea is to draw the various glyphs as, 16x16 B/W images,
> say, and use the 16*16 bits (that is, 16 ints or 8 longs) that result from
> this as a sufficiently precise description of the glyph to do the
> necessary comparisons.
>
> PIL would be great for this, except for one "little" problem: I need to be
> able to draw glyphs based on their index, not based on their character
> code.
>
> Any ideas to get around that limitation of PIL's drawing primitives?

To answer my own question: I might parse the cmap table of the ttf file, and
then invert that mapping char->index. I think that's going to be the next
approach that I will try.

Regards,
Christian