Creative Docs .NET failed to start on some machines, crashing while it was building its font list. Thanks to the help of one of the early testers, I've been able to spot the source of these troubles. It all comes down to the Win32 function
GetFontData handling of TTC fonts (
TrueType Collections).
GetFontData can be used to load specific OpenType font tables by specifying a table name in its
dwTable argument, but it can also be used to load the full font file by specifying
zero instead. This is what I use to get access to all font tables and parse the OpenType information myself.
However, when
GetFontData is applied on a TTC font, it returns only the first TrueType font in the collection, dropping the
TTC Header (which consists of the
"ttcf" tag, a version, number of fonts in TTC and an offset table specifying where each font starts in the TTC file). The result is a crippled TrueType font, where all internal table offsets are wrong.
Searching for the topic on the web did not provide any resolution to the problem, unless you consider smart-guessing the offsets to be a clean and effective solution.
So I am quite happy to have found a working solution: just call
GetFontData by asking it to return the table called "ttcf" (set
dwTable to
0x66637474) and you will get the whole TTC font. Finding the start of the first TrueType font is then just a matter of indexing into the
OffsetTable...