1
votes

Inside Lazarus the default font values for Form1 are:
Form1.Font.Name=default
Form1.Font.Size=0

How do I find what the actual "real" font name and font size is for these default values?

enter image description here

1

1 Answers

3
votes

This code seems to work:

procedure TForm1.GetFormFontName;
var
  S : String;
begin
  S := GetFontData(Self.Font.Handle).Name;
  Caption := S;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  GetFormFontName;
end;

GetFontData returns a TFontData record

 TFontData = record
    Handle: HFont;
    Height: Integer;
    Pitch: TFontPitch;
    Style: TFontStylesBase;
    CharSet: TFontCharSet;
    Quality: TFontQuality;
    Name: TFontDataName;
    Orientation: Integer;
  end;  

This does not include the font's Size, which is an explicit published property of the font.

The code above is derived from this thread: https://forum.lazarus.freepascal.org/index.php?topic=16697.0, which I found as the first hit returned by this google query

font name default site:freepascal.org