Skip to content

Commit c19ce95

Browse files
committed
[0.4.9] [USP10] Apply unfinished patch to avoid CORE-14226
Thomas linked the patch in Wine Bug 44410 I tested it for some weeks without noticing any side-effects. It avoids text rendering regressions in some setups like UltraISO like in 0.4.8 before (cherry picked from commit 937c261)
1 parent f926d74 commit c19ce95

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));
@@ -3425,7 +3429,7 @@ HRESULT WINAPI ScriptPlaceOpenType( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS
34253429
{
34263430
abc.abcA = abc.abcB = abc.abcC = 0;
34273431
}
3428-
else if (!get_cache_glyph_widths(psc, pwGlyphs[i], &abc))
3432+
else if (!get_cache_glyph_widths(psc, pwGlyphs[i], &abc, psa->fNoGlyphIndex))
34293433
{
34303434
BOOL ret;
34313435
if (!hdc) return E_PENDING;
@@ -3448,7 +3452,7 @@ HRESULT WINAPI ScriptPlaceOpenType( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS
34483452
abc.abcB = width;
34493453
abc.abcA = abc.abcC = 0;
34503454
}
3451-
set_cache_glyph_widths(psc, pwGlyphs[i], &abc);
3455+
set_cache_glyph_widths(psc, pwGlyphs[i], &abc, psa->fNoGlyphIndex);
34523456
}
34533457
if (pABC)
34543458
{
@@ -3709,7 +3713,7 @@ HRESULT WINAPI ScriptGetGlyphABCWidth(HDC hdc, SCRIPT_CACHE *psc, WORD glyph, AB
37093713
if (!abc) return E_INVALIDARG;
37103714
if ((hr = init_script_cache(hdc, psc)) != S_OK) return hr;
37113715

3712-
if (!get_cache_glyph_widths(psc, glyph, abc))
3716+
if (!get_cache_glyph_widths(psc, glyph, abc, FALSE))
37133717
{
37143718
if (!hdc) return E_PENDING;
37153719
if ((get_cache_pitch_family(psc) & TMPF_TRUETYPE))
@@ -3723,7 +3727,7 @@ HRESULT WINAPI ScriptGetGlyphABCWidth(HDC hdc, SCRIPT_CACHE *psc, WORD glyph, AB
37233727
abc->abcB = width;
37243728
abc->abcA = abc->abcC = 0;
37253729
}
3726-
set_cache_glyph_widths(psc, glyph, abc);
3730+
set_cache_glyph_widths(psc, glyph, abc, FALSE);
37273731
}
37283732
return S_OK;
37293733
}

dll/win32/usp10/usp10_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ typedef struct {
188188
BOOL sfnt;
189189
CacheGlyphPage *page[NUM_PAGES];
190190
ABC *widths[GLYPH_MAX / GLYPH_BLOCK_SIZE];
191+
ABC *glyph_widths[GLYPH_MAX / GLYPH_BLOCK_SIZE];
191192
void *GSUB_Table;
192193
void *GDEF_Table;
193194
void *CMAP_Table;

0 commit comments

Comments
 (0)