[Lazarus] Embedded font

Luca Olivetti luca at wetron.es
Tue Feb 7 00:00:42 CET 2017

El 06/02/17 a les 22:06, Darius Blaszyk via Lazarus ha escrit:
> Hi,
> Is it possible to embed a font for a GUI application in Lazarus in a
> platform independent way? I've been looking on the internet and I only
> found windows specific solutions so far.

You already know the windows way, so I'll omit it.

With qt you can use QFontDatabase_addApplicationFont, e.g.

uses qt4;
procedure TForm1.FormCreate(Sender: TObject);
var ws:WideString;

There's also a addApplicationFontFromData if you want to load the font 
from a resource.

With GTK you can use fontconfig, e.g.

uses fontconfig;
function FcConfigAppFontAddFile(config:pointer; 
fname:Pchar):FcBool;stdcall;external 'libfontconfig.so';

procedure TForm1.FormCreate(Sender: TObject);
   res: FcBool;

There isn't a function to load the font from data, so if you want to use 
resources I guess you should save it to a temporary file and load the 
font from it.

What I couldn't find is a way to know if the application is using qt or 
gtk (or win): LCLWidgetType is an ide macro, not a define.

Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007

More information about the Lazarus mailing list