Getting the correct size of a glyph in a font
- From: "Autograph" <mark.hatsell@xxxxxxxxxxxxxx>
- Date: Wed, 15 Mar 2006 16:09:02 -0000
Hi all,
I am creating an onscreen keyboard which will be configurable for differing
layouts depending on the user's locale.
I have the basic keyboard working, but I am having some problems positioning
the text for the differing keys (vertically) . I have attempted to do this
by splitting the rect of the key into 4 quadrants (as keys can have up to 4
different characters on them).
Taking the bottom right quadrant for the moment, I first tried to position
the character vertically using the tmheight from the fonts TEXTMETRIC. and
centering this at the centre of the quadrant.
This functioned, however I found that those characters which have a descent
were overlapping the bevel of the button. If I move the origin point up for
all the keys then the numbers etc look odd.
I therefore need a method of repositioning the character's which have a
descent. I have tried to use the GetGlyphOutline function to return the
GLYPHMETRICS and use the origin and its blackboxy, however it does not seem
to be returning the correct values for the font.
For Example: '0' which is 3x8pixels on the screen returned 11x11 as its size
whilst the '[' which is 3x10 returned 10x10.
Essentially I want to be able to determine if a character has a descent by:
Relating its origin and its height and comparing this to the baseline. The
origin seems to be taken from the bottom of the font (based upon the values
returned in the glyph metric). Therefore I assume the following will
determine this.
if (origin.y - blackboxy < descent)
then hasDescent = true
Unfortunately because blackboxy isn't returning the actual size of the glyph
this does not work correctly. I fear that I am misunderstanding what the
blackbox elements represent, as I'm sure the API call is working correctly.
Has anyone any idea what is going on, or can someone suggest a better method
of getting round the problem.
Thanks in Advance
Mark
.
- Prev by Date: GDI and multithreading
- Next by Date: Re: Obtaining Info about a window from its HWND?
- Previous by thread: GDI and multithreading
- Next by thread: Re: Getting the correct size of a glyph in a font
- Index(es):