[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.platform.swt] How to calculate character widths?
|
- From: Stefan Matthias Aust <sma@xxxxxxxxx>
- Date: Mon, 21 Apr 2003 19:45:43 +0200
- Newsgroups: eclipse.platform.swt
- Organization: EclipseCorner
- User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4a) Gecko/20030401
I'd like to determine the true width of single characters.
I try to find a way to create a packed bitmap with all characters to use
that as a texture for OpenGL. However, I've trouble to measure the font.
There's GC#getCharWidth() but on Windows, this method only returns the
"B" width of a character. As documented, this is the width without
leading or trailing whitespace or overhang. However, some fonts have
such an overhang. Let's assume an uppercase A which has some
tail-thingy as shown below:
/\
/__\
/ \_ uto _
-__-
^ ^ ^
'-'------------'
A B ^------^
-C
This character has a small "A" leading, a large "B" width that includes
the "tail" and a negative "C" which tells the renderer where to start
the next character - "u" in my example.
How do I get the other two values besides B? ...without directly
calling the OS.GetCharABCWidths() method? Is there a platform
independent way to get the width "A" or "C"? Can I safely assume that
GC#getAdvanceWidth() will always return A+B+C?
Interestingly, getAdvanceWidth() uses OS.GetCharWidth(). MSDN however
says, that this method cannot be used for truetype fonts. Why does this
work then?
bye
--
Stefan Matthias Aust //
www.3plus4software.de // Inter Deum Et Diabolum Semper Musica Est