Re: Automatically resize font when component size changes?
- From: Philipp <sicsicsic@xxxxxxxxxxx>
- Date: Tue, 20 Mar 2007 20:07:34 +0100
Bent C Dalager wrote:
In article <1174393441.687014.66540@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
<larkmore@xxxxxxx> wrote:
Thanks Andrew, but I kind of hoping there would be something a little
simpler. I've already looked at the FontMetrics as described in my
first post. If I use that, I would have to:
1) Figure out which string is the widest and tallest of all possible
strings. I'm betting it's likely 88:88:88 but to be safe, I'd have to
check all of them for a given font. Some weird font might make
11:11:11 really wide.
If you draw the time as one single string (e.g. "12:34:56") as opposed
to drawing each single digit (and JLabel used in the straight-forward
manner would do the former) then you may also risk (weird) fonts
having compound glyphs (or whatever the technical term is) of pairs of
digits that are wider than twice the width of any one of the digits
involved.
E.g., the string "17" may draw wider than "11" _and_ wider than "77".
That's called kerning. And you are right, the font designer is absolutely free to choose whatever he thinks is nice in the kerning table (table of pairs of characters with the space which has to be shown between these two characters).
Phil
.
- References:
- Automatically resize font when component size changes?
- From: larkmore
- Re: Automatically resize font when component size changes?
- From: Andrew Thompson
- Re: Automatically resize font when component size changes?
- From: larkmore
- Re: Automatically resize font when component size changes?
- From: Bent C Dalager
- Automatically resize font when component size changes?
- Prev by Date: HTML table used in JTextPane not working with cellspacing="0" attribute
- Next by Date: Re: JFrame from JPanel
- Previous by thread: Re: Automatically resize font when component size changes?
- Next by thread: Re: Automatically resize font when component size changes?
- Index(es):
Relevant Pages
|