[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform.swt] Re: FontMetrics missing some usefull functions...

Hans Deragon wrote:

Using FontMetric.getAverageCharWidth() is not good enough. I do not want the average, I want the size of the largest (usually 'm').

Why don't you simply enumerate all chars using GC#getAdvanceWidth() and calculate the maximum yourself?


However, please note that the advance width of two characters as measured by GC#stringExtent might not be the sum of the widths of both characters. If you want to measure strings, use the latter method because that known about kerning and stuff.

Furthermore, the advance width isn't the real width of the character glyph. This can be determined with GC#getCharWidth. This value however can't be used to calcuate the extent of a bounding box that contains a drawn character because - AFAIK - there's no way to determine the initial indent or the overhang of the character glyph.


bye -- Stefan Matthias Aust // www.3plus4software.de // Inter Deum Et Diabolum Semper Musica Est