开发者

Java, pixels in a given letter of a particular Font

开发者 https://www.devze.com 2023-02-20 04:01 出处:网络
How can I determine how many pixels are in a specific letter of a specific Font i开发者_StackOverflown Java?If you have the font loaded as a Font object, you can create a new FontMetrics object (or on

How can I determine how many pixels are in a specific letter of a specific Font i开发者_StackOverflown Java?


If you have the font loaded as a Font object, you can create a new FontMetrics object (or one of its children if your graphics toolkit has one) and its charWidth(char ch) method to determine its size. The units aren't listed in the manual, but I'm assuming pixels.

Likewise, there's a stringWidth method to get the width of an entire String.

0

精彩评论

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