Programmatically load fonts from disk

21 views
Skip to first unread message

Xavier Flix

unread,
Apr 16, 2020, 11:53:04 PM4/16/20
to Eto.Forms
I hace a WinForms application that I'm trying to port to Eto.Forms and the only thing missing is the ability to programmatically load fonts from disk.

Under WinForms I use the PrivateFontCollection class, with code similar to this one:

PrivateFontCollection fc = new PrivateFontCollection();
fc
.AddFontFile(@"Folder_Containing_The_Font_File\MyFont.ttf"));
FontFamily ff = fc.Families[0];
Font myFont = new Font(ff, 12, FontStyle.Regular);


Is there any way to do something similar with Eto.Forms?

curtis

unread,
Apr 17, 2020, 12:48:22 PM4/17/20
to Eto.Forms
Hey Xavier,

Sorry, there's currently no way to load a font from file in Eto, other than doing something specifically for each platform.

On macOS I believe you must put the font files inside the .app bundle and register them in the Info.plist.

On GTK, it appears you need to install the font on the system.

So it's only WPF and WinForms that can load a font from a specific path.

Hope this helps.

Xavier Flix

unread,
Apr 17, 2020, 1:57:53 PM4/17/20
to Eto.Forms
Thanks for the information curtis.
Reply all
Reply to author
Forward
0 new messages