Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
None
-
None
Description
When invoking DrawTextA in "Chinese(PRC)" locale, it draws wrong glyphs.
The main code for testing drawing text:
void OnPaint(HDC hdc, const RECT* prc, HFONT hf) |
{
|
char szBuffer[100]; |
WCHAR wszBuffer[100]; |
// "你好世界" encoded with GBK |
const char szTestText[] = {196, 227, 186, 195, 202, 192, 189, 231, 0}; |
// "你好世界" encoded with UTF16 |
const WCHAR wszTestText[] = {20320, 22909, 19990, 30028, 0}; |
HFONT hfOld = (HFONT)SelectObject(hdc, hf); |
int x, y; |
SIZE sz;
|
RECT rc = *prc;
|
|
SetBkColor(hdc, g_rgbBackground);
|
SetTextColor(hdc, g_rgbText);
|
|
if(g_bOpaque) |
{
|
SetBkMode(hdc, OPAQUE);
|
}
|
else |
{
|
SetBkMode(hdc, TRANSPARENT);
|
}
|
|
x = prc->left;
|
y = prc->top;
|
|
wsprintfA(szBuffer, "TextOutA Test: %s", szTestText); |
TextOutA(hdc, x, y, szBuffer, strlen(szBuffer)); |
GetTextExtentPoint32A(hdc, szBuffer, strlen(szBuffer), &sz); |
y += sz.cy;
|
|
wsprintfW(wszBuffer, L"TextOutW Test: %s", wszTestText); |
TextOutW(hdc, x, y, wszBuffer, wcslen(wszBuffer));
|
GetTextExtentPoint32W(hdc, wszBuffer, wcslen(wszBuffer), &sz);
|
y += sz.cy;
|
rc.top = y;
|
|
wsprintfA(szBuffer, "DrawTextA Test: %s", szTestText); |
DrawTextA(hdc, szBuffer, -1, &rc, DT_SINGLELINE);
|
GetTextExtentPoint32A(hdc, szBuffer, strlen(szBuffer), &sz); |
y += sz.cy;
|
rc.top = y;
|
|
wsprintfW(wszBuffer, L"DrawTextW Test: %s", wszTestText); |
DrawTextW(hdc, wszBuffer, -1, &rc, DT_SINGLELINE);
|
|
SelectObject(hdc, hfOld);
|
}
|