Shawn M. Chapla : gdiplus/tests: Add metafile unknown font deserialize test.
Alexandre Julliard
julliard at winehq.org
Mon Jul 20 15:30:08 CDT 2020
Module: wine
Branch: master
Commit: fcc21dbf4838f1c2f393a3bc21e56b4210c25bb6
URL: https://source.winehq.org/git/wine.git/?a=commit;h=fcc21dbf4838f1c2f393a3bc21e56b4210c25bb6
Author: Shawn M. Chapla <schapla at codeweavers.com>
Date: Fri Jul 17 20:50:50 2020 -0400
gdiplus/tests: Add metafile unknown font deserialize test.
Signed-off-by: Shawn M. Chapla <schapla at codeweavers.com>
Signed-off-by: Esme Povirk <esme at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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(-)
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 0000000000..227c225143
Binary files /dev/null and b/dlls/gdiplus/tests/wine_testfont0.ttf differ
More information about the wine-cvs
mailing list