gdiplus/tests: Add metafile unknown font deserialize test.
Signed-off-by: Shawn M. Chapla <schapla@codeweavers.com> Signed-off-by: Esme Povirk <esme@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
536aec5116
commit
fcc21dbf48
|
@ -18,4 +18,5 @@ C_SRCS = \
|
|||
RC_SRCS = resource.rc
|
||||
|
||||
FONT_SRCS = \
|
||||
wine_longname.sfd
|
||||
wine_longname.sfd \
|
||||
wine_testfont0.sfd
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -20,3 +20,6 @@
|
|||
|
||||
/* @makedep: wine_longname.ttf */
|
||||
1 RCDATA wine_longname.ttf
|
||||
|
||||
/* @makedep: wine_testfont0.ttf */
|
||||
2 RCDATA wine_testfont0.ttf
|
||||
|
|
|
@ -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
|
Binary file not shown.
Loading…
Reference in New Issue