[PATCH 1/2] gdi32: Fix otmfsSelection to have italic style set in case of oblique simulation

Nikolay Sivov nsivov at codeweavers.com
Tue Feb 9 08:24:27 CST 2016


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/dwrite/tests/font.c |  3 +--
 dlls/gdi32/freetype.c    |  2 ++
 dlls/gdi32/tests/font.c  | 49 +++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index 2d31541..cd63ce7 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -707,8 +707,7 @@ if (0)
 
     style = IDWriteFont_GetStyle(font);
     ok(style == DWRITE_FONT_STYLE_OBLIQUE, "got %d\n", style);
-todo_wine
-    ok(otm.otmfsSelection == 1, "got 0x%08x\n", otm.otmfsSelection);
+    ok(otm.otmfsSelection & 1, "got 0x%08x\n", otm.otmfsSelection);
 
     ret = IDWriteFont_IsSymbolFont(font);
     ok(!ret, "got %d\n", ret);
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index ea81ee1..1a488df 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -7848,6 +7848,8 @@ static BOOL get_outline_text_metrics(GdiFont *font)
     font->potm->otmFiller = 0;
     memcpy(&font->potm->otmPanoseNumber, pOS2->panose, PANOSE_COUNT);
     font->potm->otmfsSelection = pOS2->fsSelection;
+    if (font->fake_italic)
+        font->potm->otmfsSelection |= 1;
     font->potm->otmfsType = pOS2->fsType;
     font->potm->otmsCharSlopeRise = pHori->caret_Slope_Rise;
     font->potm->otmsCharSlopeRun = pHori->caret_Slope_Run;
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index b5ce93e..ce8da24 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -2106,6 +2106,34 @@ static void test_height_selection(void)
     DeleteDC(hdc);
 }
 
+static UINT get_font_fsselection(LOGFONTA *lf)
+{
+    OUTLINETEXTMETRICA *otm;
+    HFONT hfont, hfont_old;
+    DWORD ret, otm_size;
+    UINT fsSelection;
+    HDC hdc;
+
+    hdc = GetDC(0);
+    hfont = CreateFontIndirectA(lf);
+    ok(hfont != NULL, "failed to create a font\n");
+
+    hfont_old = SelectObject(hdc, hfont);
+
+    otm_size = GetOutlineTextMetricsA(hdc, 0, NULL);
+    otm = HeapAlloc(GetProcessHeap(), 0, otm_size);
+    otm->otmSize = sizeof(*otm);
+    ret = GetOutlineTextMetricsA(hdc, otm->otmSize, otm);
+    ok(ret == otm->otmSize, "expected %u, got %u, error %d\n", otm->otmSize, ret, GetLastError());
+    fsSelection = otm->otmfsSelection;
+    HeapFree(GetProcessHeap(), 0, otm);
+    SelectObject(hdc, hfont_old);
+    DeleteObject(hfont);
+    ReleaseDC(0, hdc);
+
+    return fsSelection;
+}
+
 static void test_GetOutlineTextMetrics(void)
 {
     OUTLINETEXTMETRICA *otm;
@@ -2114,6 +2142,25 @@ static void test_GetOutlineTextMetrics(void)
     HDC hdc;
     DWORD ret, otm_size;
     LPSTR unset_ptr;
+    UINT fsSelection;
+
+    /* check fsSelection field with oblique simulation */
+    memset(&lf, 0, sizeof(lf));
+
+    strcpy(lf.lfFaceName, "Tahoma");
+    lf.lfHeight = -13;
+    lf.lfWeight = FW_NORMAL;
+    lf.lfPitchAndFamily = DEFAULT_PITCH;
+    lf.lfQuality = PROOF_QUALITY;
+
+    /* regular face */
+    fsSelection = get_font_fsselection(&lf);
+    ok((fsSelection & 1) == 0, "got 0x%x\n", fsSelection);
+
+    lf.lfItalic = 1;
+    /* face with oblique simulation */
+    fsSelection = get_font_fsselection(&lf);
+    ok((fsSelection & 1) == 1, "got 0x%x\n", fsSelection);
 
     if (!is_font_installed("Arial"))
     {
@@ -2130,7 +2177,7 @@ static void test_GetOutlineTextMetrics(void)
     lf.lfPitchAndFamily = DEFAULT_PITCH;
     lf.lfQuality = PROOF_QUALITY;
     hfont = CreateFontIndirectA(&lf);
-    assert(hfont != 0);
+    ok(hfont != NULL, "failed to create a font\n");
 
     hfont_old = SelectObject(hdc, hfont);
     otm_size = GetOutlineTextMetricsA(hdc, 0, NULL);
-- 
2.7.0




More information about the wine-patches mailing list