0

I'm having trouble getting ligatures to show up in DirectWrite code. I'm using a ligature-rich font and am basically applying every ligature tag I can get my hands on:

  var typography = new Typography(dwriteFactory);

  var ligatureTags = new[]
  {
    FontFeatureTag.StandardLigatures,
    FontFeatureTag.StylisticAlternates,
    FontFeatureTag.DiscretionaryLigatures,
    FontFeatureTag.RequiredLigatures,
    FontFeatureTag.ContextualLigatures,
    FontFeatureTag.HistoricalLigatures
  };

  foreach (var tag in ligatureTags)
  {
    FontFeature ff;
    ff.NameTag = tag;
    ff.Parameter = DisableLigatures ? 0 : 1;
    typography.AddFontFeature(ff);
  }

  textLayout.SetTypography(typography, EntireRange(text));

From the above code, StylisticAlternates and DiscretionaryLigatures work. But, whatever I do, StandardLigatures do not work.

Can anyone give suggestions as to why this wouldn't be working?

Dmitri Nesteruk
  • 23,067
  • 22
  • 97
  • 166
  • I'd check what lower level API of IDWriteTextAnalyzer actually returns in this situation. It's possible it's being smart and ignoring what it considers invalid combination. Does it work if you enable only one ligature feature that you actually have in your font + text? – bunglehead Nov 17 '19 at 20:32
  • @bunglehead I'm not using `IDWriteTextAnalyzer`, I'm just using an ordinary `TextLayout` and `Typography`. I've tried different combinations, including just leaving `StandardLigatures` or `DiscretionaryLigatures` in there. It doesn't work. `StylisticAlternates` works just fine, though. – Dmitri Nesteruk Nov 17 '19 at 20:38
  • I can see that you're not using it, but you could, to figure out what's going on. Alternates are not ligatures. Does it work if you only enable let's say HistoricalLigatures, again, making sure your font supports it for text you're using. – bunglehead Nov 17 '19 at 20:50
  • @bunglehead I have tried a different font and, in that font, I got `DiscretionaryLigatures` working. But I cannot, for the life of me, get `StandardLigatures` to work. – Dmitri Nesteruk Nov 17 '19 at 21:38
  • Interesting find: if I don't set the Typography at all, ligatures do show up. – Dmitri Nesteruk Nov 19 '19 at 08:58

0 Answers0