unit ChangeDefaultFont;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes,
{$IFDEF MSWINDOWS}
WinAPI.Messages,
WinAPI.Windows,
{$ENDIF}
FMX.graphics;
type
TDefaultFont =
class (TInterfacedObject, IFMXSystemFontService)
public
function GetDefaultFontFamilyName:
string;
function GetDefaultFontSize: Single;
class function loadFont(rcname:
String):boolean;
end;
implementation
uses MyLog;
class function TDefaultFont.loadFont(rcname:
String):boolean;
{$IFDEF MSWINDOWS}
var ResStream : tResourceStream;
FontsCount : integer;
hFont : tHandle;
{$ENDIF}
begin
result:=false;
{$IFDEF MSWINDOWS}
try
ResStream := tResourceStream.Create(hInstance, rcname, Pchar('
MYFONT'));
try
hFont := AddFontMemResourceEx(ResStream.Memory, ResStream.Size,
nil, @FontsCount);
result := (hFont <> 0);
finally
ResStream.Free();
end;
except on E:
Exception do
mlog.info('
Error by loading font: '+e.
message);
end;
{$ENDIF}
end;
function TDefaultFont.GetDefaultFontFamilyName:
string;
begin
Result := '
Inter';
end;
function TDefaultFont.GetDefaultFontSize: Single;
begin
Result := 13.0;
end;
initialization
TFont.FontService := TDefaultFont.Create;
end.