0

Under which conditions kerning is enabled on using DrawString?

I tried several Font and StringFormatFlags settings but was not successful. Any Hint would be appreciated.

enter image description here enter image description here

Please note the different rendering of "Te".

Matze
  • 1,402
  • 2
  • 17
  • 24
  • Do you want to enable it for a left (smaller font size) example? [Here](https://social.msdn.microsoft.com/Forums/vstudio/en-US/b087e606-81f2-44d2-ae13-e991c25d31c1/graphicsdrawstring-ignores-kerning-instructions) they suggest to use `DrawText`. – Sinatr Jul 14 '21 at 14:20
  • If I understood : https://learn.microsoft.com/en-us/dotnet/desktop/winforms/advanced/how-to-use-antialiasing-with-text?view=netframeworkdesktop-4.8 – Rovann Linhalis Jul 14 '21 at 14:23
  • @RovannLinhalis, see [kerning](https://en.wikipedia.org/wiki/Kerning). – Sinatr Jul 14 '21 at 14:24
  • ok, I didn't know this. but are you using the same font? – Rovann Linhalis Jul 14 '21 at 14:26
  • @RovannLinhalis Anti-aliasing is not kerning. AA smoothes jagged edges. Kerning squeezes certain characters together. – Charlieface Jul 14 '21 at 14:32
  • 1
    Quote: _'WPF supports kerning, System.Drawing doesn't. One workaround is to draw each individual character and do your own spacing.'_ – TaW Jul 14 '21 at 14:32
  • 1
    DrawString() has many problems with output on low resolution devices (like monitors), it was Microsoft's first shot at resolution-independent rendering. The basic reason why TextRenderer.DrawText() was added at v2.0. WPF went through a similar ordeal, ideal vs display mode. – Hans Passant Jul 14 '21 at 15:16
  • See the notes here: [Drawing a Long String on to a Bitmap results in Drawing Issues](https://stackoverflow.com/a/49953353/7444103) -- [Graphics.MeasureCharacterRanges](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.graphics.measurecharacterranges) may be used to generate an *artificial* kerning. – Jimi Jul 14 '21 at 15:16
  • @Charlieface, yep, I didn't know kerning but read about. Thanks – Rovann Linhalis Jul 14 '21 at 18:05

0 Answers0