Got a real strange one here. I'm using a rich edit control as a
display window in an app I'm writing. Because I need to display some
special characters that are not generally available, I have created a
bitmap font (.FNT file) that has the necessary characters in it. I
can load this font correctly and display characters from it, except
they show up twice as wide as they should.
The font is 7 wide by 12 tall, and it's placed in the resource script
for my app. Loading it is a two step operation. In my WM_CREATE
handler, I do the following:
GetModuleFileName(NULL, namebuff, MAX_PATH);
AddFontResource(namebuff);
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
and then in the rich edit control creation code, I do this:
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_FACE | CFM_SIZE;
cf.dwEffects = 0;
cf.yHeight = 12;
cf.bCharSet = DEFAULT_CHARSET;
cf.bPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
strcpy(cf.szFaceName, "SpecFont");
my_displaybox->SetDefaultCharFormat(cf);
My best guess as to why it's failing is found in the notes about the
LOGFONT structure, lfWidth member: "If lfWidth is zero, the aspect
ratio of the device is matched against the digitization aspect ratio
of the available fonts to find the closest match, determined by the
absolute value of the difference." Since I can't specify the width in
a CHARFORMAT structure, I'm guessing that it's setting it to 0, and
then trying to map my 7 by 12 font into the closest thing to a square
that it can hit (i.e. 1 to 1 aspect ratio), thus hitting a 14 by 12
layout.
Any ideas? TIA.