IssacJones
asked on
space under a font
Is there a way I can determine the space under a font in MFC?
John
John
ASKER
Hi
No, sorry, you've misunderstood. What I need to know is the various dimensions for a given font e.g. if the font sits in some kind of cell (rectangle) how do I find the spacing from the bottom of the cell to the bottom of the font (assuming that is that there is a space).
Similarly, find the space from the top of the font to the top of the rectangle.
John
No, sorry, you've misunderstood. What I need to know is the various dimensions for a given font e.g. if the font sits in some kind of cell (rectangle) how do I find the spacing from the bottom of the cell to the bottom of the font (assuming that is that there is a space).
Similarly, find the space from the top of the font to the top of the rectangle.
John
call
CClient dc(this);
TEXTMETRIC tm = { 0 };
dc.GetTextMetrics(&tm);
then the you can retrieve the info from tm structure (think it is tmInternalLeading),
if it some control which has the font required use CWnd pointer of that control instead of this.
if you have only the font do
CFont newFont;
newFont.Create...();
CClient dc(this);
CFont * pOldFont = dc.SelectObject(&newFont);
before calling GetTextMetrics.
CClient dc(this);
TEXTMETRIC tm = { 0 };
dc.GetTextMetrics(&tm);
then the you can retrieve the info from tm structure (think it is tmInternalLeading),
if it some control which has the font required use CWnd pointer of that control instead of this.
if you have only the font do
CFont newFont;
newFont.Create...();
CClient dc(this);
CFont * pOldFont = dc.SelectObject(&newFont);
before calling GetTextMetrics.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
CString sHello = "Hello World";
int spcpos = sHello.Find(' ');
it is regardless what font you were using.
the space char is always ascii code 32 (0x20) for any font.