[2/2] gdiplus: GdipGetLogFont should use device scale and transform when appropriate.
Dmitry Timoshkov
dmitry at baikal.ru
Wed Oct 24 04:11:29 CDT 2012
---
dlls/gdiplus/font.c | 30 +++++++++++++++++++++++++-----
dlls/gdiplus/tests/font.c | 21 +++++++--------------
2 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c
index 6588f12..fb77b60 100644
--- a/dlls/gdiplus/font.c
+++ b/dlls/gdiplus/font.c
@@ -454,18 +454,22 @@ GpStatus WINGDIPAPI GdipGetLogFontA(GpFont *font, GpGraphics *graphics,
*/
GpStatus WINGDIPAPI GdipGetLogFontW(GpFont *font, GpGraphics *graphics, LOGFONTW *lf)
{
- REAL height;
+ REAL angle, rel_height, height;
+ GpMatrix *matrix;
+ GpPointF pt[3];
TRACE("(%p, %p, %p)\n", font, graphics, lf);
if (!font || !graphics || !lf)
return InvalidParameter;
+ GdipCloneMatrix(graphics->worldtrans, &matrix);
+
if (font->unit == UnitPixel)
{
height = units_to_pixels(font->emSize, graphics->unit, graphics->yres);
if (graphics->unit != UnitDisplay)
- height *= graphics->scale;
+ GdipScaleMatrix(matrix, graphics->scale, graphics->scale, MatrixOrderAppend);
}
else
{
@@ -475,10 +479,26 @@ GpStatus WINGDIPAPI GdipGetLogFontW(GpFont *font, GpGraphics *graphics, LOGFONTW
height = units_to_pixels(font->emSize, font->unit, graphics->yres);
}
- lf->lfHeight = -(height + 0.5);
+ pt[0].X = 0.0;
+ pt[0].Y = 0.0;
+ pt[1].X = 1.0;
+ pt[1].Y = 0.0;
+ pt[2].X = 0.0;
+ pt[2].Y = 1.0;
+ GdipTransformMatrixPoints(matrix, pt, 3);
+ angle = -gdiplus_atan2((pt[1].Y - pt[0].Y), (pt[1].X - pt[0].X));
+ rel_height = sqrt((pt[2].Y - pt[0].Y) * (pt[2].Y - pt[0].Y)+
+ (pt[2].X - pt[0].X) * (pt[2].X - pt[0].X));
+ GdipDeleteMatrix(matrix);
+
+ lf->lfHeight = -gdip_round(height * rel_height);
lf->lfWidth = 0;
- lf->lfEscapement = 0;
- lf->lfOrientation = 0;
+ lf->lfEscapement = lf->lfOrientation = gdip_round((angle / M_PI) * 1800.0);
+ while (lf->lfEscapement < 0)
+ {
+ lf->lfEscapement += 3600;
+ lf->lfOrientation += 3600;
+ }
lf->lfWeight = font->otm.otmTextMetrics.tmWeight;
lf->lfItalic = font->otm.otmTextMetrics.tmItalic ? 1 : 0;
lf->lfUnderline = font->otm.otmTextMetrics.tmUnderlined ? 1 : 0;
diff --git a/dlls/gdiplus/tests/font.c b/dlls/gdiplus/tests/font.c
index fade7d3..de6d657 100644
--- a/dlls/gdiplus/tests/font.c
+++ b/dlls/gdiplus/tests/font.c
@@ -26,6 +26,7 @@
#include "wine/test.h"
#define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
+#define expect_(expected, got, precision) ok(abs((expected) - (got)) <= (precision), "Expected %d, got %d\n", (expected), (got))
#define expectf_(expected, got, precision) ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
#define expectf(expected, got) expectf_((expected), (got), 0.001)
@@ -904,7 +905,6 @@ todo_wine
expect(Ok, status);
status = GdipGetLogFontA(font, graphics, &lf);
expect(Ok, status);
-todo_wine
expect(-300, lf.lfHeight);
expect(0, lf.lfWidth);
expect(0, lf.lfEscapement);
@@ -954,13 +954,10 @@ todo_wine
expect(Ok, status);
status = GdipGetLogFontA(font, graphics, &lf);
expect(Ok, status);
-todo_wine
expect(-300, lf.lfHeight);
expect(0, lf.lfWidth);
-todo_wine
- expect(3151, lf.lfEscapement);
-todo_wine
- expect(3151, lf.lfOrientation);
+ expect_(3151, lf.lfEscapement, 1);
+ expect_(3151, lf.lfOrientation, 1);
status = GdipGetFontHeight(font, graphics, &height);
expect(Ok, status);
expectf(120.703125, height);
@@ -1010,10 +1007,8 @@ todo_wine
todo_wine
expect(1032, lf.lfHeight);
expect(0, lf.lfWidth);
-todo_wine
- expect(3099, lf.lfEscapement);
-todo_wine
- expect(3099, lf.lfOrientation);
+ expect_(3099, lf.lfEscapement, 1);
+ expect_(3099, lf.lfOrientation, 1);
status = GdipGetFontHeight(font, graphics, &height);
expect(Ok, status);
expectf(120.703125, height);
@@ -1063,10 +1058,8 @@ todo_wine
todo_wine
expect(1032, lf.lfHeight);
expect(0, lf.lfWidth);
-todo_wine
- expect(3099, lf.lfEscapement);
-todo_wine
- expect(3099, lf.lfOrientation);
+ expect_(3099, lf.lfEscapement, 1);
+ expect_(3099, lf.lfOrientation, 1);
status = GdipGetFontHeight(font, graphics, &height);
expect(Ok, status);
expectf(120.703125, height);
--
1.7.12.3
More information about the wine-patches
mailing list