[1/5] gdiplus: Retrive LOGFONT from a GpFont using GdipGetLogFontW instead of accessing it directly.
Dmitry Timoshkov
dmitry at baikal.ru
Thu May 10 00:32:55 CDT 2012
---
dlls/gdiplus/graphics.c | 14 ++++++++------
dlls/gdiplus/graphicspath.c | 5 ++++-
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index a5e3eb2..b674035 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -2136,15 +2136,13 @@ void get_font_hfont(GpGraphics *graphics, GDIPCONST GpFont *font, HFONT *hfont)
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));
- lfw = font->lfw;
- lfw.lfHeight = roundr(-font->pixel_size * rel_height);
+ GdipGetLogFontW((GpFont *)font, graphics, &lfw);
+ lfw.lfHeight = roundr(lfw.lfHeight * rel_height);
unscaled_font = CreateFontIndirectW(&lfw);
SelectObject(hdc, unscaled_font);
GetTextMetricsW(hdc, &textmet);
- lfw = font->lfw;
- lfw.lfHeight = roundr(-font->pixel_size * rel_height);
lfw.lfWidth = roundr(textmet.tmAveCharWidth * rel_width / rel_height);
lfw.lfEscapement = lfw.lfOrientation = roundr((angle / M_PI) * 1800.0);
@@ -4919,6 +4917,7 @@ GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics* graphics,
{
GpStatus stat;
int i;
+ LOGFONTW lfw;
HFONT oldfont;
struct measure_ranges_args args;
HDC hdc, temp_hdc=NULL;
@@ -4926,12 +4925,15 @@ GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics* graphics,
TRACE("(%p %s %d %p %s %p %d %p)\n", graphics, debugstr_w(string),
length, font, debugstr_rectf(layoutRect), stringFormat, regionCount, regions);
- if (!(graphics && string && font && layoutRect && stringFormat && regions))
+ if (!graphics || !string || !font || !layoutRect || !stringFormat || !regions)
return InvalidParameter;
if (regionCount < stringFormat->range_count)
return InvalidParameter;
+ stat = GdipGetLogFontW((GpFont *)font, graphics, &lfw);
+ if (stat != Ok) return stat;
+
if(!graphics->hdc)
{
hdc = temp_hdc = CreateCompatibleDC(0);
@@ -4943,7 +4945,7 @@ GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics* graphics,
if (stringFormat->attr)
TRACE("may be ignoring some format flags: attr %x\n", stringFormat->attr);
- oldfont = SelectObject(hdc, CreateFontIndirectW(&font->lfw));
+ oldfont = SelectObject(hdc, CreateFontIndirectW(&lfw));
for (i=0; i<stringFormat->range_count; i++)
{
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c
index d37512e..5da53b2 100644
--- a/dlls/gdiplus/graphicspath.c
+++ b/dlls/gdiplus/graphicspath.c
@@ -942,6 +942,7 @@ GpStatus WINGDIPAPI GdipAddPathString(GpPath* path, GDIPCONST WCHAR* string, INT
{
GpFont *font;
GpStatus status;
+ LOGFONTW lfw;
HANDLE hfont;
HDC dc;
GpPath *backup;
@@ -956,7 +957,9 @@ GpStatus WINGDIPAPI GdipAddPathString(GpPath* path, GDIPCONST WCHAR* string, INT
if (status != Ok)
return status;
- hfont = CreateFontIndirectW(&font->lfw);
+ status = GdipGetLogFontW((GpFont *)font, NULL, &lfw);
+ if (status != Ok) return status;
+ hfont = CreateFontIndirectW(&lfw);
if (!hfont)
{
WARN("Failed to create font\n");
--
1.7.10.1
More information about the wine-patches
mailing list