Hi I am changing my font using the CreateFont. It all works for me except the calculation for the em size from my point size.
I am getting some sort of default.
Here:
HFONT font;
long lfHeight;\
lfHeight = -MulDiv(12, GetDeviceCaps(hdc, LOGPIXELSY), 72); //... logical height of font that is 12 point will be calculated.
font = CreateFont(lfHeight, //.............................int nHeight, logical height of font
0, //........................................int nWidth, logical average character width
0, //........................................int nEscapement, angle of escapement
0, //........................................int nOrientation, base-line orientation angle
FW_NORMAL, //...................int fnWeight, font weight
FALSE, //...............................DWORD fdwItalic, italic attribute flag
FALSE, //...............................DWORD fdwUnderline, underline attribute flag
FALSE, //...............................DWORD fdwStrikeOut, strikeout attribute flag
ANSI_CHARSET, //.............................DWORD fdwCharSet, character set identifier
OUT_DEFAULT_PRECIS, //.............DWORD fdwOutputPrecision, output precision
CLIP_DEFAULT_PRECIS, //.............DWORD fdwClipPrecision, clipping precision
PROOF_QUALITY, //..........................DWORD fdwQuality, output quality
VARIABLE_PITCH|FF_DECORATIVE, //....DWORD fdwPitchAndFamily, pitch and family
"Comic Sans MS"); //.........................LPCTSTR lpszFace pointer to typeface name string
SelectObject(hdc, font);\
SetTextColor(hdc, RGB(240,240,96));
I am getting my font and all other features I want (proven by changing). But I want to be able to control the text size.
In this line:
lfHeight = -MulDiv(12, GetDeviceCaps(hdc, LOGPIXELSY), 72); //... logical height of font that is 12 point will be calculated.
If a change 12 to 30, my text size does not change! No modification up or down affects the text !
If I ignore calculation and hard code -40 (a "bigger" negative number).... no problem I get a big text size (obviously not 40 pt).
So hard coding a negative integer in .... -10 or -50, and my text size always goes up or down like it should.
font = CreateFont(-40, //.............................int nHeight, logical height of font
0, //........................................int nWidth, logical average character width
0, //........................................int nEscapement, angle of escapement
0, //........................................int nOrientation, base-line orientation angle
FW_NORMAL, //...................int fnWeight, font weight
etc etc.....
What BIG thing am I doing wrong in this line:
lfHeight = -MulDiv(12, GetDeviceCaps(hdc, LOGPIXELSY), 72);
I almost got to the finish line understanding the font change. But I seem to be stymied here (not a rare event).
Thanks in advance,
Ed