Import local font and set size via code [SOLVED] lazarus / 21-General ---------------------------------------------------------------------- AlphaInc. · 2021-04-19 10:09 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.  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 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.Exe Name)+'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? ---------------------------------------------------------------------- wp · 2021-04-19 11:33 Quote from: AlphaInc. on April 19, 2021, 12:09:29 pmI 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? When you add a control to a form its Font.Size in Lazarus (unlike Delphi) become 0 - this is later replaced by the default size of the widgetset. When a font size is rescaled by some tool, its size is multiplied by some number. But when the Font.Size is zero it is still zero after multiplication. The EasySize component, an ancient control of Delphi 4 times, does not know about the Lazarus font size handling... What you can do to fix this is to initialize the font size in the object inspector with some non-zero value, e.g. 9 or 10. ---------------------------------------------------------------------- AlphaInc. · 2021-04-19 11:41 Quote from: wp on April 19, 2021, 01:33:27 pmQuote from: AlphaInc. on April 19, 2021, 12:09:29 pmI 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? When you add a control to a form its Font.Size in Lazarus (unlike Delphi) become 0 - this is later replaced by the default size of the widgetset. When a font size is rescaled by some tool, its size is multiplied by some number. But when the Font.Size is zero it is still zero after multiplication. The EasySize component, an ancient control of Delphi 4 times, does not know about the Lazarus font size handling... What you can do to fix this is to initialize the font size in the object inspector with some non-zero value, e.g. 9 or 10. For the said Button the value of Size TFont in the object inspector is set to 10. There was never a 0-value since it was set by default. Or are we talking about something else ?