Hello everybody,
I have a small tool which uses the external component EasySize to automaticly adjust the tool's windows to the Screen Size of my monitor. Now I wanted to add a local Font (saved as a .ttf-file) to my tool without installing it to Windos. I have found a thread online, where someone wanted to do the same and I've been trying to implement this code-line without succes. Beyond you can see my FormCreate and FormResize procedure as well as the LoadFonts procedure which i manually created to load the local font.
procedure TForm1.FormCreate(Sender: TObject);
begin
//Loading Images to the Paintboxes
img[1] := TImage.create(form1);
img[1].Picture.LoadFromFile('../Binaries/background.jpg');
img[2] := TImage.create(form1);
img[2].Picture.LoadFromFile('../Binaries/background.jpg');
img[3] := TImage.create(form1);
img[3].Picture.LoadFromFile('../Binaries/logo.jpg');
img[4] := TImage.create(form1);
img[4].Picture.LoadFromFile('../Binaries/logo.jpg');
PaintBox1.Tag := 1;
PaintBox2.Tag := 2;
PaintBox3.Tag := 3;
PaintBox4.Tag := 4;
//Implemetnation of Resizer
Sizer := TFormResizer.Create(self);
Sizer.EnforceMinSize := false;
Sizer.ResizeFonts := true;
Sizer.MinFontSize := 10;
Sizer.MaxFontSize := 30;
Sizer.InitializeForm;
Button1.Font.Size := 20; //Doesn't affect the font!
Width := round(Screen.Width/2.4);
Height := round(Screen.Height/2.4);
Position := poScreenCenter;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
Sizer.ResizeAll;
end;
procedure LoadFonts(); // There I want to import a local font.
begin
if FileExists(ExtractFilePath(Application.ExeName)+'Auricom_Regular.ttf') then
if AddFontResourceEx(PAnsiChar(ExtractFilePath(Application.ExeName)+'Auricom_Regular.ttf'), FR_Private, Nil) <> 0 then
begin
SendMessage(Form1.Handle, WM_FONTCHANGE, 0, 0);
ShowMessage('Font Installed!');
end else RaiseLastOSError;
end;
Also, I tried to set a custom font-size for my button in the FormCreate procedure but this won't work. First I was susspecting the EasySize component to block this (because it handel's the size of the tool) but setting the size manually with Lazarus IDE the font size changes. Therefore, did i do something wrong?