Enumerate Stylistic Sets of an OpenType Font

117 Views Asked by At

In DirectWrite there's an IDWriteTypography which has an "AddFontFeature" member. This function allows setting a stylistic style based on this list. It's demonstrated by MSDN here.

Adding, for example, DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_7 to "Gabriola" font results from this:

Without set

to this:

With set

The question is, how do I know which tags are supported by the open type font in order to have the user select from a menu? Currently, my user can only type the tag which may have or may not have an effect on the text.

Best,

1

There are 1 best solutions below

1
SoronelHaetir On

If you are willing to mix use of Uniscribe there is ScriptGetFontLanguageTags / ScriptGetFontScriptTags /ScriptGetFontFeatureTags. If not I believe you will be stuck parsing the GSUB and GPOS OpenType tables yourself, acquire them with IDWriteFontFace::TryGetFontTable and release with IDWriteFontFace::ReleaseFontTable.

The Uniscribe route would likely be far easier, use IDWriteGdiInterop::ConvertFontFaceToLOGFONT or IDWriteGdiInterop::ConvertFontToLOGFONT then use the LOGFONT with CreateFontIndirect to get an HFONT. The tricky part here may be the acquisition of an HDC, but once you have that select your HFONT then simply use the named Uniscribe functions.