Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=34789
-- v2: gdiplus: Fix GdipCreateFont character set initialization. gdiplus/tests: Test GdipCreateFont character set initialization.
From: Jeff Smith whydoubt@gmail.com
--- dlls/gdiplus/tests/font.c | 73 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+)
diff --git a/dlls/gdiplus/tests/font.c b/dlls/gdiplus/tests/font.c index 30cf159e140..7a9d50c8c2e 100644 --- a/dlls/gdiplus/tests/font.c +++ b/dlls/gdiplus/tests/font.c @@ -191,6 +191,78 @@ static void test_createfont(void) GdipDeleteFontFamily(fontfamily); }
+static void test_createfont_charset(void) +{ + GpFontFamily* fontfamily = NULL; + GpGraphics *graphics; + GpFont* font = NULL; + GpStatus stat; + LOGFONTW lf; + HDC hdc; + UINT i; + + static const struct { + LPCWSTR family_name; + BYTE char_set; + BOOL todo; + } td[] = + { + {L"Tahoma", ANSI_CHARSET}, + {L"Symbol", SYMBOL_CHARSET}, + {L"Marlett", SYMBOL_CHARSET, TRUE}, + {L"Wingdings", SYMBOL_CHARSET, TRUE}, + }; + + hdc = CreateCompatibleDC(0); + stat = GdipCreateFromHDC(hdc, &graphics); + expect (Ok, stat); + + for (i = 0; i < ARRAY_SIZE(td); i++) + { + winetest_push_context("%u", i); + + stat = GdipCreateFontFamilyFromName(td[i].family_name, NULL, &fontfamily); + expect (Ok, stat); + stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitPoint, &font); + expect (Ok, stat); + + stat = GdipGetLogFontW(font, graphics, &lf); + expect(Ok, stat); + + if (lstrcmpiW(lf.lfFaceName, td[i].family_name) != 0) + { + skip("%s not installed\n", wine_dbgstr_w(td[i].family_name)); + } + else + { + ok(lf.lfHeight < 0, "Expected negative height, got %ld\n", lf.lfHeight); + expect(0, lf.lfWidth); + expect(0, lf.lfEscapement); + expect(0, lf.lfOrientation); + ok((lf.lfWeight >= 100) && (lf.lfWeight <= 900), "Expected weight to be set\n"); + expect(0, lf.lfItalic); + expect(0, lf.lfUnderline); + expect(0, lf.lfStrikeOut); + todo_wine_if(td[i].todo) + ok(td[i].char_set == lf.lfCharSet || + (td[i].char_set == ANSI_CHARSET && lf.lfCharSet == GetTextCharset(hdc)), + "got %#x\n", lf.lfCharSet); + expect(0, lf.lfOutPrecision); + expect(0, lf.lfClipPrecision); + expect(0, lf.lfQuality); + expect(0, lf.lfPitchAndFamily); + } + + GdipDeleteFont(font); + GdipDeleteFontFamily(fontfamily); + + winetest_pop_context(); + } + + GdipDeleteGraphics(graphics); + DeleteDC(hdc); +} + static void test_logfont(void) { LOGFONTA lfa, lfa2; @@ -1479,6 +1551,7 @@ START_TEST(font) test_font_substitution(); test_font_metrics(); test_createfont(); + test_createfont_charset(); test_logfont(); test_fontfamily(); test_fontfamily_properties();
From: Jeff Smith whydoubt@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=34789 --- dlls/gdiplus/font.c | 1 + dlls/gdiplus/tests/font.c | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c index 7bd60750e6d..081fddf7c5d 100644 --- a/dlls/gdiplus/font.c +++ b/dlls/gdiplus/font.c @@ -173,6 +173,7 @@ GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily, lfw.lfItalic = style & FontStyleItalic; lfw.lfUnderline = style & FontStyleUnderline; lfw.lfStrikeOut = style & FontStyleStrikeout; + lfw.lfCharSet = DEFAULT_CHARSET;
hfont = CreateFontIndirectW(&lfw); hdc = CreateCompatibleDC(0); diff --git a/dlls/gdiplus/tests/font.c b/dlls/gdiplus/tests/font.c index 7a9d50c8c2e..8f0bbce0eb4 100644 --- a/dlls/gdiplus/tests/font.c +++ b/dlls/gdiplus/tests/font.c @@ -204,13 +204,12 @@ static void test_createfont_charset(void) static const struct { LPCWSTR family_name; BYTE char_set; - BOOL todo; } td[] = { {L"Tahoma", ANSI_CHARSET}, {L"Symbol", SYMBOL_CHARSET}, - {L"Marlett", SYMBOL_CHARSET, TRUE}, - {L"Wingdings", SYMBOL_CHARSET, TRUE}, + {L"Marlett", SYMBOL_CHARSET}, + {L"Wingdings", SYMBOL_CHARSET}, };
hdc = CreateCompatibleDC(0); @@ -243,7 +242,6 @@ static void test_createfont_charset(void) expect(0, lf.lfItalic); expect(0, lf.lfUnderline); expect(0, lf.lfStrikeOut); - todo_wine_if(td[i].todo) ok(td[i].char_set == lf.lfCharSet || (td[i].char_set == ANSI_CHARSET && lf.lfCharSet == GetTextCharset(hdc)), "got %#x\n", lf.lfCharSet);
On Sat Sep 16 22:53:37 2023 +0000, Jeffrey Smith wrote:
changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/3866/diffs?diff_id=69848&start_sha=6b6438811141721112a4cf2baa89947b3e9feda2#ee26de2954869299a14936de0bd31dca4d5ffb66_261_261)
Fixed. I had switched from GetDC to CreateCompatibleDC and missed the matching call. On a somewhat-related note, I noticed that `test_logfont` is the only function in `font.c` that uses GetDC (but CreateCompatibleDC is used several times). It could probably use CreateCompatibleDC just as well.
This merge request was approved by Esme Povirk.