Font Size Problem in Edit Control [SOLVED]
-
Hi to all, I am facing a strange problem, i had asked for help in the forum few days before. But due to certain delays i was unable to show the code. Here is the code. My Problem is with hindi fonts. When i substitute the the LOGFONT.lfHeight with 0(Zero) then everything works fine, But when i change the size of lfHeight to anything greater or lesser than zero, the Hindi fonts is displayed very small. How to solve this issue.
case WM_INITDIALOG:
LOGFONT lf;HFONT cFont; HWND target = GetDlgItem(hwnd,IDC\_STATIC1); HFONT hFont = (HFONT)GetStockObject(DEFAULT\_GUI\_FONT); GetObject(hFont, sizeof(LOGFONT), &lf); lf.lfHeight = 0; cFont = CreateFontIndirect(&lf); SendMessage(target,WM\_SETFONT,(WPARAM)cFont,MAKELPARAM(TRUE,0)); SetWindowText(target,\_T("C:\\\\Program Files\\\\অভিধান: ইংরেজী\\\\सरकारी &&")); break;
sorry for posting twice.
Regards, Vishal
modified on Thursday, June 9, 2011 1:32 PM
-
Hi to all, I am facing a strange problem, i had asked for help in the forum few days before. But due to certain delays i was unable to show the code. Here is the code. My Problem is with hindi fonts. When i substitute the the LOGFONT.lfHeight with 0(Zero) then everything works fine, But when i change the size of lfHeight to anything greater or lesser than zero, the Hindi fonts is displayed very small. How to solve this issue.
case WM_INITDIALOG:
LOGFONT lf;HFONT cFont; HWND target = GetDlgItem(hwnd,IDC\_STATIC1); HFONT hFont = (HFONT)GetStockObject(DEFAULT\_GUI\_FONT); GetObject(hFont, sizeof(LOGFONT), &lf); lf.lfHeight = 0; cFont = CreateFontIndirect(&lf); SendMessage(target,WM\_SETFONT,(WPARAM)cFont,MAKELPARAM(TRUE,0)); SetWindowText(target,\_T("C:\\\\Program Files\\\\অভিধান: ইংরেজী\\\\सरकारी &&")); break;
sorry for posting twice.
Regards, Vishal
modified on Thursday, June 9, 2011 1:32 PM
You need to convert the point height of your font into device units with the following formula:
lFont.lfHeight = MulDiv(nFontHeight, GetDeviceCaps(hDC, LOGPIXELSY), 72);// height of font
See the MSDN page for CreateFont()[^] for more information.
The best things in life are not things.
-
You need to convert the point height of your font into device units with the following formula:
lFont.lfHeight = MulDiv(nFontHeight, GetDeviceCaps(hDC, LOGPIXELSY), 72);// height of font
See the MSDN page for CreateFont()[^] for more information.
The best things in life are not things.
i am using
-MulDiv(iPointSize,GetDeviceCaps(GetDC(target),LOGPIXELSY),72);
Where iPointSize is the size of font; But, the results are not up-to mark. If i specify the
lFont.lfHeight = 14
then, the text in english font is ok but the text in hindi font seems like the
lfHeight is 8
. But if i specify thelFont.lfHeight = 0
Whether hindi or bengali or chinese every font is in same height and looks good, but their sizes are big. I am using default
MS Shell Dlg
Font.Regards, Vishal
-
i am using
-MulDiv(iPointSize,GetDeviceCaps(GetDC(target),LOGPIXELSY),72);
Where iPointSize is the size of font; But, the results are not up-to mark. If i specify the
lFont.lfHeight = 14
then, the text in english font is ok but the text in hindi font seems like the
lfHeight is 8
. But if i specify thelFont.lfHeight = 0
Whether hindi or bengali or chinese every font is in same height and looks good, but their sizes are big. I am using default
MS Shell Dlg
Font.Regards, Vishal
-
Try the positive value returned by
MulDiv()
and/or one of the other fonts, if possible one that was designed for Hindi characters.The best things in life are not things.
Yes sir, i had tried.
Mangal
gives positive result for hindi fonts. AndTrebuchet MS
for others. Sir, i have one small doubt. Do we have to distribute these fonts with application or these are system default fonts available on windows. and(negative) -MulDiv()
gives good result instead of(postive) MulDiv()
. Is it OK. Please guide.Regards, Vishal
-
Yes sir, i had tried.
Mangal
gives positive result for hindi fonts. AndTrebuchet MS
for others. Sir, i have one small doubt. Do we have to distribute these fonts with application or these are system default fonts available on windows. and(negative) -MulDiv()
gives good result instead of(postive) MulDiv()
. Is it OK. Please guide.Regards, Vishal
-
vishalgpt wrote:
Please guide.
I'm afraid I don't have the answer to these questions, you will have to investigate the rest for yourself.
The best things in life are not things.
-
Yes sir, i had tried.
Mangal
gives positive result for hindi fonts. AndTrebuchet MS
for others. Sir, i have one small doubt. Do we have to distribute these fonts with application or these are system default fonts available on windows. and(negative) -MulDiv()
gives good result instead of(postive) MulDiv()
. Is it OK. Please guide.Regards, Vishal
From memory, a negative lfHeight means "points" as opposed to pixels, but you'd have to check the definitions on msdn for LOGFONT. Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
-
From memory, a negative lfHeight means "points" as opposed to pixels, but you'd have to check the definitions on msdn for LOGFONT. Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!