[PATCH v2 3/7] gdi32: Properly handle exact fits in GetTextExtentExPoint.

Huw Davies huw at codeweavers.com
Thu Nov 12 03:25:18 CST 2020


On Mon, Nov 09, 2020 at 03:07:15PM +0100, Sven Baars wrote:
> Signed-off-by: Sven Baars <sbaars at codeweavers.com>
> ---
>  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.



More information about the wine-devel mailing list