Re: Automatically resize font when component size changes?



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".

(Perhaps this is impossible - I don't know too much about font design
- but I wouldn't bet on it.)

To support this general case, you would have to measure the size of
all possible times from 00:00:00 to 23:59:59.


The alternative is to draw each digit separately. You then only have
to measure the size of each of the digits and you can position them as
you see fit to give the impression of them all staying in the same
place as the clock ticks along (which would also avoid any problems
you might otherwise get with proportional width fonts).

Cheers
Bent D
--
Bent Dalager - bcd@xxxxxxx - http://www.pvv.org/~bcd
powered by emacs
.



Relevant Pages

  • Re: 7-bar display
    ... I would like to display digits with a 7-bar display, ... mitred just like on a pocket calculator. ... Maybe the font solution would be best. ... I just thought of another way you could do your calculator digits. ...
    (comp.infosystems.www.authoring.html)
  • Re: 7-bar display
    ... I would like to display digits with a 7-bar display, ... mitred just like on a pocket calculator. ... Maybe the font solution would be best. ... I just thought of another way you could do your calculator digits. ...
    (comp.infosystems.www.authoring.html)
  • Re: 7-bar display
    ... I would like to display digits with a 7-bar display, ... Maybe the font solution would be best. ... I just thought of another way you could do your calculator digits. ... Also I don't know if it's possible to install a font on Windows without ...
    (comp.infosystems.www.authoring.html)
  • Re: Base Twelve Page Numbers
    ... renewcommand (and I haven't found much in the way of documentation, ... I was talking about using Metafont to design two ... Pitman digits, which is what the DGBS uses, at least as I've noticed, ... figure on designing a whole new numerical font because I thought I ...
    (comp.text.tex)
  • Re: Automatically resize font when component size changes?
    ... first post. ... check all of them for a given font. ... Figure out how large I could make the biggest string found in step ... such that it would not overflow the dimensions found in step two. ...
    (comp.lang.java.gui)