Link to home
Start Free TrialLog in
Avatar of IssacJones
IssacJones

asked on

space under a font

Is there a way I can determine the space under a font in MFC?

John
Avatar of js-profi
js-profi

what do you mean by determine? if you have a CString you could spot a space by Find function (for example).
 
   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.
Avatar of IssacJones

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
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.
ASKER CERTIFIED SOLUTION
Avatar of pgnatyuk
pgnatyuk
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks