Reputation: 131
I was looking for a way to find the bounds on rendered text and encountered the FontMetrics getStringBounds method. This seems to ignore some font's descent and has an exaggerated ascent so that it returns a bounds that doesn't let me align vertically properly. I dug a bit deeper and found that GlyphVector.getPixelBounds() SEEMS to do what I want, but I don't know if there might be some problems with using it.
I wrote an applet http://breadmilkbeercigarettes.com/bmbc/shelves/users/bbb/src/java/applet/glyphvector.html that displays the difference between the two, and it seems for my system fonts it returns the correct bounds. Does anyone know if this is a costly method or if there are other possible pitfalls from using it? FontMetrics never seemed to work correctly for me. Or perhaps my expectations of it were misaligned.
Thanks, BBB
Upvotes: 1
Views: 193