如何确定 Windows 操作系统字体是否支持粗体或斜体
如何确定特定字体是否支持粗体或斜体,无论它是 True Type 还是 Type 1?我有以下与嵌入 Flex 字体问题相关的场景:
- 我有 3 个名为 Unknown1、Unknown2 和 Unknown3 的 TTF 字体文件。假设它们现在已安装
- 当我嵌入字体时,Flex 告诉我 Unknown2.ttf 不支持粗体或 Unknown3.ttf 不支持斜体样式
我的问题是,Flex 是如何知道所有这些的?我一直在搜索 C# 和 Java 库,但似乎没有一个能提供我需要的东西。或者显然,我还不够努力。无论如何,Java 或 C# 中是否有类可以为我提供一些签名,例如:
FontknownFont = Font.getFontFromAnyDirectory("Unknown2.ttf"); unknownFont.supportsAnyStyleCalled(Font.BOLD);//返回false。 unknownFont.supportsAnyStyleCalled(Font.ITALIC);//返回true。 // knownFont = Font.getFontFromAnyDirectory("Unknown3.ttf"); unknownFont.supportsAnyStyleCalled(Font.BOLD);//返回true。 knownFont.supportsAnyStyleCalled(Font.ITALIC);//返回 false。
How do you determine if a particular font supports bold or italic regardless whether it's a True Type or Type 1? I have the following scenarios relating to embedding a Flex font issue:
- I have 3 TTF font files called Unknown1, Unknown2 and Unknown3. Let's say they're installed for now
- When I embed the fonts, Flex tells me that Unknown2.ttf doesn't support a bold weight or Unknown3.ttf doesn't support an italic style
My question is, how did Flex knew all of that? I've been searching through C# and Java libraries but none of them seem to offer what I need. Or apparently, I'm not looking hard enough. Anyways, are there classes in Java or C# that can provide me with some signature like:
Font unknownFont = Font.getFontFromAnyDirectory("Unknown2.ttf");
unknownFont.supportsAnyStyleCalled(Font.BOLD);//Returns false.
unknownFont.supportsAnyStyleCalled(Font.ITALIC);//Returns true.
//
unknownFont = Font.getFontFromAnyDirectory("Unknown3.ttf");
unknownFont.supportsAnyStyleCalled(Font.BOLD);//Returns true. unknownFont.supportsAnyStyleCalled(Font.ITALIC);//Returns false.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 C# 中,您可以通过调用 FontFamily.IsStyleAvailable
in C# you can do it by invoking FontFamily.IsStyleAvailable
我知道这个问题很老了,我遇到了同样的问题,解决方案在 C# 从.ttf 获取字体样式。
您可以使用:
I know the question is pretty old, I had the same problem and the solution is stated in C# get font style from .ttf.
You can use: