Signed-off-by: Shawn M. Chapla schapla@codeweavers.com --- dlls/gdiplus/tests/Makefile.in | 3 +- dlls/gdiplus/tests/metafile.c | 118 ++++++++++++++++++++++++++ dlls/gdiplus/tests/resource.rc | 3 + dlls/gdiplus/tests/wine_testfont0.sfd | 69 +++++++++++++++ dlls/gdiplus/tests/wine_testfont0.ttf | Bin 0 -> 1688 bytes 5 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 dlls/gdiplus/tests/wine_testfont0.sfd create mode 100644 dlls/gdiplus/tests/wine_testfont0.ttf
diff --git a/dlls/gdiplus/tests/Makefile.in b/dlls/gdiplus/tests/Makefile.in index a245a48b6d..ef3f26d908 100644 --- a/dlls/gdiplus/tests/Makefile.in +++ b/dlls/gdiplus/tests/Makefile.in @@ -18,4 +18,5 @@ C_SRCS = \ RC_SRCS = resource.rc
FONT_SRCS = \ - wine_longname.sfd + wine_longname.sfd \ + wine_testfont0.sfd diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c index 371a3c21b4..9fa60098e6 100644 --- a/dlls/gdiplus/tests/metafile.c +++ b/dlls/gdiplus/tests/metafile.c @@ -3057,6 +3057,123 @@ static void test_drawdriverstring(void) GdipDisposeImage((GpImage*)metafile); }
+static const emfplus_record unknownfontdecode_records[] = { + { EMR_HEADER }, + { EmfPlusRecordTypeHeader }, + { EmfPlusRecordTypeObject, ObjectTypeFont << 8, 0, 1 }, + { EmfPlusRecordTypeDrawDriverString, 0x8000, 0, 1 }, + { EmfPlusRecordTypeEndOfFile }, + { EMR_EOF }, + { 0 } +}; + +static void test_unknownfontdecode(void) +{ + static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}}; + static const GpRectF frame = {0.0, 0.0, 100.0, 100.0}; + static const PointF pos = {10.0,30.0}; + static const INT testfont0_resnum = 2; + + BOOL rval; + DWORD written, ressize; + GpBitmap *bitmap; + GpBrush *brush; + GpFont *font; + GpFontCollection *fonts; + GpFontFamily *family; + GpGraphics *graphics; + GpMetafile *metafile; + GpStatus stat; + HANDLE file; + HDC hdc; + HRSRC res; + INT fontscount; + WCHAR path[MAX_PATH]; + void *buf; + + /* Create a custom font from a resource. */ + GetTempPathW(MAX_PATH, path); + lstrcatW(path, L"wine_testfont0.ttf"); + + file = CreateFileW(path, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0); + ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %d\n", + wine_dbgstr_w(path), GetLastError()); + + res = FindResourceA(GetModuleHandleA(NULL), MAKEINTRESOURCEA(testfont0_resnum), + (LPCSTR)RT_RCDATA); + ok(res != 0, "couldn't find resource\n"); + + buf = LockResource(LoadResource(GetModuleHandleA(NULL), res)); + ressize = SizeofResource(GetModuleHandleA(NULL), res); + + WriteFile(file, buf, ressize, &written, NULL); + expect(ressize, written); + + CloseHandle(file); + + stat = GdipNewPrivateFontCollection(&fonts); + expect(Ok, stat); + + stat = GdipPrivateAddFontFile(fonts, path); + expect(Ok, stat); + + stat = GdipGetFontCollectionFamilyCount(fonts, &fontscount); + expect(Ok, stat); + expect(1, fontscount); + + stat = GdipGetFontCollectionFamilyList(fonts, fontscount, &family, &fontscount); + expect(Ok, stat); + + stat = GdipCreateFont(family, 16.0, FontStyleRegular, UnitPixel, &font); + expect(Ok, stat); + + /* Start metafile recording. */ + hdc = CreateCompatibleDC(0); + stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitPixel, + L"winetest", &metafile); + expect(Ok, stat); + DeleteDC(hdc); + hdc = NULL; + + stat = GdipGetImageGraphicsContext((GpImage*)metafile, &graphics); + expect(Ok, stat); + + stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush); + expect(Ok, stat); + + /* Write something with the custom font so that it is encoded. */ + stat = GdipDrawDriverString(graphics, L"Test", 4, font, brush, &pos, + DriverStringOptionsCmapLookup|DriverStringOptionsRealizedAdvance, NULL); + expect(Ok, stat); + + /* Delete the custom font so that it is not present during playback. */ + GdipDeleteFont(font); + GdipDeletePrivateFontCollection(&fonts); + rval = DeleteFileW(path); + expect(TRUE, rval); + + GdipDeleteGraphics(graphics); + graphics = NULL; + + check_metafile(metafile, unknownfontdecode_records, "unknownfontdecode metafile", dst_points, + &frame, UnitPixel); + sync_metafile(&metafile, "unknownfontdecode.emf"); + + stat = GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB, NULL, &bitmap); + expect(Ok, stat); + + stat = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); + expect(Ok, stat); + + play_metafile(metafile, graphics, unknownfontdecode_records, "unknownfontdecode playback", + dst_points, &frame, UnitPixel); + + GdipDeleteGraphics(graphics); + GdipDeleteBrush(brush); + GdipDisposeImage((GpImage*)bitmap); + GdipDisposeImage((GpImage*)metafile); +} + START_TEST(metafile) { struct GdiplusStartupInput gdiplusStartupInput; @@ -3107,6 +3224,7 @@ START_TEST(metafile) test_fillpath(); test_restoredc(); test_drawdriverstring(); + test_unknownfontdecode();
GdiplusShutdown(gdiplusToken); } diff --git a/dlls/gdiplus/tests/resource.rc b/dlls/gdiplus/tests/resource.rc index d7d915ce00..2db8d6359e 100644 --- a/dlls/gdiplus/tests/resource.rc +++ b/dlls/gdiplus/tests/resource.rc @@ -20,3 +20,6 @@
/* @makedep: wine_longname.ttf */ 1 RCDATA wine_longname.ttf + +/* @makedep: wine_testfont0.ttf */ +2 RCDATA wine_testfont0.ttf diff --git a/dlls/gdiplus/tests/wine_testfont0.sfd b/dlls/gdiplus/tests/wine_testfont0.sfd new file mode 100644 index 0000000000..ba99b9f99b --- /dev/null +++ b/dlls/gdiplus/tests/wine_testfont0.sfd @@ -0,0 +1,69 @@ +SplineFontDB: 3.2 +FontName: winegdiptestfont0 +FullName: Wine GDI+ Test Font 0 +FamilyName: winegdiptestfont +Weight: Regular +Copyright: Copyright (c) 2020, Shawn M. Chapla +UComments: "2020-7-15: Created with FontForge (http://fontforge.org)" +Version: 001.000 +ItalicAngle: 0 +UnderlinePosition: -100 +UnderlineWidth: 50 +Ascent: 800 +Descent: 200 +InvalidEm: 0 +LayerCount: 2 +Layer: 0 0 "Back" 1 +Layer: 1 0 "Fore" 0 +XUID: [1021 445 409452897 2998051] +StyleMap: 0x0000 +FSType: 0 +OS2Version: 0 +OS2_WeightWidthSlopeOnly: 0 +OS2_UseTypoMetrics: 1 +CreationTime: 1594833132 +ModificationTime: 1594833348 +OS2TypoAscent: 0 +OS2TypoAOffset: 1 +OS2TypoDescent: 0 +OS2TypoDOffset: 1 +OS2TypoLinegap: 90 +OS2WinAscent: 0 +OS2WinAOffset: 1 +OS2WinDescent: 0 +OS2WinDOffset: 1 +HheadAscent: 0 +HheadAOffset: 1 +HheadDescent: 0 +HheadDOffset: 1 +MarkAttachClasses: 1 +DEI: 91125 +Encoding: ISO8859-1 +UnicodeInterp: none +NameList: AGL For New Fonts +DisplaySize: -48 +AntiAlias: 1 +FitToEm: 0 +WinInfo: 0 16 4 +BeginPrivate: 0 +EndPrivate +BeginChars: 256 1 + +StartChar: uni0000 +Encoding: 0 0 0 +Width: 2977 +VWidth: 0 +Flags: HWO +LayerCount: 2 +Fore +SplineSet +247 690 m 5 + 748 690 l 5 + 748 72 l 5 + 247 72 l 5 + 247 690 l 5 +EndSplineSet +Validated: 1 +EndChar +EndChars +EndSplineFont diff --git a/dlls/gdiplus/tests/wine_testfont0.ttf b/dlls/gdiplus/tests/wine_testfont0.ttf new file mode 100644 index 0000000000000000000000000000000000000000..227c2251432e6abd1442a5569904032a078103bc GIT binary patch literal 1688 zcmds2PiPZa82`PQN!k*v1{FQ@@J5BLt&NlTr?uuFwoU7ytkABC7dx9yGJ$k5B+<5_ z;K_riD5wW7MZ}XJHn6Y@%kD|)S@y8#9)!Jgr5?2?YWMeM#wc14ufFzs@Av)x-Z$^P zKmcgRdFYtP<;F*^O+5C2_*qIjh6jgo*o2MbClvqV*sjb^XWWN?aLG^Pr)(c<^?T(1 zA|1+~u1lEO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)
diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index cedffb23ca..d6bcbb5c12 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -2440,8 +2440,13 @@ static GpStatus METAFILE_PlaybackObject(GpMetafile *metafile, UINT flags, UINT d
status = GdipCreateFontFamilyFromName(familyname, NULL, &family); GdipFree(familyname); + + /* If a font family cannot be created from family name, native + falls back to a sans serif font. */ if (status != Ok) - return InvalidParameter; + status = GdipGetGenericFontFamilySansSerif(&family); + if (status != Ok) + return status;
status = GdipCreateFont(family, data->EmSize, data->FontStyleFlags, data->SizeUnit, (GpFont **)&object); GdipDeleteFontFamily(family); diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c index 9fa60098e6..8179e1a5fd 100644 --- a/dlls/gdiplus/tests/metafile.c +++ b/dlls/gdiplus/tests/metafile.c @@ -3060,8 +3060,8 @@ static void test_drawdriverstring(void) static const emfplus_record unknownfontdecode_records[] = { { EMR_HEADER }, { EmfPlusRecordTypeHeader }, - { EmfPlusRecordTypeObject, ObjectTypeFont << 8, 0, 1 }, - { EmfPlusRecordTypeDrawDriverString, 0x8000, 0, 1 }, + { EmfPlusRecordTypeObject, ObjectTypeFont << 8 }, + { EmfPlusRecordTypeDrawDriverString, 0x8000 }, { EmfPlusRecordTypeEndOfFile }, { EMR_EOF }, { 0 }
Signed-off-by: Esme Povirk esme@codeweavers.com