From: Sam Edwards Subject: [PATCH 2/2] gdi32/tests: Add test to make sure GetGlyphOutline clips glyphs to the font metrics. Message-Id: <5172A171.30801@gmail.com> Date: Sat, 20 Apr 2013 08:08:49 -0600 From 0eb4013a9ad8802b4fbb67578353b49da00e5119 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 20 Apr 2013 07:56:53 -0600 Subject: gdi32/tests: Add test to make sure GetGlyphOutline clips glyphs to the font metrics. --- dlls/gdi32/tests/font.c | 41 ++++++++++++++++++++++++++ dlls/gdi32/tests/wine_test.sfd | 62 +++++++++++++++++++++++++++++++++------- dlls/gdi32/tests/wine_test.ttf | Bin 1652 -> 1760 bytes 3 files changed, 92 insertions(+), 11 deletions(-) diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index e5e7ff9..bc4e614 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -4561,6 +4561,46 @@ static void test_GetGlyphOutline_empty_contour(void) ReleaseDC(NULL, hdc); } +static void test_GetGlyphOutline_metric_clipping(void) +{ + HDC hdc; + LOGFONTA lf; + HFONT hfont, hfont_prev; + GLYPHMETRICS gm; + TEXTMETRICA tm; + DWORD ret; + + memset(&lf, 0, sizeof(lf)); + lf.lfHeight = 72; + lstrcpyA(lf.lfFaceName, "wine_test"); + + SetLastError(0xdeadbeef); + hfont = CreateFontIndirectA(&lf); + ok(hfont != 0, "CreateFontIndirectA error %u\n", GetLastError()); + + hdc = GetDC(NULL); + + hfont_prev = SelectObject(hdc, hfont); + ok(hfont_prev != NULL, "SelectObject failed\n"); + + SetLastError(0xdeadbeef); + ret = GetTextMetrics(hdc, &tm); + ok(ret, "GetTextMetrics error %u\n", GetLastError()); + + GetGlyphOutlineA(hdc, 'A', GGO_METRICS, &gm, 0, NULL, &mat); + ok(gm.gmptGlyphOrigin.y <= tm.tmAscent, + "Glyph top(%d) exceeds ascent(%d)\n", + gm.gmptGlyphOrigin.y, tm.tmAscent); + GetGlyphOutlineA(hdc, 'D', GGO_METRICS, &gm, 0, NULL, &mat); + ok(gm.gmptGlyphOrigin.y - gm.gmBlackBoxY >= -tm.tmDescent, + "Glyph bottom(%d) exceeds descent(%d)\n", + gm.gmptGlyphOrigin.y - gm.gmBlackBoxY, -tm.tmDescent); + + SelectObject(hdc, hfont_prev); + DeleteObject(hfont); + ReleaseDC(NULL, hdc); +} + static void test_CreateScalableFontResource(void) { char ttf_name[MAX_PATH]; @@ -4643,6 +4683,7 @@ static void test_CreateScalableFontResource(void) ok(ret, "font wine_test should be enumerated\n"); test_GetGlyphOutline_empty_contour(); + test_GetGlyphOutline_metric_clipping(); ret = pRemoveFontResourceExA(fot_name, FR_PRIVATE, 0); ok(!ret, "RemoveFontResourceEx() with not matching flags should fail\n"); diff --git a/dlls/gdi32/tests/wine_test.sfd b/dlls/gdi32/tests/wine_test.sfd index 5adf7cf..620a34f 100644 --- a/dlls/gdi32/tests/wine_test.sfd +++ b/dlls/gdi32/tests/wine_test.sfd @@ -20,7 +20,7 @@ OS2Version: 2 OS2_WeightWidthSlopeOnly: 0 OS2_UseTypoMetrics: 1 CreationTime: 1288336343 -ModificationTime: 1352483620 +ModificationTime: 1366465321 PfmFamily: 17 TTFWeight: 500 TTFWidth: 5 @@ -32,10 +32,10 @@ OS2TypoAOffset: 1 OS2TypoDescent: 0 OS2TypoDOffset: 1 OS2TypoLinegap: 184 -OS2WinAscent: 0 -OS2WinAOffset: 1 -OS2WinDescent: 0 -OS2WinDOffset: 1 +OS2WinAscent: 1638 +OS2WinAOffset: 0 +OS2WinDescent: 410 +OS2WinDOffset: 0 HheadAscent: 0 HheadAOffset: 1 HheadDescent: 0 @@ -77,16 +77,18 @@ ShortTable: maxp 16 0 0 EndShort -LangName: 1033 "" "" "" "Wine : wine_test : 4-11-2010" -GaspTable: 1 65535 2 +LangName: 1033 "" "" "" "Wine : wine_test : 4-11-2010" +GaspTable: 1 65535 2 0 Encoding: UnicodeBmp UnicodeInterp: none NameList: Adobe Glyph List DisplaySize: -24 AntiAlias: 1 FitToEm: 1 -WinInfo: 65 65 19 -BeginChars: 65539 5 +WinInfo: 48 16 4 +BeginPrivate: 0 +EndPrivate +BeginChars: 65539 7 StartChar: .notdef Encoding: 65536 -1 0 @@ -178,10 +180,10 @@ LayerCount: 2 EndChar StartChar: dieresis -Encoding: 168 168 0 +Encoding: 168 168 4 Width: 1000 VWidth: 0 -Flags: HW +Flags: W LayerCount: 2 Fore SplineSet @@ -201,5 +203,43 @@ SplineSet 310.707 834.805 310.707 834.805 254.492 773.213 c 1,12,13 EndSplineSet EndChar + +StartChar: A +Encoding: 65 65 5 +Width: 1000 +VWidth: 0 +Flags: WO +LayerCount: 2 +Fore +SplineSet +459 1258 m 29,0,-1 + 462 1639 l 5,1,-1 + 389 1638 l 5,2,-1 + 492 1815 l 5,3,-1 + 609 1638.5 l 5,4,-1 + 531 1637.5 l 5,5,-1 + 523 1258 l 5,6,-1 + 459 1258 l 29,0,-1 +EndSplineSet +EndChar + +StartChar: D +Encoding: 68 68 6 +Width: 1000 +VWidth: 0 +Flags: WO +LayerCount: 2 +Fore +SplineSet +461 -30.7998 m 29,0,-1 + 464 -411.8 l 5,1,-1 + 391 -410.8 l 5,2,-1 + 494 -587.8 l 5,3,-1 + 611 -411.3 l 5,4,-1 + 533 -410.3 l 5,5,-1 + 525 -30.7998 l 5,6,-1 + 461 -30.7998 l 29,0,-1 +EndSplineSet +EndChar EndChars EndSplineFont diff --git a/dlls/gdi32/tests/wine_test.ttf b/dlls/gdi32/tests/wine_test.ttf index 1e546eb5f76cd3065f6b69f7976fb40a33b82b5a..2aecd2e4f58d4a88e1fe18bed1164cf5411a78bf 100644 GIT binary patch delta 657 zcmYL{J!n%=7>3{P+GFnN1ot9$)E?Zfm(aonEGH>bAJH2$FU7OClYF0W{0QN)U+ z>dZb%<;W}K&}2Dh#H%q={48+z`)i8}>Kx?3{FI!35b=es{ z#s1}$jiue2>;?T!axT7TWfo?RPsRu@jE*=J|D*QCW+8GYo=Bzhw?r%Xl3cp77PAmV zjt!d0frOQ|F^DkzescAyl~_Ez+pnYl1jrJ5Etzry_ymkE`pw?39PhQUJu_F-^?|BU zKXqWUHn;tsO_p98lVm@nQn^^$1HeL4YK?#{ABmRorQ2(hoIP)j(LtoR1~rCzK6 -- 1.7.10.4