Re: CFont and CButton

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ganapathi Hegde (GanapathiHegde_at_discussions.microsoft.com)
Date: 01/27/05


Date: Wed, 26 Jan 2005 23:21:02 -0800

I created fonts using CreateFontIndirect, and called SetFont function.

Creation font as below:

HFONT hFont ;
LOGFONT LogFont;
char szFaceName[LF_FACESIZE];
lstrcpy(szFaceName, lpszFaceName);
memset(&LogFont, 0, sizeof(LogFont));
   LogFont.lfCharSet = <>
lstrcpy(LogFont.lfFaceName, szFaceName);
LogFont.lfHeight = -MulDiv(nHeight, GetDeviceCaps(hDCPrn, LOGPIXELSY), 72);
 hFont = CreateFontIndirect(&LogFont);

Notice line LogFont.lfCharSet = <>. I kept blank here as I am setting the
charaset using EnumFonts. As MSDN says
"When initializing the members of the LOGFONT structure, be sure to specify
a specific character set in the lfCharSet member. This member is important in
the font mapping process and the results will be inconsistent if this member
is not initialized correctly. If you specify a typeface name in the
lfFaceName member of the LOGFONT structure, make sure that the lfCharSet
value matches the character set of the typeface specified in lfFaceName. For
example, if you want to select a font such as MS Mincho, lfCharSet must be
set to the predefined value SHIFTJIS_CHARSET."

For Arial CE the char set is 238
For Arial CYR the cahr set is 204

If I set LogFont.lfCharSet to DEFAULT_CHARSET then both edit box and button
behaves similar way but they apply default font.

Note:
These fonts are not present physically. Means there is no corresponding TTF
file.
Only these are substitute fonts. i.e entries in
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\FontSubstitutes

On installation of corresponding TTF file with DEFAULT_CHARSET then it works
fine in both button as well as edit box.

"Ajay Kalra" wrote:

> What does this mean? How are you setting the font? Are you saying controls
> with Arial CE etc do not respond to SetFont?
>
> --
> Ajay Kalra [MVP - VC++]
> ajaykalra@yahoo.com
>
>
> "Ganapathi Hegde" <GanapathiHegde@discussions.microsoft.com> wrote in
> message news:A5FB23F8-7572-4B05-9C60-1C6CFAD4E53A@microsoft.com...
> > I developed an MFC application. It is setting fonts properly. But it is
> not
> > setting fonts for Substitutes fonts like Arial CE, Arial CYR in Windows
> 2000.
> >
> > Also same font is working fine in edit box.
> >
> > Please let me know if you have any solution to it.
> >
> > Regards,
> > Ganapathi
>
>
>



Relevant Pages

  • Re: Display special characters on a JEditorPane
    ... to find suitable symbols to use in the fonts you are using. ... indexed by char number. ... // translate control chars into printable ones. ...
    (comp.lang.java.gui)
  • Re: Missing the long s
    ... access it through xelatex or lualatex: ... Well this example use the open type version of the fonts. ... char is in this version of the fonts. ...
    (comp.text.tex)
  • Re: Missing the long s
    ... access it through xelatex or lualatex: ... Well this example use the open type version of the fonts. ... char is in this version of the fonts. ...
    (comp.text.tex)
  • wide char to bitmap
    ... I want to make a 16x16 bitmap from one char of one of the many fonts ... but e.g. pbmtext doesn't seem to work beyond ... Therefore I want a command line solution. ...
    (comp.os.linux.x)
  • Re: Font issue
    ... Fonts: serife_fon ... I've checked the my final image has the courier TTF file in the font ... my RichText control always shows text that looks ... HFONT hFont = CreateFontIndirect; ...
    (microsoft.public.windowsxp.embedded)