From: Aric Stewart Subject: Re: [PATCH 3/5] usp10: Properly get glyph widths for OpenType fonts in ScriptPlaceOpenType(). Message-Id: <95060e51-7d20-7fdb-7e3d-4e7eb52502b8@codeweavers.com> Date: Tue, 21 Feb 2017 07:04:10 -0600 In-Reply-To: <1487524599-13189-3-git-send-email-hverbeet@codeweavers.com> References: <1487524599-13189-3-git-send-email-hverbeet@codeweavers.com> Signed-off-by: Aric Stewart On 2/19/17 11:16 AM, Henri Verbeet wrote: > I.e., don't use GetCharWidth32W() with glyph indices. This fixes glyph > advances for OpenType fonts in wordpad. > > Signed-off-by: Henri Verbeet > --- > dlls/usp10/usp10.c | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) > > diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c > index 3595ca2..f8a6aa5 100644 > --- a/dlls/usp10/usp10.c > +++ b/dlls/usp10/usp10.c > @@ -3347,15 +3347,24 @@ HRESULT WINAPI ScriptPlaceOpenType( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS > } > else if (!get_cache_glyph_widths(psc, pwGlyphs[i], &abc)) > { > + BOOL ret; > if (!hdc) return E_PENDING; > - if ((get_cache_pitch_family(psc) & TMPF_TRUETYPE) && !psa->fNoGlyphIndex) > + if (get_cache_pitch_family(psc) & TMPF_TRUETYPE) > { > - if (!GetCharABCWidthsI(hdc, 0, 1, (WORD *)&pwGlyphs[i], &abc)) return S_FALSE; > + 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; > } > else > { > INT width; > - if (!GetCharWidth32W(hdc, pwGlyphs[i], pwGlyphs[i], &width)) return S_FALSE; > + 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; > abc.abcB = width; > abc.abcA = abc.abcC = 0; > } >