Problems Measuring Font Height
From: Jonathan Wood (jwood_at_softcircuits.com)
Date: 12/03/04
- Previous message: Logos Bible Software: "RE: C++ to C# GDI+ problem"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 3 Dec 2004 13:31:22 -0700
I am trying to figure out how high a particular font will paint.
Here's my situation: I have an owner-drawn window and want to write some
text in it. I measure the font like this:
font.CreateFontIndirect(&pApp->m_lfFont);
pOldFont = dc.SelectObject(&font);
dc.GetTextMetrics(&tm);
dc.SelectObject(pOldFont);
m_dm.CharSize.cx = tm.tmAveCharWidth;
m_dm.CharSize.cy = (tm.tmHeight + tm.tmExternalLeading);
I then paint each row using ::ExtTextOut. After painting a row, I add
m_dm.CharSize.cy to my X coordinate and paint the next line.
This has worked flawlessly for many years. However, I've primarily been
using Courier and Courier New fonts and have recently found some problems
with some other fonts such as OCRB and others.
The problem is that I paint the text with OPAQUE background mode (I do not
first clear the background because that causes too much flicker) but, with
some fonts, when I then paint the next line, there is a space between the
lines that never gets painted. Apparently, my cy measurement above is not
accurate for all fonts and I'm moving too far down for the next line.
Does anyone know how to determine the height a particular font will paint,
regardless of the font?
Thanks for any tips.
-- Jonathan Wood SoftCircuits http://www.softcircuits.com Available for consulting: http://www.softcircuits.com/jwood/resume.htm
- Previous message: Logos Bible Software: "RE: C++ to C# GDI+ problem"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|