I would like to disable ligatures, which appear to be enabled by default, at least in the fonts that I'm using (i.e. Calibri). It appears that the way to do this is to use IDWriteTextLayout::SetTypography
to set an IDWriteTypography
object to the layout which contains the various ligature-related font features with a value of zero to disable them. That works to disable the ligatures, but it also affects (disables) other typography settings that I don't want to mess with, such as kerning.
After some experimentation, it turns out that I could disable ligatures just by setting an empty IDWriteTypography
object (one that was simply created by the IDWriteFactory
and then applied to the layout without alteration). An empty typography seems to have the effect of setting all possible font features to zero/disable. So what I actually want to do is retrieve the default typography settings, override the ones related to ligatures, and then set that to the layout.
Unfortunately I can't find anywhere to retrieve the default settings. Using IDWriteTextLayout::GetTypography
just returns null if none has been set, yet it clearly has various typography settings like ligatures enabled in that case. I also can't find any other methods on IDWriteFactory
(or any of its newer versions) or any of the font-related interfaces for creating an IDWriteTypography
instance. How does the IDWriteTextLayout
decide which typography settings to use when no IDWriteTypography
has been set? Are the default settings font-specific? Can I retrieve those settings somehow so that I can tweak a few of them and inherit the default values for the rest?
There's no way to get default set of features out of IDWriteTextLayout, or IDWriteTextAnalyzer to be more precise, and no, it's not font-specific, it's script-specific.
If you're interested in how it works in general, you can use opensource implementations like HarfBuzz, you can find arrays of script-specific features that are applied during shaping.
Microsoft approach to that is documented in OpenType documentation, an example for Arabic - https://www.microsoft.com/typography/OpenTypeDev/arabic/intro.htm.