Reputation: 580
The Windows Control Panel fonts window typically displays version information for the font. e.g.
Font Name: Fontawesome
Version: Version 4.3.0 2015
I have searched in the Windows API and SO, but I have not managed to find how to extract this programmatically.
Any ideas?
Upvotes: 1
Views: 582
Reputation: 514
If you have a IDWriteFont instance, you can call IDWriteFont::GetInformationalStrings with DWRITE_INFORMATIONAL_STRING_VERSION_STRINGS
Upvotes: 0
Reputation: 53598
Note that if you're talking about the font preview program; that is not "Windows", that's actually just a small utility application that comes bundled with the OS. To show you that information, it consults information from the font's name
table (spec here, for understanding its structure, with the semantics of each record id
explained in the "Name IDs" section).
To access this data yourself, use DirectWrite's (not GDI, because it's ancient and obsolete) IDWriteFontFace::TryGetFontTable method, and get a reference to the name
table, which every valid OpenType font contains. Then extract the values you need as per the spec for the naming table.
And to be clear: both ttf
and otf
fonts are OpenType fonts, the first is just "OpenType with outlines encoded using the TrueType table layout" and the second is "OpenType with outlines encoded using a CFF data block". If you don't know what the difference between those two is, that's because the difference doesn't matter: it's as if we decided to call PNG files nil
and ili
files depending on whether they used interlacing or not.
(The ttf
file extension simply predates the OpenType spec itself, and so when everyone switched to OpenType fonts, the extension was kept for backward compatibility. After several decades now, it turns out it's way easier to just keep doing that instead of deciding "when to get rid of it", so we're stuck with both extensions being used for the same kind of file. History!)
Upvotes: 3