Font won't load unless it is installed in system Fonts

SyntaxEditor for Windows Forms Forum

Posted 1 year ago by Steven Robertson
Version: 18.1.0340
Platform: .NET 4.6
Environment: Windows 10 (64-bit)
Avatar

I am trying to load a TTF font from a PrivateFontCollection. The font is not installed on the system but loaded from a file using the AddFontFile method.

The font is not being used by SyntaxEditor (latest version) unless it is installed as a system font. I can't find any way to get it to work. I have no problem using the Font instance in a label.

var filename = Path.GetTempFileName();
File.WriteAllBytes(filename, Resources.LibreBarcode128Text_Regular);
var pfc = new PrivateFontCollection();
pfc.AddFontFile(filename);
var fontFamily = pfc.Families[0];
var font = new Font(fontFamily, 32, FontStyle.Regular);

label1.Font = font;
syntaxEditor1.Font = font;

[Modified 1 year ago]

Comments (1)

Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Steven,

A lot of text rendering in the WinForms SyntaxEditor is done with GDI (Windows API) instead of GDI+ (WinForms) since it's much faster.  I wonder if loading a font up in that fashion doesn't allow it to be used with basic GDI properly?  That might explain why a WinForms control like Label has no problem rendering with it, as that would be using GDI+.


Actipro Software Support

The latest build of this product (v2018.1 build 0342) was released 12 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.