【问题标题】:In Lazarus how do I find the "real" font values used on Form1?在 Lazarus 中,我如何找到 Form1 上使用的“真实”字体值?
【发布时间】:2021-07-31 12:38:37
【问题描述】:

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

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

【问题讨论】:

    标签: lazarus freepascal


    【解决方案1】:

    此代码似乎有效:

    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

    【讨论】:

    • 我使用 TFontData.Height 发现它是-12。我机器上的默认名称是“Segeo UI”。
    猜你喜欢
    • 2011-11-01
    • 2014-12-10
    • 2013-01-12
    • 1970-01-01
    • 2013-05-14
    • 2014-10-18
    • 2017-07-17
    • 2016-11-11
    • 1970-01-01
    相关资源
    最近更新 更多