From 10f17ec369b0a8ab2a178732f9f464da861fc1ec Mon Sep 17 00:00:00 2001 From: Baruch Rutman Date: Fri, 14 Jun 2019 01:43:44 +0300 Subject: [PATCH] Update lpk.c --- dll/win32/lpk/lpk.c | 72 ++++++++++----------------------------------- 1 file changed, 16 insertions(+), 56 deletions(-) diff --git a/dll/win32/lpk/lpk.c b/dll/win32/lpk/lpk.c index f3ecaf9499..98af06520c 100644 --- a/dll/win32/lpk/lpk.c +++ b/dll/win32/lpk/lpk.c @@ -442,71 +442,31 @@ LpkGetTextExtentExPoint( DWORD dwUnused, int unknown) { - SCRIPT_STRING_ANALYSIS ssa; - HRESULT hr; - const SIZE *pSize; - INT i, extent, *Dx; + BOOL bReorder, bResult; + LPWORD lpGlyphs = NULL; + INT cGlyphs; UNREFERENCED_PARAMETER(dwUnused); UNREFERENCED_PARAMETER(unknown); - if (cString < 0 || !lpSize) - return FALSE; - - if (cString == 0) - { - lpSize->cx = 0; - lpSize->cy = 0; - return TRUE; - } - - /* Check if any processing is required */ + /* Check if complex script processing is required */ if (ScriptIsComplex(lpString, cString, SIC_COMPLEX) != S_OK) return GetTextExtentExPointWPri(hdc, lpString, cString, nMaxExtent, lpnFit, lpnDx, lpSize); - - hr = ScriptStringAnalyse(hdc, lpString, cString, 3 * cString / 2 + 16, -1, - SSA_GLYPHS, 0, NULL, NULL, NULL, NULL, NULL, &ssa); - - if (hr != S_OK) - return FALSE; - pSize = ScriptString_pSize(ssa); - if (pSize) - *lpSize = *pSize; + bReorder = BIDI_Reorder(hdc, lpString, cString, GCP_REORDER, WINE_GCPW_FORCE_LTR, + NULL, 0, NULL, &lpGlyphs, &cGlyphs); + + if (lpGlyphs && bReorder) + { + bResult = GetTextExtentExPointI(hdc, lpGlyphs, cGlyphs, nMaxExtent, lpnFit, lpnDx, lpSize); + } else - GetTextExtentExPointWPri(hdc, lpString, cString, 0, NULL, NULL, lpSize); - - /* Use logic from TextIntGetTextExtentPoint */ - if (lpnDx || lpnFit) - { - Dx = HeapAlloc(GetProcessHeap(), 0, cString * sizeof(INT)); - - if (!Dx) - { - ScriptStringFree(&ssa); - return FALSE; - } - - if (lpnFit) - *lpnFit = 0; - - ScriptStringGetLogicalWidths(ssa, Dx); - - for (i = 0, extent = 0; i < cString; i++) - { - extent += Dx[i]; - - if (extent <= nMaxExtent && lpnFit) - *lpnFit = i + 1; - - if (lpnDx) - lpnDx[i] = extent; - } - - HeapFree(GetProcessHeap(), 0, Dx); + { + WARN("BIDI_Reorder failed, falling back to original string.\n"); + bResult = GetTextExtentExPointWPri(hdc, lpString, cString, nMaxExtent, lpnFit, lpnDx, lpSize); } - ScriptStringFree(&ssa); - return TRUE; + HeapFree(GetProcessHeap(), 0, lpGlyphs); + return bResult; } -- 2.19.1.windows.1