diff --git a/dll/win32/lpk/lpk.c b/dll/win32/lpk/lpk.c index 03ed3268ef4..a31d9787a06 100644 --- a/dll/win32/lpk/lpk.c +++ b/dll/win32/lpk/lpk.c @@ -7,6 +7,7 @@ */ #include "ros_lpk.h" +#include LPK_LPEDITCONTROL_LIST LpkEditControl = {EditCreate, EditIchToXY, EditMouseToIch, EditCchInWidth, EditGetLineWidth, EditDrawText, EditHScroll, EditMoveSelection, @@ -66,28 +67,32 @@ LpkExtTextOut( LPWORD glyphs = NULL; LPWSTR reordered_str = NULL; INT cGlyphs; - BOOL bResult; + DWORD dwSICFlags = SIC_COMPLEX; + BOOL bResult, bReorder; UNREFERENCED_PARAMETER(unknown); - if (!(fuOptions & ETO_IGNORELANGUAGE)) - fuOptions |= ETO_IGNORELANGUAGE; + fuOptions |= ETO_IGNORELANGUAGE; /* Check text direction */ if ((GetLayout(hdc) & LAYOUT_RTL) || (GetTextAlign(hdc) & TA_RTLREADING)) - { - if (!(fuOptions & ETO_RTLREADING)) - fuOptions |= ETO_RTLREADING; - } + fuOptions |= ETO_RTLREADING; + + /* If text direction is RTL change flag to account neutral characters + BUG: disables reordering of propsheet titles */ + /* if (fuOptions & ETO_RTLREADING) + dwSICFlags = SIC_NEUTRAL; */ /* Check if the string requires complex script processing and not a "glyph indices" array */ - if (ScriptIsComplex(lpString, uCount, SIC_COMPLEX) == S_OK && !(fuOptions & ETO_GLYPH_INDEX)) + if (ScriptIsComplex(lpString, uCount, dwSICFlags) == S_OK && !(fuOptions & ETO_GLYPH_INDEX)) { + /* reordered_str is used as fallback in case the glyphs array fails to generate, + BIDI_Reorder doesn't attempt to write into reordered_str if memory allocation fails */ reordered_str = HeapAlloc(GetProcessHeap(), 0, uCount * sizeof(WCHAR)); - BIDI_Reorder(hdc, lpString, uCount, GCP_REORDER, - (fuOptions & ETO_RTLREADING) ? WINE_GCPW_FORCE_RTL : WINE_GCPW_FORCE_LTR, - reordered_str, uCount, NULL, &glyphs, &cGlyphs); + bReorder = BIDI_Reorder(hdc, lpString, uCount, GCP_REORDER, + (fuOptions & ETO_RTLREADING) ? WINE_GCPW_FORCE_RTL : WINE_GCPW_FORCE_LTR, + reordered_str, uCount, NULL, &glyphs, &cGlyphs); if (glyphs) { @@ -95,14 +100,17 @@ LpkExtTextOut( uCount = cGlyphs; } - if (glyphs || reordered_str) + /* Now display the reordered text if any of the arrays is valid and if BIDI_Reorder succeeded */ + if ((glyphs || reordered_str) && bReorder) { bResult = ExtTextOutW(hdc, x, y, fuOptions, lprc, glyphs ? (LPWSTR)glyphs : reordered_str, uCount, lpDx); } - else + { + DPRINT1("BIDI_Reorder failed, falling back to original string.\n"); bResult = ExtTextOutW(hdc, x, y, fuOptions, lprc, lpString, uCount, lpDx); + } HeapFree(GetProcessHeap(), 0, glyphs); HeapFree(GetProcessHeap(), 0, reordered_str); @@ -152,18 +160,17 @@ LpkGetCharacterPlacement( { if (lpGlyphs) StringCchCopyW(lpResults->lpGlyphs, cGlyphs, lpGlyphs); - else if (lpResults->lpOutString) GetGlyphIndicesW(hdc, lpResults->lpOutString, nSet, lpResults->lpGlyphs, 0); } if (lpResults->lpDx) { + int c; + /* If glyph shaping was requested */ if (dwFlags & GCP_GLYPHSHAPE) { - int c; - if (lpResults->lpGlyphs) { for (i = 0; i < lpResults->nGlyphs; i++) @@ -176,8 +183,6 @@ LpkGetCharacterPlacement( else { - int c; - for (i = 0; i < nSet; i++) { if (GetCharWidth32W(hdc, lpResults->lpOutString[i], lpResults->lpOutString[i], &c))