Commit 70c22221 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

gdi32: Avoid making a DBCS character in range.

parent a6530f40
...@@ -1596,13 +1596,15 @@ UINT WINAPI GetOutlineTextMetricsW( ...@@ -1596,13 +1596,15 @@ UINT WINAPI GetOutlineTextMetricsW(
static LPSTR FONT_GetCharsByRangeA(HDC hdc, UINT firstChar, UINT lastChar, PINT pByteLen) static LPSTR FONT_GetCharsByRangeA(HDC hdc, UINT firstChar, UINT lastChar, PINT pByteLen)
{ {
INT i, count = lastChar - firstChar + 1; INT i, count = lastChar - firstChar + 1;
UINT mbcp;
UINT c; UINT c;
LPSTR str; LPSTR str;
if (count <= 0) if (count <= 0)
return NULL; return NULL;
switch (GdiGetCodePage(hdc)) mbcp = GdiGetCodePage(hdc);
switch (mbcp)
{ {
case 932: case 932:
case 936: case 936:
...@@ -1617,6 +1619,7 @@ static LPSTR FONT_GetCharsByRangeA(HDC hdc, UINT firstChar, UINT lastChar, PINT ...@@ -1617,6 +1619,7 @@ static LPSTR FONT_GetCharsByRangeA(HDC hdc, UINT firstChar, UINT lastChar, PINT
default: default:
if (lastChar > 0xff) if (lastChar > 0xff)
return NULL; return NULL;
mbcp = 0;
break; break;
} }
...@@ -1626,9 +1629,16 @@ static LPSTR FONT_GetCharsByRangeA(HDC hdc, UINT firstChar, UINT lastChar, PINT ...@@ -1626,9 +1629,16 @@ static LPSTR FONT_GetCharsByRangeA(HDC hdc, UINT firstChar, UINT lastChar, PINT
for(i = 0, c = firstChar; c <= lastChar; i++, c++) for(i = 0, c = firstChar; c <= lastChar; i++, c++)
{ {
if (c > 0xff) if (mbcp) {
str[i++] = (BYTE)(c >> 8); if (c > 0xff)
str[i] = (BYTE)c; str[i++] = (BYTE)(c >> 8);
if (c <= 0xff && IsDBCSLeadByteEx(mbcp, c))
str[i] = 0x1f; /* FIXME: use default character */
else
str[i] = (BYTE)c;
}
else
str[i] = (BYTE)c;
} }
str[i] = '\0'; str[i] = '\0';
......
...@@ -957,7 +957,8 @@ static void test_GetCharABCWidths(void) ...@@ -957,7 +957,8 @@ static void test_GetCharABCWidths(void)
{0xffffff, 0xffffff}, {0xffffff, 0xffffff},
{0x1000000, 0x1000000}, {0x1000000, 0x1000000},
{0xffffff, 0x1000000}, {0xffffff, 0x1000000},
{0xffffffff, 0xffffffff} {0xffffffff, 0xffffffff},
{0x00, 0xff}
}; };
static const struct static const struct
{ {
...@@ -967,12 +968,18 @@ static void test_GetCharABCWidths(void) ...@@ -967,12 +968,18 @@ static void test_GetCharABCWidths(void)
BOOL r[sizeof range / sizeof range[0]]; BOOL r[sizeof range / sizeof range[0]];
} c[] = } c[] =
{ {
{ANSI_CHARSET, 0x30, 0x30, {TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}}, {ANSI_CHARSET, 0x30, 0x30,
{SHIFTJIS_CHARSET, 0x82a0, 0x3042, {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}}, {TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE}},
{HANGEUL_CHARSET, 0x8141, 0xac02, {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}}, {SHIFTJIS_CHARSET, 0x82a0, 0x3042,
{JOHAB_CHARSET, 0x8446, 0x3135, {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}}, {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE}},
{GB2312_CHARSET, 0x8141, 0x4e04, {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}}, {HANGEUL_CHARSET, 0x8141, 0xac02,
{CHINESEBIG5_CHARSET, 0xa142, 0x3001, {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}} {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE}},
{JOHAB_CHARSET, 0x8446, 0x3135,
{TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE}},
{GB2312_CHARSET, 0x8141, 0x4e04,
{TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE}},
{CHINESEBIG5_CHARSET, 0xa142, 0x3001,
{TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE}}
}; };
UINT i; UINT i;
...@@ -1057,9 +1064,18 @@ static void test_GetCharABCWidths(void) ...@@ -1057,9 +1064,18 @@ static void test_GetCharABCWidths(void)
for (j = 0; j < sizeof range / sizeof range[0]; ++j) for (j = 0; j < sizeof range / sizeof range[0]; ++j)
{ {
memset(full, 0xdd, sizeof full);
ret = pGetCharABCWidthsA(hdc, range[j].first, range[j].last, full); ret = pGetCharABCWidthsA(hdc, range[j].first, range[j].last, full);
ok(ret == c[i].r[j], "GetCharABCWidthsA %x - %x should have %s\n", ok(ret == c[i].r[j], "GetCharABCWidthsA %x - %x should have %s\n",
range[j].first, range[j].last, c[i].r[j] ? "succeeded" : "failed"); range[j].first, range[j].last, c[i].r[j] ? "succeeded" : "failed");
if (ret)
{
UINT last = range[j].last - range[j].first;
ret = pGetCharABCWidthsA(hdc, range[j].last, range[j].last, a);
ok(ret && memcmp(&full[last], &a[0], sizeof(ABC)) == 0,
"GetCharABCWidthsA %x should match. codepage = %u\n",
range[j].last, c[i].cs);
}
} }
hfont = SelectObject(hdc, hfont); hfont = SelectObject(hdc, hfont);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment