开发者

How can I find all the supported weights of a Font in Java?

开发者 https://www.devze.com 2022-12-27 20:35 出处:网络
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

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 开发者_StackOverflow中文版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."

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号