[0.4.11] [USP10] Apply unfinished patch to avoid CORE-14226

Thomas linked the patch in Wine Bug 44410
A very well-working patch, that I used to apply to every release since 0.4.8.
It avoids text rendering regressions in some setups like UltraISO
The bug is very wide-spread in unaddressed master.

like in last release
(cherry picked from commit 937c2615e6)
This commit is contained in:
Joachim Henze 2018-02-17 19:29:24 +01:00
parent 7e9c37c58f
commit 2fc468303c
2 changed files with 13 additions and 8 deletions

View file

@ -842,19 +842,23 @@ static inline WORD set_cache_glyph(SCRIPT_CACHE *psc, WCHAR c, WORD glyph)
return ((*block)[(c % 0x10000) & GLYPH_BLOCK_MASK] = glyph);
}
static inline BOOL get_cache_glyph_widths(SCRIPT_CACHE *psc, WORD glyph, ABC *abc)
static inline BOOL get_cache_glyph_widths(SCRIPT_CACHE *psc, WORD glyph, ABC *abc, BOOL no_glyph_index)
{
static const ABC nil;
ABC *block = ((ScriptCache *)*psc)->widths[glyph >> GLYPH_BLOCK_SHIFT];
ABC *block = no_glyph_index ?
((ScriptCache *)*psc)->widths[glyph >> GLYPH_BLOCK_SHIFT] :
((ScriptCache *)*psc)->glyph_widths[glyph >> GLYPH_BLOCK_SHIFT];
if (!block || !memcmp(&block[glyph & GLYPH_BLOCK_MASK], &nil, sizeof(ABC))) return FALSE;
memcpy(abc, &block[glyph & GLYPH_BLOCK_MASK], sizeof(ABC));
return TRUE;
}
static inline BOOL set_cache_glyph_widths(SCRIPT_CACHE *psc, WORD glyph, ABC *abc)
static inline BOOL set_cache_glyph_widths(SCRIPT_CACHE *psc, WORD glyph, ABC *abc, BOOL no_glyph_index)
{
ABC **block = &((ScriptCache *)*psc)->widths[glyph >> GLYPH_BLOCK_SHIFT];
ABC **block = no_glyph_index ?
&((ScriptCache *)*psc)->widths[glyph >> GLYPH_BLOCK_SHIFT] :
&((ScriptCache *)*psc)->glyph_widths[glyph >> GLYPH_BLOCK_SHIFT];
if (!*block && !(*block = heap_alloc_zero(sizeof(ABC) * GLYPH_BLOCK_SIZE))) return FALSE;
memcpy(&(*block)[glyph & GLYPH_BLOCK_MASK], abc, sizeof(ABC));
@ -3421,7 +3425,7 @@ HRESULT WINAPI ScriptPlaceOpenType( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS
{
abc.abcA = abc.abcB = abc.abcC = 0;
}
else if (!get_cache_glyph_widths(psc, pwGlyphs[i], &abc))
else if (!get_cache_glyph_widths(psc, pwGlyphs[i], &abc, psa->fNoGlyphIndex))
{
BOOL ret;
if (!hdc) return E_PENDING;
@ -3444,7 +3448,7 @@ HRESULT WINAPI ScriptPlaceOpenType( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS
abc.abcB = width;
abc.abcA = abc.abcC = 0;
}
set_cache_glyph_widths(psc, pwGlyphs[i], &abc);
set_cache_glyph_widths(psc, pwGlyphs[i], &abc, psa->fNoGlyphIndex);
}
if (pABC)
{
@ -3705,7 +3709,7 @@ HRESULT WINAPI ScriptGetGlyphABCWidth(HDC hdc, SCRIPT_CACHE *psc, WORD glyph, AB
if (!abc) return E_INVALIDARG;
if ((hr = init_script_cache(hdc, psc)) != S_OK) return hr;
if (!get_cache_glyph_widths(psc, glyph, abc))
if (!get_cache_glyph_widths(psc, glyph, abc, FALSE))
{
if (!hdc) return E_PENDING;
if ((get_cache_pitch_family(psc) & TMPF_TRUETYPE))
@ -3719,7 +3723,7 @@ HRESULT WINAPI ScriptGetGlyphABCWidth(HDC hdc, SCRIPT_CACHE *psc, WORD glyph, AB
abc->abcB = width;
abc->abcA = abc->abcC = 0;
}
set_cache_glyph_widths(psc, glyph, abc);
set_cache_glyph_widths(psc, glyph, abc, FALSE);
}
return S_OK;
}

View file

@ -201,6 +201,7 @@ typedef struct {
BOOL sfnt;
CacheGlyphPage *page[NUM_PAGES];
ABC *widths[GLYPH_MAX / GLYPH_BLOCK_SIZE];
ABC *glyph_widths[GLYPH_MAX / GLYPH_BLOCK_SIZE];
void *GSUB_Table;
void *GDEF_Table;
void *CMAP_Table;