https://git.reactos.org/?p=reactos.git;a=commitdiff;h=65a5a989c587ecbf521973...
commit 65a5a989c587ecbf52197346ab1eff8ba0e5e192 Author: Baruch Rutman peterooch@gmail.com AuthorDate: Thu Jul 26 22:08:29 2018 +0300 Commit: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org CommitDate: Fri Jul 27 00:47:48 2018 +0200
[LPK] Changes (#622).
- Changed how the ScriptIsComplex check is made to account direction, most noticeble on dxdiag, https://docs.microsoft.com/en-us/windows/desktop/api/usp10/nf-usp10-scriptis... However commented out the ScriptIsComplex flag change because of a bug.
- Added a check and debug print if BIDI_Reorder fails. --- dll/win32/lpk/lpk.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/dll/win32/lpk/lpk.c b/dll/win32/lpk/lpk.c index 03ed3268ef..a31d9787a0 100644 --- a/dll/win32/lpk/lpk.c +++ b/dll/win32/lpk/lpk.c @@ -7,6 +7,7 @@ */
#include "ros_lpk.h" +#include <debug.h>
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))