Java:以像素为单位获取具有特定高度的字体 [英] Java: Getting a font with a specific height in pixels
问题描述
使用 如何向Java请求这个? 我不认为有直接的方式来找到一个字体的高度;只是一种间接的方式...通过循环遍历尺寸,并测试每个的高度是<=所需的高度。 如果你这样做了一次,只需循环浏览它们...如果你正在做即时,那么做二进制搜索,它会快点。 干杯。基思。 It’s easy to determine the rendered height of a font using "Give me How do I ask Java for this? Jen, I don't think there's a "direct" way to find a font by height; only an indirect way... by looping through the sizes, and testing the height of each is <= required height. If you're doing this once, just loop through them... if you've doing it "on the fly" then do a binary search, it'll be quicker. Cheers. Keith. 这篇关于Java:以像素为单位获取具有特定高度的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! FontMetrics
可以很容易地确定字体的渲染高度,但是相反呢?我怎样才能获得一个字体,适合像素的特定高度?
lockquote
给我 Verdana
$ b
FontMetrics
, but what about the other way around? How can I obtain a font that will fit into a specific height in pixels?
Verdana
in a size that is 30 pixels high from ascender to descender."