Re: Font Resize
Karl Uppiano wrote:
...
On each size event, we calculated the largest font that would fit into the
available space (vertical and horizontal), by iterating through the font
sizes starting at 1 point, and creating a new font, looking at the font
metrics (advance and height + descent, IIRC). When the font got too big, we
went back to the previous point size, and used that one. We never found a
more efficient way to do this, ...
<speculative>
Cache the the last component size and current point size.
If the resize show it larger, iterate the point size upwards
from the last font size, else iterate down.
Another optimization that springs to mind is to check the
ratio of cached viewing width to point size, and use that
as a guide to the size of the font with the new width.
</speculative>
...but it was actually fast enough.
Which raises the whole question of whether doing anything
other than that, amounts to 'over optimization'.
--
Andrew Thompson
http://www.athompson.info/andrew/
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200706/1