用Delphi查找系统字体

发布于 2024-07-11 04:28:53 字数 144 浏览 6 评论 0原文

查找用户可用的所有系统字体以便将它们显示在下拉选择框中的最佳方法是什么?

我还想区分 Unicode 和非 Unicode 字体。

我正在使用完全支持 Unicode 的 Delphi 2009,并且想要一个 Delphi 解决方案。

What is the best way to find all the system fonts a user has available so they can be displayed in a dropdown selection box?

I would also like to distinguish between Unicode and non-Unicode fonts.

I am using Delphi 2009 which is fully Unicode enabled, and would like a Delphi solution.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

他不在意 2024-07-18 04:28:53

Screen.Fonts 属性通过 填充EnumFontFamiliesEx API 函数。 查看 Forms.pas 中调用该函数的示例。

它调用的回调函数将收到 TNewTextMetricEx 记录,并且该记录的成员之一是 TFontSignature< /代码>fsUsb 字段指示字体声明支持哪些 Unicode 子范围。

该系统实际上没有“Unicode 字体”。 即使名称中含有 Unicode 一词的字体也没有代表所有 Unicode 字符的字形。 您可以区分位图、打印机和 TrueType 字体,但除此之外,您能做的最好的事情就是确定您正在考虑的字体是否支持您想要的字符。 如果该字体不是您所认为的“Unicode 字体”,但它支持您需要的所有字符,那么它有什么区别呢? 要获取此信息,您可能对 GetFontUnicodeRanges< /a>.

Microsoft 的技术是 Uniscribe<,该技术根据不同字体包含哪些字符来显示不同字体的文本/a>,特别是字体后备。 我不知道 Delphi 对 Uniscribe 有任何支持; 我曾经开始为它编写一套导入单元,但我的兴趣变化无常,在完成之前我就转向了其他东西。 Michael Kaplan 的博客有时会谈论 Uniscribe,因此这是另一个值得关注的地方。

The Screen.Fonts property is populated via the EnumFontFamiliesEx API function. Look in Forms.pas for an example of calling that function.

The callback function that it calls will receive a TNewTextMetricEx record, and one of the members of that record is a TFontSignature. The fsUsb field indicates which Unicode subranges the font claims to support.

The system doesn't actually have "Unicode fonts." Even the fonts that have the word Unicode in their names don't have glyphs for all Unicode characters. You can distinguish between bitmap, printer, and TrueType fonts, but beyond that, the best you can do is to figure out whether the font you're considering supports the characters you want. And if the font isn't what you'd consider a "Unicode font," but it supports all the characters you need, then what difference does it make? To get this information, you may be interested in GetFontUnicodeRanges.

The Microsoft technology for displaying text with different fonts based on which fonts contain which characters is Uniscribe, particularly font fallback. I'm not aware of any Delphi support for Uniscribe; I started writing a set of import units for it once, but my interests are fickle, and I moved on to something else before I completed it. Michael Kaplan's blog talks about Uniscribe sometimes, so that's another place to look.

旧人哭 2024-07-18 04:28:53

我可以回答你一半的问题,你可以从全局 Screen 对象中获取当前环境可以访问的字体列表作为字符串列表,

Listbox1.Items.AddStrings(Screen.Fonts);

I can answer half your question, you can get a list of the Fonts that your current environment has access to as a string list from the global Screen object

i.e.

Listbox1.Items.AddStrings(Screen.Fonts);
皇甫轩 2024-07-18 04:28:53

您可以查看 forms.pas 源代码,了解 Codegear 如何通过枚举 Windows 字体来填充 Screen.Fonts。 返回的 LOGFONT 结构具有字符集成员,但这不提供简单的“Unicode”确定。

据我所知,Windows 无法明确告诉您字体是否为“Unicode”。 此外,如果您尝试以“非 Unicode”字体显示 Unicode 文本,Windows 可能会替换为不同的字体,因此很难说某种字体是否会显示 Unicode。 例如,我有一个古老的 Arial Black 字体文件,其中不包含 Unicode 字形,但如果我使用它在 D2009 备忘录中显示日语文本,则日语会在 Arial 中正确显示,其余部分会在 Arial Black 中正确显示。 在其他示例中,可能会出现通常的空方块。

You can look in the forms.pas source to see how Codegear fill Screen.Fonts by enumerating the Windows fonts. The returned LOGFONT structure has a charset member, but this does not provide a simple 'Unicode' determination.

As far as I know Windows cannot tell you explicitly if a font is 'Unicode'. Moreover if you try to display Unicode text in a 'non-Unicode' font Windows may substitute a different font, so it is difficult to say whether a font will or will not display Unicode. For example I have an ancient Arial Black font file which contains no Unicode glyphs, but if I use this to display Japanese text in a D2009 memo, the Japanese shows up correctly in Arial and the rest in Arial Black. In other examples, the usual empty squares may show up.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文