From 145102c7fdd5968afa3a16135ed8478a2e642714 Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Mon, 14 Nov 2011 13:17:25 -0700 Subject: [PATCH] usp10: Merge neutral scripts. --- dlls/usp10/usp10.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c index f2971250058..0ffab667c95 100644 --- a/dlls/usp10/usp10.c +++ b/dlls/usp10/usp10.c @@ -870,8 +870,41 @@ HRESULT WINAPI ScriptItemizeOpenType(const WCHAR *pwcInChars, int cInChars, int } if (psControl->fMergeNeutralItems) { - HeapFree(GetProcessHeap(),0,strength); - strength = NULL; + /* Merge the neutrals */ + for (i = 0; i < cInChars; i++) + { + if (strength[i] == BIDI_NEUTRAL || strength[i] == BIDI_WEAK) + { + int j; + for (j = i; j > 0; j--) + { + if (levels[i] != levels[j]) + break; + if ((strength[j] == BIDI_STRONG) || (strength[i] == BIDI_NEUTRAL && strength[j] == BIDI_WEAK)) + { + scripts[i] = scripts[j]; + strength[i] = strength[j]; + break; + } + } + } + /* Try going the other way */ + if (strength[i] == BIDI_NEUTRAL || strength[i] == BIDI_WEAK) + { + int j; + for (j = i; j < cInChars; j++) + { + if (levels[i] != levels[j]) + break; + if ((strength[j] == BIDI_STRONG) || (strength[i] == BIDI_NEUTRAL && strength[j] == BIDI_WEAK)) + { + scripts[i] = scripts[j]; + strength[i] = strength[j]; + break; + } + } + } + } } } }