Reputation: 792
https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getcharabcwidthsw
In the docs it states:
The GetCharABCWidths function retrieves the widths, in logical units, of consecutive characters in a specified range from the current TrueType font. This function succeeds only with TrueType fonts.
What exactly is not a TrueType font to GDI Win32? I tried some OTF fonts, PostScript Fonts, SVG fonts, all which the TEXTMETRIC
property tmPitchAndFamily
says is not a TTF font (TMPF_TRUETYPE
); yet the function still succeeds.
Can someone give me an explanation as to why that is? In what cases is this not safe to use for measuring glyph width? Is there a font that won't work that someone can link me to?
Would it better to be using the GDI+ function GdipMeasureString
instead? Or do I only use one or the other?
Any additional information would be appreciated.
Upvotes: 0
Views: 240
Reputation: 1179
Windows has its own legacy bitmap font format usually stored in .fon files, that's one of the examples of non-truetype font. Another one would be Postscript fonts, like Type 1 fonts. Not to be confused with CFF/CFF2 fonts in SFNT container, which is a modern way to use Postscript fonts.
Whether GetABCWidths() works for such fonts or not is another question, you should simply test that, it's not uncommon for msdn to be wrong, or outdated.
Regarding GDI+, you can use whatever works for you. Typically you don't have to mix GDI with GDI+ for the same task.
Another option is to use newer DirectWrite API, that supports only modern font file formats. So no .fon, not Adobe's own formats.
Upvotes: 1