diff --git a/dll/win32/usp10/usp10.c b/dll/win32/usp10/usp10.c index 1d6c4473d4f..a18c049b080 100644 --- a/dll/win32/usp10/usp10.c +++ b/dll/win32/usp10/usp10.c @@ -842,23 +842,19 @@ 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, BOOL no_glyph_index) +static inline BOOL get_cache_glyph_widths(SCRIPT_CACHE *psc, WORD glyph, ABC *abc) { static const ABC nil; - ABC *block = no_glyph_index ? - ((ScriptCache *)*psc)->widths[glyph >> GLYPH_BLOCK_SHIFT] : - ((ScriptCache *)*psc)->glyph_widths[glyph >> GLYPH_BLOCK_SHIFT]; + ABC *block = ((ScriptCache *)*psc)->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, BOOL no_glyph_index) +static inline BOOL set_cache_glyph_widths(SCRIPT_CACHE *psc, WORD glyph, ABC *abc) { - ABC **block = no_glyph_index ? - &((ScriptCache *)*psc)->widths[glyph >> GLYPH_BLOCK_SHIFT] : - &((ScriptCache *)*psc)->glyph_widths[glyph >> GLYPH_BLOCK_SHIFT]; + ABC **block = &((ScriptCache *)*psc)->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)); @@ -3420,35 +3416,41 @@ HRESULT WINAPI ScriptPlaceOpenType( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS if (pABC) memset(pABC, 0, sizeof(ABC)); for (i = 0; i < cGlyphs; i++) { + WORD glyph; ABC abc; + + /* FIXME: set to more reasonable values */ + pGoffset[i].du = pGoffset[i].dv = 0; + if (pGlyphProps[i].sva.fZeroWidth) { abc.abcA = abc.abcB = abc.abcC = 0; + if (piAdvance) piAdvance[i] = 0; + continue; } - else if (!get_cache_glyph_widths(psc, pwGlyphs[i], &abc, psa->fNoGlyphIndex)) + + if (psa->fNoGlyphIndex) + { + if (FAILED(hr = ScriptGetCMap(hdc, psc, &pwGlyphs[i], 1, 0, &glyph))) return hr; + } + else + glyph = pwGlyphs[i]; + + if (!get_cache_glyph_widths(psc, glyph, &abc)) { - BOOL ret; if (!hdc) return E_PENDING; if (get_cache_pitch_family(psc) & TMPF_TRUETYPE) { - if (psa->fNoGlyphIndex) - ret = GetCharABCWidthsW(hdc, pwGlyphs[i], pwGlyphs[i], &abc); - else - ret = GetCharABCWidthsI(hdc, 0, 1, (WORD *)&pwGlyphs[i], &abc); - if (!ret) return S_FALSE; + if (!GetCharABCWidthsI(hdc, glyph, 1, NULL, &abc)) return S_FALSE; } else { INT width; - if (psa->fNoGlyphIndex) - ret = GetCharWidth32W(hdc, pwGlyphs[i], pwGlyphs[i], &width); - else - ret = GetCharWidthI(hdc, 0, 1, (WORD *)&pwGlyphs[i], &width); - if (!ret) return S_FALSE; + if (!GetCharWidthI(hdc, glyph, 1, NULL, &width)) return S_FALSE; abc.abcB = width; abc.abcA = abc.abcC = 0; } - set_cache_glyph_widths(psc, pwGlyphs[i], &abc, psa->fNoGlyphIndex); + set_cache_glyph_widths(psc, glyph, &abc); } if (pABC) { @@ -3456,8 +3458,6 @@ HRESULT WINAPI ScriptPlaceOpenType( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS pABC->abcB += abc.abcB; pABC->abcC += abc.abcC; } - /* FIXME: set to more reasonable values */ - pGoffset[i].du = pGoffset[i].dv = 0; if (piAdvance) piAdvance[i] = abc.abcA + abc.abcB + abc.abcC; } @@ -3709,21 +3709,21 @@ 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, FALSE)) + if (!get_cache_glyph_widths(psc, glyph, abc)) { if (!hdc) return E_PENDING; - if ((get_cache_pitch_family(psc) & TMPF_TRUETYPE)) + if (get_cache_pitch_family(psc) & TMPF_TRUETYPE) { if (!GetCharABCWidthsI(hdc, 0, 1, &glyph, abc)) return S_FALSE; } else { INT width; - if (!GetCharWidth32W(hdc, glyph, glyph, &width)) return S_FALSE; + if (!GetCharWidthI(hdc, glyph, 1, NULL, &width)) return S_FALSE; abc->abcB = width; abc->abcA = abc->abcC = 0; } - set_cache_glyph_widths(psc, glyph, abc, FALSE); + set_cache_glyph_widths(psc, glyph, abc); } return S_OK; } diff --git a/dll/win32/usp10/usp10_internal.h b/dll/win32/usp10/usp10_internal.h index aa6f78dd9e4..fea68918c9c 100644 --- a/dll/win32/usp10/usp10_internal.h +++ b/dll/win32/usp10/usp10_internal.h @@ -201,7 +201,6 @@ 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;