[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.platform.swt] Re: FontMetrics missing some usefull functions...
|
- From: Hans Deragon <hans@xxxxxxxxxxx>
- Date: Wed, 23 Apr 2003 16:00:24 -0400
- Newsgroups: eclipse.platform.swt
- Organization: Deragon Informatique inc.
- User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3) Gecko/20030312
Stefan Matthias Aust wrote:
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?
Because I did not know that this function existed? :)
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.
Why are all these functions part or GC, instead of FontMetrics? I know, you
probably do not have the answer.
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.
Thanks for the info. Anybody would have a nice html page to point to, which
explains all these fonts characteristics? I am lost at all of this.
Here is what I want to do. I want to have a text field that can contain Y
characters. So I want to calculate its size accordingly, using the formula
Y*<Width of largest character), and then pass this into computeSize() to get
the size of the Text widget, and then pass the width to the FormData.width
attribute.
bye
Thanks for your reply. Its appreciated.
Hans Deragon
--
Deragon Informatique inc. Open source:
http://www.deragon.biz http://swtmvcwrapper.sourceforge.net
mailto://hans@xxxxxxxxxxx http://autopoweroff.sourceforge.net