The Calibri
font doesn't have neither one of the characters, 0x062A
and 0x660E
, but the first character gets printed using some other font. However, the character 0x660E
shows as an invalid char code. Why TextOut()
doesn't substitute the font to print this last character, the same it did with the character code 0x062A
?
If I replace the Calibri
font by Arial
, the result is the same.
Edit : also I want to call your attention to this sentence, which can be found here http://msdn.microsoft.com/en-us/goglobal/bb688134.aspx : "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." Well I've tried my code with all those fonts and the results were exactly the same : the character 0x660E is rendered invalid.
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);
lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
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 ;
}
Screen shot from the output