https://git.reactos.org/?p=reactos.git;a=commitdiff;h=33d3e56cf4abbe57a7b0f…
commit 33d3e56cf4abbe57a7b0f6cee682055894c92155
Author: Baruch Rutman <peterooch(a)gmail.com>
AuthorDate: Mon Jun 18 12:07:16 2018 +0300
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Fri Jul 27 00:46:02 2018 +0200
[LPK] Refactoring (#622).
- Moved lpDx and lpGlyphs operations to seperate brackets.
- lpGlyphs == NULL checks + memory managment additions.
CORE-14732
---
dll/win32/lpk/lpk.c | 67 +++++++++++++++++++++++++++++++++++------------------
1 file changed, 44 insertions(+), 23 deletions(-)
diff --git a/dll/win32/lpk/lpk.c b/dll/win32/lpk/lpk.c
index fde181cc52..656808ea5b 100644
--- a/dll/win32/lpk/lpk.c
+++ b/dll/win32/lpk/lpk.c
@@ -63,9 +63,6 @@ LpkExtTextOut(
const INT *lpDx,
INT unknown)
{
- LPWORD glyphs = NULL;
- INT cGlyphs;
-
UNREFERENCED_PARAMETER(unknown);
if (!(fuOptions & ETO_IGNORELANGUAGE))
@@ -81,16 +78,30 @@ LpkExtTextOut(
/* 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))
{
+ LPWORD glyphs = NULL;
+ LPWSTR reordered_str = HeapAlloc(GetProcessHeap(), 0, uCount * sizeof(WCHAR));
+ INT cGlyphs;
+ BOOL bResult;
+
BIDI_Reorder(hdc, lpString, uCount, GCP_REORDER,
(fuOptions & ETO_RTLREADING) ? WINE_GCPW_FORCE_RTL :
WINE_GCPW_FORCE_LTR,
- NULL, uCount, NULL, &glyphs, &cGlyphs);
+ reordered_str, uCount, NULL, &glyphs, &cGlyphs);
- fuOptions |= ETO_GLYPH_INDEX;
+ if (glyphs)
+ {
+ fuOptions |= ETO_GLYPH_INDEX;
- if (uCount > cGlyphs)
- cGlyphs = uCount;
+ if (uCount != cGlyphs)
+ uCount = cGlyphs;
+ }
- return ExtTextOutW(hdc, x, y, fuOptions, lprc, (LPWSTR)glyphs, cGlyphs, lpDx);
+ bResult = ExtTextOutW(hdc, x, y, fuOptions, lprc,
+ glyphs ? (LPWSTR)glyphs : reordered_str, uCount, lpDx);
+
+ HeapFree(GetProcessHeap(), 0, glyphs);
+ HeapFree(GetProcessHeap(), 0, reordered_str);
+
+ return bResult;
}
return ExtTextOutW(hdc, x, y, fuOptions, lprc, lpString, uCount, lpDx);
@@ -132,28 +143,38 @@ LpkGetCharacterPlacement(
lpResults->nGlyphs = (UINT)cGlyphs;
if (lpResults->lpGlyphs)
- wcscpy(lpResults->lpGlyphs, lpGlyphs);
-
- if (lpResults->lpDx && !(dwFlags & GCP_GLYPHSHAPE))
{
- int c;
- for (i = 0; i < nSet; i++)
- {
- if (GetCharWidth32W(hdc, lpResults->lpOutString[i],
lpResults->lpOutString[i], &c))
- lpResults->lpDx[i] = c;
- }
+ if (lpGlyphs)
+ wcscpy(lpResults->lpGlyphs, lpGlyphs);
+
+ else if (lpResults->lpOutString)
+ GetGlyphIndicesW(hdc, lpResults->lpOutString, nSet,
lpResults->lpGlyphs, 0);
}
- /* If glyph shaping was requested */
- else if (lpResults->lpDx && (dwFlags & GCP_GLYPHSHAPE))
+ if (lpResults->lpDx)
{
- int c;
+ /* If glyph shaping was requested */
+ if(dwFlags & GCP_GLYPHSHAPE)
+ {
+ int c;
+
+ if (lpResults->lpGlyphs)
+ {
+ for (i = 0; i < lpResults->nGlyphs; i++)
+ {
+ if (GetCharWidth32W(hdc, lpResults->lpGlyphs[i],
lpResults->lpGlyphs[i], &c))
+ lpResults->lpDx[i] = c;
+ }
+ }
+ }
- if (lpResults->lpGlyphs)
+ else
{
- for (i = 0; i < lpResults->nGlyphs; i++)
+ int c;
+
+ for (i = 0; i < nSet; i++)
{
- if (GetCharWidth32W(hdc, lpGlyphs[i], lpGlyphs[i], &c))
+ if (GetCharWidth32W(hdc, lpResults->lpOutString[i],
lpResults->lpOutString[i], &c))
lpResults->lpDx[i] = c;
}
}