Re: font size in pixels?
- From: "Oliver Wong" <owong@xxxxxxxxxxxxxx>
- Date: Thu, 29 Jun 2006 18:50:03 GMT
"mitch" <mgart@xxxxxxxxxx> wrote in message news:1151436278.483166.246430@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Suppose you want to use a font that's 12 pixels (not 12 points)
Arial. How would you do it? It seems like the answer has
something to do with FontRenderContext and AffineTransform
but does anybody have code that creates a font with a size in
pixels, or measures the size in pixels of an existing font?
Thanks.
I usually make a whole bunch of FontMetrics and do a binary search. E.g. 12pt too small? What about 24pt? Too big? How about 18 pt? etc.
You can cache the results in a map, e.g.: 12px -> 14.2pt, 13px -> 14.4pt, etc.
- Oliver
.
- References:
- font size in pixels?
- From: mitch
- font size in pixels?
- Prev by Date: HTMLDocument with own inner formatting
- Next by Date: JCheckbox in a JTable
- Previous by thread: Re: font size in pixels?
- Next by thread: Listeners Blocking Each Other And Needing Events To Trickle Down
- Index(es):
Relevant Pages
|