TTC indexes, the hard way...

by Michael S. Kaplan, published on 2007/06/22 03:01 -04:00, original URI:

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:


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.


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)

# Meema on 24 Jun 2007 11:31 PM:

Thanks! Yup, parsed the whole darn thing. Had to use EnumFontFamiliesEx(...) since GetOutlineTextMetrics(...) has a bug on Vista and couldn't get the Full Name of the provided font in HDC.

I'm kinda glad there's not easier way of doing it. I would have shot my leg knowing I went through all that for nothing.

referenced by

2007/07/07 TTC indexes, the easy way...

go to newer or older post, or back to index or month or day