gdi32: Add a helper function to get chars in the range.

This commit is contained in:
Akihiro Sagawa 2011-01-16 23:00:25 +09:00 committed by Alexandre Julliard
parent d4924bf9a1
commit b9c41636bb
1 changed files with 27 additions and 14 deletions

View File

@ -1553,6 +1553,31 @@ UINT WINAPI GetOutlineTextMetricsW(
return ret; return ret;
} }
static LPSTR FONT_GetCharsByRangeA(UINT firstChar, UINT lastChar, PINT pByteLen)
{
INT i, count = lastChar - firstChar + 1;
UINT c;
LPSTR str;
if (count <= 0)
return NULL;
str = HeapAlloc(GetProcessHeap(), 0, count * 2 + 1);
if (str == NULL)
return NULL;
for(i = 0, c = firstChar; c <= lastChar; i++, c++)
{
if (c > 0xff)
str[i++] = (BYTE)(c >> 8);
str[i] = (BYTE)c;
}
str[i] = '\0';
*pByteLen = i;
return str;
}
/*********************************************************************** /***********************************************************************
* GetCharWidthW (GDI32.@) * GetCharWidthW (GDI32.@)
@ -2296,27 +2321,15 @@ BOOL WINAPI GetAspectRatioFilterEx( HDC hdc, LPSIZE pAspectRatio )
BOOL WINAPI GetCharABCWidthsA(HDC hdc, UINT firstChar, UINT lastChar, BOOL WINAPI GetCharABCWidthsA(HDC hdc, UINT firstChar, UINT lastChar,
LPABC abc ) LPABC abc )
{ {
INT i, wlen, count = (INT)(lastChar - firstChar + 1); INT i, wlen;
UINT c;
LPSTR str; LPSTR str;
LPWSTR wstr; LPWSTR wstr;
BOOL ret = TRUE; BOOL ret = TRUE;
if (count <= 0) str = FONT_GetCharsByRangeA(firstChar, lastChar, &i);
return FALSE;
str = HeapAlloc(GetProcessHeap(), 0, count * 2 + 1);
if (str == NULL) if (str == NULL)
return FALSE; return FALSE;
for(i = 0, c = firstChar; c <= lastChar; i++, c++)
{
if (c > 0xff)
str[i++] = (BYTE)(c >> 8);
str[i] = (BYTE)c;
}
str[i] = '\0';
wstr = FONT_mbtowc(hdc, str, i, &wlen, NULL); wstr = FONT_mbtowc(hdc, str, i, &wlen, NULL);
if (wstr == NULL) if (wstr == NULL)
{ {