如何在 Java 中找到所有支持的字体粗细?
如何在 Java 中找到给定字体的所有可用字体粗细?
Font 中的 getAttributes() 和 getAvailableAttributes() 方法只会显示该 Font 是否支持 FONT_WEIGHT 属性,而不显示它支持哪些权重值。
如果我只是传递一个特定的值来查看返回的结果,我不能保证我会得到我所要求的结果。 TextAttribute 类表示“WEIGHT、WIDTH 和 POSTURE 的值由系统插值,系统可以选择‘最近的可用’字体或使用其他技术来近似用户的请求。”
How can I find all the available font weights for a given font in Java?
The TextAttribute for font weight lists 11 different weight constants, way more than just Font.PLAIN and Font.BOLD. I'd like to know which ones actually exist for a given font family, so I can make sure I'm only using weights for which a font face exists.
The getAttributes() and getAvailableAttributes() methods in Font will only show me whether or not the Font supports the FONT_WEIGHT attribute, not which weight values it supports.
If I just pass in a particular value to see what I get back, I don't have any guarantee that I'll get what I asked for. The TextAttribute class says "The values for WEIGHT, WIDTH, and POSTURE are interpolated by the system, which can select the 'nearest available' font or use other techniques to approximate the user's request."
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论