Problem

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

Posted 7 days ago by Avatar Steven Robertson

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 7 days ago]

Information The latest build of this product (2018.1 build 0340) was released 4 months ago, which was before this thread was created.

Comments (1)

Posted 5 days 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

Add a Comment

Please log in to a validated account to post comments.