I build a text editor and I use DirectWrite
, I want to give the user the option to enable OpenType features
on selected text, but not every font has all the features and many fonts do not at all. My question is how do I know which OpenType features are available in a given font using DirectWrite?
I have tried the following code but the res
always == S_OK
even the font missing the feature:
DWRITE_FONT_FEATURE fontFeature = { DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_7, 1 };
HRESULT res = pTypography->AddFontFeature(fontFeature); // res == S_OK
res = g_pFancyTextLayout->SetTypography(pTypography, range); // res == S_OK
UPDATE:
I have tried the following code with SharpDx
, but the list
always empty, even in Gabriola
font:
public static FontFeatureTag[] GetOpenTypeFeatures(FontFace fontFace)
{
var list = new List<FontFeatureTag>();
foreach (FontFeatureTag tag in System.Enum.GetValues(typeof(FontFeatureTag)))
{
if (fontFace.TryGetFontTable((int)tag, out DataPointer dataPointer, out IntPtr intPtr))
{
list.Add(tag);
}
}
return list.ToArray();
}
I am writing a C# application using SharpDX, however I can understand answers/examples that are provided in C++.