Rich edit control problem: bitmap font shows twice as wide as it should

Rich edit control problem: bitmap font shows twice as wide as it should

Post by David Goodenoug » Fri, 22 Oct 1999 04:00:00



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.

 
 
 

1. rich edit controls and bitmaps

I have a CRichEditCtrl  which contains text (I want it to contain text and a
bitmap.)
I have a CBitmap which I normally display in the main window.

Is there any way I can append the CBitmap image to the end of the text in
the CRichEditCtrl?

It's trivial in a CRichEditView/Document architecture, but that's not what
my application has as its core element.
The idea is I wish to send the CRichedit data as a report to the printer (I
can print it, but not any graphics within it)

Thanks for any suggestions.

Glenn Dunn

2. WM_QUERYENDSESSION question

3. Rich edit control problem (Focus not changing with tab)

4. DECSpin factsheet available.

5. Problems with Syntax Coloring in Rich Edit Control!

6. Print Odd Pages / Print Even Pages

7. mouse input problem in dialog (Rich edit control)

8. Problem getting to secure site with IE4 under WinNT

9. Rich edit control problems

10. need rich edit control for wince to use with EVC

11. Rich Edit Control

12. rich edit control

13. coloring text in a rich edit control