This repository demonstrates how to embed custom fonts in Delphi Android applications using the Skia4Delphi library.
With this approach, you can include .ttf or .otf font files directly into your Android package and use them throughout your app with clean, consistent renderingโno reliance on system fonts.
Learn how it works step-by-step by watching the full tutorial on YouTube:
๐ Delphi - How to Embed Fonts in Android (Skia4Delphi)
- Install Skia4Delphi in your Delphi environment.
- Add your custom font files to the project as resources.
- Use
TSkDefaultProvidersto register and load your fonts:
program CustomFont;
{$R *.dres}
uses
System.StartUpCopy,
FMX.Forms,
FMX.Skia,
System.Classes,
System.SysUtils, System.Types,
Main.View in 'Main.View.pas' {MainView};
{$R *.res}
procedure RegisterFontFromRCDATA(const aFontResName: string);
var
LStream: TResourceStream;
begin
LStream := TResourceStream.Create(HInstance, aFontResName, RT_RCDATA);
try
TSkDefaultProviders.RegisterTypeface(LStream);
finally
FreeAndNil(LStream);
end;
end;
begin
GlobalUseSkia := True;
RegisterFontFromRCDATA('NotoSArabicSemiCond');
Application.Initialize;
Application.CreateForm(TMainView, MainView);
Application.Run;
end.4.Apply the typeface using the Added GlobalUseSkia := True; to .dpr, which is responsible for replacing the FMX appโs renderer with the Skia render.
๐ Blog & References:
๐ skia4delph Right To Left Read Me !
This implementation is based first on the guide by EngineerTips: ๐ Delphi โ Skia4Delphi โ Embed Font
๐ Right-to-Left: From Skia4Delphi ReadMe ๐
Using Skia's render, your application will now support Right-To-Left text rendering. But for that you will need to make 3 changes to your project:
For RAD Studio prior to 11.3, open the source of your Delphi Application Project (.dpr), include the line Application.BiDiMode := TBiDiMode.bdRightToLeft;, like below:
program Project1;
uses
System.StartUpCopy,
FMX.Forms,
System.Classes,
FMX.Skia,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.BiDiMode := TBiDiMode.bdRightToLeft;
GlobalUseSkia := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.Set the property BiDiMode of your forms to bdRightToLeft; Keyboard input controls like TEdit and TMemo, need to be fixed by Embarcadero, meanwhile, as a workaround, set the ControlType property of these controls to Platform. Custom fonts Using Skia's renderer, it is possible to use custom font in any FMX control, on any platform in a very simple way. Just register them in the app initialization:
program Project1;
uses
System.StartUpCopy,
FMX.Forms,
FMX.Skia,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
GlobalUseSkia := True;
TSkDefaultProviders.RegisterTypeface('Poppins.ttf');
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.On RAD Studio 12 Athens or newer it is recommended to use IFMXFontManagerService:
program Project1;
uses
System.StartUpCopy,
FMX.Forms,
FMX.Platform,
FMX.FontManager,
FMX.Skia,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
GlobalUseSkia := True;
var LFontManager: IFMXFontManagerService;
if TPlatformServices.Current.SupportsPlatformService(IFMXFontManagerService, LFontManager) then
LFontManager.AddCustomFontFromFile('Poppins.ttf');
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.Enjoy it ..
