[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-scriptiscomplex
  However commented out the ScriptIsComplex flag change because of a bug.

- Added a check and debug print if BIDI_Reorder fails.
This commit is contained in:
Baruch Rutman 2018-07-26 22:08:29 +03:00 committed by Hermès Bélusca-Maïto
parent e054a053ff
commit 65a5a989c5
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -7,6 +7,7 @@
*/ */
#include "ros_lpk.h" #include "ros_lpk.h"
#include <debug.h>
LPK_LPEDITCONTROL_LIST LpkEditControl = {EditCreate, EditIchToXY, EditMouseToIch, EditCchInWidth, LPK_LPEDITCONTROL_LIST LpkEditControl = {EditCreate, EditIchToXY, EditMouseToIch, EditCchInWidth,
EditGetLineWidth, EditDrawText, EditHScroll, EditMoveSelection, EditGetLineWidth, EditDrawText, EditHScroll, EditMoveSelection,
@ -66,28 +67,32 @@ LpkExtTextOut(
LPWORD glyphs = NULL; LPWORD glyphs = NULL;
LPWSTR reordered_str = NULL; LPWSTR reordered_str = NULL;
INT cGlyphs; INT cGlyphs;
BOOL bResult; DWORD dwSICFlags = SIC_COMPLEX;
BOOL bResult, bReorder;
UNREFERENCED_PARAMETER(unknown); UNREFERENCED_PARAMETER(unknown);
if (!(fuOptions & ETO_IGNORELANGUAGE)) fuOptions |= ETO_IGNORELANGUAGE;
fuOptions |= ETO_IGNORELANGUAGE;
/* Check text direction */ /* Check text direction */
if ((GetLayout(hdc) & LAYOUT_RTL) || (GetTextAlign(hdc) & TA_RTLREADING)) if ((GetLayout(hdc) & LAYOUT_RTL) || (GetTextAlign(hdc) & TA_RTLREADING))
{ fuOptions |= ETO_RTLREADING;
if (!(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 */ /* 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)); reordered_str = HeapAlloc(GetProcessHeap(), 0, uCount * sizeof(WCHAR));
BIDI_Reorder(hdc, lpString, uCount, GCP_REORDER, bReorder = BIDI_Reorder(hdc, lpString, uCount, GCP_REORDER,
(fuOptions & ETO_RTLREADING) ? WINE_GCPW_FORCE_RTL : WINE_GCPW_FORCE_LTR, (fuOptions & ETO_RTLREADING) ? WINE_GCPW_FORCE_RTL : WINE_GCPW_FORCE_LTR,
reordered_str, uCount, NULL, &glyphs, &cGlyphs); reordered_str, uCount, NULL, &glyphs, &cGlyphs);
if (glyphs) if (glyphs)
{ {
@ -95,14 +100,17 @@ LpkExtTextOut(
uCount = cGlyphs; 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, bResult = ExtTextOutW(hdc, x, y, fuOptions, lprc,
glyphs ? (LPWSTR)glyphs : reordered_str, uCount, lpDx); glyphs ? (LPWSTR)glyphs : reordered_str, uCount, lpDx);
} }
else else
{
DPRINT1("BIDI_Reorder failed, falling back to original string.\n");
bResult = ExtTextOutW(hdc, x, y, fuOptions, lprc, lpString, uCount, lpDx); bResult = ExtTextOutW(hdc, x, y, fuOptions, lprc, lpString, uCount, lpDx);
}
HeapFree(GetProcessHeap(), 0, glyphs); HeapFree(GetProcessHeap(), 0, glyphs);
HeapFree(GetProcessHeap(), 0, reordered_str); HeapFree(GetProcessHeap(), 0, reordered_str);
@ -152,18 +160,17 @@ LpkGetCharacterPlacement(
{ {
if (lpGlyphs) if (lpGlyphs)
StringCchCopyW(lpResults->lpGlyphs, cGlyphs, lpGlyphs); StringCchCopyW(lpResults->lpGlyphs, cGlyphs, lpGlyphs);
else if (lpResults->lpOutString) else if (lpResults->lpOutString)
GetGlyphIndicesW(hdc, lpResults->lpOutString, nSet, lpResults->lpGlyphs, 0); GetGlyphIndicesW(hdc, lpResults->lpOutString, nSet, lpResults->lpGlyphs, 0);
} }
if (lpResults->lpDx) if (lpResults->lpDx)
{ {
int c;
/* If glyph shaping was requested */ /* If glyph shaping was requested */
if (dwFlags & GCP_GLYPHSHAPE) if (dwFlags & GCP_GLYPHSHAPE)
{ {
int c;
if (lpResults->lpGlyphs) if (lpResults->lpGlyphs)
{ {
for (i = 0; i < lpResults->nGlyphs; i++) for (i = 0; i < lpResults->nGlyphs; i++)
@ -176,8 +183,6 @@ LpkGetCharacterPlacement(
else else
{ {
int c;
for (i = 0; i < nSet; i++) for (i = 0; i < nSet; i++)
{ {
if (GetCharWidth32W(hdc, lpResults->lpOutString[i], lpResults->lpOutString[i], &c)) if (GetCharWidth32W(hdc, lpResults->lpOutString[i], lpResults->lpOutString[i], &c))