Re: CFont and CButton
From: Ganapathi Hegde (GanapathiHegde_at_discussions.microsoft.com)
Date: 01/27/05
- Next message: Frank Hickman [MVP]: "Re: Window properties in MFC"
- Previous message: Mr.Khem: "I want to Interface picture file (*.x) with c++ MFC?"
- In reply to: Ajay Kalra: "Re: CFont and CButton"
- Messages sorted by: [ date ] [ thread ]
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
>
>
>
- Next message: Frank Hickman [MVP]: "Re: Window properties in MFC"
- Previous message: Mr.Khem: "I want to Interface picture file (*.x) with c++ MFC?"
- In reply to: Ajay Kalra: "Re: CFont and CButton"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|