Friday, June 22, 2007 12:01 AM
Michael S. Kaplan
TTC indexes, the hard way...
I swear that I had already answered this question, but I couldn't find it anywhere. Hopefully it isn't a repeat. :-)
Meema asked in the Suggestion Box:
hi!
I have been looking for a solution that doesn't require parsing the actual TTC file bytes. Is there any way of getting the ttc index of a font (given the facename and style or just hDC/LOGFONT)?
Thanks. I appreciate any answer.
Meema
Unfortunately, there is not a way to do this.
You have to work with the description of the OpenType file format (here) and its information about the TTC Header table, which will have pointers to the individual fonts inside the file (and from there you can get the names of each font and eventually work backward based on the index).
This is obviously not as entirely trivial as one might like (using the best metric there is, the amount of samples that are out there, which is approximately none!).
So I talked to Sergey about the possibility of putting together some examples for working with font files for problems like this -- real problems if you want to work with functions like TTEmbedFontFromFileA and CreatFontPackage that just assume you have this data. And lots of other random tidbits that one might want to get at....
And I might also play a bit more in this space, like I did in Getting all of the localized names of a font. Because going in blind to specs like the OTF/TTF one to write a bit of code actually make for interesting little projects to work on.... :-)
This post brought to you by ശ (U+0d36, a.k.a. MALAYALAM LETTER SHA)