2
votes

Alrighty, I promise this is the closest I'll ever get to a "code for me" question :) If this doesn't drum up any responses I'll bite the bullet and build an OTF parser to check for the existence of a CFF table.

This info is available in the Windows font preview ('TrueType outlines' vs 'PostScript outlines'), so presumably there's a WinAPI function to this effect, but damned if I can find it.

Thoughts anyone?

ps - It's not a dealbreaker if only installed fonts can be checked, but checking files would be preferable.

4
Questions are not supposed to contain the "solution", so I rolled back to your original question. If you feel your edit added something not mentioned in the existing answers, you are free to add an answer of your own! If you want to: the previous version of your question is still available in its Edit history.Jongware

4 Answers

3
votes

You can do this using the GetFontData function.

Create the font in question and select it into a DC, then call GetFontData to query the size of the CFF table. This will only succeed if the font has PostScript outlines.

DWORD dwSize = GetFontData(hdc, ' FFC', 0, nullptr, 0);
if (dwSize && dwSize != GDI_ERROR)
{
    // has PostScript outlines
}
1
votes

The OpenType spec says:

OpenType fonts containing CFF data should use the tag 'OTTO' as the sfnt version number.

So, if the first four bytes of the file spell "OTTO" it uses PostScript outlines. Could it be simpler!? Tested & working so far, but I'll probably use GetFontData in the end.

0
votes

Your best bet indeed seems to be to directly read the font tables from the font file itself. This sample here will give to a head start, assuming you're already familiar with the font tables. If not, read the links in the Reference section at the bottom of the article.

0
votes

The first 4 bytes of a OpenType file who has a CFF block are "OTTO".