在 Lazarus 中,如何找到 Form1 上使用的“真实”字体值?

时间:2021-07-31 12:38:37

标签: lazarus freepascal

在 Lazarus 中,Form1 的默认字体值为:
Form1.Font.Name=默认
Form1.Font.Size=0

如何找到这些默认值的实际“真实”字体名称和字体大小?

enter image description here

1 个答案:

答案 0 :(得分:3)

此代码似乎有效:

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 返回 TFontData 记录

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

这不包括字体的 Size,它是字体的显式发布属性。

上面的代码来自这个线程:https://forum.lazarus.freepascal.org/index.php?topic=16697.0,我发现它是这个谷歌查询返回的第一个命中

<块引用>

字体名称默认站点:freepascal.org