https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ab5fdcc01f7fe3e7f21999...
commit ab5fdcc01f7fe3e7f21999d8908c866188a22355 Author: Baruch Rutman peterooch@gmail.com AuthorDate: Fri Sep 7 10:45:35 2018 +0300 Commit: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org CommitDate: Sun Sep 9 18:03:45 2018 +0200
[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 a380e1f2ed..1d92cfd002 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 075778ba7c..b567d744ca 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) + { + for (i = 0; i < nSet; i++) + { + if (ScriptStringCPtoX(ssa, i, FALSE, &pos) == S_OK) + lpResults->lpCaretPos[i] = pos; + } + ScriptStringFree(&ssa); + } + else { - if (GetTextExtentPoint32W(hdc, &(lpString[i - 1]), 1, &size)) - lpResults->lpCaretPos[i] = (pos += size.cx); + 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 871ea50952..38758fa790 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)