Is it possible to use otf fonts on winforms?

I tried using Open Type fonts for both labels, text fields, and for drawing in the paint event. But that will not work. Is there a way to make Open Type Font work?

+4
source share
2 answers

This is not possible in Winforms, GDI + only supports TrueType fonts. You will need to upgrade to WPF to get OpenType support.

+8
source

You can use the System.Windows.Media , as it would in WPF, here you have an example:

 public static string GetFontList(String ElementSeparator) { string r = ""; // WPF incl Adobe and OpenType foreach (System.Windows.Media.FontFamily fontFam in System.Windows.Media.Fonts.SystemFontFamilies) { r += fontFam.Source; r += ElementSeparator; } // True type, incl Type face names eg Arial Rounded MT Bold foreach (System.Drawing.FontFamily f in System.Drawing.FontFamily.Families) { if(!r.Contains(f.Name)) { r += f.Name; r += ElementSeparator; } } return r; } 
+4
source

Source: https://habr.com/ru/post/1347893/


All Articles