Skip to content

Commit 2fc4683

Browse files
committed
[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 937c261)
1 parent 7e9c37c commit 2fc4683

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

dll/win32/usp10/usp10.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -842,19 +842,23 @@ static inline WORD set_cache_glyph(SCRIPT_CACHE *psc, WCHAR c, WORD glyph)
842842
return ((*block)[(c % 0x10000) & GLYPH_BLOCK_MASK] = glyph);
843843
}
844844

845-
static inline BOOL get_cache_glyph_widths(SCRIPT_CACHE *psc, WORD glyph, ABC *abc)
845+
static inline BOOL get_cache_glyph_widths(SCRIPT_CACHE *psc, WORD glyph, ABC *abc, BOOL no_glyph_index)
846846
{
847847
static const ABC nil;
848-
ABC *block = ((ScriptCache *)*psc)->widths[glyph >> GLYPH_BLOCK_SHIFT];
848+
ABC *block = no_glyph_index ?
849+
((ScriptCache *)*psc)->widths[glyph >> GLYPH_BLOCK_SHIFT] :
850+
((ScriptCache *)*psc)->glyph_widths[glyph >> GLYPH_BLOCK_SHIFT];
849851

850852
if (!block || !memcmp(&block[glyph & GLYPH_BLOCK_MASK], &nil, sizeof(ABC))) return FALSE;
851853
memcpy(abc, &block[glyph & GLYPH_BLOCK_MASK], sizeof(ABC));
852854
return TRUE;
853855
}
854856

855-
static inline BOOL set_cache_glyph_widths(SCRIPT_CACHE *psc, WORD glyph, ABC *abc)
857+
static inline BOOL set_cache_glyph_widths(SCRIPT_CACHE *psc, WORD glyph, ABC *abc, BOOL no_glyph_index)
856858
{
857-
ABC **block = &((ScriptCache *)*psc)->widths[glyph >> GLYPH_BLOCK_SHIFT];
859+
ABC **block = no_glyph_index ?
860+
&((ScriptCache *)*psc)->widths[glyph >> GLYPH_BLOCK_SHIFT] :
861+
&((ScriptCache *)*psc)->glyph_widths[glyph >> GLYPH_BLOCK_SHIFT];
858862

859863
if (!*block && !(*block = heap_alloc_zero(sizeof(ABC) * GLYPH_BLOCK_SIZE))) return FALSE;
860864
memcpy(&(*block)[glyph & GLYPH_BLOCK_MASK], abc, sizeof(ABC));
@@ -3421,7 +3425,7 @@ HRESULT WINAPI ScriptPlaceOpenType( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS
34213425
{
34223426
abc.abcA = abc.abcB = abc.abcC = 0;
34233427
}
3424-
else if (!get_cache_glyph_widths(psc, pwGlyphs[i], &abc))
3428+
else if (!get_cache_glyph_widths(psc, pwGlyphs[i], &abc, psa->fNoGlyphIndex))
34253429
{
34263430
BOOL ret;
34273431
if (!hdc) return E_PENDING;
@@ -3444,7 +3448,7 @@ HRESULT WINAPI ScriptPlaceOpenType( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS
34443448
abc.abcB = width;
34453449
abc.abcA = abc.abcC = 0;
34463450
}
3447-
set_cache_glyph_widths(psc, pwGlyphs[i], &abc);
3451+
set_cache_glyph_widths(psc, pwGlyphs[i], &abc, psa->fNoGlyphIndex);
34483452
}
34493453
if (pABC)
34503454
{
@@ -3705,7 +3709,7 @@ HRESULT WINAPI ScriptGetGlyphABCWidth(HDC hdc, SCRIPT_CACHE *psc, WORD glyph, AB
37053709
if (!abc) return E_INVALIDARG;
37063710
if ((hr = init_script_cache(hdc, psc)) != S_OK) return hr;
37073711

3708-
if (!get_cache_glyph_widths(psc, glyph, abc))
3712+
if (!get_cache_glyph_widths(psc, glyph, abc, FALSE))
37093713
{
37103714
if (!hdc) return E_PENDING;
37113715
if ((get_cache_pitch_family(psc) & TMPF_TRUETYPE))
@@ -3719,7 +3723,7 @@ HRESULT WINAPI ScriptGetGlyphABCWidth(HDC hdc, SCRIPT_CACHE *psc, WORD glyph, AB
37193723
abc->abcB = width;
37203724
abc->abcA = abc->abcC = 0;
37213725
}
3722-
set_cache_glyph_widths(psc, glyph, abc);
3726+
set_cache_glyph_widths(psc, glyph, abc, FALSE);
37233727
}
37243728
return S_OK;
37253729
}

dll/win32/usp10/usp10_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ typedef struct {
201201
BOOL sfnt;
202202
CacheGlyphPage *page[NUM_PAGES];
203203
ABC *widths[GLYPH_MAX / GLYPH_BLOCK_SIZE];
204+
ABC *glyph_widths[GLYPH_MAX / GLYPH_BLOCK_SIZE];
204205
void *GSUB_Table;
205206
void *GDEF_Table;
206207
void *CMAP_Table;

0 commit comments

Comments
 (0)