gdiplus: GdipGetLogFont should use device scale and transform when appropriate.
This commit is contained in:
parent
71eb164482
commit
84ea75f1c6
@ -454,18 +454,22 @@ GpStatus WINGDIPAPI GdipGetLogFontA(GpFont *font, GpGraphics *graphics,
|
|||||||
*/
|
*/
|
||||||
GpStatus WINGDIPAPI GdipGetLogFontW(GpFont *font, GpGraphics *graphics, LOGFONTW *lf)
|
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);
|
TRACE("(%p, %p, %p)\n", font, graphics, lf);
|
||||||
|
|
||||||
if (!font || !graphics || !lf)
|
if (!font || !graphics || !lf)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
|
GdipCloneMatrix(graphics->worldtrans, &matrix);
|
||||||
|
|
||||||
if (font->unit == UnitPixel)
|
if (font->unit == UnitPixel)
|
||||||
{
|
{
|
||||||
height = units_to_pixels(font->emSize, graphics->unit, graphics->yres);
|
height = units_to_pixels(font->emSize, graphics->unit, graphics->yres);
|
||||||
if (graphics->unit != UnitDisplay)
|
if (graphics->unit != UnitDisplay)
|
||||||
height *= graphics->scale;
|
GdipScaleMatrix(matrix, graphics->scale, graphics->scale, MatrixOrderAppend);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -475,10 +479,26 @@ GpStatus WINGDIPAPI GdipGetLogFontW(GpFont *font, GpGraphics *graphics, LOGFONTW
|
|||||||
height = units_to_pixels(font->emSize, font->unit, graphics->yres);
|
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->lfWidth = 0;
|
||||||
lf->lfEscapement = 0;
|
lf->lfEscapement = lf->lfOrientation = gdip_round((angle / M_PI) * 1800.0);
|
||||||
lf->lfOrientation = 0;
|
if (lf->lfEscapement < 0)
|
||||||
|
{
|
||||||
|
lf->lfEscapement += 3600;
|
||||||
|
lf->lfOrientation += 3600;
|
||||||
|
}
|
||||||
lf->lfWeight = font->otm.otmTextMetrics.tmWeight;
|
lf->lfWeight = font->otm.otmTextMetrics.tmWeight;
|
||||||
lf->lfItalic = font->otm.otmTextMetrics.tmItalic ? 1 : 0;
|
lf->lfItalic = font->otm.otmTextMetrics.tmItalic ? 1 : 0;
|
||||||
lf->lfUnderline = font->otm.otmTextMetrics.tmUnderlined ? 1 : 0;
|
lf->lfUnderline = font->otm.otmTextMetrics.tmUnderlined ? 1 : 0;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "wine/test.h"
|
#include "wine/test.h"
|
||||||
|
|
||||||
#define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
|
#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, precision) ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
|
||||||
#define expectf(expected, got) expectf_((expected), (got), 0.001)
|
#define expectf(expected, got) expectf_((expected), (got), 0.001)
|
||||||
|
|
||||||
@ -904,7 +905,6 @@ todo_wine
|
|||||||
expect(Ok, status);
|
expect(Ok, status);
|
||||||
status = GdipGetLogFontA(font, graphics, &lf);
|
status = GdipGetLogFontA(font, graphics, &lf);
|
||||||
expect(Ok, status);
|
expect(Ok, status);
|
||||||
todo_wine
|
|
||||||
expect(-300, lf.lfHeight);
|
expect(-300, lf.lfHeight);
|
||||||
expect(0, lf.lfWidth);
|
expect(0, lf.lfWidth);
|
||||||
expect(0, lf.lfEscapement);
|
expect(0, lf.lfEscapement);
|
||||||
@ -954,13 +954,10 @@ todo_wine
|
|||||||
expect(Ok, status);
|
expect(Ok, status);
|
||||||
status = GdipGetLogFontA(font, graphics, &lf);
|
status = GdipGetLogFontA(font, graphics, &lf);
|
||||||
expect(Ok, status);
|
expect(Ok, status);
|
||||||
todo_wine
|
|
||||||
expect(-300, lf.lfHeight);
|
expect(-300, lf.lfHeight);
|
||||||
expect(0, lf.lfWidth);
|
expect(0, lf.lfWidth);
|
||||||
todo_wine
|
expect_(3151, lf.lfEscapement, 1);
|
||||||
expect(3151, lf.lfEscapement);
|
expect_(3151, lf.lfOrientation, 1);
|
||||||
todo_wine
|
|
||||||
expect(3151, lf.lfOrientation);
|
|
||||||
status = GdipGetFontHeight(font, graphics, &height);
|
status = GdipGetFontHeight(font, graphics, &height);
|
||||||
expect(Ok, status);
|
expect(Ok, status);
|
||||||
expectf(120.703125, height);
|
expectf(120.703125, height);
|
||||||
@ -1010,10 +1007,8 @@ todo_wine
|
|||||||
todo_wine
|
todo_wine
|
||||||
expect(1032, lf.lfHeight);
|
expect(1032, lf.lfHeight);
|
||||||
expect(0, lf.lfWidth);
|
expect(0, lf.lfWidth);
|
||||||
todo_wine
|
expect_(3099, lf.lfEscapement, 1);
|
||||||
expect(3099, lf.lfEscapement);
|
expect_(3099, lf.lfOrientation, 1);
|
||||||
todo_wine
|
|
||||||
expect(3099, lf.lfOrientation);
|
|
||||||
status = GdipGetFontHeight(font, graphics, &height);
|
status = GdipGetFontHeight(font, graphics, &height);
|
||||||
expect(Ok, status);
|
expect(Ok, status);
|
||||||
expectf(120.703125, height);
|
expectf(120.703125, height);
|
||||||
@ -1063,10 +1058,8 @@ todo_wine
|
|||||||
todo_wine
|
todo_wine
|
||||||
expect(1032, lf.lfHeight);
|
expect(1032, lf.lfHeight);
|
||||||
expect(0, lf.lfWidth);
|
expect(0, lf.lfWidth);
|
||||||
todo_wine
|
expect_(3099, lf.lfEscapement, 1);
|
||||||
expect(3099, lf.lfEscapement);
|
expect_(3099, lf.lfOrientation, 1);
|
||||||
todo_wine
|
|
||||||
expect(3099, lf.lfOrientation);
|
|
||||||
status = GdipGetFontHeight(font, graphics, &height);
|
status = GdipGetFontHeight(font, graphics, &height);
|
||||||
expect(Ok, status);
|
expect(Ok, status);
|
||||||
expectf(120.703125, height);
|
expectf(120.703125, height);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user