Function TextOut() does not render Japanese characters either with the Calibri, or with the Arial fo

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
It can be easily verified, by using the symbol dialog box in MS Word, that the
Calibri font doesnt have the Unicode characters 0x062A and 0x660E. Nevertheless, the function
TextOut() prints the character 0x062A (Arabic), but doesnt exhibit the character 0x660E (Japanese). Whats the reason for this behavior ?
From this http://msdn.microsoft.com/en-us/goglobal/bb688134.aspx page one can read :
<span style="color:#333333; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; font-size:13px; line-height:11px; background-color:#ced5db
The Windows core fonts (Times New Roman, Courier New, Arial, Microsoft Sans Serif, and Tahoma) contain Latin, Hebrew, Arabic, Greek, and Cyrillic scripts but do not contain East Asian script characters. They link to fonts that do., which seems to contradict
the result obtained in this program, if I replace the Calibri font by
Arial
, as the results will be the same, i.e., the Japanese character will be printed as invalid.
<pre class="prettyprint" style=" LRESULT CALLBACK WndProc (HWND hwnd, UINT message, UINT wParam, LONG lParam)
{
static HFONT s_hFont;

switch( message )
{
case WM_CREATE:
{
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = -MulDiv(20, 96, 72);
wcscpy_s(lf.lfFaceName, LF_FACESIZE, L"Calibri");

if( !(s_hFont = CreateFontIndirect(&lf)) ) return -1;
}
break;

case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hwnd, &ps);
s_hFont = (HFONT)SelectObject(ps.hdc, s_hFont);

wchar_t wchar1 = 0x062A; // Arabic character
TextOut(ps.hdc, 10, 10, &wchar1, 1);

wchar_t wchar2 = 0x660E; // Japanese character
TextOut(ps.hdc, 10, 50, &wchar2, 1);

s_hFont = (HFONT)SelectObject(ps.hdc, s_hFont);
EndPaint(hwnd, &ps);
}
break;


case WM_DESTROY:
DeleteObject(s_hFont);
PostQuitMessage(0);
break;

default:

return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0L ;
}[/code]

Screen shot from the output
<img alt="" src="http://social.msdn.microsoft.com/Forums/getfile/129727
<br/>



View the full article
 
Back
Top