[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Does FontMetrix#getAverageCharWidth() correct on Linux?

Hi folks.
I'm using Monospace Font to develop Terminal made out of SWT on Linux.
I would like to know how long width of a charactor.
So I used FontMetrix#getAverageCharWidth(),But It returns wrong value.

This is a sample code.

GC graphic = new GC(img);
Font font = new Font(display, "Monospace", 10, SWT.NORMAL);
graphics.setFont(font);
FontMetrics fm = graphics.getFontMetrics();
int char_width = graphics.stringExtent("i").x; // this command returns value '7'
// char_width = fm.getAverageCharWidth(); // this command returns value '9'


I think Monospace Font always returns same value about width when it is same font size.Why FontManager#getAverateCharWidth() returns 9? Is it a bug?