From ab5fdcc01f7fe3e7f21999d8908c866188a22355 Mon Sep 17 00:00:00 2001 From: Baruch Rutman Date: Fri, 7 Sep 2018 10:45:35 +0300 Subject: [PATCH] [LPK] Make GetCharacterPlacement caret positions respect bidi. (#842) - Try to make use of ScriptStringCPtoX when trying to fill the lpCaretPos struct member; if USP10 error happens fallback to the unreorder method. - Remove now incorrect debug print. --- dll/win32/lpk/bidi.c | 5 +++++ dll/win32/lpk/lpk.c | 34 ++++++++++++++++++++++++++------ win32ss/gdi/gdi32/objects/font.c | 2 -- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/dll/win32/lpk/bidi.c b/dll/win32/lpk/bidi.c index a380e1f2ed6..1d92cfd0021 100644 --- a/dll/win32/lpk/bidi.c +++ b/dll/win32/lpk/bidi.c @@ -460,7 +460,12 @@ BOOL BIDI_Reorder( if (lpGlyphs) { +#ifdef __REACTOS__ + /* ReactOS r57677 and r57679 */ + cMaxGlyphs = 3 * uCount / 2 + 16; +#else cMaxGlyphs = 1.5 * uCount + 16; +#endif run_glyphs = HeapAlloc(GetProcessHeap(),0,sizeof(WORD) * cMaxGlyphs); if (!run_glyphs) { diff --git a/dll/win32/lpk/lpk.c b/dll/win32/lpk/lpk.c index 075778ba7cb..b567d744ca5 100644 --- a/dll/win32/lpk/lpk.c +++ b/dll/win32/lpk/lpk.c @@ -134,9 +134,11 @@ LpkGetCharacterPlacement( DWORD dwFlags, DWORD dwUnused) { + DWORD ret = 0; + HRESULT hr; + SCRIPT_STRING_ANALYSIS ssa; LPWORD lpGlyphs = NULL; SIZE size; - DWORD ret = 0; UINT nSet, i; INT cGlyphs; @@ -190,16 +192,36 @@ LpkGetCharacterPlacement( } } - /* FIXME: Currently not bidi compliant! */ if (lpResults->lpCaretPos) { int pos = 0; - lpResults->lpCaretPos[0] = 0; - for (i = 1; i < nSet; i++) + hr = ScriptStringAnalyse(hdc, lpString, nSet, +#ifdef __REACTOS__ + /* ReactOS r57677 and r57679 */ + (3 * nSet / 2 + 16), +#else + (1.5 * nSet + 16), +#endif + -1, SSA_GLYPHS, -1, + NULL, NULL, NULL, NULL, NULL, &ssa); + if (hr == S_OK) { - if (GetTextExtentPoint32W(hdc, &(lpString[i - 1]), 1, &size)) - lpResults->lpCaretPos[i] = (pos += size.cx); + for (i = 0; i < nSet; i++) + { + if (ScriptStringCPtoX(ssa, i, FALSE, &pos) == S_OK) + lpResults->lpCaretPos[i] = pos; + } + ScriptStringFree(&ssa); + } + else + { + lpResults->lpCaretPos[0] = 0; + for (i = 1; i < nSet; i++) + { + if (GetTextExtentPoint32W(hdc, &(lpString[i - 1]), 1, &size)) + lpResults->lpCaretPos[i] = (pos += size.cx); + } } } diff --git a/win32ss/gdi/gdi32/objects/font.c b/win32ss/gdi/gdi32/objects/font.c index 871ea50952c..38758fa7902 100644 --- a/win32ss/gdi/gdi32/objects/font.c +++ b/win32ss/gdi/gdi32/objects/font.c @@ -450,8 +450,6 @@ GetCharacterPlacementW( if (dwFlags&(~GCP_REORDER)) DPRINT("flags 0x%08lx ignored\n", dwFlags); if (lpResults->lpClass) DPRINT("classes not implemented\n"); - if (lpResults->lpCaretPos && (dwFlags & GCP_REORDER)) - DPRINT("Caret positions for complex scripts not implemented\n"); nSet = (UINT)uCount; if (nSet > lpResults->nGlyphs)