【问题标题】:Why TFontDialog gives less fonts than Screen.Fonts?为什么 TFontDialog 提供的字体比 Screen.Fonts 少?
【发布时间】:2012-07-03 06:10:21
【问题描述】:

我想知道为什么 TFontDialog 提供的字体比 Screen.Fonts 少? (例如Arial*字体、Comic字体等在TFontDialog中不显示)

TFontDialog给出的字体列表好像和WordPad一样,而Screen.Fonts给出的字体列表和Word基本一样。

非常感谢您的见解!

PS: 德尔福 XE, 视窗 7

PS:相关的 SO 主题:

  1. Too many fonts when enumerating with EnumFontFamiliesEx function
  2. Finding System Fonts with Delphi
  3. How to use external fonts?

PS:相关网页:

  1. TFontDialog to show all Fonts @ borland.newsgroups.archived
  2. TFontDialog to show all Fonts @ delphigroups

unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm2 = class(TForm)
    lst1: TListBox;
    dlgFont1: TFontDialog;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
begin
  lst1.Items.AddStrings(Screen.Fonts);
end;

procedure TForm2.Button1Click(Sender: TObject);
begin
  dlgFont1.Device := fdBoth;
  if dlgFont1.Execute then
  begin

  end;
end;

end.    

【问题讨论】:

  • 使用 dlgFont1.Device 的不同值可能会得到不同的结果。尝试 fdScreen 和 fdPrinter,然后再次比较列表。
  • @Doug Device 属性在现代 Windows 上被忽略(我认为)
  • @Doug 对 dlgFont1.Device 使用不同的值没有区别。

标签: windows delphi fonts wordpad


【解决方案1】:

不同的 API,不同的结果。 Screen.Fonts 使用 EnumFontFamiliesEx(),它返回所有已安装的字体。 TFontDialog 使用 ChooseFont() 代替,它只显示与 TFontDialog.FontTFontDialog.Options 属性兼容的字体。

【讨论】:

  • 非常感谢您的宝贵时间!你能帮忙详细说明compatible with TFontDialog.FontTFontDialog.Options吗?我的意思是,是否可以让 TFontDialog 给出与 Screen.Fonts 建议的相同?
【解决方案2】:

Screen.Fonts 返回所有已安装的字体,包括在Registry\HKCU\Software\Microsoft\Windows NT\CurrentVersion\Font Management\Inactive Fonts 中管理的隐藏字体。 (Source) 显然,TFontDialog 不显示这些隐藏字体。

此外,Screen.Fonts 中列出的某些字体在TFontDialog字体 组合框中没有提及,而是添加到了字体样式 组合框中。以 Arial 为例:Font 样式列出了 10 项,似乎是 ArialArial Black 字体的组合Arial 窄体.

【讨论】:

  • 非常感谢您富有洞察力的 cmets!我现在可以操作该注册表项,或者浏览控制面板,在 TFontDialog 和写字板中显示我最喜欢的字体! :)
猜你喜欢
  • 2020-04-23
  • 1970-01-01
  • 2012-09-29
  • 1970-01-01
  • 1970-01-01
  • 2012-05-17
  • 2011-08-03
  • 2013-03-27
  • 2018-12-06
相关资源
最近更新 更多