From: Dmitry Timoshkov dmitry@baikal.ru
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/gdi32/tests/font.c | 5 ----- dlls/win32u/font.c | 38 ++++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 23 deletions(-)
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index 7b66ee9e37c..090092029dc 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -7939,17 +7939,12 @@ static void test_rotated_metrics(void)
GetTextMetricsW(hdc, &tm); /* Windows produces noticeable diff for angles 45.0 and 135.0 */ - todo_wine_if(i != 0 && i != 4) ok(match_off_by_n(tm.tmHeight, test[i].tmHeight, 25), "got %ld\n", tm.tmHeight); - todo_wine_if(i != 0 && i != 4) ok(match_off_by_n(tm.tmAscent, test[i].tmAscent, 10), "got %ld\n", tm.tmAscent); - todo_wine_if(i != 0 && i != 2 && i != 4) ok(match_off_by_n(tm.tmDescent, test[i].tmDescent, 17), "got %ld\n", tm.tmDescent);
GetTextExtentPoint32W(hdc, str, wcslen(str), &sz); - todo_wine_if(i != 0 && i != 4) ok(match_off_by_n(sz.cx, test[i].ext.cx, 10), "got %ld\n", sz.cx); - todo_wine_if(i != 0 && i != 4) ok(match_off_by_n(sz.cy, test[i].ext.cy, 21), "got %ld\n", sz.cy);
winetest_pop_context(); diff --git a/dlls/win32u/font.c b/dlls/win32u/font.c index 6e7cef3daa2..45d89b7aa0d 100644 --- a/dlls/win32u/font.c +++ b/dlls/win32u/font.c @@ -228,32 +228,34 @@ static inline int facename_compare( const WCHAR *str1, const WCHAR *str2, SIZE_T
static inline INT width_to_LP( DC *dc, INT width ) { - return GDI_ROUND( (double)width * fabs( dc->xformVport2World.eM11 )); + float scale_x; + + scale_x = hypotf( dc->xformWorld2Vport.eM11, dc->xformWorld2Vport.eM12 ); + return GDI_ROUND( (float)width / scale_x ); }
static inline INT height_to_LP( DC *dc, INT height ) { - return GDI_ROUND( (double)height * fabs( dc->xformVport2World.eM22 )); + float scale_y; + + scale_y = hypotf( dc->xformWorld2Vport.eM21, dc->xformWorld2Vport.eM22 ); + return GDI_ROUND( (float)height / scale_y ); }
static inline INT width_to_DP(DC *dc, INT width) { - POINT pt[2]; - pt[0].x = pt[0].y = 0; - pt[1].x = width; - pt[1].y = 0; - lp_to_dp(dc, pt, 2); - return pt[1].x - pt[0].x; + float scale_x; + + scale_x = hypotf( dc->xformWorld2Vport.eM11, dc->xformWorld2Vport.eM12 ); + return GDI_ROUND( (float)width * scale_x ); }
static inline INT height_to_DP(DC *dc, INT height) { - POINT pt[2]; - pt[0].x = pt[0].y = 0; - pt[1].x = 0; - pt[1].y = height; - lp_to_dp(dc, pt, 2); - return pt[1].y - pt[0].y; + float scale_y; + + scale_y = hypotf( dc->xformWorld2Vport.eM21, dc->xformWorld2Vport.eM22 ); + return GDI_ROUND( (float)height * scale_y ); }
static INT FONT_GetObjectW( HGDIOBJ handle, INT count, LPVOID buffer ); @@ -4087,8 +4089,8 @@ static void scale_outline_font_metrics( const struct gdi_font *font, OUTLINETEXT else scale_x = font->scale_y;
- scale_x *= fabs(font->matrix.eM11); - scale_y = font->scale_y * fabs(font->matrix.eM22); + scale_x *= hypotf(font->matrix.eM11, font->matrix.eM12); + scale_y = font->scale_y * hypotf(font->matrix.eM21, font->matrix.eM22);
/* Windows scales these values as signed integers even if they are unsigned */ #define SCALE_X(x) (x) = GDI_ROUND((int)(x) * (scale_x)) @@ -4302,8 +4304,8 @@ static void scale_font_metrics( struct gdi_font *font, TEXTMETRICW *tm ) else scale_x = font->scale_y;
- scale_x *= fabs(font->matrix.eM11); - scale_y = font->scale_y * fabs(font->matrix.eM22); + scale_x *= hypotf(font->matrix.eM11, font->matrix.eM12); + scale_y = font->scale_y * hypotf(font->matrix.eM21, font->matrix.eM22);
#define SCALE_X(x) (x) = GDI_ROUND((x) * scale_x) #define SCALE_Y(y) (y) = GDI_ROUND((y) * scale_y)