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

SyntaxEditor for Windows Forms Forum

Posted 6 months ago by Steven Robertson
Version: 18.1.0340
Environment: Windows 10 (64-bit)

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();
var fontFamily = pfc.Families[0];
var font = new Font(fontFamily, 32, FontStyle.Regular);

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

[Modified 6 months ago]

Comments (1)

Posted 6 months ago by Actipro Software Support - Cleveland, OH, USA

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 0341) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.