[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.
This commit is contained in:
Baruch Rutman 2018-09-07 10:45:35 +03:00 committed by Hermès Bélusca-Maïto
parent a244e4f6dd
commit ab5fdcc01f
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
3 changed files with 33 additions and 8 deletions

View file

@ -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)
{

View file

@ -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);
}
}
}

View file

@ -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)