Fix a problem with handling ETO_GLPYH_INDEX. Spotted by Rob

Shearman.
This commit is contained in:
Huw Davies 2005-09-19 14:36:32 +00:00 committed by Alexandre Julliard
parent 0ceacf017f
commit c292f4861d
1 changed files with 6 additions and 7 deletions

View File

@ -1738,7 +1738,7 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
LPWSTR reordered_str = (LPWSTR)str; LPWSTR reordered_str = (LPWSTR)str;
const WORD *glyphs = NULL; WORD *glyphs = NULL;
UINT align = GetTextAlign( hdc ); UINT align = GetTextAlign( hdc );
POINT pt; POINT pt;
TEXTMETRICW tm; TEXTMETRICW tm;
@ -1794,7 +1794,7 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
lprect, debugstr_wn(str, count), count, lpDx); lprect, debugstr_wn(str, count), count, lpDx);
if(flags & ETO_GLYPH_INDEX) if(flags & ETO_GLYPH_INDEX)
glyphs = (const WORD*)reordered_str; glyphs = reordered_str;
if(lprect) if(lprect)
TRACE("rect: %ld,%ld - %ld,%ld\n", lprect->left, lprect->top, lprect->right, TRACE("rect: %ld,%ld - %ld,%ld\n", lprect->left, lprect->top, lprect->right,
@ -1980,9 +1980,9 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
{ {
HFONT orig_font = dc->hFont, cur_font; HFONT orig_font = dc->hFont, cur_font;
UINT glyph; UINT glyph;
WORD *glyphs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WORD));
INT span = 0, *offsets = NULL, i; INT span = 0, *offsets = NULL, i;
glyphs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WORD));
for(i = 0; i < count; i++) for(i = 0; i < count; i++)
{ {
WineEngGetLinkedHFont(dc, reordered_str[i], &cur_font, &glyph); WineEngGetLinkedHFont(dc, reordered_str[i], &cur_font, &glyph);
@ -2026,14 +2026,12 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
(flags & ~ETO_OPAQUE) | ETO_GLYPH_INDEX, &rc, (flags & ~ETO_OPAQUE) | ETO_GLYPH_INDEX, &rc,
glyphs, span, deltas ? deltas + count - span : NULL); glyphs, span, deltas ? deltas + count - span : NULL);
SelectObject(hdc, orig_font); SelectObject(hdc, orig_font);
HeapFree(GetProcessHeap(), 0, glyphs);
HeapFree(GetProcessHeap(), 0, offsets); HeapFree(GetProcessHeap(), 0, offsets);
} }
} }
} }
else else
{ {
WORD *glyphs = NULL;
if(!(flags & ETO_GLYPH_INDEX) && dc->gdiFont) if(!(flags & ETO_GLYPH_INDEX) && dc->gdiFont)
{ {
glyphs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WORD)); glyphs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WORD));
@ -2041,8 +2039,7 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
flags |= ETO_GLYPH_INDEX; flags |= ETO_GLYPH_INDEX;
} }
ret = dc->funcs->pExtTextOut(dc->physDev, x, y, (flags & ~ETO_OPAQUE), &rc, ret = dc->funcs->pExtTextOut(dc->physDev, x, y, (flags & ~ETO_OPAQUE), &rc,
(flags & ETO_GLYPH_INDEX) ? glyphs: reordered_str, count, deltas); glyphs ? glyphs : reordered_str, count, deltas);
HeapFree(GetProcessHeap(), 0, glyphs);
} }
if (lf.lfUnderline || lf.lfStrikeOut) if (lf.lfUnderline || lf.lfStrikeOut)
@ -2108,6 +2105,8 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
done: done:
HeapFree(GetProcessHeap(), 0, deltas); HeapFree(GetProcessHeap(), 0, deltas);
if(glyphs != reordered_str)
HeapFree(GetProcessHeap(), 0, glyphs);
if(reordered_str != str) if(reordered_str != str)
HeapFree(GetProcessHeap(), 0, reordered_str); HeapFree(GetProcessHeap(), 0, reordered_str);