J
John B. Matthews
Roedy Green said:one of the big problems is when you substitute a font, the characters
are not the same size. I would like to normalize fonts to their true
size so that when you substitute fonts, the actual real estate
consumed varies only a little.
I must demur: a typical JComponent, such as JLabel, goes to considerable
lengths to calculate its preferred size using the metrics of the
selected Font. As long as you
- don't veto the calculation,
- don't preclude resizing,
- do use a LayoutManager, and
- do pack() the enclosing Container
the chosen Font is irrelevant. If the Font must be changed dynamically,
revalidate() and repaint() should suffice.
Another would be a guaranteed to render all glyphs, even if it means
substituting from some other font. Failing that at telling the
truth. Java claims to render a glyph when all it does in render some
generic glyph.
Font substitution shouldn't cause a problem. Missing glyphs and
mendacious canDisplay() are annoying, but the metrics are typically
reliable.