Module: wine Branch: master Commit: b9c41636bb47e092ddc1ee34c5f050cb5a6d62c3 URL: http://source.winehq.org/git/wine.git/?a=commit;h=b9c41636bb47e092ddc1ee34c5...
Author: Akihiro Sagawa sagawa.aki@gmail.com Date: Sun Jan 16 23:00:25 2011 +0900
gdi32: Add a helper function to get chars in the range.
---
dlls/gdi32/font.c | 41 +++++++++++++++++++++++++++-------------- 1 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index cf29add..1489956 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -1553,6 +1553,31 @@ UINT WINAPI GetOutlineTextMetricsW( 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.@) @@ -2296,27 +2321,15 @@ BOOL WINAPI GetAspectRatioFilterEx( HDC hdc, LPSIZE pAspectRatio ) BOOL WINAPI GetCharABCWidthsA(HDC hdc, UINT firstChar, UINT lastChar, LPABC abc ) { - INT i, wlen, count = (INT)(lastChar - firstChar + 1); - UINT c; + INT i, wlen; LPSTR str; LPWSTR wstr; BOOL ret = TRUE;
- if (count <= 0) - return FALSE; - - str = HeapAlloc(GetProcessHeap(), 0, count * 2 + 1); + str = FONT_GetCharsByRangeA(firstChar, lastChar, &i); if (str == NULL) 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); if (wstr == NULL) {