I ran into an awkward behaviour of CEdit when setting it's font: for a certain font size, letters like 'g' or 'j' have the bottom part missing, regardless of CEdit's rect height. Here are two examples:
CFont *ctrlFont = new CFont();
ctrlFont ->CreatePointFont(80, "Arial Black");
CEdit m_editName;
m_editName.SetFont(ctrlFont);
with this result:
but for
ctrlFont ->CreatePointFont(100, "Arial Black");
everything is fine
As you can observe, the CEdit's rect height is larger than the text's height in both cases. The parent control is a CDialog; the font is set on ::OnInitDialog
and CEdit's size is set with SetWindowPos
method on ::OnShowWindow
. What could cause this, and how should i handle it?
Edit: i've tried @rrirower 's suggestion, and now i'm confussed; adding the CEdit's CDC
to CFont's initialization changed the text's mask alot (you may not see it from the beggining, but i have other edit's with the old font on the same page and there's a big difference):
ctrlFont1->CreatePointFont(80, "Arial Black", m_editName.GetDC());
Call CreateFont() with all parameters
font.CreateFont(
12, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
_T("Arial"))); // lpszFacename
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With