From 3983cf99276b585e435d8854b2d521efe9a244a2 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 | 58 ++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/dll/win32/lpk/lpk.c b/dll/win32/lpk/lpk.c index f3ecaf9499..ba208cfab7 100644 --- a/dll/win32/lpk/lpk.c +++ b/dll/win32/lpk/lpk.c @@ -444,8 +444,8 @@ LpkGetTextExtentExPoint( { SCRIPT_STRING_ANALYSIS ssa; HRESULT hr; - const SIZE *pSize; INT i, extent, *Dx; + TEXTMETRICW tm; UNREFERENCED_PARAMETER(dwUnused); UNREFERENCED_PARAMETER(unknown); @@ -453,7 +453,7 @@ LpkGetTextExtentExPoint( if (cString < 0 || !lpSize) return FALSE; - if (cString == 0) + if (cString == 0 || !lpString) { lpSize->cx = 0; lpSize->cy = 0; @@ -470,43 +470,41 @@ LpkGetTextExtentExPoint( if (hr != S_OK) return FALSE; - pSize = ScriptString_pSize(ssa); - - if (pSize) - *lpSize = *pSize; - else - GetTextExtentExPointWPri(hdc, lpString, cString, 0, NULL, NULL, lpSize); + if (!GetTextMetricsW(hdc, &tm)) + { + ScriptStringFree(&ssa); + return FALSE; + } - /* Use logic from TextIntGetTextExtentPoint */ - if (lpnDx || lpnFit) - { - Dx = HeapAlloc(GetProcessHeap(), 0, cString * sizeof(INT)); + /* Use logic from TextIntGetTextExtentPoint */ + Dx = HeapAlloc(GetProcessHeap(), 0, cString * sizeof(INT)); - if (!Dx) - { - ScriptStringFree(&ssa); - return FALSE; - } + if (!Dx) + { + ScriptStringFree(&ssa); + return FALSE; + } - if (lpnFit) - *lpnFit = 0; + if (lpnFit) + *lpnFit = 0; - ScriptStringGetLogicalWidths(ssa, Dx); + ScriptStringGetLogicalWidths(ssa, Dx); - for (i = 0, extent = 0; i < cString; i++) - { - extent += Dx[i]; - - if (extent <= nMaxExtent && lpnFit) - *lpnFit = i + 1; + for (i = 0, extent = 0; i < cString; i++) + { + extent += Dx[i]; - if (lpnDx) - lpnDx[i] = extent; - } + if (extent <= nMaxExtent && lpnFit) + *lpnFit = i + 1; - HeapFree(GetProcessHeap(), 0, Dx); + if (lpnDx) + lpnDx[i] = extent; } + lpSize->cx = extent; + lpSize->cy = tm.tmHeight; + + HeapFree(GetProcessHeap(), 0, Dx); ScriptStringFree(&ssa); return TRUE; } -- 2.19.1.windows.1