From: Huw Davies Subject: Re: [PATCH v2 3/7] gdi32: Properly handle exact fits in GetTextExtentExPoint. Message-Id: <20201112092517.GA15687@merlot.physics.ox.ac.uk> Date: Thu, 12 Nov 2020 09:25:18 +0000 In-Reply-To: <20201109140720.472712-3-sbaars@codeweavers.com> References: <20201109140720.472712-1-sbaars@codeweavers.com> <20201109140720.472712-3-sbaars@codeweavers.com> On Mon, Nov 09, 2020 at 03:07:15PM +0100, Sven Baars wrote: > Signed-off-by: Sven Baars > --- > dlls/gdi32/font.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c > index 6ad03df176b..4a6ca1916ac 100644 > --- a/dlls/gdi32/font.c > +++ b/dlls/gdi32/font.c > @@ -4897,6 +4897,11 @@ BOOL WINAPI GetTextExtentExPointI( HDC hdc, const WORD *indices, INT count, INT > unsigned int dx = abs( INTERNAL_XDSTOWS( dc, pos[i] )) + (i + 1) * dc->charExtra; > if (nfit && dx > (unsigned int)max_ext) break; > if (dxs) dxs[i] = dx; > + if (nfit && dx == (unsigned int)max_ext) > + { > + i++; > + break; > + } > } > if (nfit) *nfit = i; > } > @@ -5033,7 +5038,12 @@ BOOL WINAPI GetTextExtentExPointW( HDC hdc, LPCWSTR str, INT count, INT max_ext, > { > unsigned int dx = abs( INTERNAL_XDSTOWS( dc, pos[i] )) + (i + 1) * dc->charExtra; > if (nfit && dx > (unsigned int)max_ext) break; > - if (dxs) dxs[i] = dx; > + if (dxs) dxs[i] = dx; > + if (nfit && dx == (unsigned int)max_ext) > + { > + i++; > + break; > + } > } > if (nfit) *nfit = i; > } These will need tests. Also, combining the new if()s with the test two lines above would most likely make things simpler. Huw.