Originally posted by ying lam:
And I have tried the following code on linux on java 6.
And it returns '1' for character 'A' for all the fonts on my system.
I am not sure why.
If you print out font.getSize() in addition to font.getFontName()
I bet you'll find that all the fonts are tiny, perhaps 1-point.
You don't say what font size you are looking to measure, but if
you want the width of the character 'A' at 12-point sizes, make
this one change:
FontMetrics fontMetrics = toolkit.getFontMetrics(allFonts[i]
.deriveFont(12f));