2012-07-31 06:18:02 +02:00
|
|
|
/*
|
|
|
|
* Font related tests
|
|
|
|
*
|
2018-11-22 12:29:14 +01:00
|
|
|
* Copyright 2012, 2014-2018 Nikolay Sivov for CodeWeavers
|
2014-11-04 14:37:57 +01:00
|
|
|
* Copyright 2014 Aric Stewart for CodeWeavers
|
2012-07-31 06:18:02 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2015-07-03 16:53:07 +02:00
|
|
|
#include <math.h>
|
2015-07-29 10:58:24 +02:00
|
|
|
#include <limits.h>
|
2015-07-03 16:53:07 +02:00
|
|
|
|
2012-07-31 06:18:02 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windows.h"
|
2015-07-03 16:53:07 +02:00
|
|
|
#include "winternl.h"
|
2016-03-07 15:10:17 +01:00
|
|
|
#include "dwrite_3.h"
|
2014-12-15 07:39:26 +01:00
|
|
|
#include "initguid.h"
|
|
|
|
#include "d2d1.h"
|
2012-07-31 06:18:02 +02:00
|
|
|
|
2018-01-30 23:41:04 +01:00
|
|
|
#include "wine/heap.h"
|
2012-07-31 06:18:02 +02:00
|
|
|
#include "wine/test.h"
|
|
|
|
|
2016-04-18 05:47:14 +02:00
|
|
|
#define MS_CMAP_TAG DWRITE_MAKE_OPENTYPE_TAG('c','m','a','p')
|
|
|
|
#define MS_VDMX_TAG DWRITE_MAKE_OPENTYPE_TAG('V','D','M','X')
|
|
|
|
#define MS_GASP_TAG DWRITE_MAKE_OPENTYPE_TAG('g','a','s','p')
|
|
|
|
#define MS_CPAL_TAG DWRITE_MAKE_OPENTYPE_TAG('C','P','A','L')
|
|
|
|
#define MS_0S2_TAG DWRITE_MAKE_OPENTYPE_TAG('O','S','/','2')
|
|
|
|
#define MS_HEAD_TAG DWRITE_MAKE_OPENTYPE_TAG('h','e','a','d')
|
|
|
|
#define MS_HHEA_TAG DWRITE_MAKE_OPENTYPE_TAG('h','h','e','a')
|
|
|
|
#define MS_POST_TAG DWRITE_MAKE_OPENTYPE_TAG('p','o','s','t')
|
2016-07-05 11:55:54 +02:00
|
|
|
#define MS_GSUB_TAG DWRITE_MAKE_OPENTYPE_TAG('G','S','U','B')
|
2017-03-17 19:29:34 +01:00
|
|
|
#define MS_KERN_TAG DWRITE_MAKE_OPENTYPE_TAG('k','e','r','n')
|
2017-04-19 14:15:28 +02:00
|
|
|
#define MS_GLYF_TAG DWRITE_MAKE_OPENTYPE_TAG('g','l','y','f')
|
|
|
|
#define MS_CFF__TAG DWRITE_MAKE_OPENTYPE_TAG('C','F','F',' ')
|
2017-10-09 09:47:05 +02:00
|
|
|
#define MS_CFF2_TAG DWRITE_MAKE_OPENTYPE_TAG('C','F','F','2')
|
2017-04-19 14:15:28 +02:00
|
|
|
#define MS_COLR_TAG DWRITE_MAKE_OPENTYPE_TAG('C','O','L','R')
|
2017-04-24 07:50:46 +02:00
|
|
|
#define MS_SVG__TAG DWRITE_MAKE_OPENTYPE_TAG('S','V','G',' ')
|
2017-04-25 07:54:42 +02:00
|
|
|
#define MS_SBIX_TAG DWRITE_MAKE_OPENTYPE_TAG('s','b','i','x')
|
|
|
|
#define MS_MAXP_TAG DWRITE_MAKE_OPENTYPE_TAG('m','a','x','p')
|
2017-10-09 09:47:04 +02:00
|
|
|
#define MS_CBLC_TAG DWRITE_MAKE_OPENTYPE_TAG('C','B','L','C')
|
2017-04-25 07:54:42 +02:00
|
|
|
|
|
|
|
/* 'sbix' formats */
|
|
|
|
#define MS_PNG__TAG DWRITE_MAKE_OPENTYPE_TAG('p','n','g',' ')
|
|
|
|
#define MS_JPG__TAG DWRITE_MAKE_OPENTYPE_TAG('j','p','g',' ')
|
|
|
|
#define MS_TIFF_TAG DWRITE_MAKE_OPENTYPE_TAG('t','i','f','f')
|
2016-04-10 22:59:10 +02:00
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
#define MS_WOFF_TAG DWRITE_MAKE_OPENTYPE_TAG('w','O','F','F')
|
|
|
|
#define MS_WOF2_TAG DWRITE_MAKE_OPENTYPE_TAG('w','O','F','2')
|
|
|
|
|
2016-04-10 22:59:10 +02:00
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
|
|
#define GET_BE_WORD(x) (x)
|
2016-04-20 09:50:57 +02:00
|
|
|
#define GET_BE_DWORD(x) (x)
|
2017-10-09 09:47:02 +02:00
|
|
|
#define GET_LE_WORD(x) RtlUshortByteSwap(x)
|
|
|
|
#define GET_LE_DWORD(x) RtlUlongByteSwap(x)
|
2016-04-10 22:59:10 +02:00
|
|
|
#else
|
|
|
|
#define GET_BE_WORD(x) RtlUshortByteSwap(x)
|
2016-04-20 09:50:57 +02:00
|
|
|
#define GET_BE_DWORD(x) RtlUlongByteSwap(x)
|
2017-10-09 09:47:02 +02:00
|
|
|
#define GET_LE_WORD(x) (x)
|
|
|
|
#define GET_LE_DWORD(x) (x)
|
2016-04-10 22:59:10 +02:00
|
|
|
#endif
|
2014-11-06 21:23:26 +01:00
|
|
|
|
2012-07-31 06:18:02 +02:00
|
|
|
#define EXPECT_HR(hr,hr_exp) \
|
|
|
|
ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
|
|
|
|
|
2015-06-22 16:58:40 +02:00
|
|
|
#define DEFINE_EXPECT(func) \
|
|
|
|
static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
|
|
|
|
|
|
|
|
#define SET_EXPECT(func) \
|
|
|
|
do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
|
|
|
|
|
|
|
|
#define CHECK_EXPECT2(func) \
|
|
|
|
do { \
|
|
|
|
ok(expect_ ##func, "unexpected call " #func "\n"); \
|
|
|
|
called_ ## func = TRUE; \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
#define CHECK_EXPECT(func) \
|
|
|
|
do { \
|
|
|
|
CHECK_EXPECT2(func); \
|
|
|
|
expect_ ## func = FALSE; \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
#define CHECK_CALLED(func) \
|
|
|
|
do { \
|
|
|
|
ok(called_ ## func, "expected " #func "\n"); \
|
|
|
|
expect_ ## func = called_ ## func = FALSE; \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
#define CLEAR_CALLED(func) \
|
|
|
|
expect_ ## func = called_ ## func = FALSE
|
|
|
|
|
|
|
|
DEFINE_EXPECT(setfillmode);
|
|
|
|
|
2012-08-25 11:11:31 +02:00
|
|
|
#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
|
|
|
|
static void _expect_ref(IUnknown* obj, ULONG ref, int line)
|
|
|
|
{
|
2014-10-09 07:05:27 +02:00
|
|
|
ULONG rc;
|
|
|
|
IUnknown_AddRef(obj);
|
|
|
|
rc = IUnknown_Release(obj);
|
|
|
|
ok_(__FILE__,line)(rc == ref, "expected refcount %d, got %d\n", ref, rc);
|
2012-08-25 11:11:31 +02:00
|
|
|
}
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
#define EXPECT_REF_BROKEN(obj,ref,brokenref) _expect_ref_broken((IUnknown*)obj, ref, brokenref, __LINE__)
|
|
|
|
static void _expect_ref_broken(IUnknown* obj, ULONG ref, ULONG brokenref, int line)
|
|
|
|
{
|
|
|
|
ULONG rc;
|
|
|
|
IUnknown_AddRef(obj);
|
|
|
|
rc = IUnknown_Release(obj);
|
|
|
|
ok_(__FILE__,line)(rc == ref || broken(rc == brokenref), "expected refcount %d, got %d\n", ref, rc);
|
|
|
|
}
|
|
|
|
|
2018-11-22 12:29:14 +01:00
|
|
|
static BOOL (WINAPI *pGetFontRealizationInfo)(HDC hdc, void *);
|
|
|
|
|
2014-11-06 21:23:26 +01:00
|
|
|
static const WCHAR test_fontfile[] = {'w','i','n','e','_','t','e','s','t','_','f','o','n','t','.','t','t','f',0};
|
2012-10-16 18:56:23 +02:00
|
|
|
static const WCHAR tahomaW[] = {'T','a','h','o','m','a',0};
|
2015-07-03 16:53:07 +02:00
|
|
|
static const WCHAR arialW[] = {'A','r','i','a','l',0};
|
2015-04-10 21:08:31 +02:00
|
|
|
static const WCHAR tahomaUppercaseW[] = {'T','A','H','O','M','A',0};
|
|
|
|
static const WCHAR tahomaStrangecaseW[] = {'t','A','h','O','m','A',0};
|
2012-10-21 06:24:35 +02:00
|
|
|
static const WCHAR blahW[] = {'B','l','a','h','!',0};
|
2015-09-09 16:48:12 +02:00
|
|
|
static const WCHAR emojiW[] = {'S','e','g','o','e',' ','U','I',' ','E','m','o','j','i',0};
|
2012-10-16 18:56:23 +02:00
|
|
|
|
2016-04-10 22:59:10 +02:00
|
|
|
/* PANOSE is 10 bytes in size, need to pack the structure properly */
|
|
|
|
#include "pshpack2.h"
|
|
|
|
typedef struct
|
|
|
|
{
|
2017-01-24 22:54:13 +01:00
|
|
|
USHORT majorVersion;
|
|
|
|
USHORT minorVersion;
|
2016-04-10 22:59:10 +02:00
|
|
|
ULONG revision;
|
|
|
|
ULONG checksumadj;
|
|
|
|
ULONG magic;
|
|
|
|
USHORT flags;
|
|
|
|
USHORT unitsPerEm;
|
|
|
|
ULONGLONG created;
|
|
|
|
ULONGLONG modified;
|
|
|
|
SHORT xMin;
|
|
|
|
SHORT yMin;
|
|
|
|
SHORT xMax;
|
|
|
|
SHORT yMax;
|
|
|
|
USHORT macStyle;
|
|
|
|
USHORT lowestRecPPEM;
|
|
|
|
SHORT direction_hint;
|
|
|
|
SHORT index_format;
|
|
|
|
SHORT glyphdata_format;
|
|
|
|
} TT_HEAD;
|
|
|
|
|
2016-12-04 17:22:13 +01:00
|
|
|
enum TT_HEAD_MACSTYLE
|
|
|
|
{
|
|
|
|
TT_HEAD_MACSTYLE_BOLD = 1 << 0,
|
|
|
|
TT_HEAD_MACSTYLE_ITALIC = 1 << 1,
|
|
|
|
TT_HEAD_MACSTYLE_UNDERLINE = 1 << 2,
|
|
|
|
TT_HEAD_MACSTYLE_OUTLINE = 1 << 3,
|
|
|
|
TT_HEAD_MACSTYLE_SHADOW = 1 << 4,
|
|
|
|
TT_HEAD_MACSTYLE_CONDENSED = 1 << 5,
|
|
|
|
TT_HEAD_MACSTYLE_EXTENDED = 1 << 6,
|
|
|
|
};
|
|
|
|
|
2016-04-10 22:59:10 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
USHORT version;
|
|
|
|
SHORT xAvgCharWidth;
|
|
|
|
USHORT usWeightClass;
|
|
|
|
USHORT usWidthClass;
|
|
|
|
SHORT fsType;
|
|
|
|
SHORT ySubscriptXSize;
|
|
|
|
SHORT ySubscriptYSize;
|
|
|
|
SHORT ySubscriptXOffset;
|
|
|
|
SHORT ySubscriptYOffset;
|
|
|
|
SHORT ySuperscriptXSize;
|
|
|
|
SHORT ySuperscriptYSize;
|
|
|
|
SHORT ySuperscriptXOffset;
|
|
|
|
SHORT ySuperscriptYOffset;
|
|
|
|
SHORT yStrikeoutSize;
|
|
|
|
SHORT yStrikeoutPosition;
|
|
|
|
SHORT sFamilyClass;
|
|
|
|
PANOSE panose;
|
|
|
|
ULONG ulUnicodeRange1;
|
|
|
|
ULONG ulUnicodeRange2;
|
|
|
|
ULONG ulUnicodeRange3;
|
|
|
|
ULONG ulUnicodeRange4;
|
|
|
|
CHAR achVendID[4];
|
|
|
|
USHORT fsSelection;
|
|
|
|
USHORT usFirstCharIndex;
|
|
|
|
USHORT usLastCharIndex;
|
|
|
|
/* According to the Apple spec, original version didn't have the below fields,
|
|
|
|
* version numbers were taken from the OpenType spec.
|
|
|
|
*/
|
|
|
|
/* version 0 (TrueType 1.5) */
|
|
|
|
USHORT sTypoAscender;
|
|
|
|
USHORT sTypoDescender;
|
|
|
|
USHORT sTypoLineGap;
|
|
|
|
USHORT usWinAscent;
|
|
|
|
USHORT usWinDescent;
|
|
|
|
/* version 1 (TrueType 1.66) */
|
|
|
|
ULONG ulCodePageRange1;
|
|
|
|
ULONG ulCodePageRange2;
|
|
|
|
/* version 2 (OpenType 1.2) */
|
|
|
|
SHORT sxHeight;
|
|
|
|
SHORT sCapHeight;
|
|
|
|
USHORT usDefaultChar;
|
|
|
|
USHORT usBreakChar;
|
|
|
|
USHORT usMaxContext;
|
|
|
|
} TT_OS2_V2;
|
|
|
|
|
2016-04-13 06:02:12 +02:00
|
|
|
enum OS2_FSSELECTION {
|
|
|
|
OS2_FSSELECTION_ITALIC = 1 << 0,
|
|
|
|
OS2_FSSELECTION_UNDERSCORE = 1 << 1,
|
|
|
|
OS2_FSSELECTION_NEGATIVE = 1 << 2,
|
|
|
|
OS2_FSSELECTION_OUTLINED = 1 << 3,
|
|
|
|
OS2_FSSELECTION_STRIKEOUT = 1 << 4,
|
|
|
|
OS2_FSSELECTION_BOLD = 1 << 5,
|
|
|
|
OS2_FSSELECTION_REGULAR = 1 << 6,
|
|
|
|
OS2_FSSELECTION_USE_TYPO_METRICS = 1 << 7,
|
|
|
|
OS2_FSSELECTION_WWS = 1 << 8,
|
|
|
|
OS2_FSSELECTION_OBLIQUE = 1 << 9
|
|
|
|
};
|
|
|
|
|
2016-04-10 22:59:10 +02:00
|
|
|
typedef struct {
|
|
|
|
ULONG Version;
|
|
|
|
ULONG italicAngle;
|
|
|
|
SHORT underlinePosition;
|
|
|
|
SHORT underlineThickness;
|
|
|
|
ULONG fixed_pitch;
|
|
|
|
ULONG minmemType42;
|
|
|
|
ULONG maxmemType42;
|
|
|
|
ULONG minmemType1;
|
|
|
|
ULONG maxmemType1;
|
|
|
|
} TT_POST;
|
|
|
|
|
2016-04-18 05:47:13 +02:00
|
|
|
typedef struct {
|
2017-01-24 22:54:14 +01:00
|
|
|
USHORT majorVersion;
|
|
|
|
USHORT minorVersion;
|
2016-04-18 05:47:13 +02:00
|
|
|
SHORT ascender;
|
|
|
|
SHORT descender;
|
|
|
|
SHORT linegap;
|
|
|
|
USHORT advanceWidthMax;
|
|
|
|
SHORT minLeftSideBearing;
|
|
|
|
SHORT minRightSideBearing;
|
|
|
|
SHORT xMaxExtent;
|
|
|
|
SHORT caretSlopeRise;
|
|
|
|
SHORT caretSlopeRun;
|
|
|
|
SHORT caretOffset;
|
|
|
|
SHORT reserved[4];
|
|
|
|
SHORT metricDataFormat;
|
|
|
|
USHORT numberOfHMetrics;
|
|
|
|
} TT_HHEA;
|
|
|
|
|
2016-07-05 11:55:54 +02:00
|
|
|
typedef struct {
|
|
|
|
DWORD version;
|
|
|
|
WORD ScriptList;
|
|
|
|
WORD FeatureList;
|
|
|
|
WORD LookupList;
|
|
|
|
} GSUB_Header;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
CHAR FeatureTag[4];
|
|
|
|
WORD Feature;
|
|
|
|
} OT_FeatureRecord;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD FeatureCount;
|
|
|
|
OT_FeatureRecord FeatureRecord[1];
|
|
|
|
} OT_FeatureList;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD FeatureParams;
|
|
|
|
WORD LookupCount;
|
|
|
|
WORD LookupListIndex[1];
|
|
|
|
} OT_Feature;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD LookupCount;
|
|
|
|
WORD Lookup[1];
|
|
|
|
} OT_LookupList;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD LookupType;
|
|
|
|
WORD LookupFlag;
|
|
|
|
WORD SubTableCount;
|
|
|
|
WORD SubTable[1];
|
|
|
|
} OT_LookupTable;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD SubstFormat;
|
|
|
|
WORD Coverage;
|
|
|
|
WORD DeltaGlyphID;
|
|
|
|
} GSUB_SingleSubstFormat1;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD SubstFormat;
|
|
|
|
WORD Coverage;
|
|
|
|
WORD GlyphCount;
|
|
|
|
WORD Substitute[1];
|
|
|
|
} GSUB_SingleSubstFormat2;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD SubstFormat;
|
|
|
|
WORD ExtensionLookupType;
|
|
|
|
DWORD ExtensionOffset;
|
|
|
|
} GSUB_ExtensionPosFormat1;
|
|
|
|
|
2017-04-25 07:54:42 +02:00
|
|
|
typedef struct {
|
|
|
|
WORD version;
|
|
|
|
WORD flags;
|
|
|
|
DWORD numStrikes;
|
|
|
|
DWORD strikeOffset[1];
|
|
|
|
} sbix_header;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD ppem;
|
|
|
|
WORD ppi;
|
|
|
|
DWORD glyphDataOffsets[1];
|
|
|
|
} sbix_strike;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD originOffsetX;
|
|
|
|
WORD originOffsetY;
|
|
|
|
DWORD graphicType;
|
|
|
|
BYTE data[1];
|
|
|
|
} sbix_glyph_data;
|
|
|
|
|
2017-10-09 09:47:04 +02:00
|
|
|
typedef struct {
|
|
|
|
WORD majorVersion;
|
|
|
|
WORD minorVersion;
|
|
|
|
DWORD numSizes;
|
|
|
|
} CBLCHeader;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
BYTE res[12];
|
|
|
|
} sbitLineMetrics;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DWORD indexSubTableArrayOffset;
|
|
|
|
DWORD indexTablesSize;
|
|
|
|
DWORD numberofIndexSubTables;
|
|
|
|
DWORD colorRef;
|
|
|
|
sbitLineMetrics hori;
|
|
|
|
sbitLineMetrics vert;
|
|
|
|
WORD startGlyphIndex;
|
|
|
|
WORD endGlyphIndex;
|
|
|
|
BYTE ppemX;
|
|
|
|
BYTE ppemY;
|
|
|
|
BYTE bitDepth;
|
|
|
|
BYTE flags;
|
|
|
|
} CBLCBitmapSizeTable;
|
|
|
|
|
2017-04-25 07:54:42 +02:00
|
|
|
typedef struct {
|
|
|
|
DWORD version;
|
|
|
|
WORD numGlyphs;
|
|
|
|
} maxp;
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
struct WOFFHeader
|
|
|
|
{
|
|
|
|
ULONG signature;
|
|
|
|
ULONG flavor;
|
|
|
|
ULONG length;
|
|
|
|
USHORT numTables;
|
|
|
|
USHORT reserved;
|
|
|
|
ULONG totalSfntSize;
|
|
|
|
USHORT majorVersion;
|
|
|
|
USHORT minorVersion;
|
|
|
|
ULONG metaOffset;
|
|
|
|
ULONG metaLength;
|
|
|
|
ULONG metaOrigLength;
|
|
|
|
ULONG privOffset;
|
|
|
|
ULONG privLength;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WOFFHeader2
|
|
|
|
{
|
|
|
|
ULONG signature;
|
|
|
|
ULONG flavor;
|
|
|
|
ULONG length;
|
|
|
|
USHORT numTables;
|
|
|
|
USHORT reserved;
|
|
|
|
ULONG totalSfntSize;
|
|
|
|
ULONG totalCompressedSize;
|
|
|
|
USHORT majorVersion;
|
|
|
|
USHORT minorVersion;
|
|
|
|
ULONG metaOffset;
|
|
|
|
ULONG metaLength;
|
|
|
|
ULONG metaOrigLength;
|
|
|
|
ULONG privOffset;
|
|
|
|
ULONG privLength;
|
|
|
|
};
|
|
|
|
|
2018-11-26 09:43:09 +01:00
|
|
|
struct cmap_encoding_record
|
|
|
|
{
|
|
|
|
WORD platformID;
|
|
|
|
WORD encodingID;
|
|
|
|
DWORD offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cmap_header
|
|
|
|
{
|
|
|
|
WORD version;
|
|
|
|
WORD numTables;
|
|
|
|
struct cmap_encoding_record tables[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cmap_segmented_coverage_group
|
|
|
|
{
|
|
|
|
DWORD startCharCode;
|
|
|
|
DWORD endCharCode;
|
|
|
|
DWORD startGlyphID;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cmap_segmented_coverage
|
|
|
|
{
|
|
|
|
WORD format;
|
|
|
|
WORD reserved;
|
|
|
|
DWORD length;
|
|
|
|
DWORD language;
|
|
|
|
DWORD nGroups;
|
|
|
|
struct cmap_segmented_coverage_group groups[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cmap_segmented_mapping_0
|
|
|
|
{
|
|
|
|
WORD format;
|
|
|
|
WORD length;
|
|
|
|
WORD language;
|
|
|
|
WORD segCountX2;
|
|
|
|
WORD searchRange;
|
|
|
|
WORD entrySelector;
|
|
|
|
WORD rangeShift;
|
|
|
|
WORD endCode[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
enum opentype_cmap_table_platform
|
|
|
|
{
|
|
|
|
OPENTYPE_CMAP_TABLE_PLATFORM_WIN = 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum opentype_cmap_table_encoding
|
|
|
|
{
|
|
|
|
OPENTYPE_CMAP_TABLE_ENCODING_UNICODE_BMP = 1,
|
|
|
|
OPENTYPE_CMAP_TABLE_ENCODING_UNICODE_FULL = 10,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum opentype_cmap_table_format
|
|
|
|
{
|
|
|
|
OPENTYPE_CMAP_TABLE_SEGMENT_MAPPING = 4,
|
|
|
|
OPENTYPE_CMAP_TABLE_SEGMENTED_COVERAGE = 12,
|
|
|
|
};
|
|
|
|
|
2016-04-10 22:59:10 +02:00
|
|
|
#include "poppack.h"
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
static void *create_factory_iid(REFIID riid)
|
|
|
|
{
|
|
|
|
IUnknown *factory = NULL;
|
|
|
|
DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, riid, &factory);
|
|
|
|
return factory;
|
|
|
|
}
|
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
static IDWriteFactory *create_factory(void)
|
|
|
|
{
|
2017-10-09 09:47:02 +02:00
|
|
|
IDWriteFactory *factory = create_factory_iid(&IID_IDWriteFactory);
|
|
|
|
ok(factory != NULL, "Failed to create factory.\n");
|
2014-10-22 13:42:30 +02:00
|
|
|
return factory;
|
|
|
|
}
|
|
|
|
|
2015-05-19 14:23:57 +02:00
|
|
|
static IDWriteFontFace *create_fontface(IDWriteFactory *factory)
|
|
|
|
{
|
|
|
|
static const WCHAR tahomaW[] = {'T','a','h','o','m','a',0};
|
|
|
|
IDWriteGdiInterop *interop;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFont *font;
|
|
|
|
LOGFONTW logfont;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
|
|
|
logfont.lfItalic = 1;
|
|
|
|
lstrcpyW(logfont.lfFaceName, tahomaW);
|
|
|
|
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
IDWriteGdiInterop_Release(interop);
|
|
|
|
|
|
|
|
return fontface;
|
|
|
|
}
|
|
|
|
|
2016-01-17 19:41:57 +01:00
|
|
|
static IDWriteFont *get_font(IDWriteFactory *factory, const WCHAR *name, DWRITE_FONT_STYLE style)
|
|
|
|
{
|
|
|
|
IDWriteFontCollection *collection;
|
|
|
|
IDWriteFontFamily *family;
|
|
|
|
IDWriteFont *font = NULL;
|
|
|
|
UINT32 index;
|
|
|
|
BOOL exists;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
index = ~0;
|
|
|
|
exists = FALSE;
|
|
|
|
hr = IDWriteFontCollection_FindFamilyName(collection, name, &index, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
if (!exists) goto not_found;
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(collection, index, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
|
|
|
|
DWRITE_FONT_STRETCH_NORMAL, style, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
not_found:
|
|
|
|
IDWriteFontCollection_Release(collection);
|
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IDWriteFont *get_tahoma_instance(IDWriteFactory *factory, DWRITE_FONT_STYLE style)
|
|
|
|
{
|
|
|
|
IDWriteFont *font = get_font(factory, tahomaW, style);
|
|
|
|
ok(font != NULL, "failed to get Tahoma\n");
|
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
static WCHAR *create_testfontfile(const WCHAR *filename)
|
2014-12-11 10:33:29 +01:00
|
|
|
{
|
2015-02-24 06:05:05 +01:00
|
|
|
static WCHAR pathW[MAX_PATH];
|
2014-12-11 10:33:29 +01:00
|
|
|
DWORD written;
|
|
|
|
HANDLE file;
|
|
|
|
HRSRC res;
|
|
|
|
void *ptr;
|
2015-02-24 06:05:05 +01:00
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
GetTempPathW(ARRAY_SIZE(pathW), pathW);
|
2015-02-24 06:05:05 +01:00
|
|
|
lstrcatW(pathW, filename);
|
|
|
|
|
|
|
|
file = CreateFileW(pathW, 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(pathW),
|
|
|
|
GetLastError());
|
2014-12-11 10:33:29 +01:00
|
|
|
|
|
|
|
res = FindResourceA(GetModuleHandleA(NULL), (LPCSTR)MAKEINTRESOURCE(1), (LPCSTR)RT_RCDATA);
|
|
|
|
ok( res != 0, "couldn't find resource\n" );
|
|
|
|
ptr = LockResource( LoadResource( GetModuleHandleA(NULL), res ));
|
|
|
|
WriteFile( file, ptr, SizeofResource( GetModuleHandleA(NULL), res ), &written, NULL );
|
|
|
|
ok( written == SizeofResource( GetModuleHandleA(NULL), res ), "couldn't write resource\n" );
|
|
|
|
CloseHandle( file );
|
2015-02-24 06:05:05 +01:00
|
|
|
|
|
|
|
return pathW;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DELETE_FONTFILE(filename) _delete_testfontfile(filename, __LINE__)
|
|
|
|
static void _delete_testfontfile(const WCHAR *filename, int line)
|
|
|
|
{
|
|
|
|
BOOL ret = DeleteFileW(filename);
|
|
|
|
ok_(__FILE__,line)(ret, "failed to delete file %s, error %d\n", wine_dbgstr_w(filename), GetLastError());
|
2014-12-11 10:33:29 +01:00
|
|
|
}
|
|
|
|
|
2018-11-11 07:55:00 +01:00
|
|
|
static void get_combined_font_name(const WCHAR *familyW, const WCHAR *faceW, WCHAR *nameW)
|
|
|
|
{
|
|
|
|
static const WCHAR spaceW[] = {' ', 0};
|
|
|
|
lstrcpyW(nameW, familyW);
|
|
|
|
lstrcatW(nameW, spaceW);
|
|
|
|
lstrcatW(nameW, faceW);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL has_face_variations(IDWriteFontFace *fontface)
|
|
|
|
{
|
|
|
|
IDWriteFontFace5 *fontface5;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
if (SUCCEEDED(IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace5, (void **)&fontface5))) {
|
|
|
|
ret = IDWriteFontFace5_HasVariations(fontface5);
|
|
|
|
IDWriteFontFace5_Release(fontface5);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-11-04 14:37:57 +01:00
|
|
|
struct test_fontenumerator
|
|
|
|
{
|
|
|
|
IDWriteFontFileEnumerator IDWriteFontFileEnumerator_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
DWORD index;
|
|
|
|
IDWriteFontFile *font_file;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct test_fontenumerator *impl_from_IDWriteFontFileEnumerator(IDWriteFontFileEnumerator* iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct test_fontenumerator, IDWriteFontFileEnumerator_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI singlefontfileenumerator_QueryInterface(IDWriteFontFileEnumerator *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteFontFileEnumerator))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
IDWriteFontFileEnumerator_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI singlefontfileenumerator_AddRef(IDWriteFontFileEnumerator *iface)
|
|
|
|
{
|
|
|
|
struct test_fontenumerator *This = impl_from_IDWriteFontFileEnumerator(iface);
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI singlefontfileenumerator_Release(IDWriteFontFileEnumerator *iface)
|
|
|
|
{
|
|
|
|
struct test_fontenumerator *This = impl_from_IDWriteFontFileEnumerator(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
if (!ref) {
|
|
|
|
IDWriteFontFile_Release(This->font_file);
|
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI singlefontfileenumerator_GetCurrentFontFile(IDWriteFontFileEnumerator *iface, IDWriteFontFile **font_file)
|
|
|
|
{
|
|
|
|
struct test_fontenumerator *This = impl_from_IDWriteFontFileEnumerator(iface);
|
|
|
|
IDWriteFontFile_AddRef(This->font_file);
|
|
|
|
*font_file = This->font_file;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI singlefontfileenumerator_MoveNext(IDWriteFontFileEnumerator *iface, BOOL *current)
|
|
|
|
{
|
|
|
|
struct test_fontenumerator *This = impl_from_IDWriteFontFileEnumerator(iface);
|
|
|
|
|
|
|
|
if (This->index > 1) {
|
|
|
|
*current = FALSE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->index++;
|
|
|
|
*current = TRUE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IDWriteFontFileEnumeratorVtbl singlefontfileenumeratorvtbl =
|
|
|
|
{
|
|
|
|
singlefontfileenumerator_QueryInterface,
|
|
|
|
singlefontfileenumerator_AddRef,
|
|
|
|
singlefontfileenumerator_Release,
|
|
|
|
singlefontfileenumerator_MoveNext,
|
|
|
|
singlefontfileenumerator_GetCurrentFontFile
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT create_enumerator(IDWriteFontFile *font_file, IDWriteFontFileEnumerator **ret)
|
|
|
|
{
|
|
|
|
struct test_fontenumerator *enumerator;
|
|
|
|
|
|
|
|
enumerator = heap_alloc(sizeof(struct test_fontenumerator));
|
|
|
|
if (!enumerator)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
enumerator->IDWriteFontFileEnumerator_iface.lpVtbl = &singlefontfileenumeratorvtbl;
|
|
|
|
enumerator->ref = 1;
|
|
|
|
enumerator->index = 0;
|
|
|
|
enumerator->font_file = font_file;
|
|
|
|
IDWriteFontFile_AddRef(font_file);
|
|
|
|
|
|
|
|
*ret = &enumerator->IDWriteFontFileEnumerator_iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct test_fontcollectionloader
|
|
|
|
{
|
|
|
|
IDWriteFontCollectionLoader IDWriteFontFileCollectionLoader_iface;
|
|
|
|
IDWriteFontFileLoader *loader;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct test_fontcollectionloader *impl_from_IDWriteFontFileCollectionLoader(IDWriteFontCollectionLoader* iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct test_fontcollectionloader, IDWriteFontFileCollectionLoader_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI resourcecollectionloader_QueryInterface(IDWriteFontCollectionLoader *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteFontCollectionLoader))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
IDWriteFontCollectionLoader_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI resourcecollectionloader_AddRef(IDWriteFontCollectionLoader *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI resourcecollectionloader_Release(IDWriteFontCollectionLoader *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI resourcecollectionloader_CreateEnumeratorFromKey(IDWriteFontCollectionLoader *iface, IDWriteFactory *factory,
|
|
|
|
const void * collectionKey, UINT32 collectionKeySize, IDWriteFontFileEnumerator ** fontFileEnumerator)
|
|
|
|
{
|
|
|
|
struct test_fontcollectionloader *This = impl_from_IDWriteFontFileCollectionLoader(iface);
|
|
|
|
IDWriteFontFile *font_file;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2018-01-08 14:02:52 +01:00
|
|
|
hr = IDWriteFactory_CreateCustomFontFileReference(factory, collectionKey, collectionKeySize, This->loader, &font_file);
|
|
|
|
ok(hr == S_OK, "Failed to create custom file reference, hr %#x.\n", hr);
|
2014-11-04 14:37:57 +01:00
|
|
|
|
|
|
|
hr = create_enumerator(font_file, fontFileEnumerator);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IDWriteFontFile_Release(font_file);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IDWriteFontCollectionLoaderVtbl resourcecollectionloadervtbl = {
|
|
|
|
resourcecollectionloader_QueryInterface,
|
|
|
|
resourcecollectionloader_AddRef,
|
|
|
|
resourcecollectionloader_Release,
|
|
|
|
resourcecollectionloader_CreateEnumeratorFromKey
|
|
|
|
};
|
|
|
|
|
2014-08-20 22:50:21 +02:00
|
|
|
/* Here is a functional custom font set of interfaces */
|
|
|
|
struct test_fontdatastream
|
|
|
|
{
|
|
|
|
IDWriteFontFileStream IDWriteFontFileStream_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
LPVOID data;
|
|
|
|
DWORD size;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct test_fontdatastream *impl_from_IDWriteFontFileStream(IDWriteFontFileStream* iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct test_fontdatastream, IDWriteFontFileStream_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI fontdatastream_QueryInterface(IDWriteFontFileStream *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteFontFileStream))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
IDWriteFontFileStream_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI fontdatastream_AddRef(IDWriteFontFileStream *iface)
|
|
|
|
{
|
|
|
|
struct test_fontdatastream *This = impl_from_IDWriteFontFileStream(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI fontdatastream_Release(IDWriteFontFileStream *iface)
|
|
|
|
{
|
|
|
|
struct test_fontdatastream *This = impl_from_IDWriteFontFileStream(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
if (ref == 0)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI fontdatastream_ReadFileFragment(IDWriteFontFileStream *iface, void const **fragment_start, UINT64 offset, UINT64 fragment_size, void **fragment_context)
|
|
|
|
{
|
|
|
|
struct test_fontdatastream *This = impl_from_IDWriteFontFileStream(iface);
|
|
|
|
*fragment_context = NULL;
|
|
|
|
if (offset+fragment_size > This->size)
|
|
|
|
{
|
|
|
|
*fragment_start = NULL;
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*fragment_start = (BYTE*)This->data + offset;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI fontdatastream_ReleaseFileFragment(IDWriteFontFileStream *iface, void *fragment_context)
|
|
|
|
{
|
|
|
|
/* Do Nothing */
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI fontdatastream_GetFileSize(IDWriteFontFileStream *iface, UINT64 *size)
|
|
|
|
{
|
|
|
|
struct test_fontdatastream *This = impl_from_IDWriteFontFileStream(iface);
|
|
|
|
*size = This->size;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI fontdatastream_GetLastWriteTime(IDWriteFontFileStream *iface, UINT64 *last_writetime)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteFontFileStreamVtbl fontdatastreamvtbl =
|
|
|
|
{
|
|
|
|
fontdatastream_QueryInterface,
|
|
|
|
fontdatastream_AddRef,
|
|
|
|
fontdatastream_Release,
|
|
|
|
fontdatastream_ReadFileFragment,
|
|
|
|
fontdatastream_ReleaseFileFragment,
|
|
|
|
fontdatastream_GetFileSize,
|
|
|
|
fontdatastream_GetLastWriteTime
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT create_fontdatastream(LPVOID data, UINT size, IDWriteFontFileStream** iface)
|
|
|
|
{
|
|
|
|
struct test_fontdatastream *This = HeapAlloc(GetProcessHeap(), 0, sizeof(struct test_fontdatastream));
|
|
|
|
if (!This)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->data = data;
|
|
|
|
This->size = size;
|
|
|
|
This->ref = 1;
|
|
|
|
This->IDWriteFontFileStream_iface.lpVtbl = &fontdatastreamvtbl;
|
|
|
|
|
|
|
|
*iface = &This->IDWriteFontFileStream_iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI resourcefontfileloader_QueryInterface(IDWriteFontFileLoader *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteFontFileLoader))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI resourcefontfileloader_AddRef(IDWriteFontFileLoader *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI resourcefontfileloader_Release(IDWriteFontFileLoader *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-07-05 11:55:53 +02:00
|
|
|
static HRESULT WINAPI resourcefontfileloader_CreateStreamFromKey(IDWriteFontFileLoader *iface, const void *ref_key, UINT32 key_size,
|
|
|
|
IDWriteFontFileStream **stream)
|
2014-08-20 22:50:21 +02:00
|
|
|
{
|
|
|
|
LPVOID data;
|
|
|
|
DWORD size;
|
|
|
|
HGLOBAL mem;
|
|
|
|
|
2016-07-05 11:55:53 +02:00
|
|
|
mem = LoadResource(GetModuleHandleA(NULL), *(HRSRC*)ref_key);
|
2014-08-20 22:50:21 +02:00
|
|
|
ok(mem != NULL, "Failed to lock font resource\n");
|
|
|
|
if (mem)
|
|
|
|
{
|
2016-07-05 11:55:53 +02:00
|
|
|
size = SizeofResource(GetModuleHandleA(NULL), *(HRSRC*)ref_key);
|
2014-08-20 22:50:21 +02:00
|
|
|
data = LockResource(mem);
|
2016-07-05 11:55:53 +02:00
|
|
|
return create_fontdatastream(data, size, stream);
|
2014-08-20 22:50:21 +02:00
|
|
|
}
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IDWriteFontFileLoaderVtbl resourcefontfileloadervtbl = {
|
|
|
|
resourcefontfileloader_QueryInterface,
|
|
|
|
resourcefontfileloader_AddRef,
|
|
|
|
resourcefontfileloader_Release,
|
|
|
|
resourcefontfileloader_CreateStreamFromKey
|
|
|
|
};
|
|
|
|
|
2014-10-16 05:33:51 +02:00
|
|
|
static IDWriteFontFileLoader rloader = { &resourcefontfileloadervtbl };
|
2014-08-20 22:50:21 +02:00
|
|
|
|
2014-12-15 07:39:26 +01:00
|
|
|
static D2D1_POINT_2F g_startpoints[2];
|
|
|
|
static int g_startpoint_count;
|
|
|
|
|
|
|
|
static HRESULT WINAPI test_geometrysink_QueryInterface(ID2D1SimplifiedGeometrySink *iface, REFIID riid, void **ret)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_ID2D1SimplifiedGeometrySink) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*ret = iface;
|
|
|
|
ID2D1SimplifiedGeometrySink_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI test_geometrysink_AddRef(ID2D1SimplifiedGeometrySink *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI test_geometrysink_Release(ID2D1SimplifiedGeometrySink *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI test_geometrysink_SetFillMode(ID2D1SimplifiedGeometrySink *iface, D2D1_FILL_MODE mode)
|
|
|
|
{
|
2015-06-22 16:58:40 +02:00
|
|
|
CHECK_EXPECT(setfillmode);
|
2014-12-15 07:39:26 +01:00
|
|
|
ok(mode == D2D1_FILL_MODE_WINDING, "fill mode %d\n", mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI test_geometrysink_SetSegmentFlags(ID2D1SimplifiedGeometrySink *iface, D2D1_PATH_SEGMENT flags)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected SetSegmentFlags() - flags %d\n", flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI test_geometrysink_BeginFigure(ID2D1SimplifiedGeometrySink *iface,
|
|
|
|
D2D1_POINT_2F startPoint, D2D1_FIGURE_BEGIN figureBegin)
|
|
|
|
{
|
|
|
|
ok(figureBegin == D2D1_FIGURE_BEGIN_FILLED, "begin figure %d\n", figureBegin);
|
2018-05-22 10:50:42 +02:00
|
|
|
if (g_startpoint_count < ARRAY_SIZE(g_startpoints))
|
2015-06-09 23:13:34 +02:00
|
|
|
g_startpoints[g_startpoint_count] = startPoint;
|
|
|
|
g_startpoint_count++;
|
2014-12-15 07:39:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI test_geometrysink_AddLines(ID2D1SimplifiedGeometrySink *iface,
|
|
|
|
const D2D1_POINT_2F *points, UINT32 count)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI test_geometrysink_AddBeziers(ID2D1SimplifiedGeometrySink *iface,
|
|
|
|
const D2D1_BEZIER_SEGMENT *beziers, UINT32 count)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI test_geometrysink_EndFigure(ID2D1SimplifiedGeometrySink *iface, D2D1_FIGURE_END figureEnd)
|
|
|
|
{
|
|
|
|
ok(figureEnd == D2D1_FIGURE_END_CLOSED, "end figure %d\n", figureEnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI test_geometrysink_Close(ID2D1SimplifiedGeometrySink *iface)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected Close()\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const ID2D1SimplifiedGeometrySinkVtbl test_geometrysink_vtbl = {
|
|
|
|
test_geometrysink_QueryInterface,
|
|
|
|
test_geometrysink_AddRef,
|
|
|
|
test_geometrysink_Release,
|
|
|
|
test_geometrysink_SetFillMode,
|
|
|
|
test_geometrysink_SetSegmentFlags,
|
|
|
|
test_geometrysink_BeginFigure,
|
|
|
|
test_geometrysink_AddLines,
|
|
|
|
test_geometrysink_AddBeziers,
|
|
|
|
test_geometrysink_EndFigure,
|
|
|
|
test_geometrysink_Close
|
|
|
|
};
|
|
|
|
|
2015-06-22 16:58:40 +02:00
|
|
|
static void WINAPI test_geometrysink2_BeginFigure(ID2D1SimplifiedGeometrySink *iface,
|
|
|
|
D2D1_POINT_2F startPoint, D2D1_FIGURE_BEGIN figureBegin)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI test_geometrysink2_AddLines(ID2D1SimplifiedGeometrySink *iface,
|
|
|
|
const D2D1_POINT_2F *points, UINT32 count)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI test_geometrysink2_AddBeziers(ID2D1SimplifiedGeometrySink *iface,
|
|
|
|
const D2D1_BEZIER_SEGMENT *beziers, UINT32 count)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI test_geometrysink2_EndFigure(ID2D1SimplifiedGeometrySink *iface, D2D1_FIGURE_END figureEnd)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static const ID2D1SimplifiedGeometrySinkVtbl test_geometrysink2_vtbl = {
|
|
|
|
test_geometrysink_QueryInterface,
|
|
|
|
test_geometrysink_AddRef,
|
|
|
|
test_geometrysink_Release,
|
|
|
|
test_geometrysink_SetFillMode,
|
|
|
|
test_geometrysink_SetSegmentFlags,
|
|
|
|
test_geometrysink2_BeginFigure,
|
|
|
|
test_geometrysink2_AddLines,
|
|
|
|
test_geometrysink2_AddBeziers,
|
|
|
|
test_geometrysink2_EndFigure,
|
|
|
|
test_geometrysink_Close
|
|
|
|
};
|
|
|
|
|
2014-12-15 07:39:26 +01:00
|
|
|
static ID2D1SimplifiedGeometrySink test_geomsink = { &test_geometrysink_vtbl };
|
2015-06-22 16:58:40 +02:00
|
|
|
static ID2D1SimplifiedGeometrySink test_geomsink2 = { &test_geometrysink2_vtbl };
|
2014-12-15 07:39:26 +01:00
|
|
|
|
2012-07-31 06:18:02 +02:00
|
|
|
static void test_CreateFontFromLOGFONT(void)
|
|
|
|
{
|
2012-10-16 18:56:23 +02:00
|
|
|
static const WCHAR tahomaspW[] = {'T','a','h','o','m','a',' ',0};
|
2016-04-22 15:15:35 +02:00
|
|
|
IDWriteGdiInterop1 *interop1;
|
2012-07-31 06:18:02 +02:00
|
|
|
IDWriteGdiInterop *interop;
|
|
|
|
DWRITE_FONT_WEIGHT weight;
|
|
|
|
DWRITE_FONT_STYLE style;
|
|
|
|
IDWriteFont *font;
|
|
|
|
LOGFONTW logfont;
|
2012-08-13 05:46:43 +02:00
|
|
|
LONG weights[][2] = {
|
|
|
|
{FW_NORMAL, DWRITE_FONT_WEIGHT_NORMAL},
|
|
|
|
{FW_BOLD, DWRITE_FONT_WEIGHT_BOLD},
|
|
|
|
{ 0, DWRITE_FONT_WEIGHT_NORMAL},
|
|
|
|
{ 50, DWRITE_FONT_WEIGHT_NORMAL},
|
|
|
|
{150, DWRITE_FONT_WEIGHT_NORMAL},
|
|
|
|
{250, DWRITE_FONT_WEIGHT_NORMAL},
|
|
|
|
{350, DWRITE_FONT_WEIGHT_NORMAL},
|
|
|
|
{450, DWRITE_FONT_WEIGHT_NORMAL},
|
|
|
|
{650, DWRITE_FONT_WEIGHT_BOLD},
|
|
|
|
{750, DWRITE_FONT_WEIGHT_BOLD},
|
|
|
|
{850, DWRITE_FONT_WEIGHT_BOLD},
|
|
|
|
{950, DWRITE_FONT_WEIGHT_BOLD},
|
|
|
|
{960, DWRITE_FONT_WEIGHT_BOLD},
|
|
|
|
};
|
2012-10-16 18:56:23 +02:00
|
|
|
OUTLINETEXTMETRICW otm;
|
2014-10-22 13:42:30 +02:00
|
|
|
IDWriteFactory *factory;
|
2012-07-31 06:18:02 +02:00
|
|
|
HRESULT hr;
|
|
|
|
BOOL ret;
|
2012-10-16 18:56:23 +02:00
|
|
|
HDC hdc;
|
|
|
|
HFONT hfont;
|
2014-10-16 05:30:40 +02:00
|
|
|
BOOL exists;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2012-08-13 05:46:43 +02:00
|
|
|
int i;
|
2012-10-16 18:56:23 +02:00
|
|
|
UINT r;
|
2012-07-31 06:18:02 +02:00
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
factory = create_factory();
|
|
|
|
|
2012-07-31 06:18:02 +02:00
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
|
2017-04-11 13:21:32 +02:00
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
2012-07-31 06:18:02 +02:00
|
|
|
|
2016-08-09 14:59:46 +02:00
|
|
|
if (0)
|
|
|
|
/* null out parameter crashes this call */
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, NULL, NULL);
|
2012-07-31 06:18:02 +02:00
|
|
|
|
2016-01-28 21:27:20 +01:00
|
|
|
font = (void*)0xdeadbeef;
|
2012-07-31 06:18:02 +02:00
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, NULL, &font);
|
|
|
|
EXPECT_HR(hr, E_INVALIDARG);
|
2016-01-28 21:27:20 +01:00
|
|
|
ok(font == NULL, "got %p\n", font);
|
2012-07-31 06:18:02 +02:00
|
|
|
|
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
|
|
|
logfont.lfItalic = 1;
|
2012-10-16 18:56:23 +02:00
|
|
|
lstrcpyW(logfont.lfFaceName, tahomaW);
|
2012-07-31 06:18:02 +02:00
|
|
|
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2012-10-16 18:56:23 +02:00
|
|
|
hfont = CreateFontIndirectW(&logfont);
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
otm.otmSize = sizeof(otm);
|
|
|
|
r = GetOutlineTextMetricsW(hdc, otm.otmSize, &otm);
|
|
|
|
ok(r, "got %d\n", r);
|
|
|
|
DeleteDC(hdc);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
|
2014-10-16 05:30:40 +02:00
|
|
|
exists = TRUE;
|
|
|
|
hr = IDWriteFont_HasCharacter(font, 0xd800, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(exists == FALSE, "got %d\n", exists);
|
|
|
|
|
|
|
|
exists = FALSE;
|
|
|
|
hr = IDWriteFont_HasCharacter(font, 0x20, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(exists == TRUE, "got %d\n", exists);
|
|
|
|
|
2012-07-31 06:18:02 +02:00
|
|
|
/* now check properties */
|
|
|
|
weight = IDWriteFont_GetWeight(font);
|
|
|
|
ok(weight == DWRITE_FONT_WEIGHT_NORMAL, "got %d\n", weight);
|
|
|
|
|
|
|
|
style = IDWriteFont_GetStyle(font);
|
2012-10-16 18:56:23 +02:00
|
|
|
ok(style == DWRITE_FONT_STYLE_OBLIQUE, "got %d\n", style);
|
2016-02-09 15:24:27 +01:00
|
|
|
ok(otm.otmfsSelection & 1, "got 0x%08x\n", otm.otmfsSelection);
|
2014-12-08 11:22:01 +01:00
|
|
|
|
2012-07-31 06:18:02 +02:00
|
|
|
ret = IDWriteFont_IsSymbolFont(font);
|
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
2012-08-13 05:46:43 +02:00
|
|
|
/* weight values */
|
2018-05-22 10:50:42 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(weights); i++)
|
2012-08-13 05:46:43 +02:00
|
|
|
{
|
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = weights[i][0];
|
2012-10-16 18:56:23 +02:00
|
|
|
lstrcpyW(logfont.lfFaceName, tahomaW);
|
2012-08-13 05:46:43 +02:00
|
|
|
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
weight = IDWriteFont_GetWeight(font);
|
|
|
|
ok(weight == weights[i][1],
|
|
|
|
"%d: got %d, expected %d\n", i, weight, weights[i][1]);
|
2014-10-29 20:41:47 +01:00
|
|
|
|
2012-08-13 05:46:43 +02:00
|
|
|
IDWriteFont_Release(font);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* weight not from enum */
|
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = 550;
|
2012-10-16 18:56:23 +02:00
|
|
|
lstrcpyW(logfont.lfFaceName, tahomaW);
|
2012-08-13 05:46:43 +02:00
|
|
|
|
2014-10-19 22:25:26 +02:00
|
|
|
font = NULL;
|
2012-08-13 05:46:43 +02:00
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
|
2014-10-19 22:25:26 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2012-08-13 05:46:43 +02:00
|
|
|
|
|
|
|
weight = IDWriteFont_GetWeight(font);
|
2015-08-10 12:51:28 +02:00
|
|
|
ok(weight == DWRITE_FONT_WEIGHT_NORMAL || weight == DWRITE_FONT_WEIGHT_BOLD,
|
2012-08-13 05:46:43 +02:00
|
|
|
"got %d\n", weight);
|
2017-04-11 13:21:32 +02:00
|
|
|
|
2012-08-13 05:46:43 +02:00
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
/* empty or nonexistent face name */
|
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
|
|
|
lstrcpyW(logfont.lfFaceName, blahW);
|
|
|
|
|
2012-10-07 18:29:39 +02:00
|
|
|
font = (void*)0xdeadbeef;
|
2012-08-13 05:46:43 +02:00
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
|
2014-10-19 22:25:26 +02:00
|
|
|
ok(hr == DWRITE_E_NOFONT, "got 0x%08x\n", hr);
|
2012-10-07 18:29:39 +02:00
|
|
|
ok(font == NULL, "got %p\n", font);
|
2012-08-13 05:46:43 +02:00
|
|
|
|
2014-10-19 22:25:26 +02:00
|
|
|
/* Try with name 'Tahoma ' */
|
2012-08-13 05:46:43 +02:00
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
2012-10-16 18:56:23 +02:00
|
|
|
lstrcpyW(logfont.lfFaceName, tahomaspW);
|
2012-08-13 05:46:43 +02:00
|
|
|
|
2012-10-07 18:29:39 +02:00
|
|
|
font = (void*)0xdeadbeef;
|
2012-08-13 05:46:43 +02:00
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
|
2014-10-19 22:25:26 +02:00
|
|
|
ok(hr == DWRITE_E_NOFONT, "got 0x%08x\n", hr);
|
2012-10-07 18:29:39 +02:00
|
|
|
ok(font == NULL, "got %p\n", font);
|
|
|
|
|
2014-10-19 22:25:26 +02:00
|
|
|
/* empty string as a facename */
|
2012-10-07 18:29:39 +02:00
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
|
|
|
|
|
|
|
font = (void*)0xdeadbeef;
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
|
2014-10-19 22:25:26 +02:00
|
|
|
ok(hr == DWRITE_E_NOFONT, "got 0x%08x\n", hr);
|
2012-10-07 18:29:39 +02:00
|
|
|
ok(font == NULL, "got %p\n", font);
|
2012-08-13 05:46:43 +02:00
|
|
|
|
2016-04-22 15:15:35 +02:00
|
|
|
/* IDWriteGdiInterop1::CreateFontFromLOGFONT() */
|
|
|
|
hr = IDWriteGdiInterop_QueryInterface(interop, &IID_IDWriteGdiInterop1, (void**)&interop1);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
|
|
|
logfont.lfItalic = 1;
|
|
|
|
lstrcpyW(logfont.lfFaceName, tahomaW);
|
|
|
|
|
|
|
|
hr = IDWriteGdiInterop1_CreateFontFromLOGFONT(interop1, &logfont, NULL, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
IDWriteGdiInterop1_Release(interop1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("IDWriteGdiInterop1 is not supported, skipping CreateFontFromLOGFONT() tests.\n");
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteGdiInterop_Release(interop);
|
|
|
|
ok(ref == 0, "interop is not released, %u\n", ref);
|
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory is not released, %u\n", ref);
|
2012-07-31 06:18:02 +02:00
|
|
|
}
|
|
|
|
|
2012-08-13 05:49:19 +02:00
|
|
|
static void test_CreateBitmapRenderTarget(void)
|
|
|
|
{
|
|
|
|
IDWriteBitmapRenderTarget *target, *target2;
|
2014-11-23 20:22:01 +01:00
|
|
|
IDWriteBitmapRenderTarget1 *target1;
|
2017-07-17 22:18:44 +02:00
|
|
|
IDWriteRenderingParams *params;
|
2012-08-13 05:49:19 +02:00
|
|
|
IDWriteGdiInterop *interop;
|
2017-07-17 22:18:44 +02:00
|
|
|
IDWriteFontFace *fontface;
|
2014-10-22 13:42:30 +02:00
|
|
|
IDWriteFactory *factory;
|
2017-07-17 22:18:44 +02:00
|
|
|
DWRITE_GLYPH_RUN run;
|
2014-08-01 19:11:45 +02:00
|
|
|
HBITMAP hbm, hbm2;
|
2017-07-17 22:18:44 +02:00
|
|
|
UINT16 glyphs[2];
|
2014-08-01 21:11:10 +02:00
|
|
|
DWRITE_MATRIX m;
|
2012-08-13 05:49:19 +02:00
|
|
|
DIBSECTION ds;
|
2015-08-12 20:11:35 +02:00
|
|
|
XFORM xform;
|
2015-02-20 11:50:22 +01:00
|
|
|
COLORREF c;
|
2012-08-13 05:49:19 +02:00
|
|
|
HRESULT hr;
|
2014-10-29 20:53:42 +01:00
|
|
|
FLOAT pdip;
|
2012-08-13 05:51:38 +02:00
|
|
|
SIZE size;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2017-07-17 22:18:44 +02:00
|
|
|
UINT32 ch;
|
2012-08-13 05:49:19 +02:00
|
|
|
HDC hdc;
|
|
|
|
int ret;
|
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
factory = create_factory();
|
|
|
|
|
2012-08-13 05:49:19 +02:00
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
target = NULL;
|
|
|
|
hr = IDWriteGdiInterop_CreateBitmapRenderTarget(interop, NULL, 0, 0, &target);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2016-08-09 14:59:46 +02:00
|
|
|
if (0) /* crashes on native */
|
|
|
|
hr = IDWriteBitmapRenderTarget_GetSize(target, NULL);
|
2012-08-13 05:51:38 +02:00
|
|
|
|
|
|
|
size.cx = size.cy = -1;
|
|
|
|
hr = IDWriteBitmapRenderTarget_GetSize(target, &size);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(size.cx == 0, "got %d\n", size.cx);
|
|
|
|
ok(size.cy == 0, "got %d\n", size.cy);
|
|
|
|
|
2012-08-13 05:49:19 +02:00
|
|
|
target2 = NULL;
|
|
|
|
hr = IDWriteGdiInterop_CreateBitmapRenderTarget(interop, NULL, 0, 0, &target2);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(target != target2, "got %p, %p\n", target2, target);
|
|
|
|
IDWriteBitmapRenderTarget_Release(target2);
|
|
|
|
|
|
|
|
hdc = IDWriteBitmapRenderTarget_GetMemoryDC(target);
|
|
|
|
ok(hdc != NULL, "got %p\n", hdc);
|
|
|
|
|
2015-08-12 20:11:35 +02:00
|
|
|
/* test mode */
|
|
|
|
ret = GetGraphicsMode(hdc);
|
|
|
|
ok(ret == GM_ADVANCED, "got %d\n", ret);
|
|
|
|
|
2012-08-13 05:49:19 +02:00
|
|
|
hbm = GetCurrentObject(hdc, OBJ_BITMAP);
|
|
|
|
ok(hbm != NULL, "got %p\n", hbm);
|
|
|
|
|
|
|
|
/* check DIB properties */
|
|
|
|
ret = GetObjectW(hbm, sizeof(ds), &ds);
|
|
|
|
ok(ret == sizeof(BITMAP), "got %d\n", ret);
|
|
|
|
ok(ds.dsBm.bmWidth == 1, "got %d\n", ds.dsBm.bmWidth);
|
|
|
|
ok(ds.dsBm.bmHeight == 1, "got %d\n", ds.dsBm.bmHeight);
|
|
|
|
ok(ds.dsBm.bmPlanes == 1, "got %d\n", ds.dsBm.bmPlanes);
|
|
|
|
ok(ds.dsBm.bmBitsPixel == 1, "got %d\n", ds.dsBm.bmBitsPixel);
|
|
|
|
ok(!ds.dsBm.bmBits, "got %p\n", ds.dsBm.bmBits);
|
|
|
|
|
|
|
|
IDWriteBitmapRenderTarget_Release(target);
|
|
|
|
|
|
|
|
hbm = GetCurrentObject(hdc, OBJ_BITMAP);
|
|
|
|
ok(!hbm, "got %p\n", hbm);
|
|
|
|
|
|
|
|
target = NULL;
|
|
|
|
hr = IDWriteGdiInterop_CreateBitmapRenderTarget(interop, NULL, 10, 5, &target);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hdc = IDWriteBitmapRenderTarget_GetMemoryDC(target);
|
|
|
|
ok(hdc != NULL, "got %p\n", hdc);
|
|
|
|
|
2015-02-20 11:50:22 +01:00
|
|
|
/* test context settings */
|
|
|
|
c = GetTextColor(hdc);
|
|
|
|
ok(c == RGB(0, 0, 0), "got 0x%08x\n", c);
|
|
|
|
ret = GetBkMode(hdc);
|
|
|
|
ok(ret == OPAQUE, "got %d\n", ret);
|
|
|
|
c = GetBkColor(hdc);
|
|
|
|
ok(c == RGB(255, 255, 255), "got 0x%08x\n", c);
|
|
|
|
|
2012-08-13 05:49:19 +02:00
|
|
|
hbm = GetCurrentObject(hdc, OBJ_BITMAP);
|
|
|
|
ok(hbm != NULL, "got %p\n", hbm);
|
|
|
|
|
|
|
|
/* check DIB properties */
|
|
|
|
ret = GetObjectW(hbm, sizeof(ds), &ds);
|
|
|
|
ok(ret == sizeof(ds), "got %d\n", ret);
|
|
|
|
ok(ds.dsBm.bmWidth == 10, "got %d\n", ds.dsBm.bmWidth);
|
|
|
|
ok(ds.dsBm.bmHeight == 5, "got %d\n", ds.dsBm.bmHeight);
|
|
|
|
ok(ds.dsBm.bmPlanes == 1, "got %d\n", ds.dsBm.bmPlanes);
|
|
|
|
ok(ds.dsBm.bmBitsPixel == 32, "got %d\n", ds.dsBm.bmBitsPixel);
|
|
|
|
ok(ds.dsBm.bmBits != NULL, "got %p\n", ds.dsBm.bmBits);
|
|
|
|
|
2012-08-13 05:51:38 +02:00
|
|
|
size.cx = size.cy = -1;
|
|
|
|
hr = IDWriteBitmapRenderTarget_GetSize(target, &size);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(size.cx == 10, "got %d\n", size.cx);
|
|
|
|
ok(size.cy == 5, "got %d\n", size.cy);
|
|
|
|
|
2014-08-01 19:11:45 +02:00
|
|
|
/* resize to same size */
|
|
|
|
hr = IDWriteBitmapRenderTarget_Resize(target, 10, 5);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hbm2 = GetCurrentObject(hdc, OBJ_BITMAP);
|
|
|
|
ok(hbm2 == hbm, "got %p, %p\n", hbm2, hbm);
|
|
|
|
|
|
|
|
/* shrink */
|
|
|
|
hr = IDWriteBitmapRenderTarget_Resize(target, 5, 5);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2015-07-22 10:54:53 +02:00
|
|
|
size.cx = size.cy = -1;
|
|
|
|
hr = IDWriteBitmapRenderTarget_GetSize(target, &size);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(size.cx == 5, "got %d\n", size.cx);
|
|
|
|
ok(size.cy == 5, "got %d\n", size.cy);
|
|
|
|
|
2014-08-01 19:11:45 +02:00
|
|
|
hbm2 = GetCurrentObject(hdc, OBJ_BITMAP);
|
|
|
|
ok(hbm2 != hbm, "got %p, %p\n", hbm2, hbm);
|
|
|
|
|
|
|
|
hr = IDWriteBitmapRenderTarget_Resize(target, 20, 5);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2015-07-22 10:54:53 +02:00
|
|
|
size.cx = size.cy = -1;
|
|
|
|
hr = IDWriteBitmapRenderTarget_GetSize(target, &size);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(size.cx == 20, "got %d\n", size.cx);
|
|
|
|
ok(size.cy == 5, "got %d\n", size.cy);
|
|
|
|
|
2014-08-01 19:11:45 +02:00
|
|
|
hbm2 = GetCurrentObject(hdc, OBJ_BITMAP);
|
|
|
|
ok(hbm2 != hbm, "got %p, %p\n", hbm2, hbm);
|
|
|
|
|
|
|
|
hr = IDWriteBitmapRenderTarget_Resize(target, 1, 5);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2012-08-13 05:49:19 +02:00
|
|
|
|
2015-07-22 10:54:53 +02:00
|
|
|
size.cx = size.cy = -1;
|
|
|
|
hr = IDWriteBitmapRenderTarget_GetSize(target, &size);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(size.cx == 1, "got %d\n", size.cx);
|
|
|
|
ok(size.cy == 5, "got %d\n", size.cy);
|
|
|
|
|
2014-08-01 19:11:45 +02:00
|
|
|
hbm2 = GetCurrentObject(hdc, OBJ_BITMAP);
|
|
|
|
ok(hbm2 != hbm, "got %p, %p\n", hbm2, hbm);
|
|
|
|
|
|
|
|
ret = GetObjectW(hbm2, sizeof(ds), &ds);
|
|
|
|
ok(ret == sizeof(ds), "got %d\n", ret);
|
|
|
|
ok(ds.dsBm.bmWidth == 1, "got %d\n", ds.dsBm.bmWidth);
|
|
|
|
ok(ds.dsBm.bmHeight == 5, "got %d\n", ds.dsBm.bmHeight);
|
|
|
|
ok(ds.dsBm.bmPlanes == 1, "got %d\n", ds.dsBm.bmPlanes);
|
|
|
|
ok(ds.dsBm.bmBitsPixel == 32, "got %d\n", ds.dsBm.bmBitsPixel);
|
|
|
|
ok(ds.dsBm.bmBits != NULL, "got %p\n", ds.dsBm.bmBits);
|
|
|
|
|
|
|
|
/* empty rectangle */
|
|
|
|
hr = IDWriteBitmapRenderTarget_Resize(target, 0, 5);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2015-07-22 10:54:53 +02:00
|
|
|
size.cx = size.cy = -1;
|
|
|
|
hr = IDWriteBitmapRenderTarget_GetSize(target, &size);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(size.cx == 0, "got %d\n", size.cx);
|
|
|
|
ok(size.cy == 5, "got %d\n", size.cy);
|
|
|
|
|
2014-08-01 19:11:45 +02:00
|
|
|
hbm2 = GetCurrentObject(hdc, OBJ_BITMAP);
|
|
|
|
ok(hbm2 != hbm, "got %p, %p\n", hbm2, hbm);
|
|
|
|
|
|
|
|
ret = GetObjectW(hbm2, sizeof(ds), &ds);
|
|
|
|
ok(ret == sizeof(BITMAP), "got %d\n", ret);
|
|
|
|
ok(ds.dsBm.bmWidth == 1, "got %d\n", ds.dsBm.bmWidth);
|
|
|
|
ok(ds.dsBm.bmHeight == 1, "got %d\n", ds.dsBm.bmHeight);
|
|
|
|
ok(ds.dsBm.bmPlanes == 1, "got %d\n", ds.dsBm.bmPlanes);
|
|
|
|
ok(ds.dsBm.bmBitsPixel == 1, "got %d\n", ds.dsBm.bmBitsPixel);
|
|
|
|
ok(!ds.dsBm.bmBits, "got %p\n", ds.dsBm.bmBits);
|
|
|
|
|
2015-08-12 20:11:35 +02:00
|
|
|
/* transform tests, current hdc transform is not immediately affected */
|
2016-08-09 14:59:46 +02:00
|
|
|
if (0) /* crashes on native */
|
|
|
|
hr = IDWriteBitmapRenderTarget_GetCurrentTransform(target, NULL);
|
2014-08-01 21:11:10 +02:00
|
|
|
|
|
|
|
memset(&m, 0xcc, sizeof(m));
|
|
|
|
hr = IDWriteBitmapRenderTarget_GetCurrentTransform(target, &m);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(m.m11 == 1.0 && m.m22 == 1.0 && m.m12 == 0.0 && m.m21 == 0.0, "got %.1f,%.1f,%.1f,%.1f\n", m.m11, m.m22, m.m12, m.m21);
|
2014-11-18 13:35:50 +01:00
|
|
|
ok(m.dx == 0.0 && m.dy == 0.0, "got %.1f,%.1f\n", m.dx, m.dy);
|
2015-08-12 20:11:35 +02:00
|
|
|
ret = GetWorldTransform(hdc, &xform);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(xform.eM11 == 1.0 && xform.eM22 == 1.0 && xform.eM12 == 0.0 && xform.eM21 == 0.0, "got wrong transform\n");
|
|
|
|
ok(xform.eDx == 0.0 && xform.eDy == 0.0, "got %.1f,%.1f\n", xform.eDx, xform.eDy);
|
2014-11-18 13:35:50 +01:00
|
|
|
|
|
|
|
memset(&m, 0, sizeof(m));
|
|
|
|
hr = IDWriteBitmapRenderTarget_SetCurrentTransform(target, &m);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
memset(&m, 0xcc, sizeof(m));
|
|
|
|
hr = IDWriteBitmapRenderTarget_GetCurrentTransform(target, &m);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(m.m11 == 0.0 && m.m22 == 0.0 && m.m12 == 0.0 && m.m21 == 0.0, "got %.1f,%.1f,%.1f,%.1f\n", m.m11, m.m22, m.m12, m.m21);
|
|
|
|
ok(m.dx == 0.0 && m.dy == 0.0, "got %.1f,%.1f\n", m.dx, m.dy);
|
2015-08-12 20:11:35 +02:00
|
|
|
ret = GetWorldTransform(hdc, &xform);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(xform.eM11 == 1.0 && xform.eM22 == 1.0 && xform.eM12 == 0.0 && xform.eM21 == 0.0, "got wrong transform\n");
|
|
|
|
ok(xform.eDx == 0.0 && xform.eDy == 0.0, "got %.1f,%.1f\n", xform.eDx, xform.eDy);
|
|
|
|
|
|
|
|
memset(&m, 0, sizeof(m));
|
|
|
|
m.m11 = 2.0; m.m22 = 1.0;
|
|
|
|
hr = IDWriteBitmapRenderTarget_SetCurrentTransform(target, &m);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ret = GetWorldTransform(hdc, &xform);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(xform.eM11 == 1.0 && xform.eM22 == 1.0 && xform.eM12 == 0.0 && xform.eM21 == 0.0, "got wrong transform\n");
|
|
|
|
ok(xform.eDx == 0.0 && xform.eDy == 0.0, "got %.1f,%.1f\n", xform.eDx, xform.eDy);
|
2014-11-18 13:35:50 +01:00
|
|
|
|
|
|
|
hr = IDWriteBitmapRenderTarget_SetCurrentTransform(target, NULL);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
memset(&m, 0xcc, sizeof(m));
|
|
|
|
hr = IDWriteBitmapRenderTarget_GetCurrentTransform(target, &m);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(m.m11 == 1.0 && m.m22 == 1.0 && m.m12 == 0.0 && m.m21 == 0.0, "got %.1f,%.1f,%.1f,%.1f\n", m.m11, m.m22, m.m12, m.m21);
|
2014-08-01 21:11:10 +02:00
|
|
|
ok(m.dx == 0.0 && m.dy == 0.0, "got %.1f,%.1f\n", m.dx, m.dy);
|
|
|
|
|
2014-10-29 20:53:42 +01:00
|
|
|
/* pixels per dip */
|
|
|
|
pdip = IDWriteBitmapRenderTarget_GetPixelsPerDip(target);
|
|
|
|
ok(pdip == 1.0, "got %.2f\n", pdip);
|
|
|
|
|
|
|
|
hr = IDWriteBitmapRenderTarget_SetPixelsPerDip(target, 2.0);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteBitmapRenderTarget_SetPixelsPerDip(target, -1.0);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteBitmapRenderTarget_SetPixelsPerDip(target, 0.0);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
pdip = IDWriteBitmapRenderTarget_GetPixelsPerDip(target);
|
|
|
|
ok(pdip == 2.0, "got %.2f\n", pdip);
|
|
|
|
|
2014-11-23 20:22:01 +01:00
|
|
|
hr = IDWriteBitmapRenderTarget_QueryInterface(target, &IID_IDWriteBitmapRenderTarget1, (void**)&target1);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
DWRITE_TEXT_ANTIALIAS_MODE mode;
|
|
|
|
|
|
|
|
mode = IDWriteBitmapRenderTarget1_GetTextAntialiasMode(target1);
|
|
|
|
ok(mode == DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE, "got %d\n", mode);
|
|
|
|
|
|
|
|
hr = IDWriteBitmapRenderTarget1_SetTextAntialiasMode(target1, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE+1);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
mode = IDWriteBitmapRenderTarget1_GetTextAntialiasMode(target1);
|
|
|
|
ok(mode == DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE, "got %d\n", mode);
|
|
|
|
|
|
|
|
hr = IDWriteBitmapRenderTarget1_SetTextAntialiasMode(target1, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
mode = IDWriteBitmapRenderTarget1_GetTextAntialiasMode(target1);
|
|
|
|
ok(mode == DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE, "got %d\n", mode);
|
|
|
|
|
|
|
|
IDWriteBitmapRenderTarget1_Release(target1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("IDWriteBitmapRenderTarget1 is not supported.\n");
|
|
|
|
|
2017-07-17 22:18:44 +02:00
|
|
|
/* DrawGlyphRun() argument validation. */
|
|
|
|
hr = IDWriteBitmapRenderTarget_Resize(target, 16, 16);
|
|
|
|
ok(hr == S_OK, "Failed to resize target, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
fontface = create_fontface(factory);
|
|
|
|
|
|
|
|
ch = 'A';
|
|
|
|
glyphs[0] = 0;
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(fontface, &ch, 1, glyphs);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(glyphs[0] > 0, "got %u\n", glyphs[0]);
|
|
|
|
glyphs[1] = glyphs[0];
|
|
|
|
|
|
|
|
memset(&run, 0, sizeof(run));
|
|
|
|
run.fontFace = fontface;
|
|
|
|
run.fontEmSize = 12.0f;
|
|
|
|
run.glyphCount = 2;
|
|
|
|
run.glyphIndices = glyphs;
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateCustomRenderingParams(factory, 1.0f, 0.0f, 0.0f, DWRITE_PIXEL_GEOMETRY_FLAT,
|
|
|
|
DWRITE_RENDERING_MODE_DEFAULT, ¶ms);
|
|
|
|
ok(hr == S_OK, "Failed to create rendering params, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteBitmapRenderTarget_DrawGlyphRun(target, 0.0f, 0.0f, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
&run, NULL, RGB(255, 0, 0), NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteBitmapRenderTarget_DrawGlyphRun(target, 0.0f, 0.0f, DWRITE_MEASURING_MODE_GDI_NATURAL + 1,
|
|
|
|
&run, NULL, RGB(255, 0, 0), NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteBitmapRenderTarget_DrawGlyphRun(target, 0.0f, 0.0f, DWRITE_MEASURING_MODE_GDI_NATURAL + 1,
|
|
|
|
&run, params, RGB(255, 0, 0), NULL);
|
|
|
|
ok(hr == E_INVALIDARG || broken(hr == S_OK) /* Vista */, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteBitmapRenderTarget_DrawGlyphRun(target, 0.0f, 0.0f, DWRITE_MEASURING_MODE_GDI_NATURAL,
|
|
|
|
&run, params, RGB(255, 0, 0), NULL);
|
|
|
|
ok(hr == S_OK, "Failed to draw a run, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
IDWriteRenderingParams_Release(params);
|
|
|
|
|
|
|
|
/* Zero sized target returns earlier. */
|
|
|
|
hr = IDWriteBitmapRenderTarget_Resize(target, 0, 16);
|
|
|
|
ok(hr == S_OK, "Failed to resize target, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteBitmapRenderTarget_DrawGlyphRun(target, 0.0f, 0.0f, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
&run, NULL, RGB(255, 0, 0), NULL);
|
|
|
|
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteBitmapRenderTarget_DrawGlyphRun(target, 0.0f, 0.0f, DWRITE_MEASURING_MODE_GDI_NATURAL + 1,
|
|
|
|
&run, params, RGB(255, 0, 0), NULL);
|
|
|
|
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteBitmapRenderTarget_Release(target);
|
|
|
|
ok(ref == 0, "render target not released, %u\n", ref);
|
|
|
|
ref = IDWriteGdiInterop_Release(interop);
|
|
|
|
ok(ref == 0, "interop not released, %u\n", ref);
|
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2012-08-13 05:49:19 +02:00
|
|
|
}
|
|
|
|
|
2012-08-25 11:11:31 +02:00
|
|
|
static void test_GetFontFamily(void)
|
|
|
|
{
|
2014-10-19 21:57:53 +02:00
|
|
|
IDWriteFontCollection *collection, *collection2;
|
|
|
|
IDWriteFontCollection *syscoll;
|
2012-08-25 11:11:31 +02:00
|
|
|
IDWriteFontFamily *family, *family2;
|
2016-03-08 20:46:51 +01:00
|
|
|
IDWriteFontFamily1 *family1;
|
2012-08-25 11:11:31 +02:00
|
|
|
IDWriteGdiInterop *interop;
|
2014-10-19 21:57:53 +02:00
|
|
|
IDWriteFont *font, *font2;
|
2014-10-22 13:42:30 +02:00
|
|
|
IDWriteFactory *factory;
|
2012-08-25 11:11:31 +02:00
|
|
|
LOGFONTW logfont;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2012-08-25 11:11:31 +02:00
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
factory = create_factory();
|
|
|
|
|
2012-08-25 11:11:31 +02:00
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2014-10-19 21:57:53 +02:00
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &syscoll, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2012-08-25 11:11:31 +02:00
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
|
|
|
logfont.lfItalic = 1;
|
2012-10-16 18:56:23 +02:00
|
|
|
lstrcpyW(logfont.lfFaceName, tahomaW);
|
2012-08-25 11:11:31 +02:00
|
|
|
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
|
2014-10-19 21:57:53 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(font2 != font, "got %p, %p\n", font2, font);
|
2012-08-25 11:11:31 +02:00
|
|
|
|
|
|
|
if (0) /* crashes on native */
|
|
|
|
hr = IDWriteFont_GetFontFamily(font, NULL);
|
|
|
|
|
|
|
|
EXPECT_REF(font, 1);
|
|
|
|
hr = IDWriteFont_GetFontFamily(font, &family);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
EXPECT_REF(font, 1);
|
|
|
|
EXPECT_REF(family, 2);
|
|
|
|
|
|
|
|
hr = IDWriteFont_GetFontFamily(font, &family2);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
ok(family2 == family, "got %p, previous %p\n", family2, family);
|
|
|
|
EXPECT_REF(font, 1);
|
|
|
|
EXPECT_REF(family, 3);
|
|
|
|
IDWriteFontFamily_Release(family2);
|
|
|
|
|
|
|
|
hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFontFamily, (void**)&family2);
|
|
|
|
EXPECT_HR(hr, E_NOINTERFACE);
|
|
|
|
ok(family2 == NULL, "got %p\n", family2);
|
|
|
|
|
2014-10-19 21:57:53 +02:00
|
|
|
hr = IDWriteFont_GetFontFamily(font2, &family2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(family2 != family, "got %p, %p\n", family2, family);
|
|
|
|
|
|
|
|
collection = NULL;
|
|
|
|
hr = IDWriteFontFamily_GetFontCollection(family, &collection);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
collection2 = NULL;
|
|
|
|
hr = IDWriteFontFamily_GetFontCollection(family2, &collection2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(collection == collection2, "got %p, %p\n", collection, collection2);
|
|
|
|
ok(collection == syscoll, "got %p, %p\n", collection, syscoll);
|
|
|
|
|
2016-03-08 20:46:51 +01:00
|
|
|
IDWriteFont_Release(font);
|
|
|
|
IDWriteFont_Release(font2);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_QueryInterface(family, &IID_IDWriteFontFamily1, (void**)&family1);
|
|
|
|
if (hr == S_OK) {
|
2016-05-05 23:34:03 +02:00
|
|
|
IDWriteFontFaceReference *ref, *ref1;
|
2018-05-21 22:11:02 +02:00
|
|
|
IDWriteFontList1 *fontlist1;
|
2016-03-08 20:46:55 +01:00
|
|
|
IDWriteFontList *fontlist;
|
2016-03-08 20:46:51 +01:00
|
|
|
IDWriteFont3 *font3;
|
|
|
|
IDWriteFont1 *font1;
|
|
|
|
|
|
|
|
font3 = (void*)0xdeadbeef;
|
|
|
|
hr = IDWriteFontFamily1_GetFont(family1, ~0u, &font3);
|
|
|
|
ok(hr == E_FAIL, "got 0x%08x\n", hr);
|
|
|
|
ok(font3 == NULL, "got %p\n", font3);
|
2016-03-08 20:46:52 +01:00
|
|
|
|
2016-03-08 20:46:51 +01:00
|
|
|
hr = IDWriteFontFamily1_GetFont(family1, 0, &font3);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFont3_QueryInterface(font3, &IID_IDWriteFont, (void**)&font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
hr = IDWriteFont3_QueryInterface(font3, &IID_IDWriteFont1, (void**)&font1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFont1_Release(font1);
|
|
|
|
|
2018-05-21 22:11:02 +02:00
|
|
|
hr = IDWriteFontFamily1_QueryInterface(family1, &IID_IDWriteFontList1, (void **)&fontlist1);
|
|
|
|
ok(hr == S_OK || broken(hr == E_NOINTERFACE), "Failed to get interface, hr %#x.\n", hr);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
hr = IDWriteFontFamily1_QueryInterface(family1, &IID_IDWriteFontList, (void **)&fontlist);
|
|
|
|
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
|
|
|
ok(fontlist == (IDWriteFontList *)fontlist1, "Unexpected interface pointer.\n");
|
|
|
|
ok(fontlist != (IDWriteFontList *)family1, "Unexpected interface pointer.\n");
|
|
|
|
ok(fontlist != (IDWriteFontList *)family, "Unexpected interface pointer.\n");
|
|
|
|
IDWriteFontList1_Release(fontlist1);
|
|
|
|
IDWriteFontList_Release(fontlist);
|
|
|
|
}
|
2016-03-08 20:46:55 +01:00
|
|
|
|
|
|
|
hr = IDWriteFontFamily1_QueryInterface(family1, &IID_IDWriteFontList, (void**)&fontlist);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontList_Release(fontlist);
|
|
|
|
|
2016-03-08 20:46:51 +01:00
|
|
|
IDWriteFont3_Release(font3);
|
2016-05-05 23:34:03 +02:00
|
|
|
|
|
|
|
hr = IDWriteFontFamily1_GetFontFaceReference(family1, 0, &ref);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily1_GetFontFaceReference(family1, 0, &ref1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(ref != ref1, "got %p, %p\n", ref, ref1);
|
|
|
|
|
|
|
|
IDWriteFontFaceReference_Release(ref);
|
|
|
|
IDWriteFontFaceReference_Release(ref1);
|
|
|
|
|
2016-03-08 20:46:51 +01:00
|
|
|
IDWriteFontFamily1_Release(family1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("IDWriteFontFamily1 is not supported.\n");
|
|
|
|
|
2014-10-19 21:57:53 +02:00
|
|
|
IDWriteFontCollection_Release(syscoll);
|
|
|
|
IDWriteFontCollection_Release(collection2);
|
|
|
|
IDWriteFontCollection_Release(collection);
|
|
|
|
IDWriteFontFamily_Release(family2);
|
2012-08-25 11:11:31 +02:00
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
IDWriteGdiInterop_Release(interop);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2012-08-25 11:11:31 +02:00
|
|
|
}
|
|
|
|
|
2012-10-07 19:11:04 +02:00
|
|
|
static void test_GetFamilyNames(void)
|
|
|
|
{
|
|
|
|
IDWriteFontFamily *family;
|
|
|
|
IDWriteLocalizedStrings *names, *names2;
|
|
|
|
IDWriteGdiInterop *interop;
|
2014-10-22 13:42:30 +02:00
|
|
|
IDWriteFactory *factory;
|
2012-10-07 19:11:04 +02:00
|
|
|
IDWriteFont *font;
|
|
|
|
LOGFONTW logfont;
|
2012-10-08 00:43:15 +02:00
|
|
|
WCHAR buffer[100];
|
2012-10-07 19:11:04 +02:00
|
|
|
HRESULT hr;
|
2012-10-07 23:25:23 +02:00
|
|
|
UINT32 len;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2012-10-07 19:11:04 +02:00
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
factory = create_factory();
|
|
|
|
|
2012-10-07 19:11:04 +02:00
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
|
|
|
logfont.lfItalic = 1;
|
2012-10-16 18:56:23 +02:00
|
|
|
lstrcpyW(logfont.lfFaceName, tahomaW);
|
2012-10-07 19:11:04 +02:00
|
|
|
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IDWriteFont_GetFontFamily(font, &family);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
2016-08-09 14:59:46 +02:00
|
|
|
if (0) /* crashes on native */
|
|
|
|
hr = IDWriteFontFamily_GetFamilyNames(family, NULL);
|
2012-10-07 19:11:04 +02:00
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFamilyNames(family, &names);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
EXPECT_REF(names, 1);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFamilyNames(family, &names2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
EXPECT_REF(names2, 1);
|
|
|
|
ok(names != names2, "got %p, was %p\n", names2, names);
|
|
|
|
|
|
|
|
IDWriteLocalizedStrings_Release(names2);
|
|
|
|
|
2012-10-07 23:25:23 +02:00
|
|
|
/* GetStringLength */
|
2016-08-09 14:59:46 +02:00
|
|
|
if (0) /* crashes on native */
|
|
|
|
hr = IDWriteLocalizedStrings_GetStringLength(names, 0, NULL);
|
2012-10-07 23:25:23 +02:00
|
|
|
|
2012-10-08 00:43:15 +02:00
|
|
|
len = 100;
|
|
|
|
hr = IDWriteLocalizedStrings_GetStringLength(names, 10, &len);
|
|
|
|
ok(hr == E_FAIL, "got 0x%08x\n", hr);
|
|
|
|
ok(len == (UINT32)-1, "got %u\n", len);
|
|
|
|
|
2012-10-07 23:25:23 +02:00
|
|
|
len = 0;
|
|
|
|
hr = IDWriteLocalizedStrings_GetStringLength(names, 0, &len);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(len > 0, "got %u\n", len);
|
|
|
|
|
2012-10-08 00:43:15 +02:00
|
|
|
/* GetString */
|
|
|
|
hr = IDWriteLocalizedStrings_GetString(names, 0, NULL, 0);
|
|
|
|
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteLocalizedStrings_GetString(names, 10, NULL, 0);
|
2012-10-07 23:25:23 +02:00
|
|
|
ok(hr == E_FAIL, "got 0x%08x\n", hr);
|
2012-10-08 00:43:15 +02:00
|
|
|
|
2016-08-09 14:59:46 +02:00
|
|
|
if (0)
|
|
|
|
hr = IDWriteLocalizedStrings_GetString(names, 0, NULL, 100);
|
2012-10-08 00:43:15 +02:00
|
|
|
|
|
|
|
buffer[0] = 1;
|
|
|
|
hr = IDWriteLocalizedStrings_GetString(names, 10, buffer, 100);
|
|
|
|
ok(hr == E_FAIL, "got 0x%08x\n", hr);
|
|
|
|
ok(buffer[0] == 0, "got %x\n", buffer[0]);
|
|
|
|
|
|
|
|
buffer[0] = 1;
|
|
|
|
hr = IDWriteLocalizedStrings_GetString(names, 0, buffer, len-1);
|
|
|
|
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr);
|
|
|
|
ok(buffer[0] == 0, "got %x\n", buffer[0]);
|
|
|
|
|
|
|
|
buffer[0] = 1;
|
|
|
|
hr = IDWriteLocalizedStrings_GetString(names, 0, buffer, len);
|
|
|
|
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr);
|
|
|
|
ok(buffer[0] == 0, "got %x\n", buffer[0]);
|
|
|
|
|
|
|
|
buffer[0] = 0;
|
|
|
|
hr = IDWriteLocalizedStrings_GetString(names, 0, buffer, len+1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(buffer[0] != 0, "got %x\n", buffer[0]);
|
2012-10-07 23:25:23 +02:00
|
|
|
|
|
|
|
IDWriteLocalizedStrings_Release(names);
|
|
|
|
|
2012-10-07 19:11:04 +02:00
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
IDWriteGdiInterop_Release(interop);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2012-10-07 19:11:04 +02:00
|
|
|
}
|
|
|
|
|
2012-10-07 21:03:52 +02:00
|
|
|
static void test_CreateFontFace(void)
|
|
|
|
{
|
|
|
|
IDWriteFontFace *fontface, *fontface2;
|
2014-10-22 09:06:15 +02:00
|
|
|
IDWriteFontCollection *collection;
|
2014-12-11 10:33:29 +01:00
|
|
|
DWRITE_FONT_FILE_TYPE file_type;
|
|
|
|
DWRITE_FONT_FACE_TYPE face_type;
|
2012-10-07 21:03:52 +02:00
|
|
|
IDWriteGdiInterop *interop;
|
2014-10-22 09:06:15 +02:00
|
|
|
IDWriteFont *font, *font2;
|
|
|
|
IDWriteFontFamily *family;
|
2014-10-22 13:42:30 +02:00
|
|
|
IDWriteFactory *factory;
|
2014-12-11 10:33:29 +01:00
|
|
|
IDWriteFontFile *file;
|
2012-10-07 21:03:52 +02:00
|
|
|
LOGFONTW logfont;
|
2014-12-11 10:33:29 +01:00
|
|
|
BOOL supported;
|
|
|
|
UINT32 count;
|
2015-02-24 06:05:05 +01:00
|
|
|
WCHAR *path;
|
2012-10-07 21:03:52 +02:00
|
|
|
HRESULT hr;
|
2018-12-14 01:05:26 +01:00
|
|
|
ULONG ref;
|
2012-10-07 21:03:52 +02:00
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
factory = create_factory();
|
|
|
|
|
2012-10-07 21:03:52 +02:00
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
|
|
|
logfont.lfItalic = 1;
|
2012-10-16 18:56:23 +02:00
|
|
|
lstrcpyW(logfont.lfFaceName, tahomaW);
|
2012-10-07 21:03:52 +02:00
|
|
|
|
2014-10-22 09:06:15 +02:00
|
|
|
font = NULL;
|
2012-10-07 21:03:52 +02:00
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2014-10-22 09:06:15 +02:00
|
|
|
font2 = NULL;
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(font != font2, "got %p, %p\n", font, font2);
|
|
|
|
|
2012-10-07 21:03:52 +02:00
|
|
|
hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFontFace, (void**)&fontface);
|
|
|
|
ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
|
|
|
|
|
2016-08-09 14:59:46 +02:00
|
|
|
if (0) /* crashes on native */
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, NULL);
|
2012-10-07 21:03:52 +02:00
|
|
|
|
2014-10-22 09:06:15 +02:00
|
|
|
fontface = NULL;
|
2012-10-07 21:03:52 +02:00
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2014-10-22 09:06:15 +02:00
|
|
|
fontface2 = NULL;
|
2012-10-07 21:03:52 +02:00
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(fontface == fontface2, "got %p, was %p\n", fontface2, fontface);
|
2014-10-22 09:06:15 +02:00
|
|
|
IDWriteFontFace_Release(fontface2);
|
|
|
|
|
|
|
|
fontface2 = NULL;
|
|
|
|
hr = IDWriteFont_CreateFontFace(font2, &fontface2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(fontface == fontface2, "got %p, was %p\n", fontface2, fontface);
|
|
|
|
IDWriteFontFace_Release(fontface2);
|
|
|
|
|
|
|
|
IDWriteFont_Release(font2);
|
2014-10-16 05:29:31 +02:00
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFont, (void**)&font);
|
|
|
|
ok(hr == E_NOINTERFACE || broken(hr == E_NOTIMPL), "got 0x%08x\n", hr);
|
2012-10-07 21:03:52 +02:00
|
|
|
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
IDWriteGdiInterop_Release(interop);
|
2014-10-22 09:06:15 +02:00
|
|
|
|
|
|
|
/* Create from system collection */
|
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
font = NULL;
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
|
|
|
|
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
font2 = NULL;
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
|
|
|
|
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &font2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(font != font2, "got %p, %p\n", font, font2);
|
|
|
|
|
|
|
|
fontface = NULL;
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
fontface2 = NULL;
|
|
|
|
hr = IDWriteFont_CreateFontFace(font2, &fontface2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(fontface == fontface2, "got %p, was %p\n", fontface2, fontface);
|
|
|
|
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
IDWriteFontFace_Release(fontface2);
|
|
|
|
IDWriteFont_Release(font2);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
IDWriteFontCollection_Release(collection);
|
2018-12-14 01:05:26 +01:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u.\n", ref);
|
2014-12-11 10:33:29 +01:00
|
|
|
|
|
|
|
/* IDWriteFactory::CreateFontFace() */
|
2015-02-24 06:05:05 +01:00
|
|
|
path = create_testfontfile(test_fontfile);
|
2014-12-11 10:33:29 +01:00
|
|
|
factory = create_factory();
|
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
|
2014-12-11 10:33:29 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n",hr);
|
|
|
|
|
|
|
|
supported = FALSE;
|
|
|
|
file_type = DWRITE_FONT_FILE_TYPE_UNKNOWN;
|
|
|
|
face_type = DWRITE_FONT_FACE_TYPE_CFF;
|
|
|
|
count = 0;
|
|
|
|
hr = IDWriteFontFile_Analyze(file, &supported, &file_type, &face_type, &count);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(supported == TRUE, "got %i\n", supported);
|
|
|
|
ok(file_type == DWRITE_FONT_FILE_TYPE_TRUETYPE, "got %i\n", file_type);
|
|
|
|
ok(face_type == DWRITE_FONT_FACE_TYPE_TRUETYPE, "got %i\n", face_type);
|
|
|
|
ok(count == 1, "got %i\n", count);
|
|
|
|
|
2016-05-05 13:35:24 +02:00
|
|
|
/* invalid simulation flags */
|
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_CFF, 1, &file, 0, ~0u, &fontface);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_CFF, 1, &file, 0, 0xf, &fontface);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
2014-12-11 10:33:29 +01:00
|
|
|
/* try mismatching face type, the one that's not supported */
|
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_CFF, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
|
|
|
|
ok(hr == DWRITE_E_FILEFORMAT, "got 0x%08x\n", hr);
|
|
|
|
|
2016-11-05 22:12:37 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_OPENTYPE_COLLECTION, 1, &file, 0,
|
2014-12-11 10:33:29 +01:00
|
|
|
DWRITE_FONT_SIMULATIONS_NONE, &fontface);
|
2015-09-04 11:15:41 +02:00
|
|
|
ok(hr == DWRITE_E_FILEFORMAT || broken(hr == E_FAIL) /* < win10 */, "got 0x%08x\n", hr);
|
2014-12-11 10:33:29 +01:00
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_RAW_CFF, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
|
|
|
|
todo_wine
|
|
|
|
ok(hr == DWRITE_E_UNSUPPORTEDOPERATION || broken(hr == E_INVALIDARG) /* older versions */, "got 0x%08x\n", hr);
|
|
|
|
|
2016-01-28 21:27:20 +01:00
|
|
|
fontface = (void*)0xdeadbeef;
|
2014-12-11 10:33:29 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TYPE1, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2016-01-28 21:27:20 +01:00
|
|
|
ok(fontface == NULL, "got %p\n", fontface);
|
2014-12-11 10:33:29 +01:00
|
|
|
|
2016-01-28 21:27:20 +01:00
|
|
|
fontface = (void*)0xdeadbeef;
|
2014-12-11 10:33:29 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_VECTOR, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2016-01-28 21:27:20 +01:00
|
|
|
ok(fontface == NULL, "got %p\n", fontface);
|
2014-12-11 10:33:29 +01:00
|
|
|
|
2016-01-28 21:27:20 +01:00
|
|
|
fontface = (void*)0xdeadbeef;
|
2014-12-11 10:33:29 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_BITMAP, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2016-01-28 21:27:20 +01:00
|
|
|
ok(fontface == NULL, "got %p\n", fontface);
|
2014-12-11 10:33:29 +01:00
|
|
|
|
2016-01-28 21:27:20 +01:00
|
|
|
fontface = NULL;
|
2014-12-11 10:33:29 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_UNKNOWN, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
|
2015-09-04 11:16:08 +02:00
|
|
|
todo_wine
|
|
|
|
ok(hr == S_OK || broken(hr == E_INVALIDARG) /* < win10 */, "got 0x%08x\n", hr);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
ok(fontface != NULL, "got %p\n", fontface);
|
|
|
|
face_type = IDWriteFontFace_GetType(fontface);
|
|
|
|
ok(face_type == DWRITE_FONT_FACE_TYPE_TRUETYPE, "got %d\n", face_type);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
}
|
2014-12-11 10:33:29 +01:00
|
|
|
|
|
|
|
IDWriteFontFile_Release(file);
|
2018-12-14 01:05:26 +01:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u.\n", ref);
|
2015-02-24 06:05:05 +01:00
|
|
|
DELETE_FONTFILE(path);
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2016-04-13 06:02:12 +02:00
|
|
|
static void get_expected_font_metrics(IDWriteFontFace *fontface, DWRITE_FONT_METRICS1 *metrics)
|
2016-04-10 22:59:10 +02:00
|
|
|
{
|
2016-04-18 05:47:13 +02:00
|
|
|
void *os2_context, *head_context, *post_context, *hhea_context;
|
2016-04-10 22:59:10 +02:00
|
|
|
const TT_OS2_V2 *tt_os2;
|
|
|
|
const TT_HEAD *tt_head;
|
|
|
|
const TT_POST *tt_post;
|
2016-04-18 05:47:13 +02:00
|
|
|
const TT_HHEA *tt_hhea;
|
2016-04-10 22:59:10 +02:00
|
|
|
UINT32 size;
|
|
|
|
BOOL exists;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
memset(metrics, 0, sizeof(*metrics));
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_TryGetFontTable(fontface, MS_0S2_TAG, (const void**)&tt_os2, &size, &os2_context, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
hr = IDWriteFontFace_TryGetFontTable(fontface, MS_HEAD_TAG, (const void**)&tt_head, &size, &head_context, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2016-04-18 05:47:13 +02:00
|
|
|
hr = IDWriteFontFace_TryGetFontTable(fontface, MS_HHEA_TAG, (const void**)&tt_hhea, &size, &hhea_context, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2016-04-10 22:59:10 +02:00
|
|
|
hr = IDWriteFontFace_TryGetFontTable(fontface, MS_POST_TAG, (const void**)&tt_post, &size, &post_context, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2016-04-14 18:10:31 +02:00
|
|
|
if (tt_head) {
|
2016-04-10 22:59:10 +02:00
|
|
|
metrics->designUnitsPerEm = GET_BE_WORD(tt_head->unitsPerEm);
|
2016-04-14 18:10:31 +02:00
|
|
|
metrics->glyphBoxLeft = GET_BE_WORD(tt_head->xMin);
|
|
|
|
metrics->glyphBoxTop = GET_BE_WORD(tt_head->yMax);
|
|
|
|
metrics->glyphBoxRight = GET_BE_WORD(tt_head->xMax);
|
|
|
|
metrics->glyphBoxBottom = GET_BE_WORD(tt_head->yMin);
|
|
|
|
}
|
2016-04-10 22:59:10 +02:00
|
|
|
|
|
|
|
if (tt_os2) {
|
2016-04-13 06:02:12 +02:00
|
|
|
if (GET_BE_WORD(tt_os2->fsSelection) & OS2_FSSELECTION_USE_TYPO_METRICS) {
|
|
|
|
SHORT descent = GET_BE_WORD(tt_os2->sTypoDescender);
|
|
|
|
metrics->ascent = GET_BE_WORD(tt_os2->sTypoAscender);
|
|
|
|
metrics->descent = descent < 0 ? -descent : 0;
|
2016-04-18 05:47:13 +02:00
|
|
|
metrics->lineGap = GET_BE_WORD(tt_os2->sTypoLineGap);
|
2016-04-13 06:02:12 +02:00
|
|
|
metrics->hasTypographicMetrics = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
metrics->ascent = GET_BE_WORD(tt_os2->usWinAscent);
|
|
|
|
/* Some fonts have usWinDescent value stored as signed short, which could be wrongly
|
|
|
|
interpreted as large unsigned value. */
|
|
|
|
metrics->descent = abs((SHORT)GET_BE_WORD(tt_os2->usWinDescent));
|
2016-04-18 05:47:13 +02:00
|
|
|
|
|
|
|
if (tt_hhea) {
|
|
|
|
SHORT descender = (SHORT)GET_BE_WORD(tt_hhea->descender);
|
|
|
|
INT32 linegap;
|
|
|
|
|
|
|
|
linegap = GET_BE_WORD(tt_hhea->ascender) + abs(descender) + GET_BE_WORD(tt_hhea->linegap) -
|
|
|
|
metrics->ascent - metrics->descent;
|
|
|
|
metrics->lineGap = linegap > 0 ? linegap : 0;
|
|
|
|
}
|
2016-04-13 06:02:12 +02:00
|
|
|
}
|
|
|
|
|
2016-04-10 22:59:10 +02:00
|
|
|
metrics->strikethroughPosition = GET_BE_WORD(tt_os2->yStrikeoutPosition);
|
|
|
|
metrics->strikethroughThickness = GET_BE_WORD(tt_os2->yStrikeoutSize);
|
2016-04-14 22:22:56 +02:00
|
|
|
|
|
|
|
metrics->subscriptPositionX = GET_BE_WORD(tt_os2->ySubscriptXOffset);
|
|
|
|
metrics->subscriptPositionY = -GET_BE_WORD(tt_os2->ySubscriptYOffset);
|
|
|
|
metrics->subscriptSizeX = GET_BE_WORD(tt_os2->ySubscriptXSize);
|
|
|
|
metrics->subscriptSizeY = GET_BE_WORD(tt_os2->ySubscriptYSize);
|
|
|
|
metrics->superscriptPositionX = GET_BE_WORD(tt_os2->ySuperscriptXOffset);
|
|
|
|
metrics->superscriptPositionY = GET_BE_WORD(tt_os2->ySuperscriptYOffset);
|
|
|
|
metrics->superscriptSizeX = GET_BE_WORD(tt_os2->ySuperscriptXSize);
|
|
|
|
metrics->superscriptSizeY = GET_BE_WORD(tt_os2->ySuperscriptYSize);
|
2016-04-10 22:59:10 +02:00
|
|
|
}
|
2018-11-11 07:55:00 +01:00
|
|
|
else {
|
|
|
|
metrics->strikethroughPosition = metrics->designUnitsPerEm / 3;
|
|
|
|
if (tt_hhea) {
|
|
|
|
metrics->ascent = GET_BE_WORD(tt_hhea->ascender);
|
|
|
|
metrics->descent = abs((SHORT)GET_BE_WORD(tt_hhea->descender));
|
|
|
|
}
|
|
|
|
}
|
2016-04-10 22:59:10 +02:00
|
|
|
|
|
|
|
if (tt_post) {
|
|
|
|
metrics->underlinePosition = GET_BE_WORD(tt_post->underlinePosition);
|
|
|
|
metrics->underlineThickness = GET_BE_WORD(tt_post->underlineThickness);
|
|
|
|
}
|
|
|
|
|
2016-12-20 10:37:03 +01:00
|
|
|
if (metrics->underlineThickness == 0)
|
2016-04-10 22:59:10 +02:00
|
|
|
metrics->underlineThickness = metrics->designUnitsPerEm / 14;
|
2016-12-20 10:37:03 +01:00
|
|
|
if (metrics->strikethroughThickness == 0)
|
|
|
|
metrics->strikethroughThickness = metrics->underlineThickness;
|
2016-04-10 22:59:10 +02:00
|
|
|
|
|
|
|
if (tt_os2)
|
|
|
|
IDWriteFontFace_ReleaseFontTable(fontface, os2_context);
|
|
|
|
if (tt_head)
|
|
|
|
IDWriteFontFace_ReleaseFontTable(fontface, head_context);
|
2016-04-18 05:47:13 +02:00
|
|
|
if (tt_hhea)
|
|
|
|
IDWriteFontFace_ReleaseFontTable(fontface, hhea_context);
|
2016-04-10 22:59:10 +02:00
|
|
|
if (tt_post)
|
|
|
|
IDWriteFontFace_ReleaseFontTable(fontface, post_context);
|
|
|
|
}
|
|
|
|
|
2018-11-11 07:55:00 +01:00
|
|
|
static void check_font_metrics(const WCHAR *nameW, IDWriteFontFace *fontface, const DWRITE_FONT_METRICS1 *expected)
|
2016-04-10 22:59:10 +02:00
|
|
|
{
|
2018-11-11 07:55:00 +01:00
|
|
|
IDWriteFontFace1 *fontface1 = NULL;
|
|
|
|
DWRITE_FONT_METRICS1 metrics;
|
|
|
|
DWORD simulations;
|
|
|
|
BOOL has_metrics1;
|
|
|
|
|
|
|
|
has_metrics1 = SUCCEEDED(IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void **)&fontface1));
|
|
|
|
simulations = IDWriteFontFace_GetSimulations(fontface);
|
|
|
|
|
|
|
|
if (fontface1) {
|
|
|
|
IDWriteFontFace1_GetMetrics(fontface1, &metrics);
|
|
|
|
IDWriteFontFace1_Release(fontface1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
IDWriteFontFace_GetMetrics(fontface, (DWRITE_FONT_METRICS *)&metrics);
|
|
|
|
|
|
|
|
ok(metrics.designUnitsPerEm == expected->designUnitsPerEm, "font %s: designUnitsPerEm %u, expected %u\n",
|
|
|
|
wine_dbgstr_w(nameW), metrics.designUnitsPerEm, expected->designUnitsPerEm);
|
|
|
|
ok(metrics.ascent == expected->ascent, "font %s: ascent %u, expected %u\n", wine_dbgstr_w(nameW), metrics.ascent,
|
2016-04-13 06:02:12 +02:00
|
|
|
expected->ascent);
|
2018-11-11 07:55:00 +01:00
|
|
|
ok(metrics.descent == expected->descent, "font %s: descent %u, expected %u\n", wine_dbgstr_w(nameW),
|
|
|
|
metrics.descent, expected->descent);
|
|
|
|
ok(metrics.lineGap == expected->lineGap, "font %s: lineGap %d, expected %d\n", wine_dbgstr_w(nameW),
|
|
|
|
metrics.lineGap, expected->lineGap);
|
|
|
|
ok(metrics.underlinePosition == expected->underlinePosition, "font %s: underlinePosition %d, expected %d\n",
|
|
|
|
wine_dbgstr_w(nameW), metrics.underlinePosition, expected->underlinePosition);
|
|
|
|
ok(metrics.underlineThickness == expected->underlineThickness, "font %s: underlineThickness %u, "
|
|
|
|
"expected %u\n", wine_dbgstr_w(nameW), metrics.underlineThickness, expected->underlineThickness);
|
|
|
|
ok(metrics.strikethroughPosition == expected->strikethroughPosition, "font %s: strikethroughPosition %d, expected %d\n",
|
|
|
|
wine_dbgstr_w(nameW), metrics.strikethroughPosition, expected->strikethroughPosition);
|
|
|
|
ok(metrics.strikethroughThickness == expected->strikethroughThickness, "font %s: strikethroughThickness %u, "
|
|
|
|
"expected %u\n", wine_dbgstr_w(nameW), metrics.strikethroughThickness, expected->strikethroughThickness);
|
2016-04-13 06:02:12 +02:00
|
|
|
|
|
|
|
if (has_metrics1) {
|
2018-11-11 07:55:00 +01:00
|
|
|
/* For simulated faces metrics are adjusted. Enable tests when exact pattern is understood. */
|
|
|
|
if (simulations & DWRITE_FONT_SIMULATIONS_OBLIQUE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ok(metrics.hasTypographicMetrics == expected->hasTypographicMetrics, "font %s: hasTypographicMetrics %d, "
|
|
|
|
"expected %d\n", wine_dbgstr_w(nameW), metrics.hasTypographicMetrics, expected->hasTypographicMetrics);
|
|
|
|
ok(metrics.glyphBoxLeft == expected->glyphBoxLeft, "font %s: glyphBoxLeft %d, expected %d\n",
|
|
|
|
wine_dbgstr_w(nameW), metrics.glyphBoxLeft, expected->glyphBoxLeft);
|
|
|
|
ok(metrics.glyphBoxTop == expected->glyphBoxTop, "font %s: glyphBoxTop %d, expected %d\n",
|
|
|
|
wine_dbgstr_w(nameW), metrics.glyphBoxTop, expected->glyphBoxTop);
|
|
|
|
ok(metrics.glyphBoxRight == expected->glyphBoxRight, "font %s: glyphBoxRight %d, expected %d\n",
|
|
|
|
wine_dbgstr_w(nameW), metrics.glyphBoxRight, expected->glyphBoxRight);
|
|
|
|
ok(metrics.glyphBoxBottom == expected->glyphBoxBottom, "font %s: glyphBoxBottom %d, expected %d\n",
|
|
|
|
wine_dbgstr_w(nameW), metrics.glyphBoxBottom, expected->glyphBoxBottom);
|
|
|
|
|
|
|
|
ok(metrics.subscriptPositionX == expected->subscriptPositionX, "font %s: subscriptPositionX %d, expected %d\n",
|
|
|
|
wine_dbgstr_w(nameW), metrics.subscriptPositionX, expected->subscriptPositionX);
|
|
|
|
ok(metrics.subscriptPositionY == expected->subscriptPositionY, "font %s: subscriptPositionY %d, expected %d\n",
|
|
|
|
wine_dbgstr_w(nameW), metrics.subscriptPositionY, expected->subscriptPositionY);
|
|
|
|
ok(metrics.subscriptSizeX == expected->subscriptSizeX, "font %s: subscriptSizeX %d, expected %d\n",
|
|
|
|
wine_dbgstr_w(nameW), metrics.subscriptSizeX, expected->subscriptSizeX);
|
|
|
|
ok(metrics.subscriptSizeY == expected->subscriptSizeY, "font %s: subscriptSizeY %d, expected %d\n",
|
|
|
|
wine_dbgstr_w(nameW), metrics.subscriptSizeY, expected->subscriptSizeY);
|
|
|
|
ok(metrics.superscriptPositionX == expected->superscriptPositionX, "font %s: superscriptPositionX %d, expected %d\n",
|
|
|
|
wine_dbgstr_w(nameW), metrics.superscriptPositionX, expected->superscriptPositionX);
|
|
|
|
ok(metrics.superscriptPositionY == expected->superscriptPositionY, "font %s: superscriptPositionY %d, expected %d\n",
|
|
|
|
wine_dbgstr_w(nameW), metrics.superscriptPositionY, expected->superscriptPositionY);
|
|
|
|
ok(metrics.superscriptSizeX == expected->superscriptSizeX, "font %s: superscriptSizeX %d, expected %d\n",
|
|
|
|
wine_dbgstr_w(nameW), metrics.superscriptSizeX, expected->superscriptSizeX);
|
|
|
|
ok(metrics.superscriptSizeY == expected->superscriptSizeY, "font %s: superscriptSizeY %d, expected %d\n",
|
|
|
|
wine_dbgstr_w(nameW), metrics.superscriptSizeY, expected->superscriptSizeY);
|
2016-04-13 06:02:12 +02:00
|
|
|
}
|
2016-04-10 22:59:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void get_enus_string(IDWriteLocalizedStrings *strings, WCHAR *buff, UINT32 size)
|
|
|
|
{
|
|
|
|
static const WCHAR enusW[] = {'e','n','-','u','s',0};
|
|
|
|
BOOL exists = FALSE;
|
|
|
|
UINT32 index;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IDWriteLocalizedStrings_FindLocaleName(strings, enusW, &index, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(exists, "got %d\n", exists);
|
|
|
|
|
|
|
|
hr = IDWriteLocalizedStrings_GetString(strings, index, buff, size);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
}
|
|
|
|
|
2012-10-16 18:56:23 +02:00
|
|
|
static void test_GetMetrics(void)
|
|
|
|
{
|
2016-01-17 19:41:57 +01:00
|
|
|
DWRITE_FONT_METRICS metrics, metrics2;
|
2016-04-10 22:59:10 +02:00
|
|
|
IDWriteFontCollection *syscollection;
|
2012-10-16 18:56:23 +02:00
|
|
|
IDWriteGdiInterop *interop;
|
2014-11-06 06:50:12 +01:00
|
|
|
IDWriteFontFace *fontface;
|
2014-10-22 13:42:30 +02:00
|
|
|
IDWriteFactory *factory;
|
2012-10-16 18:56:23 +02:00
|
|
|
OUTLINETEXTMETRICW otm;
|
2016-01-17 19:41:57 +01:00
|
|
|
IDWriteFontFile *file;
|
2014-11-06 09:49:06 +01:00
|
|
|
IDWriteFont1 *font1;
|
2012-10-16 18:56:23 +02:00
|
|
|
IDWriteFont *font;
|
|
|
|
LOGFONTW logfont;
|
2016-04-10 22:59:10 +02:00
|
|
|
UINT32 count, i;
|
2012-10-16 18:56:23 +02:00
|
|
|
HRESULT hr;
|
|
|
|
HDC hdc;
|
|
|
|
HFONT hfont;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2012-10-16 18:56:23 +02:00
|
|
|
int ret;
|
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
factory = create_factory();
|
|
|
|
|
2012-10-16 18:56:23 +02:00
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
|
|
|
logfont.lfItalic = 1;
|
|
|
|
lstrcpyW(logfont.lfFaceName, tahomaW);
|
|
|
|
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectW(&logfont);
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
otm.otmSize = sizeof(otm);
|
|
|
|
ret = GetOutlineTextMetricsW(hdc, otm.otmSize, &otm);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
DeleteDC(hdc);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
|
2016-08-09 14:59:46 +02:00
|
|
|
if (0) /* crashes on native */
|
|
|
|
IDWriteFont_GetMetrics(font, NULL);
|
2012-10-16 18:56:23 +02:00
|
|
|
|
|
|
|
memset(&metrics, 0, sizeof(metrics));
|
|
|
|
IDWriteFont_GetMetrics(font, &metrics);
|
|
|
|
|
|
|
|
ok(metrics.designUnitsPerEm != 0, "designUnitsPerEm %u\n", metrics.designUnitsPerEm);
|
|
|
|
ok(metrics.ascent != 0, "ascent %u\n", metrics.ascent);
|
|
|
|
ok(metrics.descent != 0, "descent %u\n", metrics.descent);
|
|
|
|
ok(metrics.lineGap == 0, "lineGap %d\n", metrics.lineGap);
|
|
|
|
ok(metrics.capHeight, "capHeight %u\n", metrics.capHeight);
|
|
|
|
ok(metrics.xHeight != 0, "xHeight %u\n", metrics.xHeight);
|
|
|
|
ok(metrics.underlinePosition < 0, "underlinePosition %d\n", metrics.underlinePosition);
|
|
|
|
ok(metrics.underlineThickness != 0, "underlineThickness %u\n", metrics.underlineThickness);
|
|
|
|
ok(metrics.strikethroughPosition > 0, "strikethroughPosition %d\n", metrics.strikethroughPosition);
|
|
|
|
ok(metrics.strikethroughThickness != 0, "strikethroughThickness %u\n", metrics.strikethroughThickness);
|
|
|
|
|
2014-11-06 06:50:12 +01:00
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
memset(&metrics, 0, sizeof(metrics));
|
|
|
|
IDWriteFontFace_GetMetrics(fontface, &metrics);
|
|
|
|
|
|
|
|
ok(metrics.designUnitsPerEm != 0, "designUnitsPerEm %u\n", metrics.designUnitsPerEm);
|
|
|
|
ok(metrics.ascent != 0, "ascent %u\n", metrics.ascent);
|
|
|
|
ok(metrics.descent != 0, "descent %u\n", metrics.descent);
|
|
|
|
ok(metrics.lineGap == 0, "lineGap %d\n", metrics.lineGap);
|
|
|
|
ok(metrics.capHeight, "capHeight %u\n", metrics.capHeight);
|
|
|
|
ok(metrics.xHeight != 0, "xHeight %u\n", metrics.xHeight);
|
|
|
|
ok(metrics.underlinePosition < 0, "underlinePosition %d\n", metrics.underlinePosition);
|
|
|
|
ok(metrics.underlineThickness != 0, "underlineThickness %u\n", metrics.underlineThickness);
|
|
|
|
ok(metrics.strikethroughPosition > 0, "strikethroughPosition %d\n", metrics.strikethroughPosition);
|
|
|
|
ok(metrics.strikethroughThickness != 0, "strikethroughThickness %u\n", metrics.strikethroughThickness);
|
|
|
|
|
2014-11-06 09:49:06 +01:00
|
|
|
hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFont1, (void**)&font1);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
DWRITE_FONT_METRICS1 metrics1;
|
|
|
|
IDWriteFontFace1 *fontface1;
|
|
|
|
|
|
|
|
memset(&metrics1, 0, sizeof(metrics1));
|
|
|
|
IDWriteFont1_GetMetrics(font1, &metrics1);
|
|
|
|
|
|
|
|
ok(metrics1.designUnitsPerEm != 0, "designUnitsPerEm %u\n", metrics1.designUnitsPerEm);
|
|
|
|
ok(metrics1.ascent != 0, "ascent %u\n", metrics1.ascent);
|
|
|
|
ok(metrics1.descent != 0, "descent %u\n", metrics1.descent);
|
|
|
|
ok(metrics1.lineGap == 0, "lineGap %d\n", metrics1.lineGap);
|
|
|
|
ok(metrics1.capHeight, "capHeight %u\n", metrics1.capHeight);
|
|
|
|
ok(metrics1.xHeight != 0, "xHeight %u\n", metrics1.xHeight);
|
|
|
|
ok(metrics1.underlinePosition < 0, "underlinePosition %d\n", metrics1.underlinePosition);
|
|
|
|
ok(metrics1.underlineThickness != 0, "underlineThickness %u\n", metrics1.underlineThickness);
|
|
|
|
ok(metrics1.strikethroughPosition > 0, "strikethroughPosition %d\n", metrics1.strikethroughPosition);
|
|
|
|
ok(metrics1.strikethroughThickness != 0, "strikethroughThickness %u\n", metrics1.strikethroughThickness);
|
|
|
|
ok(metrics1.glyphBoxLeft < 0, "glyphBoxLeft %d\n", metrics1.glyphBoxLeft);
|
|
|
|
ok(metrics1.glyphBoxTop > 0, "glyphBoxTop %d\n", metrics1.glyphBoxTop);
|
|
|
|
ok(metrics1.glyphBoxRight > 0, "glyphBoxRight %d\n", metrics1.glyphBoxRight);
|
|
|
|
ok(metrics1.glyphBoxBottom < 0, "glyphBoxBottom %d\n", metrics1.glyphBoxBottom);
|
|
|
|
ok(metrics1.subscriptPositionY < 0, "subscriptPositionY %d\n", metrics1.subscriptPositionY);
|
|
|
|
ok(metrics1.subscriptSizeX > 0, "subscriptSizeX %d\n", metrics1.subscriptSizeX);
|
|
|
|
ok(metrics1.subscriptSizeY > 0, "subscriptSizeY %d\n", metrics1.subscriptSizeY);
|
|
|
|
ok(metrics1.superscriptPositionY > 0, "superscriptPositionY %d\n", metrics1.superscriptPositionY);
|
|
|
|
ok(metrics1.superscriptSizeX > 0, "superscriptSizeX %d\n", metrics1.superscriptSizeX);
|
|
|
|
ok(metrics1.superscriptSizeY > 0, "superscriptSizeY %d\n", metrics1.superscriptSizeY);
|
|
|
|
ok(!metrics1.hasTypographicMetrics, "hasTypographicMetrics %d\n", metrics1.hasTypographicMetrics);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
memset(&metrics1, 0, sizeof(metrics1));
|
|
|
|
IDWriteFontFace1_GetMetrics(fontface1, &metrics1);
|
|
|
|
|
|
|
|
ok(metrics1.designUnitsPerEm != 0, "designUnitsPerEm %u\n", metrics1.designUnitsPerEm);
|
|
|
|
ok(metrics1.ascent != 0, "ascent %u\n", metrics1.ascent);
|
|
|
|
ok(metrics1.descent != 0, "descent %u\n", metrics1.descent);
|
|
|
|
ok(metrics1.lineGap == 0, "lineGap %d\n", metrics1.lineGap);
|
|
|
|
ok(metrics1.capHeight, "capHeight %u\n", metrics1.capHeight);
|
|
|
|
ok(metrics1.xHeight != 0, "xHeight %u\n", metrics1.xHeight);
|
|
|
|
ok(metrics1.underlinePosition < 0, "underlinePosition %d\n", metrics1.underlinePosition);
|
|
|
|
ok(metrics1.underlineThickness != 0, "underlineThickness %u\n", metrics1.underlineThickness);
|
|
|
|
ok(metrics1.strikethroughPosition > 0, "strikethroughPosition %d\n", metrics1.strikethroughPosition);
|
|
|
|
ok(metrics1.strikethroughThickness != 0, "strikethroughThickness %u\n", metrics1.strikethroughThickness);
|
|
|
|
ok(metrics1.glyphBoxLeft < 0, "glyphBoxLeft %d\n", metrics1.glyphBoxLeft);
|
|
|
|
ok(metrics1.glyphBoxTop > 0, "glyphBoxTop %d\n", metrics1.glyphBoxTop);
|
|
|
|
ok(metrics1.glyphBoxRight > 0, "glyphBoxRight %d\n", metrics1.glyphBoxRight);
|
|
|
|
ok(metrics1.glyphBoxBottom < 0, "glyphBoxBottom %d\n", metrics1.glyphBoxBottom);
|
|
|
|
ok(metrics1.subscriptPositionY < 0, "subscriptPositionY %d\n", metrics1.subscriptPositionY);
|
|
|
|
ok(metrics1.subscriptSizeX > 0, "subscriptSizeX %d\n", metrics1.subscriptSizeX);
|
|
|
|
ok(metrics1.subscriptSizeY > 0, "subscriptSizeY %d\n", metrics1.subscriptSizeY);
|
|
|
|
ok(metrics1.superscriptPositionY > 0, "superscriptPositionY %d\n", metrics1.superscriptPositionY);
|
|
|
|
ok(metrics1.superscriptSizeX > 0, "superscriptSizeX %d\n", metrics1.superscriptSizeX);
|
|
|
|
ok(metrics1.superscriptSizeY > 0, "superscriptSizeY %d\n", metrics1.superscriptSizeY);
|
|
|
|
ok(!metrics1.hasTypographicMetrics, "hasTypographicMetrics %d\n", metrics1.hasTypographicMetrics);
|
|
|
|
|
|
|
|
IDWriteFontFace1_Release(fontface1);
|
|
|
|
IDWriteFont1_Release(font1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("DWRITE_FONT_METRICS1 is not supported.\n");
|
|
|
|
|
2014-11-06 06:50:12 +01:00
|
|
|
IDWriteFontFace_Release(fontface);
|
2012-10-16 18:56:23 +02:00
|
|
|
IDWriteFont_Release(font);
|
|
|
|
IDWriteGdiInterop_Release(interop);
|
2016-01-17 19:41:57 +01:00
|
|
|
|
|
|
|
/* bold simulation affects returned font metrics */
|
|
|
|
font = get_tahoma_instance(factory, DWRITE_FONT_STYLE_NORMAL);
|
|
|
|
|
|
|
|
/* create regulat Tahoma with bold simulation */
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
count = 1;
|
|
|
|
hr = IDWriteFontFace_GetFiles(fontface, &count, &file);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IDWriteFontFace_GetMetrics(fontface, &metrics);
|
|
|
|
ok(IDWriteFontFace_GetSimulations(fontface) == 0, "wrong simulations flags\n");
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file,
|
|
|
|
0, DWRITE_FONT_SIMULATIONS_BOLD, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFace_GetMetrics(fontface, &metrics2);
|
|
|
|
ok(IDWriteFontFace_GetSimulations(fontface) == DWRITE_FONT_SIMULATIONS_BOLD, "wrong simulations flags\n");
|
|
|
|
|
|
|
|
ok(metrics.ascent == metrics2.ascent, "got %u, %u\n", metrics2.ascent, metrics.ascent);
|
|
|
|
ok(metrics.descent == metrics2.descent, "got %u, %u\n", metrics2.descent, metrics.descent);
|
|
|
|
ok(metrics.lineGap == metrics2.lineGap, "got %d, %d\n", metrics2.lineGap, metrics.lineGap);
|
|
|
|
ok(metrics.capHeight == metrics2.capHeight, "got %u, %u\n", metrics2.capHeight, metrics.capHeight);
|
|
|
|
ok(metrics.xHeight == metrics2.xHeight, "got %u, %u\n", metrics2.xHeight, metrics.xHeight);
|
|
|
|
ok(metrics.underlinePosition == metrics2.underlinePosition, "got %d, %d\n", metrics2.underlinePosition,
|
|
|
|
metrics.underlinePosition);
|
|
|
|
ok(metrics.underlineThickness == metrics2.underlineThickness, "got %u, %u\n", metrics2.underlineThickness,
|
|
|
|
metrics.underlineThickness);
|
|
|
|
ok(metrics.strikethroughPosition == metrics2.strikethroughPosition, "got %d, %d\n", metrics2.strikethroughPosition,
|
|
|
|
metrics.strikethroughPosition);
|
|
|
|
ok(metrics.strikethroughThickness == metrics2.strikethroughThickness, "got %u, %u\n", metrics2.strikethroughThickness,
|
|
|
|
metrics.strikethroughThickness);
|
|
|
|
|
|
|
|
IDWriteFontFile_Release(file);
|
2017-04-11 13:21:32 +02:00
|
|
|
IDWriteFontFace_Release(fontface);
|
2016-01-17 19:41:57 +01:00
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
2016-04-10 22:59:10 +02:00
|
|
|
/* test metrics for whole system collection */
|
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
count = IDWriteFontCollection_GetFontFamilyCount(syscollection);
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
2018-11-11 07:55:00 +01:00
|
|
|
DWRITE_FONT_METRICS1 expected_metrics;
|
|
|
|
WCHAR familyW[256], faceW[256];
|
2016-04-10 22:59:10 +02:00
|
|
|
IDWriteLocalizedStrings *names;
|
|
|
|
IDWriteFontFamily *family;
|
2018-11-11 07:55:00 +01:00
|
|
|
UINT32 fontcount, j;
|
2016-04-10 22:59:10 +02:00
|
|
|
IDWriteFont *font;
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(syscollection, i, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2018-11-11 07:55:00 +01:00
|
|
|
fontcount = IDWriteFontFamily_GetFontCount(family);
|
2016-04-10 22:59:10 +02:00
|
|
|
|
2018-11-11 07:55:00 +01:00
|
|
|
hr = IDWriteFontFamily_GetFamilyNames(family, &names);
|
|
|
|
ok(hr == S_OK, "Failed to get family names, hr %#x.\n", hr);
|
|
|
|
get_enus_string(names, familyW, ARRAY_SIZE(familyW));
|
|
|
|
IDWriteLocalizedStrings_Release(names);
|
2016-04-10 22:59:10 +02:00
|
|
|
|
2018-11-11 07:55:00 +01:00
|
|
|
for (j = 0; j < fontcount; j++) {
|
|
|
|
WCHAR nameW[256];
|
2016-04-13 06:02:12 +02:00
|
|
|
|
2018-11-11 07:55:00 +01:00
|
|
|
hr = IDWriteFontFamily_GetFont(family, j, &font);
|
|
|
|
ok(hr == S_OK, "Failed to get a font, hr %#x.\n", hr);
|
2016-04-10 22:59:10 +02:00
|
|
|
|
2018-11-11 07:55:00 +01:00
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "Failed to create face instance, hr %#x.\n", hr);
|
2016-04-10 22:59:10 +02:00
|
|
|
|
2018-11-11 07:55:00 +01:00
|
|
|
hr = IDWriteFont_GetFaceNames(font, &names);
|
|
|
|
ok(hr == S_OK, "Failed to get face names, hr %#x.\n", hr);
|
|
|
|
get_enus_string(names, faceW, ARRAY_SIZE(faceW));
|
|
|
|
IDWriteLocalizedStrings_Release(names);
|
2016-04-10 22:59:10 +02:00
|
|
|
|
2018-11-11 07:55:00 +01:00
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
get_combined_font_name(familyW, faceW, nameW);
|
|
|
|
|
|
|
|
if (has_face_variations(fontface)) {
|
|
|
|
skip("%s: test does not support variable fonts.\n", wine_dbgstr_w(nameW));
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
get_expected_font_metrics(fontface, &expected_metrics);
|
|
|
|
check_font_metrics(nameW, fontface, &expected_metrics);
|
|
|
|
|
|
|
|
IDWriteFontFace_Release(fontface);
|
2016-04-13 06:02:12 +02:00
|
|
|
}
|
|
|
|
|
2016-04-10 22:59:10 +02:00
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
}
|
|
|
|
IDWriteFontCollection_Release(syscollection);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2012-10-16 18:56:23 +02:00
|
|
|
}
|
|
|
|
|
2012-10-21 06:24:35 +02:00
|
|
|
static void test_system_fontcollection(void)
|
|
|
|
{
|
2012-10-22 05:20:42 +02:00
|
|
|
IDWriteFontCollection *collection, *coll2;
|
2014-10-22 14:33:29 +02:00
|
|
|
IDWriteLocalFontFileLoader *localloader;
|
2016-03-08 20:46:53 +01:00
|
|
|
IDWriteFontCollection1 *collection1;
|
2014-10-22 13:42:30 +02:00
|
|
|
IDWriteFactory *factory, *factory2;
|
2014-10-22 14:33:29 +02:00
|
|
|
IDWriteFontFileLoader *loader;
|
2012-10-22 06:06:03 +02:00
|
|
|
IDWriteFontFamily *family;
|
2014-10-22 14:33:29 +02:00
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFontFile *file;
|
|
|
|
IDWriteFont *font;
|
2012-10-21 06:24:35 +02:00
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2012-10-21 06:24:35 +02:00
|
|
|
UINT32 i;
|
|
|
|
BOOL ret;
|
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
factory = create_factory();
|
|
|
|
|
2012-10-21 06:24:35 +02:00
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2012-10-22 05:20:42 +02:00
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &coll2, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(coll2 == collection, "got %p, was %p\n", coll2, collection);
|
|
|
|
IDWriteFontCollection_Release(coll2);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &coll2, TRUE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(coll2 == collection, "got %p, was %p\n", coll2, collection);
|
|
|
|
IDWriteFontCollection_Release(coll2);
|
|
|
|
|
2014-10-27 09:24:47 +01:00
|
|
|
factory2 = create_factory();
|
2014-10-16 05:29:31 +02:00
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory2, &coll2, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(coll2 != collection, "got %p, was %p\n", coll2, collection);
|
|
|
|
IDWriteFontCollection_Release(coll2);
|
|
|
|
IDWriteFactory_Release(factory2);
|
|
|
|
|
2012-10-21 06:24:35 +02:00
|
|
|
i = IDWriteFontCollection_GetFontFamilyCount(collection);
|
|
|
|
ok(i, "got %u\n", i);
|
|
|
|
|
2012-10-22 06:06:03 +02:00
|
|
|
/* invalid index */
|
|
|
|
family = (void*)0xdeadbeef;
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(collection, i, &family);
|
|
|
|
ok(hr == E_FAIL, "got 0x%08x\n", hr);
|
|
|
|
ok(family == NULL, "got %p\n", family);
|
|
|
|
|
2012-10-21 06:24:35 +02:00
|
|
|
ret = FALSE;
|
|
|
|
i = (UINT32)-1;
|
|
|
|
hr = IDWriteFontCollection_FindFamilyName(collection, tahomaW, &i, &ret);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(i != (UINT32)-1, "got %u\n", i);
|
|
|
|
|
2015-04-10 21:08:31 +02:00
|
|
|
ret = FALSE;
|
|
|
|
i = (UINT32)-1;
|
|
|
|
hr = IDWriteFontCollection_FindFamilyName(collection, tahomaUppercaseW, &i, &ret);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(i != (UINT32)-1, "got %u\n", i);
|
|
|
|
|
|
|
|
ret = FALSE;
|
|
|
|
i = (UINT32)-1;
|
|
|
|
hr = IDWriteFontCollection_FindFamilyName(collection, tahomaStrangecaseW, &i, &ret);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(i != (UINT32)-1, "got %u\n", i);
|
|
|
|
|
2014-10-22 14:33:29 +02:00
|
|
|
/* get back local file loader */
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(collection, i, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
|
|
|
|
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
i = 1;
|
|
|
|
file = NULL;
|
|
|
|
hr = IDWriteFontFace_GetFiles(fontface, &i, &file);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(file != NULL, "got %p\n", file);
|
2017-04-11 13:21:32 +02:00
|
|
|
IDWriteFontFace_Release(fontface);
|
2014-10-22 14:33:29 +02:00
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetLoader(file, &loader);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
|
|
|
|
hr = IDWriteFontFileLoader_QueryInterface(loader, &IID_IDWriteLocalFontFileLoader, (void**)&localloader);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteLocalFontFileLoader_Release(localloader);
|
|
|
|
|
|
|
|
/* local loader is not registered by default */
|
|
|
|
hr = IDWriteFactory_RegisterFontFileLoader(factory, loader);
|
2014-10-24 09:39:16 +02:00
|
|
|
ok(hr == S_OK || broken(hr == DWRITE_E_ALREADYREGISTERED), "got 0x%08x\n", hr);
|
2014-10-22 14:33:29 +02:00
|
|
|
hr = IDWriteFactory_UnregisterFontFileLoader(factory, loader);
|
2014-10-24 09:39:16 +02:00
|
|
|
ok(hr == S_OK || broken(hr == E_INVALIDARG), "got 0x%08x\n", hr);
|
2014-10-27 09:24:47 +01:00
|
|
|
|
|
|
|
/* try with a different factory */
|
|
|
|
factory2 = create_factory();
|
|
|
|
hr = IDWriteFactory_RegisterFontFileLoader(factory2, loader);
|
|
|
|
ok(hr == S_OK || broken(hr == DWRITE_E_ALREADYREGISTERED), "got 0x%08x\n", hr);
|
|
|
|
hr = IDWriteFactory_RegisterFontFileLoader(factory2, loader);
|
|
|
|
ok(hr == DWRITE_E_ALREADYREGISTERED, "got 0x%08x\n", hr);
|
|
|
|
hr = IDWriteFactory_UnregisterFontFileLoader(factory2, loader);
|
|
|
|
ok(hr == S_OK || broken(hr == E_INVALIDARG), "got 0x%08x\n", hr);
|
|
|
|
hr = IDWriteFactory_UnregisterFontFileLoader(factory2, loader);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFactory_Release(factory2);
|
|
|
|
|
2014-10-22 14:33:29 +02:00
|
|
|
IDWriteFontFileLoader_Release(loader);
|
2014-10-29 20:41:47 +01:00
|
|
|
|
2012-10-21 06:24:35 +02:00
|
|
|
ret = TRUE;
|
|
|
|
i = 0;
|
|
|
|
hr = IDWriteFontCollection_FindFamilyName(collection, blahW, &i, &ret);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
ok(i == (UINT32)-1, "got %u\n", i);
|
2012-10-21 06:31:11 +02:00
|
|
|
|
2016-03-08 20:46:53 +01:00
|
|
|
hr = IDWriteFontCollection_QueryInterface(collection, &IID_IDWriteFontCollection1, (void**)&collection1);
|
|
|
|
if (hr == S_OK) {
|
2017-08-22 11:42:14 +02:00
|
|
|
IDWriteFontSet *fontset, *fontset2;
|
2016-03-08 20:46:53 +01:00
|
|
|
IDWriteFontFamily1 *family1;
|
2017-08-22 11:42:14 +02:00
|
|
|
IDWriteFactory3 *factory3;
|
2016-03-08 20:46:53 +01:00
|
|
|
|
|
|
|
hr = IDWriteFontCollection1_QueryInterface(collection1, &IID_IDWriteFontCollection, (void**)&coll2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(coll2 == collection, "got %p, %p\n", collection, coll2);
|
|
|
|
IDWriteFontCollection_Release(coll2);
|
|
|
|
|
|
|
|
family1 = (void*)0xdeadbeef;
|
|
|
|
hr = IDWriteFontCollection1_GetFontFamily(collection1, ~0u, &family1);
|
|
|
|
ok(hr == E_FAIL, "got 0x%08x\n", hr);
|
|
|
|
ok(family1 == NULL, "got %p\n", family1);
|
2016-04-19 08:39:26 +02:00
|
|
|
|
2016-03-08 20:46:53 +01:00
|
|
|
hr = IDWriteFontCollection1_GetFontFamily(collection1, 0, &family1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFamily1_Release(family1);
|
2017-08-22 11:42:14 +02:00
|
|
|
|
|
|
|
/* system fontset */
|
|
|
|
EXPECT_REF(collection1, 2);
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
hr = IDWriteFontCollection1_GetFontSet(collection1, &fontset);
|
|
|
|
todo_wine
|
|
|
|
ok(hr == S_OK, "Failed to get fontset, hr %#x.\n", hr);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
EXPECT_REF(collection1, 2);
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
EXPECT_REF(fontset, 1);
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection1_GetFontSet(collection1, &fontset2);
|
|
|
|
ok(hr == S_OK, "Failed to get fontset, hr %#x.\n", hr);
|
|
|
|
ok(fontset != fontset2, "Expected new fontset instance.\n");
|
|
|
|
EXPECT_REF(fontset2, 1);
|
|
|
|
IDWriteFontSet_Release(fontset2);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory3, (void **)&factory3);
|
|
|
|
ok(hr == S_OK, "Failed to get IDWriteFactory3 interface, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
EXPECT_REF(factory, 3);
|
|
|
|
hr = IDWriteFactory3_GetSystemFontSet(factory3, &fontset2);
|
|
|
|
ok(hr == S_OK, "Failed to get system font set, hr %#x.\n", hr);
|
|
|
|
ok(fontset != fontset2, "Expected new fontset instance.\n");
|
|
|
|
EXPECT_REF(fontset2, 1);
|
|
|
|
EXPECT_REF(factory, 4);
|
|
|
|
|
|
|
|
IDWriteFontSet_Release(fontset2);
|
|
|
|
IDWriteFontSet_Release(fontset);
|
|
|
|
|
|
|
|
IDWriteFactory3_Release(factory3);
|
|
|
|
}
|
2016-03-08 20:46:53 +01:00
|
|
|
IDWriteFontCollection1_Release(collection1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("IDWriteFontCollection1 is not supported.\n");
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFontCollection_Release(collection);
|
|
|
|
ok(ref == 0, "collection not released, %u\n", ref);
|
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2012-10-21 06:24:35 +02:00
|
|
|
}
|
|
|
|
|
2016-12-07 14:46:39 +01:00
|
|
|
static void get_logfont_from_font(IDWriteFont *font, LOGFONTW *logfont)
|
2014-01-05 22:24:17 +01:00
|
|
|
{
|
2016-12-07 14:46:39 +01:00
|
|
|
void *os2_context, *head_context;
|
|
|
|
IDWriteLocalizedStrings *names;
|
2014-11-04 16:31:31 +01:00
|
|
|
DWRITE_FONT_SIMULATIONS sim;
|
2016-12-07 14:46:39 +01:00
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
const TT_OS2_V2 *tt_os2;
|
|
|
|
DWRITE_FONT_STYLE style;
|
|
|
|
const TT_HEAD *tt_head;
|
|
|
|
LONG weight;
|
|
|
|
UINT32 size;
|
|
|
|
BOOL exists;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* These are rendering time properties. */
|
|
|
|
logfont->lfHeight = 0;
|
|
|
|
logfont->lfWidth = 0;
|
|
|
|
logfont->lfEscapement = 0;
|
|
|
|
logfont->lfOrientation = 0;
|
|
|
|
logfont->lfUnderline = 0;
|
|
|
|
logfont->lfStrikeOut = 0;
|
|
|
|
|
|
|
|
logfont->lfWeight = 0;
|
|
|
|
logfont->lfItalic = 0;
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "Failed to create font face, %#x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_TryGetFontTable(fontface, MS_0S2_TAG, (const void **)&tt_os2, &size,
|
|
|
|
&os2_context, &exists);
|
|
|
|
ok(hr == S_OK, "Failed to get OS/2 table, %#x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_TryGetFontTable(fontface, MS_HEAD_TAG, (const void **)&tt_head, &size,
|
|
|
|
&head_context, &exists);
|
|
|
|
ok(hr == S_OK, "Failed to get head table, %#x\n", hr);
|
|
|
|
|
|
|
|
sim = IDWriteFont_GetSimulations(font);
|
|
|
|
|
|
|
|
/* lfWeight */
|
|
|
|
weight = FW_REGULAR;
|
|
|
|
if (tt_os2) {
|
|
|
|
USHORT usWeightClass = GET_BE_WORD(tt_os2->usWeightClass);
|
|
|
|
|
|
|
|
if (usWeightClass >= 1 && usWeightClass <= 9)
|
|
|
|
usWeightClass *= 100;
|
|
|
|
|
|
|
|
if (usWeightClass > DWRITE_FONT_WEIGHT_ULTRA_BLACK)
|
|
|
|
weight = DWRITE_FONT_WEIGHT_ULTRA_BLACK;
|
|
|
|
else if (usWeightClass > 0)
|
|
|
|
weight = usWeightClass;
|
|
|
|
}
|
|
|
|
else if (tt_head) {
|
|
|
|
USHORT macStyle = GET_BE_WORD(tt_head->macStyle);
|
|
|
|
if (macStyle & TT_HEAD_MACSTYLE_BOLD)
|
|
|
|
weight = DWRITE_FONT_WEIGHT_BOLD;
|
|
|
|
}
|
|
|
|
if (sim & DWRITE_FONT_SIMULATIONS_BOLD)
|
|
|
|
weight += (FW_BOLD - FW_REGULAR) / 2 + 1;
|
|
|
|
logfont->lfWeight = weight;
|
|
|
|
|
|
|
|
/* lfItalic */
|
|
|
|
if (IDWriteFont_GetSimulations(font) & DWRITE_FONT_SIMULATIONS_OBLIQUE)
|
|
|
|
logfont->lfItalic = 1;
|
|
|
|
|
|
|
|
style = IDWriteFont_GetStyle(font);
|
|
|
|
if (!logfont->lfItalic && ((style == DWRITE_FONT_STYLE_ITALIC) || (style == DWRITE_FONT_STYLE_OBLIQUE))) {
|
|
|
|
if (tt_os2) {
|
|
|
|
USHORT fsSelection = GET_BE_WORD(tt_os2->fsSelection);
|
|
|
|
logfont->lfItalic = !!(fsSelection & OS2_FSSELECTION_ITALIC);
|
|
|
|
}
|
|
|
|
else if (tt_head) {
|
|
|
|
USHORT macStyle = GET_BE_WORD(tt_head->macStyle);
|
|
|
|
logfont->lfItalic = !!(macStyle & TT_HEAD_MACSTYLE_ITALIC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* lfFaceName */
|
|
|
|
exists = FALSE;
|
|
|
|
logfont->lfFaceName[0] = 0;
|
|
|
|
hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &names, &exists);
|
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
if (exists) {
|
|
|
|
static const WCHAR enusW[] = {'e','n','-','u','s',0};
|
|
|
|
WCHAR localeW[LOCALE_NAME_MAX_LENGTH];
|
2018-05-22 10:50:43 +02:00
|
|
|
WCHAR nameW[256];
|
2016-12-07 14:46:39 +01:00
|
|
|
UINT32 index;
|
|
|
|
|
|
|
|
/* Fallback to en-us if there's no string for user locale. */
|
|
|
|
exists = FALSE;
|
2018-05-22 10:50:42 +02:00
|
|
|
if (GetSystemDefaultLocaleName(localeW, ARRAY_SIZE(localeW)))
|
2016-12-07 14:46:39 +01:00
|
|
|
IDWriteLocalizedStrings_FindLocaleName(names, localeW, &index, &exists);
|
|
|
|
|
|
|
|
if (!exists)
|
|
|
|
IDWriteLocalizedStrings_FindLocaleName(names, enusW, &index, &exists);
|
|
|
|
|
2018-05-22 10:50:43 +02:00
|
|
|
if (exists) {
|
|
|
|
nameW[0] = 0;
|
|
|
|
hr = IDWriteLocalizedStrings_GetString(names, index, nameW, ARRAY_SIZE(nameW));
|
|
|
|
ok(hr == S_OK, "Failed to get name string, hr %#x.\n", hr);
|
|
|
|
lstrcpynW(logfont->lfFaceName, nameW, ARRAY_SIZE(logfont->lfFaceName));
|
|
|
|
}
|
2016-12-07 14:46:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteLocalizedStrings_Release(names);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tt_os2)
|
|
|
|
IDWriteFontFace_ReleaseFontTable(fontface, os2_context);
|
|
|
|
if (tt_head)
|
|
|
|
IDWriteFontFace_ReleaseFontTable(fontface, head_context);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_ConvertFontFaceToLOGFONT(void)
|
|
|
|
{
|
2017-04-11 13:21:32 +02:00
|
|
|
IDWriteFontCollection *collection;
|
2014-01-05 22:24:17 +01:00
|
|
|
IDWriteGdiInterop *interop;
|
|
|
|
IDWriteFontFace *fontface;
|
2014-10-22 13:42:30 +02:00
|
|
|
IDWriteFactory *factory;
|
2014-01-05 22:24:17 +01:00
|
|
|
LOGFONTW logfont;
|
2016-12-07 14:46:39 +01:00
|
|
|
UINT32 count, i;
|
2014-01-05 22:24:17 +01:00
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-01-05 22:24:17 +01:00
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
factory = create_factory();
|
|
|
|
|
2014-01-05 22:24:17 +01:00
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2016-12-07 14:46:39 +01:00
|
|
|
if (0) /* crashes on native */
|
|
|
|
{
|
|
|
|
hr = IDWriteGdiInterop_ConvertFontFaceToLOGFONT(interop, NULL, NULL);
|
|
|
|
hr = IDWriteGdiInterop_ConvertFontFaceToLOGFONT(interop, fontface, NULL);
|
|
|
|
}
|
|
|
|
memset(&logfont, 0xcc, sizeof(logfont));
|
|
|
|
hr = IDWriteGdiInterop_ConvertFontFaceToLOGFONT(interop, NULL, &logfont);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(logfont.lfFaceName[0] == 0, "got face name %s\n", wine_dbgstr_w(logfont.lfFaceName));
|
2014-01-05 22:24:17 +01:00
|
|
|
|
2016-12-07 14:46:39 +01:00
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
|
2014-01-05 22:24:17 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2016-12-07 14:46:39 +01:00
|
|
|
count = IDWriteFontCollection_GetFontFamilyCount(collection);
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
WCHAR nameW[128], familynameW[64], facenameW[64];
|
|
|
|
IDWriteLocalizedStrings *names;
|
|
|
|
DWRITE_FONT_SIMULATIONS sim;
|
|
|
|
IDWriteFontFamily *family;
|
|
|
|
UINT32 font_count, j;
|
|
|
|
IDWriteFont *font;
|
|
|
|
LOGFONTW lf;
|
2014-11-04 16:31:31 +01:00
|
|
|
|
2016-12-07 14:46:39 +01:00
|
|
|
hr = IDWriteFontCollection_GetFontFamily(collection, i, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2014-11-04 16:31:31 +01:00
|
|
|
|
2016-12-07 14:46:39 +01:00
|
|
|
hr = IDWriteFontFamily_GetFamilyNames(family, &names);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2014-11-04 16:31:31 +01:00
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
get_enus_string(names, familynameW, ARRAY_SIZE(familynameW));
|
2016-12-07 14:46:39 +01:00
|
|
|
IDWriteLocalizedStrings_Release(names);
|
2014-01-05 22:24:17 +01:00
|
|
|
|
2016-12-07 14:46:39 +01:00
|
|
|
font_count = IDWriteFontFamily_GetFontCount(family);
|
2014-01-05 22:24:17 +01:00
|
|
|
|
2016-12-07 14:46:39 +01:00
|
|
|
for (j = 0; j < font_count; j++) {
|
|
|
|
IDWriteFontFace *fontface;
|
2014-01-05 22:24:17 +01:00
|
|
|
|
2016-12-07 14:46:39 +01:00
|
|
|
hr = IDWriteFontFamily_GetFont(family, j, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFont_GetFaceNames(font, &names);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
get_enus_string(names, facenameW, ARRAY_SIZE(facenameW));
|
2016-12-07 14:46:39 +01:00
|
|
|
IDWriteLocalizedStrings_Release(names);
|
|
|
|
|
2018-11-11 07:55:00 +01:00
|
|
|
get_combined_font_name(familynameW, facenameW, nameW);
|
2016-12-07 14:46:39 +01:00
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2018-05-23 07:24:38 +02:00
|
|
|
if (has_face_variations(fontface)) {
|
|
|
|
skip("%s: test does not support variable fonts.\n", wine_dbgstr_w(nameW));
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-12-07 14:46:39 +01:00
|
|
|
memset(&logfont, 0xcc, sizeof(logfont));
|
|
|
|
hr = IDWriteGdiInterop_ConvertFontFaceToLOGFONT(interop, fontface, &logfont);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
sim = IDWriteFontFace_GetSimulations(fontface);
|
|
|
|
get_logfont_from_font(font, &lf);
|
2017-04-11 13:21:32 +02:00
|
|
|
|
2016-12-07 14:46:39 +01:00
|
|
|
ok(logfont.lfWeight == lf.lfWeight, "%s: unexpected lfWeight %d, expected lfWeight %d, font weight %d, "
|
|
|
|
"bold simulation %s\n", wine_dbgstr_w(nameW), logfont.lfWeight, lf.lfWeight, IDWriteFont_GetWeight(font),
|
|
|
|
sim & DWRITE_FONT_SIMULATIONS_BOLD ? "yes" : "no");
|
|
|
|
ok(logfont.lfItalic == lf.lfItalic, "%s: unexpected italic flag %d, oblique simulation %s\n",
|
|
|
|
wine_dbgstr_w(nameW), logfont.lfItalic, sim & DWRITE_FONT_SIMULATIONS_OBLIQUE ? "yes" : "no");
|
|
|
|
ok(!lstrcmpW(logfont.lfFaceName, lf.lfFaceName), "%s: unexpected facename %s, expected %s\n",
|
|
|
|
wine_dbgstr_w(nameW), wine_dbgstr_w(logfont.lfFaceName), wine_dbgstr_w(lf.lfFaceName));
|
|
|
|
|
|
|
|
ok(logfont.lfOutPrecision == OUT_OUTLINE_PRECIS, "%s: unexpected output precision %d\n", wine_dbgstr_w(nameW),
|
|
|
|
logfont.lfOutPrecision);
|
|
|
|
ok(logfont.lfClipPrecision == CLIP_DEFAULT_PRECIS, "%s: unexpected clipping precision %d\n", wine_dbgstr_w(nameW),
|
|
|
|
logfont.lfClipPrecision);
|
|
|
|
ok(logfont.lfQuality == DEFAULT_QUALITY, "%s: unexpected quality %d\n", wine_dbgstr_w(nameW), logfont.lfQuality);
|
|
|
|
ok(logfont.lfPitchAndFamily == DEFAULT_PITCH, "%s: unexpected pitch %d\n", wine_dbgstr_w(nameW),
|
|
|
|
logfont.lfPitchAndFamily);
|
|
|
|
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontCollection_Release(collection);
|
2014-01-05 22:24:17 +01:00
|
|
|
IDWriteGdiInterop_Release(interop);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2014-01-05 22:24:17 +01:00
|
|
|
}
|
|
|
|
|
2014-11-04 14:37:57 +01:00
|
|
|
static HRESULT WINAPI fontfileenumerator_QueryInterface(IDWriteFontFileEnumerator *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteFontFileEnumerator))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
IDWriteFontFileEnumerator_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI fontfileenumerator_AddRef(IDWriteFontFileEnumerator *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI fontfileenumerator_Release(IDWriteFontFileEnumerator *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI fontfileenumerator_GetCurrentFontFile(IDWriteFontFileEnumerator *iface, IDWriteFontFile **file)
|
|
|
|
{
|
|
|
|
*file = NULL;
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI fontfileenumerator_MoveNext(IDWriteFontFileEnumerator *iface, BOOL *current)
|
|
|
|
{
|
|
|
|
*current = FALSE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IDWriteFontFileEnumeratorVtbl dwritefontfileenumeratorvtbl =
|
|
|
|
{
|
|
|
|
fontfileenumerator_QueryInterface,
|
|
|
|
fontfileenumerator_AddRef,
|
|
|
|
fontfileenumerator_Release,
|
|
|
|
fontfileenumerator_MoveNext,
|
|
|
|
fontfileenumerator_GetCurrentFontFile,
|
|
|
|
};
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
struct collection_loader
|
|
|
|
{
|
|
|
|
IDWriteFontCollectionLoader IDWriteFontCollectionLoader_iface;
|
|
|
|
LONG ref;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct collection_loader *impl_from_IDWriteFontCollectionLoader(IDWriteFontCollectionLoader *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct collection_loader, IDWriteFontCollectionLoader_iface);
|
|
|
|
}
|
|
|
|
|
2014-08-07 00:01:09 +02:00
|
|
|
static HRESULT WINAPI fontcollectionloader_QueryInterface(IDWriteFontCollectionLoader *iface, REFIID riid, void **obj)
|
|
|
|
{
|
2017-04-11 13:21:32 +02:00
|
|
|
struct collection_loader *loader = impl_from_IDWriteFontCollectionLoader(iface);
|
|
|
|
|
|
|
|
if (IsEqualIID(&IID_IDWriteFontCollectionLoader, riid) ||
|
|
|
|
IsEqualIID(&IID_IUnknown, riid))
|
|
|
|
{
|
|
|
|
*obj = &loader->IDWriteFontCollectionLoader_iface;
|
|
|
|
IDWriteFontCollectionLoader_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
2014-08-07 00:01:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI fontcollectionloader_AddRef(IDWriteFontCollectionLoader *iface)
|
|
|
|
{
|
2017-04-11 13:21:32 +02:00
|
|
|
struct collection_loader *loader = impl_from_IDWriteFontCollectionLoader(iface);
|
|
|
|
return InterlockedIncrement(&loader->ref);
|
2014-08-07 00:01:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI fontcollectionloader_Release(IDWriteFontCollectionLoader *iface)
|
|
|
|
{
|
2017-04-11 13:21:32 +02:00
|
|
|
struct collection_loader *loader = impl_from_IDWriteFontCollectionLoader(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&loader->ref);
|
|
|
|
|
|
|
|
if (!ref)
|
|
|
|
heap_free(loader);
|
|
|
|
|
|
|
|
return ref;
|
2014-08-07 00:01:09 +02:00
|
|
|
}
|
|
|
|
|
2014-11-04 14:37:57 +01:00
|
|
|
static HRESULT WINAPI fontcollectionloader_CreateEnumeratorFromKey(IDWriteFontCollectionLoader *iface, IDWriteFactory *factory, const void *key,
|
|
|
|
UINT32 key_size, IDWriteFontFileEnumerator **ret)
|
2014-08-07 00:01:09 +02:00
|
|
|
{
|
2014-11-04 14:37:57 +01:00
|
|
|
static IDWriteFontFileEnumerator enumerator = { &dwritefontfileenumeratorvtbl };
|
|
|
|
*ret = &enumerator;
|
2014-08-07 00:01:09 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IDWriteFontCollectionLoaderVtbl dwritefontcollectionloadervtbl = {
|
|
|
|
fontcollectionloader_QueryInterface,
|
|
|
|
fontcollectionloader_AddRef,
|
|
|
|
fontcollectionloader_Release,
|
|
|
|
fontcollectionloader_CreateEnumeratorFromKey
|
|
|
|
};
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
static IDWriteFontCollectionLoader *create_collection_loader(void)
|
|
|
|
{
|
|
|
|
struct collection_loader *loader = heap_alloc(sizeof(*loader));
|
|
|
|
|
|
|
|
loader->IDWriteFontCollectionLoader_iface.lpVtbl = &dwritefontcollectionloadervtbl;
|
|
|
|
loader->ref = 1;
|
|
|
|
|
|
|
|
return &loader->IDWriteFontCollectionLoader_iface;
|
|
|
|
}
|
|
|
|
|
2014-08-07 00:01:09 +02:00
|
|
|
static void test_CustomFontCollection(void)
|
|
|
|
{
|
2014-11-04 14:37:57 +01:00
|
|
|
static const WCHAR fontnameW[] = {'w','i','n','e','_','t','e','s','t',0};
|
2017-04-11 13:21:32 +02:00
|
|
|
IDWriteFontCollectionLoader *loader, *loader2, *loader3;
|
2014-11-04 14:37:57 +01:00
|
|
|
IDWriteFontCollection *font_collection = NULL;
|
|
|
|
static IDWriteFontFileLoader rloader = { &resourcefontfileloadervtbl };
|
|
|
|
struct test_fontcollectionloader resource_collection = { { &resourcecollectionloadervtbl }, &rloader };
|
|
|
|
IDWriteFontFamily *family, *family2, *family3;
|
|
|
|
IDWriteFontFace *idfontface, *idfontface2;
|
|
|
|
IDWriteFontFile *fontfile, *fontfile2;
|
|
|
|
IDWriteLocalizedStrings *string;
|
|
|
|
IDWriteFont *idfont, *idfont2;
|
2014-10-22 13:42:30 +02:00
|
|
|
IDWriteFactory *factory;
|
2014-11-04 14:37:57 +01:00
|
|
|
UINT32 index, count;
|
|
|
|
BOOL exists;
|
2014-08-07 00:01:09 +02:00
|
|
|
HRESULT hr;
|
2014-11-04 14:37:57 +01:00
|
|
|
HRSRC font;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-08-07 00:01:09 +02:00
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
factory = create_factory();
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
loader = create_collection_loader();
|
|
|
|
loader2 = create_collection_loader();
|
|
|
|
loader3 = create_collection_loader();
|
|
|
|
|
2014-10-08 12:49:12 +02:00
|
|
|
hr = IDWriteFactory_RegisterFontCollectionLoader(factory, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_UnregisterFontCollectionLoader(factory, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
EXPECT_REF(loader, 1);
|
|
|
|
EXPECT_REF(loader2, 1);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_RegisterFontCollectionLoader(factory, loader);
|
2014-08-07 00:01:09 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2017-04-11 13:21:32 +02:00
|
|
|
hr = IDWriteFactory_RegisterFontCollectionLoader(factory, loader2);
|
2014-08-07 00:01:09 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2017-04-11 13:21:32 +02:00
|
|
|
hr = IDWriteFactory_RegisterFontCollectionLoader(factory, loader);
|
2014-08-07 00:01:09 +02:00
|
|
|
ok(hr == DWRITE_E_ALREADYREGISTERED, "got 0x%08x\n", hr);
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
EXPECT_REF(loader, 2);
|
|
|
|
EXPECT_REF(loader2, 2);
|
|
|
|
|
2014-11-04 14:37:57 +01:00
|
|
|
hr = IDWriteFactory_RegisterFontFileLoader(factory, &rloader);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
hr = IDWriteFactory_RegisterFontCollectionLoader(factory, &resource_collection.IDWriteFontFileCollectionLoader_iface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
/* Loader wasn't registered. */
|
2016-01-28 21:27:20 +01:00
|
|
|
font_collection = (void*)0xdeadbeef;
|
2017-04-11 13:21:32 +02:00
|
|
|
hr = IDWriteFactory_CreateCustomFontCollection(factory, loader3, "Billy", 6, &font_collection);
|
2014-11-04 14:37:57 +01:00
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2016-01-28 21:27:20 +01:00
|
|
|
ok(font_collection == NULL, "got %p\n", font_collection);
|
2014-11-04 14:37:57 +01:00
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
EXPECT_REF(factory, 1);
|
|
|
|
hr = IDWriteFactory_CreateCustomFontCollection(factory, loader, "Billy", 6, &font_collection);
|
2014-11-04 14:37:57 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2017-04-11 13:21:32 +02:00
|
|
|
todo_wine
|
|
|
|
EXPECT_REF(factory, 1);
|
|
|
|
EXPECT_REF(loader, 2);
|
2014-11-04 14:37:57 +01:00
|
|
|
IDWriteFontCollection_Release(font_collection);
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
hr = IDWriteFactory_CreateCustomFontCollection(factory, loader2, "Billy", 6, &font_collection);
|
2014-11-04 14:37:57 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontCollection_Release(font_collection);
|
|
|
|
|
2016-01-28 21:27:20 +01:00
|
|
|
font_collection = (void*)0xdeadbeef;
|
2014-11-04 14:37:57 +01:00
|
|
|
hr = IDWriteFactory_CreateCustomFontCollection(factory, (IDWriteFontCollectionLoader*)0xdeadbeef, "Billy", 6, &font_collection);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2016-01-28 21:27:20 +01:00
|
|
|
ok(font_collection == NULL, "got %p\n", font_collection);
|
2014-11-04 14:37:57 +01:00
|
|
|
|
|
|
|
font = FindResourceA(GetModuleHandleA(NULL), (LPCSTR)MAKEINTRESOURCE(1), (LPCSTR)RT_RCDATA);
|
|
|
|
ok(font != NULL, "Failed to find font resource\n");
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateCustomFontCollection(factory, &resource_collection.IDWriteFontFileCollectionLoader_iface,
|
|
|
|
&font, sizeof(HRSRC), &font_collection);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n",hr);
|
2017-04-11 13:21:32 +02:00
|
|
|
EXPECT_REF(font_collection, 1);
|
2014-11-04 14:37:57 +01:00
|
|
|
|
|
|
|
index = 1;
|
|
|
|
exists = FALSE;
|
|
|
|
hr = IDWriteFontCollection_FindFamilyName(font_collection, fontnameW, &index, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(index == 0, "got index %i\n", index);
|
|
|
|
ok(exists, "got exists %i\n", exists);
|
|
|
|
|
|
|
|
count = IDWriteFontCollection_GetFontFamilyCount(font_collection);
|
|
|
|
ok(count == 1, "got %u\n", count);
|
|
|
|
|
|
|
|
family = NULL;
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(font_collection, 0, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
EXPECT_REF(family, 1);
|
|
|
|
|
|
|
|
family2 = NULL;
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(font_collection, 0, &family2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
EXPECT_REF(family2, 1);
|
|
|
|
ok(family != family2, "got %p, %p\n", family, family2);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFont(family, 0, &idfont);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
EXPECT_REF(idfont, 1);
|
|
|
|
EXPECT_REF(family, 2);
|
|
|
|
hr = IDWriteFontFamily_GetFont(family, 0, &idfont2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
EXPECT_REF(idfont2, 1);
|
|
|
|
EXPECT_REF(family, 3);
|
|
|
|
ok(idfont != idfont2, "got %p, %p\n", idfont, idfont2);
|
|
|
|
IDWriteFont_Release(idfont2);
|
|
|
|
|
|
|
|
hr = IDWriteFont_GetInformationalStrings(idfont, DWRITE_INFORMATIONAL_STRING_COPYRIGHT_NOTICE, &string, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(exists, "got %d\n", exists);
|
|
|
|
EXPECT_REF(string, 1);
|
2015-10-29 08:20:55 +01:00
|
|
|
IDWriteLocalizedStrings_Release(string);
|
2014-11-04 14:37:57 +01:00
|
|
|
|
|
|
|
family3 = NULL;
|
|
|
|
hr = IDWriteFont_GetFontFamily(idfont, &family3);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
EXPECT_REF(family, 3);
|
|
|
|
ok(family == family3, "got %p, %p\n", family, family3);
|
|
|
|
IDWriteFontFamily_Release(family3);
|
|
|
|
|
|
|
|
idfontface = NULL;
|
|
|
|
hr = IDWriteFont_CreateFontFace(idfont, &idfontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
EXPECT_REF(idfont, 1);
|
|
|
|
|
|
|
|
idfont2 = NULL;
|
|
|
|
hr = IDWriteFontFamily_GetFont(family2, 0, &idfont2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
EXPECT_REF(idfont2, 1);
|
|
|
|
EXPECT_REF(idfont, 1);
|
2014-12-05 12:21:02 +01:00
|
|
|
ok(idfont2 != idfont, "Font instances should not match\n");
|
2014-11-04 14:37:57 +01:00
|
|
|
|
|
|
|
idfontface2 = NULL;
|
|
|
|
hr = IDWriteFont_CreateFontFace(idfont2, &idfontface2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(idfontface2 == idfontface, "fontfaces should match\n");
|
|
|
|
|
|
|
|
index = 1;
|
|
|
|
fontfile = NULL;
|
|
|
|
hr = IDWriteFontFace_GetFiles(idfontface, &index, &fontfile);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
index = 1;
|
|
|
|
fontfile2 = NULL;
|
|
|
|
hr = IDWriteFontFace_GetFiles(idfontface2, &index, &fontfile2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(fontfile == fontfile2, "fontfiles should match\n");
|
|
|
|
|
|
|
|
IDWriteFont_Release(idfont);
|
|
|
|
IDWriteFont_Release(idfont2);
|
|
|
|
IDWriteFontFile_Release(fontfile);
|
|
|
|
IDWriteFontFile_Release(fontfile2);
|
|
|
|
IDWriteFontFace_Release(idfontface);
|
|
|
|
IDWriteFontFace_Release(idfontface2);
|
|
|
|
IDWriteFontFamily_Release(family2);
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
IDWriteFontCollection_Release(font_collection);
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
hr = IDWriteFactory_UnregisterFontCollectionLoader(factory, loader);
|
2014-08-07 00:01:09 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2017-04-11 13:21:32 +02:00
|
|
|
hr = IDWriteFactory_UnregisterFontCollectionLoader(factory, loader);
|
2014-08-07 00:01:09 +02:00
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2017-04-11 13:21:32 +02:00
|
|
|
hr = IDWriteFactory_UnregisterFontCollectionLoader(factory, loader2);
|
2014-08-07 00:01:09 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2014-11-04 14:37:57 +01:00
|
|
|
hr = IDWriteFactory_UnregisterFontCollectionLoader(factory, &resource_collection.IDWriteFontFileCollectionLoader_iface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
hr = IDWriteFactory_UnregisterFontFileLoader(factory, &rloader);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2014-10-22 13:42:30 +02:00
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
IDWriteFontCollectionLoader_Release(loader);
|
|
|
|
IDWriteFontCollectionLoader_Release(loader2);
|
|
|
|
IDWriteFontCollectionLoader_Release(loader3);
|
|
|
|
|
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2014-08-07 00:01:09 +02:00
|
|
|
}
|
|
|
|
|
2014-08-12 21:11:30 +02:00
|
|
|
static HRESULT WINAPI fontfileloader_QueryInterface(IDWriteFontFileLoader *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteFontFileLoader))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
IDWriteFontFileLoader_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI fontfileloader_AddRef(IDWriteFontFileLoader *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI fontfileloader_Release(IDWriteFontFileLoader *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-07-05 11:55:53 +02:00
|
|
|
static HRESULT WINAPI fontfileloader_CreateStreamFromKey(IDWriteFontFileLoader *iface, const void *ref_key, UINT32 key_size,
|
|
|
|
IDWriteFontFileStream **stream)
|
2014-08-12 21:11:30 +02:00
|
|
|
{
|
|
|
|
return 0x8faecafe;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IDWriteFontFileLoaderVtbl dwritefontfileloadervtbl = {
|
|
|
|
fontfileloader_QueryInterface,
|
|
|
|
fontfileloader_AddRef,
|
|
|
|
fontfileloader_Release,
|
|
|
|
fontfileloader_CreateStreamFromKey
|
|
|
|
};
|
|
|
|
|
2014-10-22 09:06:15 +02:00
|
|
|
static void test_CreateCustomFontFileReference(void)
|
2014-08-12 21:11:30 +02:00
|
|
|
{
|
|
|
|
IDWriteFontFileLoader floader = { &dwritefontfileloadervtbl };
|
|
|
|
IDWriteFontFileLoader floader2 = { &dwritefontfileloadervtbl };
|
2014-08-12 21:11:34 +02:00
|
|
|
IDWriteFontFileLoader floader3 = { &dwritefontfileloadervtbl };
|
2014-10-24 09:40:06 +02:00
|
|
|
IDWriteFactory *factory, *factory2;
|
2016-04-20 09:51:00 +02:00
|
|
|
IDWriteFontFileLoader *loader;
|
2014-10-22 09:06:15 +02:00
|
|
|
IDWriteFontFile *file, *file2;
|
|
|
|
BOOL support;
|
|
|
|
DWRITE_FONT_FILE_TYPE file_type;
|
|
|
|
DWRITE_FONT_FACE_TYPE face_type;
|
|
|
|
UINT32 count;
|
|
|
|
IDWriteFontFace *face, *face2;
|
2014-08-12 21:11:30 +02:00
|
|
|
HRESULT hr;
|
2014-10-22 09:06:15 +02:00
|
|
|
HRSRC fontrsrc;
|
2014-09-03 14:26:43 +02:00
|
|
|
UINT32 codePoints[1] = {0xa8};
|
2015-03-13 19:57:50 +01:00
|
|
|
UINT16 indices[2];
|
2016-04-20 09:51:00 +02:00
|
|
|
const void *key;
|
|
|
|
UINT32 key_size;
|
|
|
|
WCHAR *path;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2016-04-20 09:51:00 +02:00
|
|
|
|
|
|
|
path = create_testfontfile(test_fontfile);
|
2014-08-12 21:11:30 +02:00
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
factory = create_factory();
|
2014-10-24 09:40:06 +02:00
|
|
|
factory2 = create_factory();
|
2014-10-22 13:42:30 +02:00
|
|
|
|
2015-09-04 11:16:08 +02:00
|
|
|
if (0) { /* crashes on win10 */
|
2014-08-12 21:11:30 +02:00
|
|
|
hr = IDWriteFactory_RegisterFontFileLoader(factory, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2015-09-04 11:16:08 +02:00
|
|
|
}
|
2016-04-20 09:51:00 +02:00
|
|
|
/* local loader is accepted too */
|
|
|
|
hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetLoader(file, &loader);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetReferenceKey(file, &key, &key_size);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateCustomFontFileReference(factory, key, key_size, loader, &file2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IDWriteFontFile_Release(file2);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
IDWriteFontFileLoader_Release(loader);
|
|
|
|
|
2014-08-12 21:11:30 +02:00
|
|
|
hr = IDWriteFactory_RegisterFontFileLoader(factory, &floader);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
hr = IDWriteFactory_RegisterFontFileLoader(factory, &floader2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
hr = IDWriteFactory_RegisterFontFileLoader(factory, &floader);
|
|
|
|
ok(hr == DWRITE_E_ALREADYREGISTERED, "got 0x%08x\n", hr);
|
2014-08-20 22:50:21 +02:00
|
|
|
hr = IDWriteFactory_RegisterFontFileLoader(factory, &rloader);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2014-08-12 21:11:30 +02:00
|
|
|
|
2014-10-22 09:06:15 +02:00
|
|
|
file = NULL;
|
|
|
|
hr = IDWriteFactory_CreateCustomFontFileReference(factory, "test", 4, &floader, &file);
|
2014-08-12 21:11:34 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2014-10-22 09:06:15 +02:00
|
|
|
IDWriteFontFile_Release(file);
|
2014-08-12 21:11:34 +02:00
|
|
|
|
2016-01-28 21:27:20 +01:00
|
|
|
file = (void*)0xdeadbeef;
|
2014-10-22 09:06:15 +02:00
|
|
|
hr = IDWriteFactory_CreateCustomFontFileReference(factory, "test", 4, &floader3, &file);
|
2014-08-12 21:11:34 +02:00
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2016-01-28 21:27:20 +01:00
|
|
|
ok(file == NULL, "got %p\n", file);
|
2014-08-12 21:11:34 +02:00
|
|
|
|
2016-01-28 21:27:20 +01:00
|
|
|
file = (void*)0xdeadbeef;
|
2014-10-22 09:06:15 +02:00
|
|
|
hr = IDWriteFactory_CreateCustomFontFileReference(factory, "test", 4, NULL, &file);
|
2014-08-12 21:11:34 +02:00
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2016-01-28 21:27:20 +01:00
|
|
|
ok(file == NULL, "got %p\n", file);
|
2014-08-12 21:11:34 +02:00
|
|
|
|
2014-10-22 09:06:15 +02:00
|
|
|
file = NULL;
|
|
|
|
hr = IDWriteFactory_CreateCustomFontFileReference(factory, "test", 4, &floader, &file);
|
2014-08-12 21:11:37 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2014-10-22 09:06:15 +02:00
|
|
|
|
|
|
|
file_type = DWRITE_FONT_FILE_TYPE_TRUETYPE;
|
|
|
|
face_type = DWRITE_FONT_FACE_TYPE_TRUETYPE;
|
|
|
|
support = TRUE;
|
|
|
|
count = 1;
|
2015-03-30 10:57:28 +02:00
|
|
|
hr = IDWriteFontFile_Analyze(file, &support, &file_type, &face_type, &count);
|
|
|
|
ok(hr == 0x8faecafe, "got 0x%08x\n", hr);
|
2014-08-12 21:11:37 +02:00
|
|
|
ok(support == FALSE, "got %i\n", support);
|
2014-10-22 09:06:15 +02:00
|
|
|
ok(file_type == DWRITE_FONT_FILE_TYPE_UNKNOWN, "got %i\n", file_type);
|
|
|
|
ok(face_type == DWRITE_FONT_FACE_TYPE_UNKNOWN, "got %i\n", face_type);
|
2014-08-12 21:11:37 +02:00
|
|
|
ok(count == 0, "got %i\n", count);
|
2014-08-17 03:40:48 +02:00
|
|
|
|
2014-10-22 09:06:15 +02:00
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_CFF, 1, &file, 0, 0, &face);
|
2014-08-17 03:40:48 +02:00
|
|
|
ok(hr == 0x8faecafe, "got 0x%08x\n", hr);
|
2014-10-22 09:06:15 +02:00
|
|
|
IDWriteFontFile_Release(file);
|
2014-08-12 21:11:37 +02:00
|
|
|
|
2014-10-22 09:06:15 +02:00
|
|
|
fontrsrc = FindResourceA(GetModuleHandleA(NULL), (LPCSTR)MAKEINTRESOURCE(1), (LPCSTR)RT_RCDATA);
|
|
|
|
ok(fontrsrc != NULL, "Failed to find font resource\n");
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateCustomFontFileReference(factory, &fontrsrc, sizeof(HRSRC), &rloader, &file);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
file_type = DWRITE_FONT_FILE_TYPE_UNKNOWN;
|
|
|
|
face_type = DWRITE_FONT_FACE_TYPE_UNKNOWN;
|
|
|
|
support = FALSE;
|
|
|
|
count = 0;
|
|
|
|
hr = IDWriteFontFile_Analyze(file, &support, &file_type, &face_type, &count);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(support == TRUE, "got %i\n", support);
|
|
|
|
ok(file_type == DWRITE_FONT_FILE_TYPE_TRUETYPE, "got %i\n", file_type);
|
|
|
|
ok(face_type == DWRITE_FONT_FACE_TYPE_TRUETYPE, "got %i\n", face_type);
|
|
|
|
ok(count == 1, "got %i\n", count);
|
|
|
|
|
|
|
|
/* invalid index */
|
2016-01-28 21:27:20 +01:00
|
|
|
face = (void*)0xdeadbeef;
|
2014-10-22 09:06:15 +02:00
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, face_type, 1, &file, 1, DWRITE_FONT_SIMULATIONS_NONE, &face);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2016-01-28 21:27:20 +01:00
|
|
|
ok(face == NULL, "got %p\n", face);
|
2014-10-22 09:06:15 +02:00
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, face_type, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &face);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, face_type, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &face2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
/* fontface instances are reused starting with win7 */
|
|
|
|
ok(face == face2 || broken(face != face2), "got %p, %p\n", face, face2);
|
|
|
|
IDWriteFontFace_Release(face2);
|
|
|
|
|
2014-10-24 09:40:06 +02:00
|
|
|
/* file was created with different factory */
|
2014-10-26 18:49:26 +01:00
|
|
|
face2 = NULL;
|
2014-10-24 09:40:06 +02:00
|
|
|
hr = IDWriteFactory_CreateFontFace(factory2, face_type, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &face2);
|
2014-10-26 18:49:26 +01:00
|
|
|
todo_wine
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2016-08-09 14:59:46 +02:00
|
|
|
if (face2) {
|
2014-10-26 18:49:26 +01:00
|
|
|
IDWriteFontFace_Release(face2);
|
2016-08-09 14:59:46 +02:00
|
|
|
}
|
2014-10-22 09:06:15 +02:00
|
|
|
file2 = NULL;
|
|
|
|
hr = IDWriteFactory_CreateCustomFontFileReference(factory, &fontrsrc, sizeof(HRSRC), &rloader, &file2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(file != file2, "got %p, %p\n", file, file2);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, face_type, 1, &file2, 0, DWRITE_FONT_SIMULATIONS_NONE, &face2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
/* fontface instances are reused starting with win7 */
|
|
|
|
ok(face == face2 || broken(face != face2), "got %p, %p\n", face, face2);
|
|
|
|
IDWriteFontFace_Release(face2);
|
|
|
|
IDWriteFontFile_Release(file2);
|
|
|
|
|
2015-03-13 19:57:50 +01:00
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(face, NULL, 0, NULL);
|
|
|
|
ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(face, codePoints, 0, NULL);
|
|
|
|
ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(face, codePoints, 0, indices);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(face, NULL, 0, indices);
|
|
|
|
ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
indices[0] = indices[1] = 11;
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(face, NULL, 1, indices);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(indices[0] == 0, "got index %i\n", indices[0]);
|
|
|
|
ok(indices[1] == 11, "got index %i\n", indices[1]);
|
|
|
|
|
2016-08-09 14:59:46 +02:00
|
|
|
if (0) /* crashes on native */
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(face, NULL, 1, NULL);
|
2015-03-13 19:57:50 +01:00
|
|
|
|
2014-10-22 09:06:15 +02:00
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(face, codePoints, 1, indices);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2017-08-25 07:29:46 +02:00
|
|
|
ok(indices[0] == 7, "Unexpected glyph index, %u.\n", indices[0]);
|
2014-10-22 09:06:15 +02:00
|
|
|
IDWriteFontFace_Release(face);
|
|
|
|
IDWriteFontFile_Release(file);
|
2014-08-20 22:50:21 +02:00
|
|
|
|
2014-08-12 21:11:30 +02:00
|
|
|
hr = IDWriteFactory_UnregisterFontFileLoader(factory, &floader);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
hr = IDWriteFactory_UnregisterFontFileLoader(factory, &floader);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
hr = IDWriteFactory_UnregisterFontFileLoader(factory, &floader2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2014-08-20 22:50:21 +02:00
|
|
|
hr = IDWriteFactory_UnregisterFontFileLoader(factory, &rloader);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2014-10-22 13:42:30 +02:00
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory2);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2016-04-20 09:51:00 +02:00
|
|
|
DELETE_FONTFILE(path);
|
2014-08-12 21:11:30 +02:00
|
|
|
}
|
|
|
|
|
2014-11-06 21:23:26 +01:00
|
|
|
static void test_CreateFontFileReference(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IDWriteFontFile *ffile = NULL;
|
|
|
|
BOOL support;
|
|
|
|
DWRITE_FONT_FILE_TYPE type;
|
|
|
|
DWRITE_FONT_FACE_TYPE face;
|
|
|
|
UINT32 count;
|
|
|
|
IDWriteFontFace *fface = NULL;
|
|
|
|
IDWriteFactory *factory;
|
2015-02-24 06:05:05 +01:00
|
|
|
WCHAR *path;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-11-06 21:23:26 +01:00
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
path = create_testfontfile(test_fontfile);
|
2014-10-22 13:42:30 +02:00
|
|
|
factory = create_factory();
|
|
|
|
|
2016-04-20 09:50:59 +02:00
|
|
|
ffile = (void*)0xdeadbeef;
|
|
|
|
hr = IDWriteFactory_CreateFontFileReference(factory, NULL, NULL, &ffile);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n",hr);
|
|
|
|
ok(ffile == NULL, "got %p\n", ffile);
|
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &ffile);
|
2014-08-26 17:11:59 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n",hr);
|
|
|
|
|
2014-11-06 21:23:26 +01:00
|
|
|
support = FALSE;
|
|
|
|
type = DWRITE_FONT_FILE_TYPE_UNKNOWN;
|
|
|
|
face = DWRITE_FONT_FACE_TYPE_CFF;
|
|
|
|
count = 0;
|
|
|
|
hr = IDWriteFontFile_Analyze(ffile, &support, &type, &face, &count);
|
2014-08-26 17:11:59 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(support == TRUE, "got %i\n", support);
|
|
|
|
ok(type == DWRITE_FONT_FILE_TYPE_TRUETYPE, "got %i\n", type);
|
|
|
|
ok(face == DWRITE_FONT_FACE_TYPE_TRUETYPE, "got %i\n", face);
|
|
|
|
ok(count == 1, "got %i\n", count);
|
|
|
|
|
2014-10-24 09:40:06 +02:00
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, face, 1, &ffile, 0, DWRITE_FONT_SIMULATIONS_NONE, &fface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2014-08-26 17:11:59 +02:00
|
|
|
|
|
|
|
IDWriteFontFace_Release(fface);
|
|
|
|
IDWriteFontFile_Release(ffile);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2014-08-26 17:11:59 +02:00
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
DELETE_FONTFILE(path);
|
2014-08-26 17:11:59 +02:00
|
|
|
}
|
|
|
|
|
2014-10-09 07:05:27 +02:00
|
|
|
static void test_shared_isolated(void)
|
|
|
|
{
|
|
|
|
IDWriteFactory *isolated, *isolated2;
|
|
|
|
IDWriteFactory *shared, *shared2;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-10-09 07:05:27 +02:00
|
|
|
|
|
|
|
/* invalid type */
|
|
|
|
shared = NULL;
|
|
|
|
hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED+1, &IID_IDWriteFactory, (IUnknown**)&shared);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(shared != NULL, "got %p\n", shared);
|
|
|
|
IDWriteFactory_Release(shared);
|
|
|
|
|
|
|
|
hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, &IID_IDWriteFactory, (IUnknown**)&shared);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, &IID_IDWriteFactory, (IUnknown**)&shared2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(shared == shared2, "got %p, and %p\n", shared, shared2);
|
2016-03-28 12:33:56 +02:00
|
|
|
IDWriteFactory_Release(shared2);
|
|
|
|
|
2014-10-09 07:05:27 +02:00
|
|
|
IDWriteFactory_Release(shared);
|
|
|
|
|
|
|
|
/* we got 2 references, released 2 - still same pointer is returned */
|
|
|
|
hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, &IID_IDWriteFactory, (IUnknown**)&shared2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(shared == shared2, "got %p, and %p\n", shared, shared2);
|
|
|
|
IDWriteFactory_Release(shared2);
|
|
|
|
|
|
|
|
hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, &IID_IDWriteFactory, (IUnknown**)&isolated);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, &IID_IDWriteFactory, (IUnknown**)&isolated2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(isolated != isolated2, "got %p, and %p\n", isolated, isolated2);
|
|
|
|
IDWriteFactory_Release(isolated2);
|
|
|
|
|
2016-03-28 12:33:56 +02:00
|
|
|
hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, &IID_IUnknown, (IUnknown**)&isolated2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFactory_Release(isolated2);
|
|
|
|
|
2014-10-09 07:05:27 +02:00
|
|
|
hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED+1, &IID_IDWriteFactory, (IUnknown**)&isolated2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(shared != isolated2, "got %p, and %p\n", shared, isolated2);
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(isolated);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
|
|
|
ref = IDWriteFactory_Release(isolated2);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2014-10-09 07:05:27 +02:00
|
|
|
}
|
|
|
|
|
2018-11-26 09:43:09 +01:00
|
|
|
struct dwrite_fonttable
|
|
|
|
{
|
|
|
|
BYTE *data;
|
|
|
|
void *context;
|
|
|
|
UINT32 size;
|
|
|
|
};
|
|
|
|
|
|
|
|
static WORD table_read_be_word(const struct dwrite_fonttable *table, void *ptr, DWORD offset)
|
|
|
|
{
|
|
|
|
if (!ptr)
|
|
|
|
ptr = table->data;
|
|
|
|
|
|
|
|
if ((BYTE *)ptr < table->data || (BYTE *)ptr - table->data >= table->size)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (offset > table->size - sizeof(WORD))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return GET_BE_WORD(*(WORD *)((BYTE *)ptr + offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD table_read_be_dword(const struct dwrite_fonttable *table, void *ptr, DWORD offset)
|
|
|
|
{
|
|
|
|
if (!ptr)
|
|
|
|
ptr = table->data;
|
|
|
|
|
|
|
|
if ((BYTE *)ptr < table->data || (BYTE *)ptr - table->data >= table->size)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (offset > table->size - sizeof(WORD))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return GET_BE_DWORD(*(DWORD *)((BYTE *)ptr + offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
|
|
|
|
{
|
|
|
|
size_t new_capacity, max_capacity;
|
|
|
|
void *new_elements;
|
|
|
|
|
|
|
|
if (count <= *capacity)
|
|
|
|
return;
|
|
|
|
|
|
|
|
max_capacity = ~(SIZE_T)0 / size;
|
|
|
|
if (count > max_capacity)
|
|
|
|
return;
|
|
|
|
|
|
|
|
new_capacity = max(4, *capacity);
|
|
|
|
while (new_capacity < count && new_capacity <= max_capacity / 2)
|
|
|
|
new_capacity *= 2;
|
|
|
|
if (new_capacity < count)
|
|
|
|
new_capacity = max_capacity;
|
|
|
|
|
|
|
|
if (!(new_elements = heap_realloc(*elements, new_capacity * size)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
*elements = new_elements;
|
|
|
|
*capacity = new_capacity;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void opentype_cmap_read_table(const struct dwrite_fonttable *table, UINT16 cmap_index, UINT32 *count,
|
|
|
|
size_t *capacity, DWRITE_UNICODE_RANGE **ranges)
|
|
|
|
{
|
|
|
|
const BYTE *tables = table->data + FIELD_OFFSET(struct cmap_header, tables);
|
|
|
|
struct cmap_encoding_record *record;
|
|
|
|
DWORD table_offset;
|
|
|
|
WORD format;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
record = (struct cmap_encoding_record *)(tables + cmap_index * sizeof(*record));
|
|
|
|
|
|
|
|
if (!(table_offset = table_read_be_dword(table, record, FIELD_OFFSET(struct cmap_encoding_record, offset))))
|
|
|
|
return;
|
|
|
|
|
|
|
|
format = table_read_be_word(table, NULL, table_offset);
|
|
|
|
switch (format)
|
|
|
|
{
|
|
|
|
case OPENTYPE_CMAP_TABLE_SEGMENT_MAPPING:
|
|
|
|
{
|
|
|
|
UINT16 segment_count = table_read_be_word(table, NULL, table_offset +
|
|
|
|
FIELD_OFFSET(struct cmap_segmented_mapping_0, segCountX2)) / 2;
|
|
|
|
DWORD start_code_offset = table_offset + sizeof(struct cmap_segmented_mapping_0) +
|
|
|
|
sizeof(WORD) * segment_count;
|
|
|
|
|
|
|
|
for (j = 0; j < segment_count; ++j) {
|
|
|
|
WORD endcode = table_read_be_word(table, NULL, table_offset +
|
|
|
|
FIELD_OFFSET(struct cmap_segmented_mapping_0, endCode) + j * sizeof(WORD));
|
|
|
|
WORD first;
|
|
|
|
|
|
|
|
if (endcode == 0xffff)
|
|
|
|
break;
|
|
|
|
|
|
|
|
first = table_read_be_word(table, NULL, start_code_offset + j * sizeof(WORD));
|
|
|
|
|
|
|
|
array_reserve((void **)ranges, capacity, *count + 1, sizeof(**ranges));
|
|
|
|
(*ranges)[*count].first = first;
|
|
|
|
(*ranges)[*count].last = endcode;
|
|
|
|
(*count)++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OPENTYPE_CMAP_TABLE_SEGMENTED_COVERAGE:
|
|
|
|
{
|
|
|
|
DWORD num_groups = table_read_be_dword(table, NULL, table_offset +
|
|
|
|
FIELD_OFFSET(struct cmap_segmented_coverage, nGroups));
|
|
|
|
|
|
|
|
for (j = 0; j < num_groups; ++j) {
|
|
|
|
DWORD group_offset = table_offset + FIELD_OFFSET(struct cmap_segmented_coverage, groups) +
|
|
|
|
j * sizeof(struct cmap_segmented_coverage_group);
|
|
|
|
DWORD first = table_read_be_dword(table, NULL, group_offset +
|
|
|
|
FIELD_OFFSET(struct cmap_segmented_coverage_group, startCharCode));
|
|
|
|
DWORD last = table_read_be_dword(table, NULL, group_offset +
|
|
|
|
FIELD_OFFSET(struct cmap_segmented_coverage_group, endCharCode));
|
|
|
|
|
|
|
|
array_reserve((void **)ranges, capacity, *count + 1, sizeof(**ranges));
|
|
|
|
(*ranges)[*count].first = first;
|
|
|
|
(*ranges)[*count].last = last;
|
|
|
|
(*count)++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
ok(0, "%u table format %#x unhandled.\n", cmap_index, format);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 opentype_cmap_get_unicode_ranges(const struct dwrite_fonttable *table, DWRITE_UNICODE_RANGE **ranges)
|
|
|
|
{
|
|
|
|
int index_full = -1, index_bmp = -1;
|
|
|
|
unsigned int i, count = 0;
|
|
|
|
size_t capacity = 0;
|
|
|
|
const BYTE *tables;
|
|
|
|
WORD num_tables;
|
|
|
|
|
|
|
|
*ranges = NULL;
|
|
|
|
|
|
|
|
num_tables = table_read_be_word(table, 0, FIELD_OFFSET(struct cmap_header, numTables));
|
|
|
|
tables = table->data + FIELD_OFFSET(struct cmap_header, tables);
|
|
|
|
|
|
|
|
for (i = 0; i < num_tables; ++i)
|
|
|
|
{
|
|
|
|
struct cmap_encoding_record *record = (struct cmap_encoding_record *)(tables + i * sizeof(*record));
|
|
|
|
WORD platform, encoding;
|
|
|
|
|
|
|
|
platform = table_read_be_word(table, record, FIELD_OFFSET(struct cmap_encoding_record, platformID));
|
|
|
|
encoding = table_read_be_word(table, record, FIELD_OFFSET(struct cmap_encoding_record, encodingID));
|
|
|
|
|
|
|
|
if (platform == OPENTYPE_CMAP_TABLE_PLATFORM_WIN)
|
|
|
|
{
|
|
|
|
if (encoding == OPENTYPE_CMAP_TABLE_ENCODING_UNICODE_FULL)
|
|
|
|
{
|
|
|
|
index_full = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (encoding == OPENTYPE_CMAP_TABLE_ENCODING_UNICODE_BMP)
|
|
|
|
index_bmp = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index_full != -1)
|
|
|
|
opentype_cmap_read_table(table, index_full, &count, &capacity, ranges);
|
|
|
|
else if (index_bmp != -1)
|
|
|
|
opentype_cmap_read_table(table, index_bmp, &count, &capacity, ranges);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 fontface_get_expected_unicode_ranges(IDWriteFontFace1 *fontface, DWRITE_UNICODE_RANGE **out)
|
|
|
|
{
|
|
|
|
struct dwrite_fonttable cmap;
|
|
|
|
DWRITE_UNICODE_RANGE *ranges;
|
|
|
|
UINT32 i, j, count;
|
|
|
|
BOOL exists;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
*out = NULL;
|
|
|
|
|
|
|
|
hr = IDWriteFontFace1_TryGetFontTable(fontface, MS_CMAP_TAG, (const void **)&cmap.data,
|
|
|
|
&cmap.size, &cmap.context, &exists);
|
|
|
|
if (FAILED(hr) || !exists)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
count = opentype_cmap_get_unicode_ranges(&cmap, &ranges);
|
|
|
|
IDWriteFontFace1_ReleaseFontTable(fontface, cmap.context);
|
|
|
|
|
|
|
|
*out = heap_alloc(count * sizeof(**out));
|
|
|
|
|
|
|
|
/* Eliminate duplicates and merge ranges together. */
|
|
|
|
for (i = 0, j = 0; i < count; ++i) {
|
|
|
|
if (j) {
|
|
|
|
DWRITE_UNICODE_RANGE *prev = &(*out)[j-1];
|
|
|
|
/* Merge adjacent ranges. */
|
|
|
|
if (ranges[i].first == prev->last + 1) {
|
|
|
|
prev->last = ranges[i].last;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
(*out)[j++] = ranges[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
heap_free(ranges);
|
|
|
|
|
|
|
|
return j;
|
|
|
|
}
|
|
|
|
|
2014-10-16 05:33:51 +02:00
|
|
|
static void test_GetUnicodeRanges(void)
|
|
|
|
{
|
2018-11-26 09:43:09 +01:00
|
|
|
IDWriteFontCollection *syscollection;
|
2014-10-16 05:33:51 +02:00
|
|
|
DWRITE_UNICODE_RANGE *ranges, r;
|
|
|
|
IDWriteFontFile *ffile = NULL;
|
|
|
|
IDWriteFontFace1 *fontface1;
|
|
|
|
IDWriteFontFace *fontface;
|
2014-10-22 13:42:30 +02:00
|
|
|
IDWriteFactory *factory;
|
2018-11-26 09:43:09 +01:00
|
|
|
UINT32 count, i;
|
2014-10-16 05:33:51 +02:00
|
|
|
HRESULT hr;
|
|
|
|
HRSRC font;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-10-16 05:33:51 +02:00
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
factory = create_factory();
|
|
|
|
|
2014-10-16 05:33:51 +02:00
|
|
|
hr = IDWriteFactory_RegisterFontFileLoader(factory, &rloader);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
font = FindResourceA(GetModuleHandleA(NULL), (LPCSTR)MAKEINTRESOURCE(1), (LPCSTR)RT_RCDATA);
|
|
|
|
ok(font != NULL, "Failed to find font resource\n");
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateCustomFontFileReference(factory, &font, sizeof(HRSRC), &rloader, &ffile);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &ffile, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFile_Release(ffile);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
if (hr != S_OK) {
|
|
|
|
win_skip("GetUnicodeRanges() is not supported.\n");
|
2014-10-22 13:42:30 +02:00
|
|
|
IDWriteFactory_Release(factory);
|
2014-10-16 05:33:51 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
hr = IDWriteFontFace1_GetUnicodeRanges(fontface1, 0, NULL, &count);
|
|
|
|
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr);
|
|
|
|
ok(count > 0, "got %u\n", count);
|
|
|
|
|
|
|
|
count = 1;
|
|
|
|
hr = IDWriteFontFace1_GetUnicodeRanges(fontface1, 1, NULL, &count);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(count == 0, "got %u\n", count);
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
hr = IDWriteFontFace1_GetUnicodeRanges(fontface1, 1, &r, &count);
|
|
|
|
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr);
|
|
|
|
ok(count > 1, "got %u\n", count);
|
|
|
|
|
|
|
|
ranges = heap_alloc(count*sizeof(DWRITE_UNICODE_RANGE));
|
|
|
|
hr = IDWriteFontFace1_GetUnicodeRanges(fontface1, count, ranges, &count);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
ranges[0].first = ranges[0].last = 0;
|
|
|
|
hr = IDWriteFontFace1_GetUnicodeRanges(fontface1, 1, ranges, &count);
|
|
|
|
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr);
|
|
|
|
ok(ranges[0].first != 0 && ranges[0].last != 0, "got 0x%x-0x%0x\n", ranges[0].first, ranges[0].last);
|
|
|
|
|
|
|
|
heap_free(ranges);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_UnregisterFontFileLoader(factory, &rloader);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IDWriteFontFace1_Release(fontface1);
|
2018-11-26 09:43:09 +01:00
|
|
|
|
|
|
|
if (strcmp(winetest_platform, "wine")) {
|
|
|
|
|
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE);
|
|
|
|
ok(hr == S_OK, "Failed to get system collection, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
count = IDWriteFontCollection_GetFontFamilyCount(syscollection);
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
WCHAR familynameW[256], facenameW[128];
|
|
|
|
IDWriteLocalizedStrings *names;
|
|
|
|
IDWriteFontFamily *family;
|
|
|
|
UINT32 j, k, fontcount;
|
|
|
|
IDWriteFont *font;
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(syscollection, i, &family);
|
|
|
|
ok(hr == S_OK, "Failed to get font family, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFamilyNames(family, &names);
|
|
|
|
ok(hr == S_OK, "Failed to get family names, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
get_enus_string(names, familynameW, ARRAY_SIZE(familynameW));
|
|
|
|
IDWriteLocalizedStrings_Release(names);
|
|
|
|
|
|
|
|
fontcount = IDWriteFontFamily_GetFontCount(family);
|
|
|
|
for (j = 0; j < fontcount; j++) {
|
|
|
|
DWRITE_UNICODE_RANGE *expected_ranges = NULL;
|
|
|
|
UINT32 range_count, expected_count;
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFont(family, j, &font);
|
|
|
|
ok(hr == S_OK, "Failed to get font, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "Failed to create fontface, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFont_GetFaceNames(font, &names);
|
|
|
|
ok(hr == S_OK, "Failed to get face names, hr %#x.\n", hr);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
get_enus_string(names, facenameW, ARRAY_SIZE(facenameW));
|
|
|
|
|
|
|
|
IDWriteLocalizedStrings_Release(names);
|
|
|
|
|
|
|
|
if (IDWriteFontFace_IsSymbolFont(fontface)) {
|
|
|
|
skip("Skipping for symbol font %s %s.\n", wine_dbgstr_w(familynameW), wine_dbgstr_w(facenameW));
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void **)&fontface1);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace1_GetUnicodeRanges(fontface1, 0, NULL, &range_count);
|
|
|
|
ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
ranges = heap_alloc(range_count * sizeof(*ranges));
|
|
|
|
|
|
|
|
hr = IDWriteFontFace1_GetUnicodeRanges(fontface1, range_count, ranges, &range_count);
|
|
|
|
ok(hr == S_OK, "Failed to get ranges, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
expected_count = fontface_get_expected_unicode_ranges(fontface1, &expected_ranges);
|
|
|
|
ok(expected_count == range_count, "%s - %s: unexpected range count %u, expected %u.\n",
|
|
|
|
wine_dbgstr_w(familynameW), wine_dbgstr_w(facenameW), range_count, expected_count);
|
|
|
|
|
|
|
|
if (expected_count == range_count) {
|
|
|
|
if (memcmp(expected_ranges, ranges, expected_count * sizeof(*ranges))) {
|
|
|
|
for (k = 0; k < expected_count; ++k) {
|
|
|
|
BOOL failed = memcmp(&expected_ranges[k], &ranges[k], sizeof(*ranges));
|
|
|
|
ok(!failed, "%u: %s - %s mismatching range [%#x, %#x] vs [%#x, %#x].\n", k,
|
|
|
|
wine_dbgstr_w(familynameW), wine_dbgstr_w(facenameW), ranges[k].first, ranges[k].last,
|
|
|
|
expected_ranges[k].first, expected_ranges[k].last);
|
|
|
|
if (failed)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
heap_free(expected_ranges);
|
|
|
|
heap_free(ranges);
|
|
|
|
|
|
|
|
IDWriteFontFace1_Release(fontface1);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontCollection_Release(syscollection);
|
|
|
|
}
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2014-10-16 05:33:51 +02:00
|
|
|
}
|
|
|
|
|
2014-10-17 06:39:41 +02:00
|
|
|
static void test_GetFontFromFontFace(void)
|
|
|
|
{
|
|
|
|
IDWriteFontFace *fontface, *fontface2;
|
|
|
|
IDWriteFontCollection *collection;
|
|
|
|
IDWriteFont *font, *font2, *font3;
|
|
|
|
IDWriteFontFamily *family;
|
2014-10-22 13:42:30 +02:00
|
|
|
IDWriteFactory *factory;
|
2015-02-18 20:46:10 +01:00
|
|
|
IDWriteFontFile *file;
|
2015-02-24 06:05:05 +01:00
|
|
|
WCHAR *path;
|
2014-10-17 06:39:41 +02:00
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-10-17 06:39:41 +02:00
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
factory = create_factory();
|
|
|
|
|
2014-10-17 06:39:41 +02:00
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
|
|
|
|
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
font2 = NULL;
|
|
|
|
hr = IDWriteFontCollection_GetFontFromFontFace(collection, fontface, &font2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(font2 != font, "got %p, %p\n", font2, font);
|
|
|
|
|
|
|
|
font3 = NULL;
|
|
|
|
hr = IDWriteFontCollection_GetFontFromFontFace(collection, fontface, &font3);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(font3 != font && font3 != font2, "got %p, %p, %p\n", font3, font2, font);
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font2, &fontface2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(fontface2 == fontface, "got %p, %p\n", fontface2, fontface);
|
|
|
|
IDWriteFontFace_Release(fontface2);
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font3, &fontface2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(fontface2 == fontface, "got %p, %p\n", fontface2, fontface);
|
|
|
|
IDWriteFontFace_Release(fontface2);
|
2015-02-18 20:46:10 +01:00
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
IDWriteFont_Release(font3);
|
|
|
|
IDWriteFactory_Release(factory);
|
|
|
|
|
|
|
|
/* fontface that wasn't created from this collection */
|
|
|
|
factory = create_factory();
|
2015-02-24 06:05:05 +01:00
|
|
|
path = create_testfontfile(test_fontfile);
|
2015-02-18 20:46:10 +01:00
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
|
2015-02-18 20:46:10 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n",hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFromFontFace(collection, fontface, &font3);
|
|
|
|
ok(hr == DWRITE_E_NOFONT, "got 0x%08x\n", hr);
|
|
|
|
ok(font3 == NULL, "got %p\n", font3);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
2014-10-17 06:39:41 +02:00
|
|
|
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
IDWriteFont_Release(font2);
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
IDWriteFontCollection_Release(collection);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-02-24 06:05:05 +01:00
|
|
|
DELETE_FONTFILE(path);
|
2014-10-17 06:39:41 +02:00
|
|
|
}
|
|
|
|
|
2015-02-03 11:27:24 +01:00
|
|
|
static void test_GetFirstMatchingFont(void)
|
|
|
|
{
|
|
|
|
DWRITE_FONT_SIMULATIONS simulations;
|
2016-03-08 20:46:55 +01:00
|
|
|
IDWriteFontCollection *collection;
|
|
|
|
IDWriteFontFamily *family;
|
2015-02-03 11:27:24 +01:00
|
|
|
IDWriteFont *font, *font2;
|
|
|
|
IDWriteFactory *factory;
|
2016-03-08 20:46:55 +01:00
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2015-02-03 11:27:24 +01:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
2016-03-08 20:46:55 +01:00
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
|
|
|
|
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
|
|
|
|
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &font2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2014-10-17 06:39:41 +02:00
|
|
|
ok(font != font2, "got %p, %p\n", font, font2);
|
2014-10-27 17:01:48 +01:00
|
|
|
IDWriteFont_Release(font);
|
2015-02-03 11:27:24 +01:00
|
|
|
IDWriteFont_Release(font2);
|
2014-10-27 17:01:48 +01:00
|
|
|
|
2016-07-19 22:03:00 +02:00
|
|
|
/* out-of-range font props are allowed */
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, 1000, DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL, 10, DWRITE_FONT_STYLE_NORMAL, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
|
|
|
|
10, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
2016-03-08 20:46:55 +01:00
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
|
2015-02-03 11:27:24 +01:00
|
|
|
font = get_tahoma_instance(factory, DWRITE_FONT_STYLE_ITALIC);
|
2014-10-27 17:01:48 +01:00
|
|
|
simulations = IDWriteFont_GetSimulations(font);
|
|
|
|
ok(simulations == DWRITE_FONT_SIMULATIONS_OBLIQUE, "%d\n", simulations);
|
2014-10-17 06:39:41 +02:00
|
|
|
IDWriteFont_Release(font);
|
2015-02-03 11:27:24 +01:00
|
|
|
|
2016-03-08 20:46:55 +01:00
|
|
|
IDWriteFontCollection_Release(collection);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2016-03-08 20:46:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_GetMatchingFonts(void)
|
|
|
|
{
|
|
|
|
IDWriteFontCollection *collection;
|
|
|
|
IDWriteFontFamily *family;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFontList *fontlist, *fontlist2;
|
|
|
|
IDWriteFontList1 *fontlist1;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2016-03-08 20:46:55 +01:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2016-07-19 22:03:00 +02:00
|
|
|
/* out-of-range font props are allowed */
|
|
|
|
hr = IDWriteFontFamily_GetMatchingFonts(family, 1000, DWRITE_FONT_STRETCH_NORMAL,
|
|
|
|
DWRITE_FONT_STYLE_NORMAL, &fontlist);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontList_Release(fontlist);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetMatchingFonts(family, DWRITE_FONT_WEIGHT_NORMAL, 10,
|
|
|
|
DWRITE_FONT_STYLE_NORMAL, &fontlist);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontList_Release(fontlist);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetMatchingFonts(family, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
|
|
|
|
10, &fontlist);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontList_Release(fontlist);
|
|
|
|
|
2016-03-08 20:46:55 +01:00
|
|
|
hr = IDWriteFontFamily_GetMatchingFonts(family, DWRITE_FONT_WEIGHT_NORMAL,
|
|
|
|
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &fontlist);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetMatchingFonts(family, DWRITE_FONT_WEIGHT_NORMAL,
|
|
|
|
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &fontlist2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(fontlist != fontlist2, "got %p, %p\n", fontlist, fontlist2);
|
|
|
|
IDWriteFontList_Release(fontlist2);
|
|
|
|
|
|
|
|
hr = IDWriteFontList_QueryInterface(fontlist, &IID_IDWriteFontList1, (void**)&fontlist1);
|
|
|
|
if (hr == S_OK) {
|
2016-05-05 23:34:02 +02:00
|
|
|
IDWriteFontFaceReference *ref, *ref1;
|
2016-03-08 20:46:55 +01:00
|
|
|
IDWriteFont3 *font;
|
2016-05-05 23:34:02 +02:00
|
|
|
UINT32 count;
|
|
|
|
|
|
|
|
count = IDWriteFontList1_GetFontCount(fontlist1);
|
|
|
|
ok(count > 0, "got %u\n", count);
|
2016-03-08 20:46:55 +01:00
|
|
|
|
|
|
|
font = (void*)0xdeadbeef;
|
|
|
|
hr = IDWriteFontList1_GetFont(fontlist1, ~0u, &font);
|
|
|
|
ok(hr == E_FAIL, "got 0x%08x\n", hr);
|
|
|
|
ok(font == NULL, "got %p\n", font);
|
2016-05-05 23:34:01 +02:00
|
|
|
|
|
|
|
font = (void*)0xdeadbeef;
|
2016-05-05 23:34:02 +02:00
|
|
|
hr = IDWriteFontList1_GetFont(fontlist1, count, &font);
|
2016-05-05 23:34:01 +02:00
|
|
|
ok(hr == E_FAIL, "got 0x%08x\n", hr);
|
|
|
|
ok(font == NULL, "got %p\n", font);
|
|
|
|
|
|
|
|
hr = IDWriteFontList1_GetFont(fontlist1, 0, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFont3_Release(font);
|
|
|
|
|
2016-05-05 23:34:02 +02:00
|
|
|
hr = IDWriteFontList1_GetFontFaceReference(fontlist1, 0, &ref);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontList1_GetFontFaceReference(fontlist1, 0, &ref1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(ref != ref1, "got %p, %p\n", ref, ref1);
|
|
|
|
|
|
|
|
IDWriteFontFaceReference_Release(ref1);
|
|
|
|
IDWriteFontFaceReference_Release(ref);
|
2016-03-08 20:46:55 +01:00
|
|
|
IDWriteFontList1_Release(fontlist1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("IDWriteFontList1 is not supported.\n");
|
|
|
|
|
|
|
|
IDWriteFontList_Release(fontlist);
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
|
|
|
|
IDWriteFontCollection_Release(collection);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2014-10-17 06:39:41 +02:00
|
|
|
}
|
|
|
|
|
2014-10-19 21:57:53 +02:00
|
|
|
static void test_GetInformationalStrings(void)
|
|
|
|
{
|
|
|
|
IDWriteLocalizedStrings *strings, *strings2;
|
|
|
|
IDWriteFontCollection *collection;
|
|
|
|
IDWriteFontFamily *family;
|
2014-10-22 13:42:30 +02:00
|
|
|
IDWriteFactory *factory;
|
2014-10-19 21:57:53 +02:00
|
|
|
IDWriteFont *font;
|
|
|
|
BOOL exists;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-10-19 21:57:53 +02:00
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
factory = create_factory();
|
|
|
|
|
2014-10-19 21:57:53 +02:00
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
|
|
|
|
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
exists = TRUE;
|
|
|
|
strings = (void*)0xdeadbeef;
|
|
|
|
hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_POSTSCRIPT_CID_NAME+1, &strings, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(exists == FALSE, "got %d\n", exists);
|
|
|
|
ok(strings == NULL, "got %p\n", strings);
|
2014-10-20 19:45:57 +02:00
|
|
|
|
2014-10-19 21:57:53 +02:00
|
|
|
exists = TRUE;
|
|
|
|
strings = NULL;
|
|
|
|
hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_NONE, &strings, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(exists == FALSE, "got %d\n", exists);
|
|
|
|
|
2014-10-29 20:41:47 +01:00
|
|
|
exists = FALSE;
|
|
|
|
strings = NULL;
|
|
|
|
hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &strings, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(exists == TRUE, "got %d\n", exists);
|
|
|
|
|
2014-10-19 21:57:53 +02:00
|
|
|
/* strings instance is not reused */
|
|
|
|
strings2 = NULL;
|
|
|
|
hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &strings2, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(strings2 != strings, "got %p, %p\n", strings2, strings);
|
|
|
|
|
|
|
|
IDWriteLocalizedStrings_Release(strings);
|
|
|
|
IDWriteLocalizedStrings_Release(strings2);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
IDWriteFontCollection_Release(collection);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2014-10-19 21:57:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_GetGdiInterop(void)
|
|
|
|
{
|
|
|
|
IDWriteGdiInterop *interop, *interop2;
|
2014-10-22 13:42:30 +02:00
|
|
|
IDWriteFactory *factory, *factory2;
|
2014-10-19 21:57:53 +02:00
|
|
|
IDWriteFont *font;
|
|
|
|
LOGFONTW logfont;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-10-19 21:57:53 +02:00
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
factory = create_factory();
|
|
|
|
|
2014-10-19 21:57:53 +02:00
|
|
|
interop = NULL;
|
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
interop2 = NULL;
|
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(interop == interop2, "got %p, %p\n", interop, interop2);
|
|
|
|
IDWriteGdiInterop_Release(interop2);
|
|
|
|
|
|
|
|
hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, &IID_IDWriteFactory, (IUnknown**)&factory2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
/* each factory gets its own interop */
|
|
|
|
interop2 = NULL;
|
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory2, &interop2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(interop != interop2, "got %p, %p\n", interop, interop2);
|
|
|
|
|
|
|
|
/* release factory - interop still works */
|
|
|
|
IDWriteFactory_Release(factory2);
|
|
|
|
|
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
|
|
|
logfont.lfItalic = 1;
|
|
|
|
lstrcpyW(logfont.lfFaceName, tahomaW);
|
|
|
|
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop2, &logfont, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2015-02-20 11:48:37 +01:00
|
|
|
IDWriteFont_Release(font);
|
2014-10-19 21:57:53 +02:00
|
|
|
|
|
|
|
IDWriteGdiInterop_Release(interop2);
|
|
|
|
IDWriteGdiInterop_Release(interop);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2014-10-19 21:57:53 +02:00
|
|
|
}
|
|
|
|
|
2018-11-19 10:27:36 +01:00
|
|
|
static void *map_font_file(const WCHAR *filename, DWORD *file_size)
|
|
|
|
{
|
|
|
|
HANDLE file, mapping;
|
|
|
|
void *ptr;
|
|
|
|
|
|
|
|
file = CreateFileW(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
|
|
|
|
if (file == INVALID_HANDLE_VALUE) return NULL;
|
|
|
|
|
|
|
|
*file_size = GetFileSize(file, NULL);
|
|
|
|
|
|
|
|
mapping = CreateFileMappingA(file, NULL, PAGE_READONLY, 0, 0, NULL);
|
|
|
|
if (!mapping)
|
|
|
|
{
|
|
|
|
CloseHandle(file);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
|
|
|
|
|
|
|
|
CloseHandle(file);
|
|
|
|
CloseHandle(mapping);
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2018-11-22 12:29:14 +01:00
|
|
|
struct font_realization_info
|
|
|
|
{
|
|
|
|
DWORD size;
|
|
|
|
DWORD flags;
|
|
|
|
DWORD cache_num;
|
|
|
|
DWORD instance_id;
|
|
|
|
DWORD unk;
|
|
|
|
WORD face_index;
|
|
|
|
WORD simulations;
|
|
|
|
};
|
|
|
|
|
2014-10-20 06:55:39 +02:00
|
|
|
static void test_CreateFontFaceFromHdc(void)
|
|
|
|
{
|
2018-11-19 10:27:36 +01:00
|
|
|
IDWriteFontFileStream *stream, *stream2;
|
|
|
|
void *font_data, *fragment_context;
|
2018-11-22 12:29:14 +01:00
|
|
|
struct font_realization_info info;
|
2018-11-19 10:27:36 +01:00
|
|
|
const void *refkey, *fragment;
|
|
|
|
IDWriteFontFileLoader *loader;
|
|
|
|
DWORD data_size, num_fonts;
|
2014-10-20 06:55:39 +02:00
|
|
|
IDWriteGdiInterop *interop;
|
|
|
|
IDWriteFontFace *fontface;
|
2014-10-22 13:42:30 +02:00
|
|
|
IDWriteFactory *factory;
|
2018-11-19 10:27:36 +01:00
|
|
|
UINT64 size, writetime;
|
|
|
|
IDWriteFontFile *file;
|
2014-10-20 06:55:39 +02:00
|
|
|
HFONT hfont, oldhfont;
|
2018-11-22 12:29:14 +01:00
|
|
|
UINT32 count, dummy;
|
2014-10-20 06:55:39 +02:00
|
|
|
LOGFONTW logfont;
|
2018-11-19 10:27:36 +01:00
|
|
|
HANDLE resource;
|
|
|
|
IUnknown *unk;
|
2017-04-19 14:15:29 +02:00
|
|
|
LOGFONTA lf;
|
2018-11-19 10:27:36 +01:00
|
|
|
WCHAR *path;
|
2014-10-20 06:55:39 +02:00
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2018-11-19 10:27:36 +01:00
|
|
|
BOOL ret;
|
2014-10-20 06:55:39 +02:00
|
|
|
HDC hdc;
|
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
factory = create_factory();
|
|
|
|
|
2018-11-22 12:29:14 +01:00
|
|
|
pGetFontRealizationInfo = (void *)GetProcAddress(GetModuleHandleA("gdi32"), "GetFontRealizationInfo");
|
|
|
|
|
2014-10-20 06:55:39 +02:00
|
|
|
interop = NULL;
|
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2017-04-19 14:15:29 +02:00
|
|
|
/* Invalid HDC. */
|
2016-01-28 21:27:20 +01:00
|
|
|
fontface = (void*)0xdeadbeef;
|
2014-10-20 06:55:39 +02:00
|
|
|
hr = IDWriteGdiInterop_CreateFontFaceFromHdc(interop, NULL, &fontface);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2016-01-28 21:27:20 +01:00
|
|
|
ok(fontface == NULL, "got %p\n", fontface);
|
2014-10-20 06:55:39 +02:00
|
|
|
|
2017-04-19 14:15:29 +02:00
|
|
|
fontface = (void *)0xdeadbeef;
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFaceFromHdc(interop, (HDC)0xdeadbeef, &fontface);
|
|
|
|
ok(hr == E_FAIL, "got 0x%08x\n", hr);
|
|
|
|
ok(fontface == NULL, "got %p\n", fontface);
|
|
|
|
|
2014-10-20 06:55:39 +02:00
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
|
|
|
logfont.lfItalic = 1;
|
|
|
|
lstrcpyW(logfont.lfFaceName, tahomaW);
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectW(&logfont);
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
oldhfont = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
fontface = NULL;
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFaceFromHdc(interop, hdc, &fontface);
|
2018-11-22 12:29:14 +01:00
|
|
|
ok(hr == S_OK, "Failed to create font face, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
count = 1;
|
|
|
|
hr = IDWriteFontFace_GetFiles(fontface, &count, &file);
|
|
|
|
ok(hr == S_OK, "Failed to get font files, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetLoader(file, &loader);
|
|
|
|
ok(hr == S_OK, "Failed to get file loader, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFileLoader_QueryInterface(loader, &IID_IDWriteLocalFontFileLoader, (void **)&unk);
|
|
|
|
ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* Vista */, "Expected local loader, hr %#x.\n", hr);
|
|
|
|
if (unk)
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
|
|
|
|
IDWriteFontFileLoader_Release(loader);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
|
2014-10-20 06:55:39 +02:00
|
|
|
IDWriteFontFace_Release(fontface);
|
2017-04-19 14:15:29 +02:00
|
|
|
DeleteObject(SelectObject(hdc, oldhfont));
|
|
|
|
|
|
|
|
/* Select bitmap font MS Sans Serif, format that's not supported by DirectWrite. */
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = -12;
|
|
|
|
strcpy(lf.lfFaceName, "MS Sans Serif");
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
oldhfont = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
fontface = (void *)0xdeadbeef;
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFaceFromHdc(interop, hdc, &fontface);
|
|
|
|
ok(hr == DWRITE_E_FILEFORMAT || broken(hr == E_FAIL) /* Vista */, "got 0x%08x\n", hr);
|
|
|
|
ok(fontface == NULL, "got %p\n", fontface);
|
|
|
|
|
2014-10-20 06:55:39 +02:00
|
|
|
DeleteObject(SelectObject(hdc, oldhfont));
|
|
|
|
|
2018-11-19 10:27:36 +01:00
|
|
|
/* Memory resource font */
|
|
|
|
path = create_testfontfile(test_fontfile);
|
|
|
|
|
|
|
|
data_size = 0;
|
|
|
|
font_data = map_font_file(path, &data_size);
|
|
|
|
|
|
|
|
num_fonts = 0;
|
|
|
|
resource = AddFontMemResourceEx(font_data, data_size, NULL, &num_fonts);
|
|
|
|
ok(resource != NULL, "Failed to add memory resource font, %d.\n", GetLastError());
|
|
|
|
ok(num_fonts == 1, "Unexpected number of fonts.\n");
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = -12;
|
|
|
|
strcpy(lf.lfFaceName, "wine_test");
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != NULL, "Failed to create a font.\n");
|
|
|
|
oldhfont = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFaceFromHdc(interop, hdc, &fontface);
|
|
|
|
ok(hr == S_OK, "Failed to create fontface, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
count = 1;
|
|
|
|
hr = IDWriteFontFace_GetFiles(fontface, &count, &file);
|
|
|
|
ok(hr == S_OK, "Failed to get font files, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetLoader(file, &loader);
|
|
|
|
ok(hr == S_OK, "Failed to get file loader, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_RegisterFontFileLoader(factory, loader);
|
|
|
|
ok(hr == DWRITE_E_ALREADYREGISTERED, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFileLoader_QueryInterface(loader, &IID_IDWriteInMemoryFontFileLoader, (void **)&unk);
|
|
|
|
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFileLoader_QueryInterface(loader, &IID_IDWriteLocalFontFileLoader, (void **)&unk);
|
|
|
|
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
hr = IDWriteFontFile_GetReferenceKey(file, &refkey, &count);
|
|
|
|
ok(hr == S_OK, "Failed to get ref key, hr %#x.\n", hr);
|
|
|
|
ok(count > 0, "Unexpected key length %u.\n", count);
|
|
|
|
|
2018-11-22 12:29:14 +01:00
|
|
|
if (pGetFontRealizationInfo)
|
|
|
|
{
|
|
|
|
info.size = sizeof(info);
|
|
|
|
ret = pGetFontRealizationInfo(hdc, &info);
|
|
|
|
ok(ret, "Failed to get realization info.\n");
|
|
|
|
ok(count == sizeof(info.instance_id), "Unexpected key size.\n");
|
|
|
|
ok(*(DWORD *)refkey == info.instance_id, "Unexpected stream key.\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("GetFontRealizationInfo() is not available.\n");
|
|
|
|
|
2018-11-19 10:27:36 +01:00
|
|
|
hr = IDWriteFontFileLoader_CreateStreamFromKey(loader, refkey, count, &stream);
|
|
|
|
ok(hr == S_OK, "Failed to create file stream, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFileLoader_CreateStreamFromKey(loader, refkey, count, &stream2);
|
|
|
|
ok(hr == S_OK, "Failed to create file stream, hr %#x.\n", hr);
|
|
|
|
ok(stream2 != stream, "Unexpected stream instance.\n");
|
|
|
|
IDWriteFontFileStream_Release(stream2);
|
|
|
|
|
2018-11-22 12:29:14 +01:00
|
|
|
dummy = 1;
|
|
|
|
hr = IDWriteFontFileLoader_CreateStreamFromKey(loader, &dummy, count, &stream2);
|
|
|
|
ok(hr == S_OK, "Failed to create file stream, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
writetime = 1;
|
|
|
|
hr = IDWriteFontFileStream_GetLastWriteTime(stream2, &writetime);
|
|
|
|
ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
|
|
|
|
ok(writetime == 1, "Unexpected write time.\n");
|
|
|
|
|
|
|
|
IDWriteFontFileStream_Release(stream2);
|
|
|
|
|
2018-11-19 10:27:36 +01:00
|
|
|
hr = IDWriteFontFileStream_GetFileSize(stream, &size);
|
|
|
|
ok(hr == S_OK, "Failed to get stream size, hr %#x.\n", hr);
|
|
|
|
ok(size == data_size, "Unexpected stream size.\n");
|
|
|
|
|
|
|
|
hr = IDWriteFontFileStream_GetLastWriteTime(stream, &writetime);
|
|
|
|
ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
fragment_context = NULL;
|
|
|
|
hr = IDWriteFontFileStream_ReadFileFragment(stream, &fragment, 0, size, &fragment_context);
|
|
|
|
ok(hr == S_OK, "Failed to read fragment, hr %#x.\n", hr);
|
|
|
|
ok(fragment_context != NULL, "Unexpected context %p.\n", fragment_context);
|
|
|
|
ok(fragment == fragment_context, "Unexpected data pointer %p, context %p.\n", fragment, fragment_context);
|
|
|
|
IDWriteFontFileStream_ReleaseFileFragment(stream, fragment_context);
|
|
|
|
|
2018-11-22 12:29:14 +01:00
|
|
|
hr = IDWriteFontFileStream_ReadFileFragment(stream, &fragment, 0, size + 1, &fragment_context);
|
|
|
|
ok(FAILED(hr), "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFileStream_ReadFileFragment(stream, &fragment, size - 1, size / 2, &fragment_context);
|
|
|
|
ok(FAILED(hr), "Unexpected hr %#x.\n", hr);
|
|
|
|
|
2018-11-19 10:27:36 +01:00
|
|
|
IDWriteFontFileStream_Release(stream);
|
|
|
|
|
|
|
|
IDWriteFontFileLoader_Release(loader);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
|
|
|
|
IDWriteFontFace_Release(fontface);
|
2018-11-22 12:29:14 +01:00
|
|
|
|
2018-11-19 10:27:36 +01:00
|
|
|
ret = RemoveFontMemResourceEx(resource);
|
|
|
|
ok(ret, "Failed to remove memory resource font, %d.\n", GetLastError());
|
|
|
|
|
|
|
|
UnmapViewOfFile(font_data);
|
|
|
|
|
|
|
|
DELETE_FONTFILE(path);
|
|
|
|
|
|
|
|
DeleteObject(SelectObject(hdc, oldhfont));
|
|
|
|
DeleteDC(hdc);
|
2014-10-20 06:55:39 +02:00
|
|
|
IDWriteGdiInterop_Release(interop);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2014-10-20 06:55:39 +02:00
|
|
|
}
|
|
|
|
|
2014-10-27 15:37:49 +01:00
|
|
|
static void test_GetSimulations(void)
|
|
|
|
{
|
|
|
|
DWRITE_FONT_SIMULATIONS simulations;
|
|
|
|
IDWriteGdiInterop *interop;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFont *font;
|
|
|
|
LOGFONTW logfont;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-10-27 15:37:49 +01:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
|
|
|
logfont.lfItalic = 1;
|
|
|
|
lstrcpyW(logfont.lfFaceName, tahomaW);
|
|
|
|
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
simulations = IDWriteFont_GetSimulations(font);
|
|
|
|
ok(simulations == DWRITE_FONT_SIMULATIONS_OBLIQUE, "got %d\n", simulations);
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
simulations = IDWriteFontFace_GetSimulations(fontface);
|
|
|
|
ok(simulations == DWRITE_FONT_SIMULATIONS_OBLIQUE, "got %d\n", simulations);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
|
|
|
logfont.lfItalic = 0;
|
|
|
|
lstrcpyW(logfont.lfFaceName, tahomaW);
|
|
|
|
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
simulations = IDWriteFont_GetSimulations(font);
|
2014-11-04 16:31:31 +01:00
|
|
|
ok(simulations == DWRITE_FONT_SIMULATIONS_NONE, "got %d\n", simulations);
|
2014-10-27 15:37:49 +01:00
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
simulations = IDWriteFontFace_GetSimulations(fontface);
|
2014-11-04 16:31:31 +01:00
|
|
|
ok(simulations == DWRITE_FONT_SIMULATIONS_NONE, "got %d\n", simulations);
|
2014-10-27 15:37:49 +01:00
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
IDWriteGdiInterop_Release(interop);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2014-10-27 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
2014-11-04 20:53:19 +01:00
|
|
|
static void test_GetFaceNames(void)
|
|
|
|
{
|
|
|
|
static const WCHAR obliqueW[] = {'O','b','l','i','q','u','e',0};
|
2014-11-05 06:49:48 +01:00
|
|
|
static const WCHAR enus2W[] = {'e','n','-','U','s',0};
|
2014-11-04 20:53:19 +01:00
|
|
|
static const WCHAR enusW[] = {'e','n','-','u','s',0};
|
|
|
|
IDWriteLocalizedStrings *strings, *strings2;
|
|
|
|
IDWriteGdiInterop *interop;
|
|
|
|
IDWriteFactory *factory;
|
2014-11-05 06:49:48 +01:00
|
|
|
UINT32 count, index;
|
2014-11-04 20:53:19 +01:00
|
|
|
IDWriteFont *font;
|
|
|
|
LOGFONTW logfont;
|
|
|
|
WCHAR buffW[255];
|
2014-11-05 06:49:48 +01:00
|
|
|
BOOL exists;
|
2014-11-04 20:53:19 +01:00
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-11-04 20:53:19 +01:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = 12;
|
|
|
|
logfont.lfWidth = 12;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
|
|
|
logfont.lfItalic = 1;
|
|
|
|
lstrcpyW(logfont.lfFaceName, tahomaW);
|
|
|
|
|
|
|
|
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFont_GetFaceNames(font, &strings);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFont_GetFaceNames(font, &strings2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(strings != strings2, "got %p, %p\n", strings2, strings);
|
|
|
|
IDWriteLocalizedStrings_Release(strings2);
|
|
|
|
|
|
|
|
count = IDWriteLocalizedStrings_GetCount(strings);
|
|
|
|
ok(count == 1, "got %d\n", count);
|
|
|
|
|
2014-11-05 06:49:48 +01:00
|
|
|
index = 1;
|
|
|
|
exists = FALSE;
|
|
|
|
hr = IDWriteLocalizedStrings_FindLocaleName(strings, enus2W, &index, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(index == 0 && exists, "got %d, %d\n", index, exists);
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
hr = IDWriteLocalizedStrings_GetLocaleNameLength(strings, 1, &count);
|
|
|
|
ok(hr == E_FAIL, "got 0x%08x\n", hr);
|
|
|
|
ok(count == ~0, "got %d\n", count);
|
|
|
|
|
2014-11-04 20:53:19 +01:00
|
|
|
/* for simulated faces names are also simulated */
|
|
|
|
buffW[0] = 0;
|
2018-05-22 10:50:42 +02:00
|
|
|
hr = IDWriteLocalizedStrings_GetLocaleName(strings, 0, buffW, ARRAY_SIZE(buffW));
|
2014-11-04 20:53:19 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!lstrcmpW(buffW, enusW), "got %s\n", wine_dbgstr_w(buffW));
|
|
|
|
|
|
|
|
buffW[0] = 0;
|
2018-05-22 10:50:42 +02:00
|
|
|
hr = IDWriteLocalizedStrings_GetString(strings, 0, buffW, ARRAY_SIZE(buffW));
|
2014-11-04 20:53:19 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!lstrcmpW(buffW, obliqueW), "got %s\n", wine_dbgstr_w(buffW));
|
|
|
|
IDWriteLocalizedStrings_Release(strings);
|
|
|
|
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
IDWriteGdiInterop_Release(interop);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2014-11-04 20:53:19 +01:00
|
|
|
}
|
|
|
|
|
2014-11-15 17:19:00 +01:00
|
|
|
struct local_refkey
|
|
|
|
{
|
|
|
|
FILETIME writetime;
|
|
|
|
WCHAR name[1];
|
|
|
|
};
|
|
|
|
|
2014-11-06 21:23:26 +01:00
|
|
|
static void test_TryGetFontTable(void)
|
|
|
|
{
|
2014-11-15 17:19:00 +01:00
|
|
|
IDWriteLocalFontFileLoader *localloader;
|
|
|
|
WIN32_FILE_ATTRIBUTE_DATA info;
|
|
|
|
const struct local_refkey *key;
|
|
|
|
IDWriteFontFileLoader *loader;
|
2014-11-06 21:23:26 +01:00
|
|
|
const void *table, *table2;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
void *context, *context2;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFontFile *file;
|
2014-11-15 17:19:00 +01:00
|
|
|
WCHAR buffW[MAX_PATH];
|
|
|
|
BOOL exists, ret;
|
|
|
|
UINT32 size, len;
|
2015-02-24 06:05:05 +01:00
|
|
|
WCHAR *path;
|
2014-11-06 21:23:26 +01:00
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-11-06 21:23:26 +01:00
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
path = create_testfontfile(test_fontfile);
|
2014-11-06 21:23:26 +01:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
|
2014-11-06 21:23:26 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n",hr);
|
|
|
|
|
2014-11-15 17:19:00 +01:00
|
|
|
key = NULL;
|
|
|
|
size = 0;
|
|
|
|
hr = IDWriteFontFile_GetReferenceKey(file, (const void**)&key, &size);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(size != 0, "got %u\n", size);
|
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
ret = GetFileAttributesExW(path, GetFileExInfoStandard, &info);
|
2014-11-15 17:19:00 +01:00
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(!memcmp(&info.ftLastWriteTime, &key->writetime, sizeof(key->writetime)), "got wrong write time\n");
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetLoader(file, &loader);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFileLoader_QueryInterface(loader, &IID_IDWriteLocalFontFileLoader, (void**)&localloader);
|
|
|
|
IDWriteFontFileLoader_Release(loader);
|
|
|
|
|
|
|
|
hr = IDWriteLocalFontFileLoader_GetFilePathLengthFromKey(localloader, key, size, &len);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(lstrlenW(key->name) == len, "path length %d\n", len);
|
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
hr = IDWriteLocalFontFileLoader_GetFilePathFromKey(localloader, key, size, buffW, ARRAY_SIZE(buffW));
|
2014-11-15 17:19:00 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!lstrcmpW(buffW, key->name), "got %s, expected %s\n", wine_dbgstr_w(buffW), wine_dbgstr_w(key->name));
|
|
|
|
IDWriteLocalFontFileLoader_Release(localloader);
|
|
|
|
|
2014-11-06 21:23:26 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file, 0, 0, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n",hr);
|
|
|
|
|
|
|
|
exists = FALSE;
|
|
|
|
context = (void*)0xdeadbeef;
|
|
|
|
table = NULL;
|
|
|
|
hr = IDWriteFontFace_TryGetFontTable(fontface, MS_CMAP_TAG, &table, &size, &context, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n",hr);
|
|
|
|
ok(exists == TRUE, "got %d\n", exists);
|
|
|
|
ok(context == NULL && table != NULL, "cmap: context %p, table %p\n", context, table);
|
|
|
|
|
|
|
|
exists = FALSE;
|
|
|
|
context2 = (void*)0xdeadbeef;
|
|
|
|
table2 = NULL;
|
|
|
|
hr = IDWriteFontFace_TryGetFontTable(fontface, MS_CMAP_TAG, &table2, &size, &context2, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n",hr);
|
|
|
|
ok(exists == TRUE, "got %d\n", exists);
|
|
|
|
ok(context2 == context && table2 == table, "cmap: context2 %p, table2 %p\n", context2, table2);
|
|
|
|
|
|
|
|
IDWriteFontFace_ReleaseFontTable(fontface, context2);
|
|
|
|
IDWriteFontFace_ReleaseFontTable(fontface, context);
|
|
|
|
|
2016-04-01 07:40:07 +02:00
|
|
|
/* table does not exist */
|
|
|
|
exists = TRUE;
|
|
|
|
context = (void*)0xdeadbeef;
|
|
|
|
table = (void*)0xdeadbeef;
|
|
|
|
hr = IDWriteFontFace_TryGetFontTable(fontface, 0xabababab, &table, &size, &context, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(exists == FALSE, "got %d\n", exists);
|
|
|
|
ok(context == NULL && table == NULL, "got context %p, table pointer %p\n", context, table);
|
|
|
|
|
2014-11-06 21:23:26 +01:00
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
IDWriteFontFile_Release(file);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-02-24 06:05:05 +01:00
|
|
|
DELETE_FONTFILE(path);
|
2014-11-06 21:23:26 +01:00
|
|
|
}
|
|
|
|
|
2014-11-07 11:17:38 +01:00
|
|
|
static void test_ConvertFontToLOGFONT(void)
|
|
|
|
{
|
|
|
|
IDWriteFactory *factory, *factory2;
|
|
|
|
IDWriteFontCollection *collection;
|
|
|
|
IDWriteGdiInterop *interop;
|
|
|
|
IDWriteFontFamily *family;
|
|
|
|
IDWriteFont *font;
|
|
|
|
LOGFONTW logfont;
|
2016-12-04 17:22:13 +01:00
|
|
|
UINT32 i, count;
|
2014-11-07 11:17:38 +01:00
|
|
|
BOOL system;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-11-07 11:17:38 +01:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
factory2 = create_factory();
|
|
|
|
|
|
|
|
interop = NULL;
|
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory2, &collection, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
|
|
|
|
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
if (0) { /* crashes on native */
|
|
|
|
IDWriteGdiInterop_ConvertFontToLOGFONT(interop, NULL, NULL, NULL);
|
|
|
|
IDWriteGdiInterop_ConvertFontToLOGFONT(interop, NULL, &logfont, NULL);
|
|
|
|
IDWriteGdiInterop_ConvertFontToLOGFONT(interop, font, NULL, &system);
|
|
|
|
}
|
2015-08-06 16:57:26 +02:00
|
|
|
|
|
|
|
memset(&logfont, 0xcc, sizeof(logfont));
|
2014-11-07 11:17:38 +01:00
|
|
|
system = TRUE;
|
|
|
|
hr = IDWriteGdiInterop_ConvertFontToLOGFONT(interop, NULL, &logfont, &system);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(!system, "got %d\n", system);
|
2015-08-06 16:57:26 +02:00
|
|
|
ok(logfont.lfFaceName[0] == 0, "got face name %s\n", wine_dbgstr_w(logfont.lfFaceName));
|
2014-11-07 11:17:38 +01:00
|
|
|
|
2016-12-04 17:22:13 +01:00
|
|
|
count = IDWriteFontCollection_GetFontFamilyCount(collection);
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
WCHAR nameW[128], familynameW[64], facenameW[64];
|
|
|
|
IDWriteLocalizedStrings *names;
|
|
|
|
DWRITE_FONT_SIMULATIONS sim;
|
|
|
|
IDWriteFontFamily *family;
|
|
|
|
UINT32 font_count, j;
|
|
|
|
IDWriteFont *font;
|
|
|
|
LOGFONTW lf;
|
2015-08-06 16:57:26 +02:00
|
|
|
|
2016-12-04 17:22:13 +01:00
|
|
|
hr = IDWriteFontCollection_GetFontFamily(collection, i, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2015-08-06 16:57:26 +02:00
|
|
|
|
2016-12-04 17:22:13 +01:00
|
|
|
hr = IDWriteFontFamily_GetFamilyNames(family, &names);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2015-08-06 16:57:26 +02:00
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
get_enus_string(names, familynameW, ARRAY_SIZE(familynameW));
|
2016-12-04 17:22:13 +01:00
|
|
|
IDWriteLocalizedStrings_Release(names);
|
|
|
|
|
|
|
|
font_count = IDWriteFontFamily_GetFontCount(family);
|
|
|
|
|
|
|
|
for (j = 0; j < font_count; j++) {
|
|
|
|
static const WCHAR spaceW[] = {' ', 0};
|
2018-05-23 07:24:38 +02:00
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
BOOL has_variations;
|
2016-12-04 17:22:13 +01:00
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFont(family, j, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFont_GetFaceNames(font, &names);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
get_enus_string(names, facenameW, ARRAY_SIZE(facenameW));
|
2016-12-04 17:22:13 +01:00
|
|
|
IDWriteLocalizedStrings_Release(names);
|
|
|
|
|
|
|
|
lstrcpyW(nameW, familynameW);
|
|
|
|
lstrcatW(nameW, spaceW);
|
|
|
|
lstrcatW(nameW, facenameW);
|
|
|
|
|
2018-05-23 07:24:38 +02:00
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
has_variations = has_face_variations(fontface);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
|
|
|
|
if (has_variations) {
|
|
|
|
skip("%s: test does not support variable fonts.\n", wine_dbgstr_w(nameW));
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-12-04 17:22:13 +01:00
|
|
|
system = FALSE;
|
|
|
|
memset(&logfont, 0xcc, sizeof(logfont));
|
|
|
|
hr = IDWriteGdiInterop_ConvertFontToLOGFONT(interop, font, &logfont, &system);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(system, "got %d\n", system);
|
|
|
|
|
|
|
|
sim = IDWriteFont_GetSimulations(font);
|
|
|
|
|
|
|
|
get_logfont_from_font(font, &lf);
|
2016-12-04 17:22:14 +01:00
|
|
|
ok(logfont.lfWeight == lf.lfWeight, "%s: unexpected lfWeight %d, expected lfWeight %d, font weight %d, "
|
|
|
|
"bold simulation %s\n", wine_dbgstr_w(nameW), logfont.lfWeight, lf.lfWeight, IDWriteFont_GetWeight(font),
|
|
|
|
sim & DWRITE_FONT_SIMULATIONS_BOLD ? "yes" : "no");
|
2016-12-04 17:22:13 +01:00
|
|
|
ok(logfont.lfItalic == lf.lfItalic, "%s: unexpected italic flag %d, oblique simulation %s\n",
|
|
|
|
wine_dbgstr_w(nameW), logfont.lfItalic, sim & DWRITE_FONT_SIMULATIONS_OBLIQUE ? "yes" : "no");
|
2016-12-04 17:22:16 +01:00
|
|
|
ok(!lstrcmpW(logfont.lfFaceName, lf.lfFaceName), "%s: unexpected facename %s, expected %s\n",
|
|
|
|
wine_dbgstr_w(nameW), wine_dbgstr_w(logfont.lfFaceName), wine_dbgstr_w(lf.lfFaceName));
|
2016-12-04 17:22:13 +01:00
|
|
|
|
2016-12-04 17:22:15 +01:00
|
|
|
ok(logfont.lfOutPrecision == OUT_OUTLINE_PRECIS, "%s: unexpected output precision %d\n", wine_dbgstr_w(nameW),
|
|
|
|
logfont.lfOutPrecision);
|
|
|
|
ok(logfont.lfClipPrecision == CLIP_DEFAULT_PRECIS, "%s: unexpected clipping precision %d\n", wine_dbgstr_w(nameW),
|
|
|
|
logfont.lfClipPrecision);
|
|
|
|
ok(logfont.lfQuality == DEFAULT_QUALITY, "%s: unexpected quality %d\n", wine_dbgstr_w(nameW), logfont.lfQuality);
|
|
|
|
ok(logfont.lfPitchAndFamily == DEFAULT_PITCH, "%s: unexpected pitch %d\n", wine_dbgstr_w(nameW),
|
|
|
|
logfont.lfPitchAndFamily);
|
2016-12-04 17:22:13 +01:00
|
|
|
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
}
|
2014-11-07 11:17:38 +01:00
|
|
|
|
|
|
|
IDWriteFactory_Release(factory2);
|
|
|
|
|
|
|
|
IDWriteFontCollection_Release(collection);
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
IDWriteGdiInterop_Release(interop);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2014-11-07 11:17:38 +01:00
|
|
|
}
|
|
|
|
|
2014-11-17 10:30:25 +01:00
|
|
|
static void test_CreateStreamFromKey(void)
|
|
|
|
{
|
|
|
|
IDWriteLocalFontFileLoader *localloader;
|
|
|
|
IDWriteFontFileStream *stream, *stream2;
|
|
|
|
IDWriteFontFileLoader *loader;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFontFile *file;
|
2014-11-18 10:43:10 +01:00
|
|
|
UINT64 writetime;
|
2015-02-24 06:05:05 +01:00
|
|
|
WCHAR *path;
|
2014-11-17 10:30:25 +01:00
|
|
|
void *key;
|
|
|
|
UINT32 size;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-11-17 10:30:25 +01:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
path = create_testfontfile(test_fontfile);
|
2014-11-17 10:30:25 +01:00
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
|
2014-11-17 10:30:25 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n",hr);
|
|
|
|
|
|
|
|
key = NULL;
|
|
|
|
size = 0;
|
|
|
|
hr = IDWriteFontFile_GetReferenceKey(file, (const void**)&key, &size);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(size != 0, "got %u\n", size);
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetLoader(file, &loader);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFileLoader_QueryInterface(loader, &IID_IDWriteLocalFontFileLoader, (void**)&localloader);
|
|
|
|
IDWriteFontFileLoader_Release(loader);
|
|
|
|
|
|
|
|
hr = IDWriteLocalFontFileLoader_CreateStreamFromKey(localloader, key, size, &stream);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
EXPECT_REF(stream, 1);
|
|
|
|
|
|
|
|
hr = IDWriteLocalFontFileLoader_CreateStreamFromKey(localloader, key, size, &stream2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2014-11-27 07:26:45 +01:00
|
|
|
ok(stream == stream2 || broken(stream != stream2) /* Win7 SP0 */, "got %p, %p\n", stream, stream2);
|
|
|
|
if (stream == stream2)
|
|
|
|
EXPECT_REF(stream, 2);
|
2014-11-17 10:30:25 +01:00
|
|
|
IDWriteFontFileStream_Release(stream);
|
|
|
|
IDWriteFontFileStream_Release(stream2);
|
|
|
|
|
|
|
|
hr = IDWriteLocalFontFileLoader_CreateStreamFromKey(localloader, key, size, &stream);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
EXPECT_REF(stream, 1);
|
2014-11-18 10:43:10 +01:00
|
|
|
|
|
|
|
writetime = 0;
|
|
|
|
hr = IDWriteFontFileStream_GetLastWriteTime(stream, &writetime);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2017-07-05 04:37:15 +02:00
|
|
|
ok(writetime != 0, "got %s\n", wine_dbgstr_longlong(writetime));
|
2014-11-18 10:43:10 +01:00
|
|
|
|
2014-11-17 10:30:25 +01:00
|
|
|
IDWriteFontFileStream_Release(stream);
|
2015-10-29 08:20:55 +01:00
|
|
|
IDWriteFontFile_Release(file);
|
2014-11-17 10:30:25 +01:00
|
|
|
|
|
|
|
IDWriteLocalFontFileLoader_Release(localloader);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-02-24 06:05:05 +01:00
|
|
|
DELETE_FONTFILE(path);
|
2014-11-17 10:30:25 +01:00
|
|
|
}
|
|
|
|
|
2014-11-18 11:18:46 +01:00
|
|
|
static void test_ReadFileFragment(void)
|
|
|
|
{
|
|
|
|
IDWriteLocalFontFileLoader *localloader;
|
|
|
|
IDWriteFontFileStream *stream;
|
|
|
|
IDWriteFontFileLoader *loader;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFontFile *file;
|
|
|
|
const void *fragment, *fragment2;
|
|
|
|
void *key, *context, *context2;
|
|
|
|
UINT64 filesize;
|
|
|
|
UINT32 size;
|
2015-02-24 06:05:05 +01:00
|
|
|
WCHAR *path;
|
2014-11-18 11:18:46 +01:00
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-11-18 11:18:46 +01:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
path = create_testfontfile(test_fontfile);
|
2014-11-18 11:18:46 +01:00
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
|
2014-11-18 11:18:46 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n",hr);
|
|
|
|
|
|
|
|
key = NULL;
|
|
|
|
size = 0;
|
|
|
|
hr = IDWriteFontFile_GetReferenceKey(file, (const void**)&key, &size);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(size != 0, "got %u\n", size);
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetLoader(file, &loader);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFileLoader_QueryInterface(loader, &IID_IDWriteLocalFontFileLoader, (void**)&localloader);
|
|
|
|
IDWriteFontFileLoader_Release(loader);
|
|
|
|
|
|
|
|
hr = IDWriteLocalFontFileLoader_CreateStreamFromKey(localloader, key, size, &stream);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFileStream_GetFileSize(stream, &filesize);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
/* reading past the end of the stream */
|
|
|
|
fragment = (void*)0xdeadbeef;
|
|
|
|
context = (void*)0xdeadbeef;
|
|
|
|
hr = IDWriteFontFileStream_ReadFileFragment(stream, &fragment, 0, filesize+1, &context);
|
|
|
|
ok(hr == E_FAIL, "got 0x%08x\n", hr);
|
|
|
|
ok(context == NULL, "got %p\n", context);
|
|
|
|
ok(fragment == NULL, "got %p\n", fragment);
|
2014-11-26 06:59:04 +01:00
|
|
|
|
2014-11-18 11:18:46 +01:00
|
|
|
fragment = (void*)0xdeadbeef;
|
|
|
|
context = (void*)0xdeadbeef;
|
|
|
|
hr = IDWriteFontFileStream_ReadFileFragment(stream, &fragment, 0, filesize, &context);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(context == NULL, "got %p\n", context);
|
|
|
|
ok(fragment != NULL, "got %p\n", fragment);
|
|
|
|
|
|
|
|
fragment2 = (void*)0xdeadbeef;
|
|
|
|
context2 = (void*)0xdeadbeef;
|
|
|
|
hr = IDWriteFontFileStream_ReadFileFragment(stream, &fragment2, 0, filesize, &context2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(context2 == NULL, "got %p\n", context2);
|
|
|
|
ok(fragment == fragment2, "got %p, %p\n", fragment, fragment2);
|
2014-11-26 06:59:04 +01:00
|
|
|
|
2014-11-18 11:18:46 +01:00
|
|
|
IDWriteFontFileStream_ReleaseFileFragment(stream, context);
|
|
|
|
IDWriteFontFileStream_ReleaseFileFragment(stream, context2);
|
|
|
|
|
2014-11-26 06:59:04 +01:00
|
|
|
/* fragment is released, try again */
|
|
|
|
fragment = (void*)0xdeadbeef;
|
|
|
|
context = (void*)0xdeadbeef;
|
|
|
|
hr = IDWriteFontFileStream_ReadFileFragment(stream, &fragment, 0, filesize, &context);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(context == NULL, "got %p\n", context);
|
|
|
|
ok(fragment == fragment2, "got %p, %p\n", fragment, fragment2);
|
|
|
|
IDWriteFontFileStream_ReleaseFileFragment(stream, context);
|
|
|
|
|
2015-10-29 08:20:55 +01:00
|
|
|
IDWriteFontFile_Release(file);
|
2014-11-18 11:18:46 +01:00
|
|
|
IDWriteFontFileStream_Release(stream);
|
|
|
|
IDWriteLocalFontFileLoader_Release(localloader);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-02-24 06:05:05 +01:00
|
|
|
DELETE_FONTFILE(path);
|
2014-11-18 11:18:46 +01:00
|
|
|
}
|
|
|
|
|
2014-12-08 11:24:39 +01:00
|
|
|
static void test_GetDesignGlyphMetrics(void)
|
|
|
|
{
|
|
|
|
DWRITE_GLYPH_METRICS metrics[2];
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFontFile *file;
|
|
|
|
UINT16 indices[2];
|
|
|
|
UINT32 codepoint;
|
2015-02-24 06:05:05 +01:00
|
|
|
WCHAR *path;
|
2014-12-08 11:24:39 +01:00
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-12-08 11:24:39 +01:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
path = create_testfontfile(test_fontfile);
|
2014-12-08 11:24:39 +01:00
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
|
2014-12-08 11:24:39 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n",hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file,
|
|
|
|
0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n",hr);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
|
|
|
|
codepoint = 'A';
|
|
|
|
indices[0] = 0;
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(fontface, &codepoint, 1, &indices[0]);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(indices[0] > 0, "got %u\n", indices[0]);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_GetDesignGlyphMetrics(fontface, NULL, 0, metrics, FALSE);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n",hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_GetDesignGlyphMetrics(fontface, NULL, 1, metrics, FALSE);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n",hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_GetDesignGlyphMetrics(fontface, indices, 0, metrics, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n",hr);
|
|
|
|
|
|
|
|
/* missing glyphs are ignored */
|
|
|
|
indices[1] = 1;
|
|
|
|
memset(metrics, 0xcc, sizeof(metrics));
|
|
|
|
hr = IDWriteFontFace_GetDesignGlyphMetrics(fontface, indices, 2, metrics, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n",hr);
|
|
|
|
ok(metrics[0].advanceWidth == 1000, "got %d\n", metrics[0].advanceWidth);
|
|
|
|
ok(metrics[1].advanceWidth == 0, "got %d\n", metrics[1].advanceWidth);
|
|
|
|
|
|
|
|
IDWriteFontFace_Release(fontface);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-02-24 06:05:05 +01:00
|
|
|
DELETE_FONTFILE(path);
|
2014-12-08 11:24:39 +01:00
|
|
|
}
|
|
|
|
|
2014-12-09 07:58:14 +01:00
|
|
|
static void test_IsMonospacedFont(void)
|
|
|
|
{
|
|
|
|
static const WCHAR courierW[] = {'C','o','u','r','i','e','r',' ','N','e','w',0};
|
|
|
|
IDWriteFontCollection *collection;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
UINT32 index;
|
|
|
|
BOOL exists;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-12-09 07:58:14 +01:00
|
|
|
|
|
|
|
factory = create_factory();
|
2018-12-14 01:05:26 +01:00
|
|
|
|
2014-12-09 07:58:14 +01:00
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
exists = FALSE;
|
|
|
|
hr = IDWriteFontCollection_FindFamilyName(collection, courierW, &index, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
if (exists) {
|
|
|
|
IDWriteFontFamily *family;
|
|
|
|
IDWriteFont1 *font1;
|
|
|
|
IDWriteFont *font;
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(collection, index, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
|
|
|
|
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
|
|
|
|
hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFont1, (void**)&font1);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
IDWriteFontFace1 *fontface1;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
BOOL is_monospaced;
|
|
|
|
|
|
|
|
is_monospaced = IDWriteFont1_IsMonospacedFont(font1);
|
|
|
|
ok(is_monospaced, "got %d\n", is_monospaced);
|
|
|
|
|
|
|
|
hr = IDWriteFont1_CreateFontFace(font1, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
is_monospaced = IDWriteFontFace1_IsMonospacedFont(fontface1);
|
|
|
|
ok(is_monospaced, "got %d\n", is_monospaced);
|
|
|
|
IDWriteFontFace1_Release(fontface1);
|
|
|
|
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
IDWriteFont1_Release(font1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("IsMonospacedFont() is not supported.\n");
|
2017-04-11 13:21:32 +02:00
|
|
|
|
|
|
|
IDWriteFont_Release(font);
|
2014-12-09 07:58:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("Courier New font not found.\n");
|
|
|
|
|
2018-12-14 01:05:26 +01:00
|
|
|
IDWriteFontCollection_Release(collection);
|
|
|
|
ref = IDWriteFactory_Release(factory);
|
2017-04-11 13:21:32 +02:00
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2014-12-09 07:58:14 +01:00
|
|
|
}
|
|
|
|
|
2014-12-09 08:00:45 +01:00
|
|
|
static void test_GetDesignGlyphAdvances(void)
|
|
|
|
{
|
|
|
|
IDWriteFontFace1 *fontface1;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFontFile *file;
|
2015-02-24 06:05:05 +01:00
|
|
|
WCHAR *path;
|
2014-12-09 08:00:45 +01:00
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-12-09 08:00:45 +01:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
path = create_testfontfile(test_fontfile);
|
2014-12-09 08:00:45 +01:00
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
|
2014-12-09 08:00:45 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file,
|
|
|
|
0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
UINT32 codepoint;
|
|
|
|
UINT16 index;
|
|
|
|
INT32 advance;
|
|
|
|
|
|
|
|
codepoint = 'A';
|
|
|
|
index = 0;
|
|
|
|
hr = IDWriteFontFace1_GetGlyphIndices(fontface1, &codepoint, 1, &index);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(index > 0, "got %u\n", index);
|
|
|
|
|
|
|
|
advance = 0;
|
|
|
|
hr = IDWriteFontFace1_GetDesignGlyphAdvances(fontface1, 1, &index, &advance, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(advance == 1000, "got %i\n", advance);
|
|
|
|
|
|
|
|
advance = 0;
|
|
|
|
hr = IDWriteFontFace1_GetDesignGlyphAdvances(fontface1, 1, &index, &advance, TRUE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2015-08-24 09:43:19 +02:00
|
|
|
todo_wine
|
2014-12-09 08:00:45 +01:00
|
|
|
ok(advance == 2048, "got %i\n", advance);
|
|
|
|
|
|
|
|
IDWriteFontFace1_Release(fontface1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("GetDesignGlyphAdvances() is not supported.\n");
|
|
|
|
|
|
|
|
IDWriteFontFace_Release(fontface);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-02-24 06:05:05 +01:00
|
|
|
DELETE_FONTFILE(path);
|
2014-12-09 08:00:45 +01:00
|
|
|
}
|
|
|
|
|
2014-12-15 07:39:26 +01:00
|
|
|
static void test_GetGlyphRunOutline(void)
|
|
|
|
{
|
|
|
|
DWRITE_GLYPH_OFFSET offsets[2];
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFontFile *file;
|
|
|
|
IDWriteFontFace *face;
|
|
|
|
UINT32 codepoint;
|
|
|
|
FLOAT advances[2];
|
|
|
|
UINT16 glyphs[2];
|
2015-02-24 06:05:05 +01:00
|
|
|
WCHAR *path;
|
2014-12-15 07:39:26 +01:00
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-12-15 07:39:26 +01:00
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
path = create_testfontfile(test_fontfile);
|
2014-12-15 07:39:26 +01:00
|
|
|
factory = create_factory();
|
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
|
2014-12-15 07:39:26 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n",hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &face);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
|
|
|
|
codepoint = 'A';
|
|
|
|
glyphs[0] = 0;
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(face, &codepoint, 1, glyphs);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(glyphs[0] > 0, "got %u\n", glyphs[0]);
|
|
|
|
glyphs[1] = glyphs[0];
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_GetGlyphRunOutline(face, 2048.0, glyphs, advances, offsets, 1, FALSE, FALSE, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_GetGlyphRunOutline(face, 2048.0, NULL, NULL, offsets, 1, FALSE, FALSE, &test_geomsink);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
advances[0] = 1.0;
|
|
|
|
advances[1] = 0.0;
|
|
|
|
|
|
|
|
offsets[0].advanceOffset = 1.0;
|
|
|
|
offsets[0].ascenderOffset = 1.0;
|
|
|
|
offsets[1].advanceOffset = 0.0;
|
|
|
|
offsets[1].ascenderOffset = 0.0;
|
|
|
|
|
|
|
|
/* default advances, no offsets */
|
|
|
|
memset(g_startpoints, 0, sizeof(g_startpoints));
|
|
|
|
g_startpoint_count = 0;
|
2015-06-22 16:58:40 +02:00
|
|
|
SET_EXPECT(setfillmode);
|
2014-12-15 07:39:26 +01:00
|
|
|
hr = IDWriteFontFace_GetGlyphRunOutline(face, 1024.0, glyphs, NULL, NULL, 2, FALSE, FALSE, &test_geomsink);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(g_startpoint_count == 2, "got %d\n", g_startpoint_count);
|
|
|
|
if (g_startpoint_count == 2) {
|
|
|
|
/* glyph advance of 500 is applied */
|
|
|
|
ok(g_startpoints[0].x == 229.5 && g_startpoints[0].y == -629.0, "0: got (%.2f,%.2f)\n", g_startpoints[0].x, g_startpoints[0].y);
|
|
|
|
ok(g_startpoints[1].x == 729.5 && g_startpoints[1].y == -629.0, "1: got (%.2f,%.2f)\n", g_startpoints[1].x, g_startpoints[1].y);
|
|
|
|
}
|
2015-06-22 16:58:40 +02:00
|
|
|
CHECK_CALLED(setfillmode);
|
2014-12-15 07:39:26 +01:00
|
|
|
|
|
|
|
/* default advances, no offsets, RTL */
|
|
|
|
memset(g_startpoints, 0, sizeof(g_startpoints));
|
|
|
|
g_startpoint_count = 0;
|
2015-06-22 16:58:40 +02:00
|
|
|
SET_EXPECT(setfillmode);
|
2014-12-15 07:39:26 +01:00
|
|
|
hr = IDWriteFontFace_GetGlyphRunOutline(face, 1024.0, glyphs, NULL, NULL, 2, FALSE, TRUE, &test_geomsink);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(g_startpoint_count == 2, "got %d\n", g_startpoint_count);
|
|
|
|
if (g_startpoint_count == 2) {
|
|
|
|
/* advance is -500 now */
|
|
|
|
ok(g_startpoints[0].x == -270.5 && g_startpoints[0].y == -629.0, "0: got (%.2f,%.2f)\n", g_startpoints[0].x, g_startpoints[0].y);
|
|
|
|
ok(g_startpoints[1].x == -770.5 && g_startpoints[1].y == -629.0, "1: got (%.2f,%.2f)\n", g_startpoints[1].x, g_startpoints[1].y);
|
|
|
|
}
|
2015-06-22 16:58:40 +02:00
|
|
|
CHECK_CALLED(setfillmode);
|
2014-12-15 07:39:26 +01:00
|
|
|
|
|
|
|
/* default advances, additional offsets */
|
|
|
|
memset(g_startpoints, 0, sizeof(g_startpoints));
|
|
|
|
g_startpoint_count = 0;
|
2015-06-22 16:58:40 +02:00
|
|
|
SET_EXPECT(setfillmode);
|
2014-12-15 07:39:26 +01:00
|
|
|
hr = IDWriteFontFace_GetGlyphRunOutline(face, 1024.0, glyphs, NULL, offsets, 2, FALSE, FALSE, &test_geomsink);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(g_startpoint_count == 2, "got %d\n", g_startpoint_count);
|
|
|
|
if (g_startpoint_count == 2) {
|
|
|
|
/* offsets applied to first contour */
|
|
|
|
ok(g_startpoints[0].x == 230.5 && g_startpoints[0].y == -630.0, "0: got (%.2f,%.2f)\n", g_startpoints[0].x, g_startpoints[0].y);
|
|
|
|
ok(g_startpoints[1].x == 729.5 && g_startpoints[1].y == -629.0, "1: got (%.2f,%.2f)\n", g_startpoints[1].x, g_startpoints[1].y);
|
|
|
|
}
|
2015-06-22 16:58:40 +02:00
|
|
|
CHECK_CALLED(setfillmode);
|
2014-12-15 07:39:26 +01:00
|
|
|
|
|
|
|
/* default advances, additional offsets, RTL */
|
|
|
|
memset(g_startpoints, 0, sizeof(g_startpoints));
|
|
|
|
g_startpoint_count = 0;
|
2015-06-22 16:58:40 +02:00
|
|
|
SET_EXPECT(setfillmode);
|
2014-12-15 07:39:26 +01:00
|
|
|
hr = IDWriteFontFace_GetGlyphRunOutline(face, 1024.0, glyphs, NULL, offsets, 2, FALSE, TRUE, &test_geomsink);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(g_startpoint_count == 2, "got %d\n", g_startpoint_count);
|
|
|
|
if (g_startpoint_count == 2) {
|
|
|
|
ok(g_startpoints[0].x == -271.5 && g_startpoints[0].y == -630.0, "0: got (%.2f,%.2f)\n", g_startpoints[0].x, g_startpoints[0].y);
|
|
|
|
ok(g_startpoints[1].x == -770.5 && g_startpoints[1].y == -629.0, "1: got (%.2f,%.2f)\n", g_startpoints[1].x, g_startpoints[1].y);
|
|
|
|
}
|
2015-06-22 16:58:40 +02:00
|
|
|
CHECK_CALLED(setfillmode);
|
2014-12-15 07:39:26 +01:00
|
|
|
|
|
|
|
/* custom advances and offsets, offset turns total advance value to zero */
|
|
|
|
memset(g_startpoints, 0, sizeof(g_startpoints));
|
|
|
|
g_startpoint_count = 0;
|
2015-06-22 16:58:40 +02:00
|
|
|
SET_EXPECT(setfillmode);
|
2014-12-15 07:39:26 +01:00
|
|
|
hr = IDWriteFontFace_GetGlyphRunOutline(face, 1024.0, glyphs, advances, offsets, 2, FALSE, FALSE, &test_geomsink);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(g_startpoint_count == 2, "got %d\n", g_startpoint_count);
|
|
|
|
if (g_startpoint_count == 2) {
|
|
|
|
ok(g_startpoints[0].x == 230.5 && g_startpoints[0].y == -630.0, "0: got (%.2f,%.2f)\n", g_startpoints[0].x, g_startpoints[0].y);
|
|
|
|
ok(g_startpoints[1].x == 230.5 && g_startpoints[1].y == -629.0, "1: got (%.2f,%.2f)\n", g_startpoints[1].x, g_startpoints[1].y);
|
|
|
|
}
|
2015-06-22 16:58:40 +02:00
|
|
|
CHECK_CALLED(setfillmode);
|
2014-12-15 07:39:26 +01:00
|
|
|
|
2015-06-22 16:58:40 +02:00
|
|
|
/* 0 glyph count */
|
|
|
|
hr = IDWriteFontFace_GetGlyphRunOutline(face, 1024.0, glyphs, NULL, NULL, 0, FALSE, FALSE, &test_geomsink2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2014-12-15 07:39:26 +01:00
|
|
|
|
2017-08-25 07:29:46 +02:00
|
|
|
/* Glyph with open figure, single contour point. */
|
|
|
|
codepoint = 'B';
|
|
|
|
glyphs[0] = 0;
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(face, &codepoint, 1, glyphs);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(glyphs[0] > 0, "got %u\n", glyphs[0]);
|
|
|
|
|
|
|
|
SET_EXPECT(setfillmode);
|
|
|
|
hr = IDWriteFontFace_GetGlyphRunOutline(face, 1024.0, glyphs, NULL, NULL, 1, FALSE, FALSE, &test_geomsink2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
CHECK_CALLED(setfillmode);
|
|
|
|
|
2015-06-22 16:58:40 +02:00
|
|
|
IDWriteFactory_Release(factory);
|
|
|
|
IDWriteFontFace_Release(face);
|
2015-02-24 06:05:05 +01:00
|
|
|
DELETE_FONTFILE(path);
|
2015-06-22 16:58:40 +02:00
|
|
|
|
|
|
|
/* space glyph */
|
|
|
|
factory = create_factory();
|
|
|
|
face = create_fontface(factory);
|
|
|
|
|
|
|
|
codepoint = ' ';
|
|
|
|
glyphs[0] = 0;
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(face, &codepoint, 1, glyphs);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(glyphs[0] > 0, "got %u\n", glyphs[0]);
|
|
|
|
|
|
|
|
SET_EXPECT(setfillmode);
|
|
|
|
hr = IDWriteFontFace_GetGlyphRunOutline(face, 1024.0, glyphs, NULL, NULL, 1, FALSE, FALSE, &test_geomsink2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
CHECK_CALLED(setfillmode);
|
|
|
|
|
|
|
|
IDWriteFontFace_Release(face);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2014-12-15 07:39:26 +01:00
|
|
|
}
|
|
|
|
|
2014-12-17 07:54:13 +01:00
|
|
|
static void test_GetEudcFontCollection(void)
|
|
|
|
{
|
|
|
|
IDWriteFontCollection *coll, *coll2;
|
2017-10-09 09:47:02 +02:00
|
|
|
IDWriteFactory1 *factory;
|
2014-12-17 07:54:13 +01:00
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2014-12-17 07:54:13 +01:00
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
factory = create_factory_iid(&IID_IDWriteFactory1);
|
|
|
|
if (!factory) {
|
2014-12-17 07:54:13 +01:00
|
|
|
win_skip("GetEudcFontCollection() is not supported.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
EXPECT_REF(factory, 1);
|
|
|
|
hr = IDWriteFactory1_GetEudcFontCollection(factory, &coll, FALSE);
|
2014-12-17 07:54:13 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2017-10-09 09:47:02 +02:00
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
hr = IDWriteFactory1_GetEudcFontCollection(factory, &coll2, FALSE);
|
2014-12-17 07:54:13 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2017-10-09 09:47:02 +02:00
|
|
|
EXPECT_REF(factory, 2);
|
2014-12-17 07:54:13 +01:00
|
|
|
ok(coll == coll2, "got %p, %p\n", coll, coll2);
|
|
|
|
IDWriteFontCollection_Release(coll);
|
|
|
|
IDWriteFontCollection_Release(coll2);
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
ref = IDWriteFactory1_Release(factory);
|
2017-04-11 13:21:32 +02:00
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2014-12-17 07:54:13 +01:00
|
|
|
}
|
|
|
|
|
2015-02-03 11:27:24 +01:00
|
|
|
static void test_GetCaretMetrics(void)
|
|
|
|
{
|
|
|
|
DWRITE_FONT_METRICS1 metrics;
|
|
|
|
IDWriteFontFace1 *fontface1;
|
|
|
|
DWRITE_CARET_METRICS caret;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFontFile *file;
|
|
|
|
IDWriteFont *font;
|
2015-02-24 06:05:05 +01:00
|
|
|
WCHAR *path;
|
2015-02-03 11:27:24 +01:00
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2015-02-03 11:27:24 +01:00
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
path = create_testfontfile(test_fontfile);
|
2015-02-03 11:27:24 +01:00
|
|
|
factory = create_factory();
|
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
|
2015-02-03 11:27:24 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
if (hr != S_OK) {
|
|
|
|
win_skip("GetCaretMetrics() is not supported.\n");
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-02-24 06:05:05 +01:00
|
|
|
DELETE_FONTFILE(path);
|
2015-02-03 11:27:24 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&caret, 0xcc, sizeof(caret));
|
|
|
|
IDWriteFontFace1_GetCaretMetrics(fontface1, &caret);
|
|
|
|
ok(caret.slopeRise == 1, "got %d\n", caret.slopeRise);
|
|
|
|
ok(caret.slopeRun == 0, "got %d\n", caret.slopeRun);
|
|
|
|
ok(caret.offset == 0, "got %d\n", caret.offset);
|
|
|
|
IDWriteFontFace1_Release(fontface1);
|
2015-02-05 13:54:05 +01:00
|
|
|
IDWriteFactory_Release(factory);
|
2015-02-03 11:27:24 +01:00
|
|
|
|
|
|
|
/* now with Tahoma Normal */
|
2015-02-05 13:54:05 +01:00
|
|
|
factory = create_factory();
|
2015-02-03 11:27:24 +01:00
|
|
|
font = get_tahoma_instance(factory, DWRITE_FONT_STYLE_NORMAL);
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
|
|
|
|
memset(&caret, 0xcc, sizeof(caret));
|
|
|
|
IDWriteFontFace1_GetCaretMetrics(fontface1, &caret);
|
|
|
|
ok(caret.slopeRise == 1, "got %d\n", caret.slopeRise);
|
|
|
|
ok(caret.slopeRun == 0, "got %d\n", caret.slopeRun);
|
|
|
|
ok(caret.offset == 0, "got %d\n", caret.offset);
|
|
|
|
IDWriteFontFace1_Release(fontface1);
|
|
|
|
|
|
|
|
/* simulated italic */
|
|
|
|
font = get_tahoma_instance(factory, DWRITE_FONT_STYLE_ITALIC);
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
|
|
|
|
IDWriteFontFace1_GetMetrics(fontface1, &metrics);
|
|
|
|
|
|
|
|
memset(&caret, 0xcc, sizeof(caret));
|
|
|
|
IDWriteFontFace1_GetCaretMetrics(fontface1, &caret);
|
|
|
|
ok(caret.slopeRise == metrics.designUnitsPerEm, "got %d\n", caret.slopeRise);
|
|
|
|
ok(caret.slopeRun > 0, "got %d\n", caret.slopeRun);
|
|
|
|
ok(caret.offset == 0, "got %d\n", caret.offset);
|
|
|
|
IDWriteFontFace1_Release(fontface1);
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-02-24 06:05:05 +01:00
|
|
|
DELETE_FONTFILE(path);
|
2015-02-03 11:27:24 +01:00
|
|
|
}
|
|
|
|
|
2015-02-05 13:54:05 +01:00
|
|
|
static void test_GetGlyphCount(void)
|
|
|
|
{
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFontFile *file;
|
|
|
|
UINT16 count;
|
2015-02-24 06:05:05 +01:00
|
|
|
WCHAR *path;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2015-02-05 13:54:05 +01:00
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
path = create_testfontfile(test_fontfile);
|
2015-02-05 13:54:05 +01:00
|
|
|
factory = create_factory();
|
|
|
|
|
2015-02-24 06:05:05 +01:00
|
|
|
hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
|
2015-02-05 13:54:05 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
|
|
|
|
count = IDWriteFontFace_GetGlyphCount(fontface);
|
2017-08-25 07:29:46 +02:00
|
|
|
ok(count == 8, "got %u\n", count);
|
2015-02-05 13:54:05 +01:00
|
|
|
|
|
|
|
IDWriteFontFace_Release(fontface);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-02-24 06:05:05 +01:00
|
|
|
DELETE_FONTFILE(path);
|
2015-02-05 13:54:05 +01:00
|
|
|
}
|
|
|
|
|
2015-03-13 21:19:18 +01:00
|
|
|
static void test_GetKerningPairAdjustments(void)
|
|
|
|
{
|
|
|
|
IDWriteFontFace1 *fontface1;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFontFile *file;
|
|
|
|
WCHAR *path;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2015-03-13 21:19:18 +01:00
|
|
|
|
|
|
|
path = create_testfontfile(test_fontfile);
|
|
|
|
factory = create_factory();
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
INT32 adjustments[1];
|
|
|
|
|
|
|
|
hr = IDWriteFontFace1_GetKerningPairAdjustments(fontface1, 0, NULL, NULL);
|
|
|
|
ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "got 0x%08x\n", hr);
|
|
|
|
|
2016-08-09 14:59:46 +02:00
|
|
|
if (0) /* crashes on native */
|
|
|
|
hr = IDWriteFontFace1_GetKerningPairAdjustments(fontface1, 1, NULL, NULL);
|
2015-03-13 21:19:18 +01:00
|
|
|
|
|
|
|
adjustments[0] = 1;
|
|
|
|
hr = IDWriteFontFace1_GetKerningPairAdjustments(fontface1, 1, NULL, adjustments);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(adjustments[0] == 0, "got %d\n", adjustments[0]);
|
|
|
|
|
|
|
|
IDWriteFontFace1_Release(fontface1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("GetKerningPairAdjustments() is not supported.\n");
|
|
|
|
|
|
|
|
IDWriteFontFace_Release(fontface);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-03-13 21:19:18 +01:00
|
|
|
DELETE_FONTFILE(path);
|
|
|
|
}
|
|
|
|
|
2015-03-31 10:39:59 +02:00
|
|
|
static void test_CreateRenderingParams(void)
|
|
|
|
{
|
|
|
|
IDWriteRenderingParams2 *params2;
|
|
|
|
IDWriteRenderingParams1 *params1;
|
|
|
|
IDWriteRenderingParams *params;
|
2015-07-27 10:10:04 +02:00
|
|
|
DWRITE_RENDERING_MODE mode;
|
2016-04-19 08:39:25 +02:00
|
|
|
IDWriteFactory3 *factory3;
|
2015-03-31 10:39:59 +02:00
|
|
|
IDWriteFactory *factory;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2015-03-31 10:39:59 +02:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateCustomRenderingParams(factory, 1.0, 0.0, 0.0, DWRITE_PIXEL_GEOMETRY_FLAT,
|
|
|
|
DWRITE_RENDERING_MODE_DEFAULT, ¶ms);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteRenderingParams_QueryInterface(params, &IID_IDWriteRenderingParams1, (void**)¶ms1);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
FLOAT enhcontrast;
|
|
|
|
|
|
|
|
/* test what enhanced contrast setting set by default to */
|
|
|
|
enhcontrast = IDWriteRenderingParams1_GetGrayscaleEnhancedContrast(params1);
|
|
|
|
ok(enhcontrast == 1.0, "got %.2f\n", enhcontrast);
|
|
|
|
IDWriteRenderingParams1_Release(params1);
|
|
|
|
|
|
|
|
hr = IDWriteRenderingParams_QueryInterface(params, &IID_IDWriteRenderingParams2, (void**)¶ms2);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
DWRITE_GRID_FIT_MODE gridfit;
|
|
|
|
|
|
|
|
/* default gridfit mode */
|
|
|
|
gridfit = IDWriteRenderingParams2_GetGridFitMode(params2);
|
|
|
|
ok(gridfit == DWRITE_GRID_FIT_MODE_DEFAULT, "got %d\n", gridfit);
|
|
|
|
|
|
|
|
IDWriteRenderingParams2_Release(params2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("IDWriteRenderingParams2 not supported.\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("IDWriteRenderingParams1 not supported.\n");
|
|
|
|
|
|
|
|
IDWriteRenderingParams_Release(params);
|
2015-07-27 10:10:04 +02:00
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateRenderingParams(factory, ¶ms);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
mode = IDWriteRenderingParams_GetRenderingMode(params);
|
|
|
|
ok(mode == DWRITE_RENDERING_MODE_DEFAULT, "got %d\n", mode);
|
|
|
|
IDWriteRenderingParams_Release(params);
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
hr = IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory3, (void**)&factory3);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
IDWriteRenderingParams3 *params3;
|
|
|
|
|
|
|
|
hr = IDWriteFactory3_CreateCustomRenderingParams(factory3, 1.0f, 0.0f, 0.0f, 1.0f, DWRITE_PIXEL_GEOMETRY_FLAT,
|
|
|
|
DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED, DWRITE_GRID_FIT_MODE_DEFAULT, ¶ms3);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteRenderingParams3_QueryInterface(params3, &IID_IDWriteRenderingParams, (void**)¶ms);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
mode = IDWriteRenderingParams_GetRenderingMode(params);
|
|
|
|
ok(mode == DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC, "got %d\n", mode);
|
|
|
|
|
|
|
|
IDWriteRenderingParams_Release(params);
|
|
|
|
IDWriteRenderingParams3_Release(params3);
|
|
|
|
IDWriteFactory3_Release(factory3);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("IDWriteRenderingParams3 not supported.\n");
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-03-31 10:39:59 +02:00
|
|
|
}
|
2015-03-13 21:19:18 +01:00
|
|
|
|
2015-05-19 14:23:57 +02:00
|
|
|
static void test_CreateGlyphRunAnalysis(void)
|
|
|
|
{
|
2015-07-17 10:56:17 +02:00
|
|
|
static const DWRITE_RENDERING_MODE rendermodes[] = {
|
|
|
|
DWRITE_RENDERING_MODE_ALIASED,
|
|
|
|
DWRITE_RENDERING_MODE_GDI_CLASSIC,
|
|
|
|
DWRITE_RENDERING_MODE_GDI_NATURAL,
|
|
|
|
DWRITE_RENDERING_MODE_NATURAL,
|
|
|
|
DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC,
|
|
|
|
};
|
|
|
|
|
2015-11-03 20:05:25 +01:00
|
|
|
IDWriteGlyphRunAnalysis *analysis, *analysis2;
|
2017-07-17 22:18:43 +02:00
|
|
|
IDWriteRenderingParams *params;
|
2017-09-05 12:35:29 +02:00
|
|
|
IDWriteFactory3 *factory3;
|
2017-07-17 22:18:43 +02:00
|
|
|
IDWriteFactory2 *factory2;
|
2015-05-19 14:23:57 +02:00
|
|
|
IDWriteFactory *factory;
|
|
|
|
DWRITE_GLYPH_RUN run;
|
|
|
|
IDWriteFontFace *face;
|
2015-08-04 10:16:10 +02:00
|
|
|
UINT16 glyph, glyphs[10];
|
2015-10-19 07:43:02 +02:00
|
|
|
FLOAT advances[2];
|
2015-05-19 14:23:57 +02:00
|
|
|
HRESULT hr;
|
|
|
|
UINT32 ch;
|
2015-07-31 00:29:39 +02:00
|
|
|
RECT rect, rect2;
|
2015-10-19 07:43:02 +02:00
|
|
|
DWRITE_GLYPH_OFFSET offsets[2];
|
2015-07-17 10:56:17 +02:00
|
|
|
DWRITE_GLYPH_METRICS metrics;
|
2015-07-20 14:14:32 +02:00
|
|
|
DWRITE_FONT_METRICS fm;
|
2015-11-02 14:38:43 +01:00
|
|
|
DWRITE_MATRIX m;
|
2017-09-05 12:35:29 +02:00
|
|
|
ULONG size;
|
|
|
|
BYTE *bits;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2015-07-17 10:56:17 +02:00
|
|
|
int i;
|
2015-05-19 14:23:57 +02:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
face = create_fontface(factory);
|
|
|
|
|
|
|
|
ch = 'A';
|
2015-07-17 10:56:17 +02:00
|
|
|
glyph = 0;
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(face, &ch, 1, &glyph);
|
2015-05-19 14:23:57 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2015-07-17 10:56:17 +02:00
|
|
|
ok(glyph > 0, "got %u\n", glyph);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_GetDesignGlyphMetrics(face, &glyph, 1, &metrics, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2015-10-19 07:43:02 +02:00
|
|
|
advances[0] = metrics.advanceWidth;
|
2015-07-17 10:56:17 +02:00
|
|
|
|
2015-10-19 07:43:02 +02:00
|
|
|
offsets[0].advanceOffset = 0.0;
|
|
|
|
offsets[0].ascenderOffset = 0.0;
|
2015-05-19 14:23:57 +02:00
|
|
|
|
|
|
|
run.fontFace = face;
|
|
|
|
run.fontEmSize = 24.0;
|
|
|
|
run.glyphCount = 1;
|
2015-07-17 10:56:17 +02:00
|
|
|
run.glyphIndices = &glyph;
|
2015-10-19 07:43:02 +02:00
|
|
|
run.glyphAdvances = advances;
|
|
|
|
run.glyphOffsets = offsets;
|
2015-05-19 14:23:57 +02:00
|
|
|
run.isSideways = FALSE;
|
|
|
|
run.bidiLevel = 0;
|
|
|
|
|
2015-10-16 12:21:53 +02:00
|
|
|
/* zero ppdip */
|
|
|
|
analysis = (void*)0xdeadbeef;
|
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 0.0, NULL,
|
|
|
|
DWRITE_RENDERING_MODE_ALIASED, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(analysis == NULL, "got %p\n", analysis);
|
|
|
|
|
|
|
|
/* negative ppdip */
|
|
|
|
analysis = (void*)0xdeadbeef;
|
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, -1.0, NULL,
|
|
|
|
DWRITE_RENDERING_MODE_ALIASED, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(analysis == NULL, "got %p\n", analysis);
|
|
|
|
|
2015-05-19 14:23:57 +02:00
|
|
|
/* default mode is not allowed */
|
2015-10-16 12:21:53 +02:00
|
|
|
analysis = (void*)0xdeadbeef;
|
2015-05-19 14:23:57 +02:00
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
|
|
|
|
DWRITE_RENDERING_MODE_DEFAULT, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2015-10-16 12:21:53 +02:00
|
|
|
ok(analysis == NULL, "got %p\n", analysis);
|
2015-05-19 14:23:57 +02:00
|
|
|
|
|
|
|
/* outline too */
|
2015-10-16 12:21:53 +02:00
|
|
|
analysis = (void*)0xdeadbeef;
|
2015-05-19 14:23:57 +02:00
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
|
|
|
|
DWRITE_RENDERING_MODE_OUTLINE, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2015-10-16 12:21:53 +02:00
|
|
|
ok(analysis == NULL, "got %p\n", analysis);
|
2015-05-19 14:23:57 +02:00
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
|
2015-07-17 10:56:17 +02:00
|
|
|
DWRITE_RENDERING_MODE_ALIASED, DWRITE_MEASURING_MODE_NATURAL,
|
2015-05-19 14:23:57 +02:00
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2015-07-17 10:56:17 +02:00
|
|
|
|
|
|
|
/* invalid texture type */
|
|
|
|
memset(&rect, 0xcc, sizeof(rect));
|
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1+1, &rect);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(rect.left == 0 && rect.right == 0 &&
|
|
|
|
rect.top == 0 && rect.bottom == 0, "unexpected rect\n");
|
2015-07-31 00:29:39 +02:00
|
|
|
|
|
|
|
/* check how origin affects bounds */
|
2016-07-30 22:01:04 +02:00
|
|
|
SetRectEmpty(&rect);
|
2015-07-31 00:29:39 +02:00
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!IsRectEmpty(&rect), "got empty rect\n");
|
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
|
2015-10-16 12:21:53 +02:00
|
|
|
/* doubled ppdip */
|
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 2.0, NULL,
|
|
|
|
DWRITE_RENDERING_MODE_ALIASED, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2016-07-30 22:01:04 +02:00
|
|
|
SetRectEmpty(&rect2);
|
2015-10-16 12:21:53 +02:00
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(rect.right - rect.left < rect2.right - rect2.left, "expected wider rect\n");
|
|
|
|
ok(rect.bottom - rect.top < rect2.bottom - rect2.top, "expected taller rect\n");
|
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
|
2015-07-31 00:29:39 +02:00
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
|
|
|
|
DWRITE_RENDERING_MODE_ALIASED, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
10.0, -5.0, &analysis);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2016-07-30 22:01:04 +02:00
|
|
|
SetRectEmpty(&rect2);
|
2015-07-31 00:29:39 +02:00
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!IsRectEmpty(&rect2), "got empty rect\n");
|
2015-05-19 14:23:57 +02:00
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
|
2015-07-31 00:29:39 +02:00
|
|
|
ok(!EqualRect(&rect, &rect2), "got equal bounds\n");
|
|
|
|
OffsetRect(&rect, 10, -5);
|
|
|
|
ok(EqualRect(&rect, &rect2), "got different bounds\n");
|
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(rendermodes); i++) {
|
2015-07-17 10:56:17 +02:00
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
|
|
|
|
rendermodes[i], DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
if (rendermodes[i] == DWRITE_RENDERING_MODE_ALIASED) {
|
2016-07-30 22:01:04 +02:00
|
|
|
SetRectEmpty(&rect);
|
2015-07-17 10:56:17 +02:00
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!IsRectEmpty(&rect), "got empty rect\n");
|
2015-07-29 10:59:02 +02:00
|
|
|
|
2016-05-03 11:09:53 +02:00
|
|
|
SetRect(&rect, 0, 0, 1, 1);
|
2015-07-17 10:56:17 +02:00
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(IsRectEmpty(&rect), "unexpected empty rect\n");
|
|
|
|
}
|
|
|
|
else {
|
2016-05-03 11:09:53 +02:00
|
|
|
SetRect(&rect, 0, 0, 1, 1);
|
2015-07-17 10:56:17 +02:00
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(IsRectEmpty(&rect), "got empty rect\n");
|
|
|
|
|
2016-07-30 22:01:04 +02:00
|
|
|
SetRectEmpty(&rect);
|
2015-07-17 10:56:17 +02:00
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!IsRectEmpty(&rect), "got empty rect\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
}
|
|
|
|
|
2015-07-20 14:14:32 +02:00
|
|
|
IDWriteFontFace_GetMetrics(run.fontFace, &fm);
|
|
|
|
|
|
|
|
/* check bbox for a single glyph run */
|
|
|
|
for (run.fontEmSize = 1.0; run.fontEmSize <= 100.0; run.fontEmSize += 1.0) {
|
|
|
|
DWRITE_GLYPH_METRICS gm;
|
|
|
|
LONG bboxX, bboxY;
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
|
|
|
|
DWRITE_RENDERING_MODE_ALIASED, DWRITE_MEASURING_MODE_GDI_CLASSIC,
|
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2016-07-30 22:01:04 +02:00
|
|
|
SetRectEmpty(&rect);
|
2015-07-20 14:14:32 +02:00
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_GetGdiCompatibleGlyphMetrics(run.fontFace, run.fontEmSize, 1.0, NULL,
|
|
|
|
DWRITE_MEASURING_MODE_GDI_CLASSIC, run.glyphIndices, 1, &gm, run.isSideways);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
/* metrics are in design units */
|
|
|
|
bboxX = (int)floorf((gm.advanceWidth - gm.leftSideBearing - gm.rightSideBearing) * run.fontEmSize / fm.designUnitsPerEm + 0.5f);
|
|
|
|
bboxY = (int)floorf((gm.advanceHeight - gm.topSideBearing - gm.bottomSideBearing) * run.fontEmSize / fm.designUnitsPerEm + 0.5f);
|
|
|
|
|
|
|
|
rect.right -= rect.left;
|
|
|
|
rect.bottom -= rect.top;
|
2015-07-29 10:59:02 +02:00
|
|
|
ok(abs(bboxX - rect.right) <= 2, "%.0f: bbox width %d, from metrics %d\n", run.fontEmSize, rect.right, bboxX);
|
|
|
|
ok(abs(bboxY - rect.bottom) <= 2, "%.0f: bbox height %d, from metrics %d\n", run.fontEmSize, rect.bottom, bboxY);
|
2015-07-20 14:14:32 +02:00
|
|
|
|
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
}
|
|
|
|
|
2015-08-04 10:16:10 +02:00
|
|
|
/* without offsets */
|
|
|
|
run.fontFace = face;
|
|
|
|
run.fontEmSize = 24.0;
|
|
|
|
run.glyphCount = 1;
|
|
|
|
run.glyphIndices = &glyph;
|
2015-10-19 07:43:02 +02:00
|
|
|
run.glyphAdvances = advances;
|
2015-08-04 10:16:10 +02:00
|
|
|
run.glyphOffsets = NULL;
|
|
|
|
run.isSideways = FALSE;
|
|
|
|
run.bidiLevel = 0;
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
|
|
|
|
DWRITE_RENDERING_MODE_ALIASED, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
SetRectEmpty(&rect);
|
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!IsRectEmpty(&rect), "got empty bounds\n");
|
|
|
|
|
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
|
|
|
|
/* without explicit advances */
|
|
|
|
run.fontFace = face;
|
|
|
|
run.fontEmSize = 24.0;
|
|
|
|
run.glyphCount = 1;
|
|
|
|
run.glyphIndices = &glyph;
|
|
|
|
run.glyphAdvances = NULL;
|
|
|
|
run.glyphOffsets = NULL;
|
|
|
|
run.isSideways = FALSE;
|
|
|
|
run.bidiLevel = 0;
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
|
|
|
|
DWRITE_RENDERING_MODE_ALIASED, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
SetRectEmpty(&rect);
|
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!IsRectEmpty(&rect), "got empty bounds\n");
|
|
|
|
|
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
|
2015-10-19 07:43:02 +02:00
|
|
|
/* test that advances are scaled according to ppdip too */
|
2015-08-04 10:16:10 +02:00
|
|
|
glyphs[0] = glyphs[1] = glyph;
|
2015-10-19 07:43:02 +02:00
|
|
|
advances[0] = advances[1] = 100.0f;
|
2015-08-04 10:16:10 +02:00
|
|
|
run.fontFace = face;
|
|
|
|
run.fontEmSize = 24.0;
|
|
|
|
run.glyphCount = 2;
|
|
|
|
run.glyphIndices = glyphs;
|
2015-10-19 07:43:02 +02:00
|
|
|
run.glyphAdvances = advances;
|
2015-08-04 10:16:10 +02:00
|
|
|
run.glyphOffsets = NULL;
|
|
|
|
run.isSideways = FALSE;
|
|
|
|
run.bidiLevel = 0;
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
|
|
|
|
DWRITE_RENDERING_MODE_ALIASED, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
SetRectEmpty(&rect2);
|
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!IsRectEmpty(&rect2), "got empty bounds\n");
|
|
|
|
ok(!EqualRect(&rect, &rect2), "got wrong rect2\n");
|
2015-10-19 07:43:02 +02:00
|
|
|
ok((rect2.right - rect.left) > advances[0], "got rect width %d for advance %f\n", rect.right - rect.left, advances[0]);
|
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 2.0, NULL,
|
|
|
|
DWRITE_RENDERING_MODE_ALIASED, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2015-08-04 10:16:10 +02:00
|
|
|
|
2015-10-19 07:43:02 +02:00
|
|
|
SetRectEmpty(&rect);
|
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok((rect.right - rect.left) > 2 * advances[0], "got rect width %d for advance %f\n", rect.right - rect.left, advances[0]);
|
2015-08-04 10:16:10 +02:00
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
|
2015-11-02 14:38:43 +01:00
|
|
|
/* with scaling transform */
|
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
|
|
|
|
DWRITE_RENDERING_MODE_ALIASED, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
SetRectEmpty(&rect);
|
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!IsRectEmpty(&rect), "got rect width %d\n", rect.right - rect.left);
|
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
|
|
|
|
memset(&m, 0, sizeof(m));
|
|
|
|
m.m11 = 2.0;
|
|
|
|
m.m22 = 1.0;
|
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, &m,
|
|
|
|
DWRITE_RENDERING_MODE_ALIASED, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
SetRectEmpty(&rect2);
|
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok((rect2.right - rect2.left) > (rect.right - rect.left), "got rect width %d\n", rect2.right - rect2.left);
|
2015-11-03 20:05:25 +01:00
|
|
|
|
|
|
|
/* instances are not reused for same runs */
|
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, &m,
|
|
|
|
DWRITE_RENDERING_MODE_ALIASED, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
0.0, 0.0, &analysis2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(analysis2 != analysis, "got %p, previous instance %p\n", analysis2, analysis);
|
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis2);
|
|
|
|
|
2015-11-02 14:38:43 +01:00
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
|
2017-07-17 22:18:43 +02:00
|
|
|
if (IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory2, (void **)&factory2) == S_OK) {
|
|
|
|
FLOAT gamma, contrast, cleartype_level;
|
|
|
|
|
|
|
|
/* Invalid antialias mode. */
|
|
|
|
hr = IDWriteFactory2_CreateGlyphRunAnalysis(factory2, &run, NULL, DWRITE_RENDERING_MODE_ALIASED,
|
|
|
|
DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DEFAULT, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE + 1,
|
|
|
|
0.0f, 0.0f, &analysis);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
/* Invalid grid fit mode. */
|
|
|
|
hr = IDWriteFactory2_CreateGlyphRunAnalysis(factory2, &run, NULL, DWRITE_RENDERING_MODE_ALIASED,
|
|
|
|
DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_ENABLED + 1, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
|
|
|
|
0.0f, 0.0f, &analysis);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
/* Invalid rendering mode. */
|
|
|
|
hr = IDWriteFactory2_CreateGlyphRunAnalysis(factory2, &run, NULL, DWRITE_RENDERING_MODE_OUTLINE,
|
|
|
|
DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_ENABLED, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
|
|
|
|
0.0f, 0.0f, &analysis);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
/* Invalid measuring mode. */
|
|
|
|
hr = IDWriteFactory2_CreateGlyphRunAnalysis(factory2, &run, NULL, DWRITE_RENDERING_MODE_ALIASED,
|
|
|
|
DWRITE_MEASURING_MODE_GDI_NATURAL + 1, DWRITE_GRID_FIT_MODE_ENABLED, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
|
|
|
|
0.0f, 0.0f, &analysis);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
2017-09-05 12:35:29 +02:00
|
|
|
/* Win8 does not accept default grid fitting mode. */
|
2017-07-17 22:18:43 +02:00
|
|
|
hr = IDWriteFactory2_CreateGlyphRunAnalysis(factory2, &run, NULL, DWRITE_RENDERING_MODE_NATURAL,
|
|
|
|
DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DEFAULT, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
|
|
|
|
0.0f, 0.0f, &analysis);
|
2017-09-05 12:35:29 +02:00
|
|
|
ok(hr == S_OK || broken(hr == E_INVALIDARG) /* Win8 */, "Failed to create analysis, hr %#x.\n", hr);
|
|
|
|
if (hr == S_OK)
|
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
2017-07-17 22:18:43 +02:00
|
|
|
|
2017-09-05 12:35:29 +02:00
|
|
|
/* Natural mode, grayscale antialiased. */
|
|
|
|
hr = IDWriteFactory2_CreateGlyphRunAnalysis(factory2, &run, NULL, DWRITE_RENDERING_MODE_NATURAL,
|
|
|
|
DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DISABLED, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
|
|
|
|
0.0f, 0.0f, &analysis);
|
|
|
|
ok(hr == S_OK, "Failed to create analysis, hr %#x.\n", hr);
|
2017-07-17 22:18:43 +02:00
|
|
|
|
2017-09-05 12:35:29 +02:00
|
|
|
SetRect(&rect, 0, 1, 0, 1);
|
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect);
|
|
|
|
ok(hr == S_OK, "Failed to get texture bounds, hr %#x.\n", hr);
|
|
|
|
ok(IsRectEmpty(&rect), "Expected empty bbox.\n");
|
2017-07-17 22:18:43 +02:00
|
|
|
|
2017-09-05 12:35:29 +02:00
|
|
|
SetRectEmpty(&rect);
|
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
|
|
|
|
ok(hr == S_OK, "Failed to get texture bounds, hr %#x.\n", hr);
|
|
|
|
ok(!IsRectEmpty(&rect), "Unexpected empty bbox.\n");
|
|
|
|
|
|
|
|
size = (rect.right - rect.left) * (rect.bottom - rect.top);
|
|
|
|
bits = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect, bits, size);
|
|
|
|
ok(hr == S_OK, "Failed to get alpha texture, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect, bits, size - 1);
|
|
|
|
ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect, bits, size);
|
|
|
|
ok(hr == DWRITE_E_UNSUPPORTEDOPERATION, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect, bits, size - 1);
|
|
|
|
todo_wine
|
|
|
|
ok(hr == DWRITE_E_UNSUPPORTEDOPERATION, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, bits);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateCustomRenderingParams(factory, 0.1f, 0.0f, 1.0f, DWRITE_PIXEL_GEOMETRY_FLAT,
|
|
|
|
DWRITE_RENDERING_MODE_NATURAL, ¶ms);
|
|
|
|
ok(hr == S_OK, "Failed to create custom parameters, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaBlendParams(analysis, params, &gamma, &contrast, &cleartype_level);
|
|
|
|
ok(hr == S_OK, "Failed to get alpha blend params, hr %#x.\n", hr);
|
|
|
|
todo_wine
|
|
|
|
ok(cleartype_level == 0.0f, "Unexpected cleartype level %f.\n", cleartype_level);
|
|
|
|
|
|
|
|
IDWriteRenderingParams_Release(params);
|
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
2017-07-17 22:18:43 +02:00
|
|
|
|
|
|
|
IDWriteFactory2_Release(factory2);
|
|
|
|
}
|
|
|
|
|
2017-09-05 12:35:29 +02:00
|
|
|
if (IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory3, (void **)&factory3) == S_OK) {
|
|
|
|
|
|
|
|
/* Invalid antialias mode. */
|
|
|
|
hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_ALIASED,
|
|
|
|
DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DEFAULT, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE + 1,
|
|
|
|
0.0f, 0.0f, &analysis);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
/* Invalid grid fit mode. */
|
|
|
|
hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_ALIASED,
|
|
|
|
DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_ENABLED + 1, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
|
|
|
|
0.0f, 0.0f, &analysis);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
/* Invalid rendering mode. */
|
|
|
|
hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_OUTLINE,
|
|
|
|
DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_ENABLED, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
|
|
|
|
0.0f, 0.0f, &analysis);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
/* Invalid measuring mode. */
|
|
|
|
hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_ALIASED,
|
|
|
|
DWRITE_MEASURING_MODE_GDI_NATURAL + 1, DWRITE_GRID_FIT_MODE_ENABLED,
|
|
|
|
DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE, 0.0f, 0.0f, &analysis);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_NATURAL,
|
|
|
|
DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DEFAULT, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
|
|
|
|
0.0f, 0.0f, &analysis);
|
|
|
|
ok(hr == S_OK, "Failed to create analysis, hr %#x.\n", hr);
|
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
|
|
|
|
/* Natural mode, grayscale antialiased. */
|
|
|
|
hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_NATURAL,
|
|
|
|
DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DISABLED, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
|
|
|
|
0.0f, 0.0f, &analysis);
|
|
|
|
ok(hr == S_OK, "Failed to create analysis, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
SetRect(&rect, 0, 1, 0, 1);
|
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect);
|
|
|
|
ok(hr == S_OK, "Failed to get texture bounds, hr %#x.\n", hr);
|
|
|
|
ok(IsRectEmpty(&rect), "Expected empty bbox.\n");
|
|
|
|
|
|
|
|
SetRectEmpty(&rect);
|
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
|
|
|
|
ok(hr == S_OK, "Failed to get texture bounds, hr %#x.\n", hr);
|
|
|
|
ok(!IsRectEmpty(&rect), "Unexpected empty bbox.\n");
|
|
|
|
|
|
|
|
size = (rect.right - rect.left) * (rect.bottom - rect.top);
|
|
|
|
bits = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect, bits, size);
|
|
|
|
ok(hr == S_OK, "Failed to get alpha texture, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect, bits, size - 1);
|
|
|
|
ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect, bits, size);
|
|
|
|
ok(hr == DWRITE_E_UNSUPPORTEDOPERATION, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect, bits, size - 1);
|
|
|
|
todo_wine
|
|
|
|
ok(hr == DWRITE_E_UNSUPPORTEDOPERATION, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, bits);
|
|
|
|
|
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
|
|
|
|
IDWriteFactory3_Release(factory3);
|
|
|
|
}
|
|
|
|
|
2015-05-19 14:23:57 +02:00
|
|
|
IDWriteFontFace_Release(face);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-05-19 14:23:57 +02:00
|
|
|
}
|
|
|
|
|
2015-07-03 16:53:07 +02:00
|
|
|
#define round(x) ((int)floor((x) + 0.5))
|
|
|
|
|
|
|
|
struct VDMX_Header
|
|
|
|
{
|
|
|
|
WORD version;
|
|
|
|
WORD numRecs;
|
|
|
|
WORD numRatios;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VDMX_Ratio
|
|
|
|
{
|
|
|
|
BYTE bCharSet;
|
|
|
|
BYTE xRatio;
|
|
|
|
BYTE yStartRatio;
|
|
|
|
BYTE yEndRatio;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VDMX_group
|
|
|
|
{
|
|
|
|
WORD recs;
|
|
|
|
BYTE startsz;
|
|
|
|
BYTE endsz;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VDMX_vTable
|
|
|
|
{
|
|
|
|
WORD yPelHeight;
|
|
|
|
SHORT yMax;
|
|
|
|
SHORT yMin;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct VDMX_group *find_vdmx_group(const struct VDMX_Header *hdr)
|
|
|
|
{
|
|
|
|
WORD num_ratios, i, group_offset = 0;
|
|
|
|
struct VDMX_Ratio *ratios = (struct VDMX_Ratio*)(hdr + 1);
|
|
|
|
BYTE dev_x_ratio = 1, dev_y_ratio = 1;
|
|
|
|
|
|
|
|
num_ratios = GET_BE_WORD(hdr->numRatios);
|
|
|
|
|
|
|
|
for (i = 0; i < num_ratios; i++)
|
|
|
|
{
|
|
|
|
if (!ratios[i].bCharSet) continue;
|
|
|
|
|
|
|
|
if ((ratios[i].xRatio == 0 && ratios[i].yStartRatio == 0 &&
|
|
|
|
ratios[i].yEndRatio == 0) ||
|
|
|
|
(ratios[i].xRatio == dev_x_ratio && ratios[i].yStartRatio <= dev_y_ratio &&
|
|
|
|
ratios[i].yEndRatio >= dev_y_ratio))
|
|
|
|
{
|
|
|
|
group_offset = GET_BE_WORD(*((WORD *)(ratios + num_ratios) + i));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (group_offset)
|
|
|
|
return (const struct VDMX_group *)((BYTE *)hdr + group_offset);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL get_vdmx_size(const struct VDMX_group *group, int emsize, int *a, int *d)
|
|
|
|
{
|
|
|
|
WORD recs, i;
|
|
|
|
const struct VDMX_vTable *tables;
|
|
|
|
|
|
|
|
if (!group) return FALSE;
|
|
|
|
|
|
|
|
recs = GET_BE_WORD(group->recs);
|
|
|
|
if (emsize < group->startsz || emsize >= group->endsz) return FALSE;
|
|
|
|
|
|
|
|
tables = (const struct VDMX_vTable *)(group + 1);
|
|
|
|
for (i = 0; i < recs; i++)
|
|
|
|
{
|
|
|
|
WORD ppem = GET_BE_WORD(tables[i].yPelHeight);
|
|
|
|
if (ppem > emsize)
|
|
|
|
{
|
|
|
|
/* FIXME: Supposed to interpolate */
|
|
|
|
trace("FIXME interpolate %d\n", emsize);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ppem == emsize)
|
|
|
|
{
|
|
|
|
*a = (SHORT)GET_BE_WORD(tables[i].yMax);
|
|
|
|
*d = -(SHORT)GET_BE_WORD(tables[i].yMin);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-07-06 22:08:59 +02:00
|
|
|
static void test_metrics_cmp(FLOAT emsize, const DWRITE_FONT_METRICS *metrics, const DWRITE_FONT_METRICS1 *expected)
|
|
|
|
{
|
|
|
|
ok(metrics->designUnitsPerEm == expected->designUnitsPerEm, "%.2f: emsize: got %u expect %u\n",
|
|
|
|
emsize, metrics->designUnitsPerEm, expected->designUnitsPerEm);
|
|
|
|
ok(metrics->ascent == expected->ascent, "%.2f a: got %u expect %u\n",
|
|
|
|
emsize, metrics->ascent, expected->ascent);
|
|
|
|
ok(metrics->descent == expected->descent, "%.2f d: got %u expect %u\n",
|
|
|
|
emsize, metrics->descent, expected->descent);
|
|
|
|
ok(metrics->lineGap == expected->lineGap, "%.2f lg: got %d expect %d\n",
|
|
|
|
emsize, metrics->lineGap, expected->lineGap);
|
|
|
|
ok(metrics->capHeight == expected->capHeight, "%.2f capH: got %u expect %u\n",
|
|
|
|
emsize, metrics->capHeight, expected->capHeight);
|
|
|
|
ok(metrics->xHeight == expected->xHeight, "%.2f xH: got %u expect %u\n",
|
|
|
|
emsize, metrics->xHeight, expected->xHeight);
|
|
|
|
ok(metrics->underlinePosition == expected->underlinePosition, "%.2f ulP: got %d expect %d\n",
|
|
|
|
emsize, metrics->underlinePosition, expected->underlinePosition);
|
|
|
|
ok(metrics->underlineThickness == expected->underlineThickness, "%.2f ulTh: got %u expect %u\n",
|
|
|
|
emsize, metrics->underlineThickness, expected->underlineThickness);
|
|
|
|
ok(metrics->strikethroughPosition == expected->strikethroughPosition, "%.2f stP: got %d expect %d\n",
|
|
|
|
emsize, metrics->strikethroughPosition, expected->strikethroughPosition);
|
|
|
|
ok(metrics->strikethroughThickness == expected->strikethroughThickness, "%.2f stTh: got %u expect %u\n",
|
|
|
|
emsize, metrics->strikethroughThickness, expected->strikethroughThickness);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_metrics1_cmp(FLOAT emsize, const DWRITE_FONT_METRICS1 *metrics, const DWRITE_FONT_METRICS1 *expected)
|
|
|
|
{
|
|
|
|
ok(metrics->designUnitsPerEm == expected->designUnitsPerEm, "%.2f: emsize: got %u expect %u\n",
|
|
|
|
emsize, metrics->designUnitsPerEm, expected->designUnitsPerEm);
|
|
|
|
ok(metrics->ascent == expected->ascent, "%.2f a: got %u expect %u\n",
|
|
|
|
emsize, metrics->ascent, expected->ascent);
|
|
|
|
ok(metrics->descent == expected->descent, "%.2f d: got %u expect %u\n",
|
|
|
|
emsize, metrics->descent, expected->descent);
|
|
|
|
ok(metrics->lineGap == expected->lineGap, "%.2f lg: got %d expect %d\n",
|
|
|
|
emsize, metrics->lineGap, expected->lineGap);
|
|
|
|
ok(metrics->capHeight == expected->capHeight, "%.2f capH: got %u expect %u\n",
|
|
|
|
emsize, metrics->capHeight, expected->capHeight);
|
|
|
|
ok(metrics->xHeight == expected->xHeight, "%.2f xH: got %u expect %u\n",
|
|
|
|
emsize, metrics->xHeight, expected->xHeight);
|
|
|
|
ok(metrics->underlinePosition == expected->underlinePosition, "%.2f ulP: got %d expect %d\n",
|
|
|
|
emsize, metrics->underlinePosition, expected->underlinePosition);
|
|
|
|
ok(metrics->underlineThickness == expected->underlineThickness, "%.2f ulTh: got %u expect %u\n",
|
|
|
|
emsize, metrics->underlineThickness, expected->underlineThickness);
|
|
|
|
ok(metrics->strikethroughPosition == expected->strikethroughPosition, "%.2f stP: got %d expect %d\n",
|
|
|
|
emsize, metrics->strikethroughPosition, expected->strikethroughPosition);
|
|
|
|
ok(metrics->strikethroughThickness == expected->strikethroughThickness, "%.2f stTh: got %u expect %u\n",
|
|
|
|
emsize, metrics->strikethroughThickness, expected->strikethroughThickness);
|
|
|
|
ok(metrics->glyphBoxLeft == expected->glyphBoxLeft, "%.2f box left: got %d expect %d\n",
|
|
|
|
emsize, metrics->glyphBoxLeft, expected->glyphBoxLeft);
|
|
|
|
if (0) { /* this is not consistent */
|
|
|
|
ok(metrics->glyphBoxTop == expected->glyphBoxTop, "%.2f box top: got %d expect %d\n",
|
|
|
|
emsize, metrics->glyphBoxTop, expected->glyphBoxTop);
|
|
|
|
ok(metrics->glyphBoxRight == expected->glyphBoxRight, "%.2f box right: got %d expect %d\n",
|
|
|
|
emsize, metrics->glyphBoxRight, expected->glyphBoxRight);
|
|
|
|
}
|
|
|
|
ok(metrics->glyphBoxBottom == expected->glyphBoxBottom, "%.2f box bottom: got %d expect %d\n",
|
|
|
|
emsize, metrics->glyphBoxBottom, expected->glyphBoxBottom);
|
|
|
|
ok(metrics->subscriptPositionX == expected->subscriptPositionX, "%.2f subX: got %d expect %d\n",
|
|
|
|
emsize, metrics->subscriptPositionX, expected->subscriptPositionX);
|
|
|
|
ok(metrics->subscriptPositionY == expected->subscriptPositionY, "%.2f subY: got %d expect %d\n",
|
|
|
|
emsize, metrics->subscriptPositionY, expected->subscriptPositionY);
|
|
|
|
ok(metrics->subscriptSizeX == expected->subscriptSizeX, "%.2f subsizeX: got %d expect %d\n",
|
|
|
|
emsize, metrics->subscriptSizeX, expected->subscriptSizeX);
|
|
|
|
ok(metrics->subscriptPositionY == expected->subscriptPositionY, "%.2f subsizeY: got %d expect %d\n",
|
|
|
|
emsize, metrics->subscriptSizeY, expected->subscriptSizeY);
|
|
|
|
ok(metrics->superscriptPositionX == expected->superscriptPositionX, "%.2f supX: got %d expect %d\n",
|
|
|
|
emsize, metrics->superscriptPositionX, expected->superscriptPositionX);
|
|
|
|
if (0)
|
|
|
|
ok(metrics->superscriptPositionY == expected->superscriptPositionY, "%.2f supY: got %d expect %d\n",
|
|
|
|
emsize, metrics->superscriptPositionY, expected->superscriptPositionY);
|
|
|
|
ok(metrics->superscriptSizeX == expected->superscriptSizeX, "%.2f supsizeX: got %d expect %d\n",
|
|
|
|
emsize, metrics->superscriptSizeX, expected->superscriptSizeX);
|
|
|
|
ok(metrics->superscriptSizeY == expected->superscriptSizeY, "%.2f supsizeY: got %d expect %d\n",
|
|
|
|
emsize, metrics->superscriptSizeY, expected->superscriptSizeY);
|
|
|
|
ok(metrics->hasTypographicMetrics == expected->hasTypographicMetrics, "%.2f hastypo: got %d expect %d\n",
|
|
|
|
emsize, metrics->hasTypographicMetrics, expected->hasTypographicMetrics);
|
|
|
|
}
|
|
|
|
|
2015-07-12 22:35:52 +02:00
|
|
|
struct compatmetrics_test {
|
|
|
|
DWRITE_MATRIX m;
|
|
|
|
FLOAT ppdip;
|
|
|
|
FLOAT emsize;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct compatmetrics_test compatmetrics_tests[] = {
|
|
|
|
{ { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0 }, 1.0, 5.0 },
|
|
|
|
{ { 0.0, 0.0, 0.0, -1.0, 0.0, 0.0 }, 1.0, 5.0 },
|
|
|
|
{ { 0.0, 0.0, 0.0, -1.0, 0.0, 0.0 }, 2.0, 5.0 },
|
|
|
|
{ { 0.0, 0.0, 0.0, 3.0, 0.0, 0.0 }, 2.0, 5.0 },
|
|
|
|
{ { 0.0, 0.0, 0.0, -3.0, 0.0, 0.0 }, 2.0, 5.0 },
|
|
|
|
{ { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 }, 2.0, 5.0 },
|
|
|
|
{ { 1.0, 0.0, 0.0, 1.0, 5.0, 0.0 }, 2.0, 5.0 },
|
|
|
|
{ { 1.0, 0.0, 0.0, 1.0, 0.0, 5.0 }, 2.0, 5.0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static void get_expected_metrics(IDWriteFontFace *fontface, struct compatmetrics_test *ptr,
|
|
|
|
DWRITE_FONT_METRICS *expected)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
memset(expected, 0, sizeof(*expected));
|
|
|
|
hr = IDWriteFontFace_GetGdiCompatibleMetrics(fontface, ptr->ppdip * fabsf(ptr->m.m22) * ptr->emsize, 1.0, NULL, expected);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
}
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
static void test_gdicompat_metrics(IDWriteFontFace *face)
|
2015-07-03 16:53:07 +02:00
|
|
|
{
|
2015-07-06 22:08:59 +02:00
|
|
|
IDWriteFontFace1 *fontface1 = NULL;
|
2015-07-03 16:53:07 +02:00
|
|
|
HRESULT hr;
|
2015-07-08 11:36:48 +02:00
|
|
|
DWRITE_FONT_METRICS design_metrics, comp_metrics;
|
|
|
|
DWRITE_FONT_METRICS1 design_metrics1, expected;
|
2015-07-03 16:53:07 +02:00
|
|
|
FLOAT emsize, scale;
|
2015-07-06 22:08:59 +02:00
|
|
|
int ascent, descent;
|
2015-07-03 16:53:07 +02:00
|
|
|
const struct VDMX_Header *vdmx;
|
|
|
|
UINT32 vdmx_len;
|
|
|
|
void *vdmx_ctx;
|
|
|
|
BOOL exists;
|
|
|
|
const struct VDMX_group *vdmx_group = NULL;
|
2015-07-12 22:35:52 +02:00
|
|
|
int i;
|
2015-07-03 16:53:07 +02:00
|
|
|
|
2015-07-06 22:08:59 +02:00
|
|
|
hr = IDWriteFontFace_QueryInterface(face, &IID_IDWriteFontFace1, (void**)&fontface1);
|
|
|
|
if (hr != S_OK)
|
|
|
|
win_skip("gdi compatible DWRITE_FONT_METRICS1 are not supported.\n");
|
|
|
|
|
|
|
|
if (fontface1) {
|
|
|
|
IDWriteFontFace1_GetMetrics(fontface1, &design_metrics1);
|
|
|
|
memcpy(&design_metrics, &design_metrics1, sizeof(design_metrics));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
IDWriteFontFace_GetMetrics(face, &design_metrics);
|
2015-07-03 16:53:07 +02:00
|
|
|
|
|
|
|
hr = IDWriteFontFace_TryGetFontTable(face, MS_VDMX_TAG, (const void **)&vdmx,
|
|
|
|
&vdmx_len, &vdmx_ctx, &exists);
|
|
|
|
if (hr != S_OK || !exists)
|
|
|
|
vdmx = NULL;
|
|
|
|
else
|
|
|
|
vdmx_group = find_vdmx_group(vdmx);
|
|
|
|
|
2015-07-12 22:35:52 +02:00
|
|
|
/* negative emsize */
|
|
|
|
memset(&comp_metrics, 0xcc, sizeof(comp_metrics));
|
|
|
|
memset(&expected, 0, sizeof(expected));
|
|
|
|
hr = IDWriteFontFace_GetGdiCompatibleMetrics(face, -10.0, 1.0, NULL, &comp_metrics);
|
|
|
|
ok(hr == E_INVALIDARG, "got %08x\n", hr);
|
|
|
|
test_metrics_cmp(0.0, &comp_metrics, &expected);
|
|
|
|
|
|
|
|
/* zero emsize */
|
|
|
|
memset(&comp_metrics, 0xcc, sizeof(comp_metrics));
|
|
|
|
memset(&expected, 0, sizeof(expected));
|
|
|
|
hr = IDWriteFontFace_GetGdiCompatibleMetrics(face, 0.0, 1.0, NULL, &comp_metrics);
|
|
|
|
ok(hr == E_INVALIDARG, "got %08x\n", hr);
|
|
|
|
test_metrics_cmp(0.0, &comp_metrics, &expected);
|
|
|
|
|
2015-07-08 11:36:48 +02:00
|
|
|
/* zero pixels per dip */
|
|
|
|
memset(&comp_metrics, 0xcc, sizeof(comp_metrics));
|
|
|
|
memset(&expected, 0, sizeof(expected));
|
|
|
|
hr = IDWriteFontFace_GetGdiCompatibleMetrics(face, 5.0, 0.0, NULL, &comp_metrics);
|
|
|
|
ok(hr == E_INVALIDARG, "got %08x\n", hr);
|
|
|
|
test_metrics_cmp(5.0, &comp_metrics, &expected);
|
|
|
|
|
|
|
|
memset(&comp_metrics, 0xcc, sizeof(comp_metrics));
|
|
|
|
hr = IDWriteFontFace_GetGdiCompatibleMetrics(face, 5.0, -1.0, NULL, &comp_metrics);
|
|
|
|
ok(hr == E_INVALIDARG, "got %08x\n", hr);
|
|
|
|
test_metrics_cmp(5.0, &comp_metrics, &expected);
|
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(compatmetrics_tests); i++) {
|
2015-07-12 22:35:52 +02:00
|
|
|
struct compatmetrics_test *ptr = &compatmetrics_tests[i];
|
2015-07-08 11:36:48 +02:00
|
|
|
|
2015-07-12 22:35:52 +02:00
|
|
|
get_expected_metrics(face, ptr, (DWRITE_FONT_METRICS*)&expected);
|
|
|
|
hr = IDWriteFontFace_GetGdiCompatibleMetrics(face, ptr->emsize, ptr->ppdip, &ptr->m, &comp_metrics);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
test_metrics_cmp(ptr->emsize, &comp_metrics, &expected);
|
|
|
|
}
|
2015-07-08 11:36:48 +02:00
|
|
|
|
2015-07-03 16:53:07 +02:00
|
|
|
for (emsize = 5; emsize <= design_metrics.designUnitsPerEm; emsize++)
|
|
|
|
{
|
2015-07-06 22:08:59 +02:00
|
|
|
DWRITE_FONT_METRICS1 comp_metrics1, expected;
|
|
|
|
|
|
|
|
if (fontface1) {
|
|
|
|
hr = IDWriteFontFace1_GetGdiCompatibleMetrics(fontface1, emsize, 1.0, NULL, &comp_metrics1);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
hr = IDWriteFontFace_GetGdiCompatibleMetrics(face, emsize, 1.0, NULL, &comp_metrics);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
}
|
2015-07-03 16:53:07 +02:00
|
|
|
|
2015-07-06 22:08:59 +02:00
|
|
|
scale = emsize / design_metrics.designUnitsPerEm;
|
2015-07-03 16:53:07 +02:00
|
|
|
if (!get_vdmx_size(vdmx_group, emsize, &ascent, &descent))
|
|
|
|
{
|
|
|
|
ascent = round(design_metrics.ascent * scale);
|
|
|
|
descent = round(design_metrics.descent * scale);
|
|
|
|
}
|
|
|
|
|
2015-07-06 22:08:59 +02:00
|
|
|
expected.designUnitsPerEm = design_metrics.designUnitsPerEm;
|
|
|
|
expected.ascent = round(ascent / scale );
|
|
|
|
expected.descent = round(descent / scale );
|
|
|
|
expected.lineGap = round(round(design_metrics.lineGap * scale) / scale);
|
|
|
|
expected.capHeight = round(round(design_metrics.capHeight * scale) / scale);
|
|
|
|
expected.xHeight = round(round(design_metrics.xHeight * scale) / scale);
|
|
|
|
expected.underlinePosition = round(round(design_metrics.underlinePosition * scale) / scale);
|
|
|
|
expected.underlineThickness = round(round(design_metrics.underlineThickness * scale) / scale);
|
|
|
|
expected.strikethroughPosition = round(round(design_metrics.strikethroughPosition * scale) / scale);
|
|
|
|
expected.strikethroughThickness = round(round(design_metrics.strikethroughThickness * scale) / scale);
|
|
|
|
|
|
|
|
if (fontface1) {
|
|
|
|
expected.glyphBoxLeft = round(round(design_metrics1.glyphBoxLeft * scale) / scale);
|
|
|
|
|
|
|
|
if (0) { /* those two fail on Tahoma and Win7 */
|
|
|
|
expected.glyphBoxTop = round(round(design_metrics1.glyphBoxTop * scale) / scale);
|
|
|
|
expected.glyphBoxRight = round(round(design_metrics1.glyphBoxRight * scale) / scale);
|
|
|
|
}
|
|
|
|
expected.glyphBoxBottom = round(round(design_metrics1.glyphBoxBottom * scale) / scale);
|
|
|
|
expected.subscriptPositionX = round(round(design_metrics1.subscriptPositionX * scale) / scale);
|
|
|
|
expected.subscriptPositionY = round(round(design_metrics1.subscriptPositionY * scale) / scale);
|
|
|
|
expected.subscriptSizeX = round(round(design_metrics1.subscriptSizeX * scale) / scale);
|
|
|
|
expected.subscriptSizeY = round(round(design_metrics1.subscriptSizeY * scale) / scale);
|
|
|
|
expected.superscriptPositionX = round(round(design_metrics1.superscriptPositionX * scale) / scale);
|
2016-08-09 14:59:46 +02:00
|
|
|
if (0) /* this fails for 3 emsizes, Tahoma from [5, 2048] range */ {
|
2015-07-06 22:08:59 +02:00
|
|
|
expected.superscriptPositionY = round(round(design_metrics1.superscriptPositionY * scale) / scale);
|
2016-08-09 14:59:46 +02:00
|
|
|
}
|
2015-07-06 22:08:59 +02:00
|
|
|
expected.superscriptSizeX = round(round(design_metrics1.superscriptSizeX * scale) / scale);
|
|
|
|
expected.superscriptSizeY = round(round(design_metrics1.superscriptSizeY * scale) / scale);
|
|
|
|
expected.hasTypographicMetrics = design_metrics1.hasTypographicMetrics;
|
|
|
|
|
|
|
|
test_metrics1_cmp(emsize, &comp_metrics1, &expected);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
test_metrics_cmp(emsize, &comp_metrics, &expected);
|
2015-07-03 16:53:07 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-07-06 22:08:59 +02:00
|
|
|
if (fontface1)
|
|
|
|
IDWriteFontFace1_Release(fontface1);
|
2015-07-03 16:53:07 +02:00
|
|
|
if (vdmx) IDWriteFontFace_ReleaseFontTable(face, vdmx_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_GetGdiCompatibleMetrics(void)
|
|
|
|
{
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFont *font;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2015-07-03 16:53:07 +02:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
|
|
|
font = get_font(factory, tahomaW, DWRITE_FONT_STYLE_NORMAL);
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFont_Release(font);
|
2017-04-11 13:21:32 +02:00
|
|
|
test_gdicompat_metrics(fontface);
|
2015-07-03 16:53:07 +02:00
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
|
|
|
|
font = get_font(factory, arialW, DWRITE_FONT_STYLE_NORMAL);
|
|
|
|
if (!font)
|
|
|
|
skip("Skipping tests with Arial\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
test_gdicompat_metrics(fontface);
|
2015-07-03 16:53:07 +02:00
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
}
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-07-03 16:53:07 +02:00
|
|
|
}
|
|
|
|
|
2016-12-15 04:48:58 +01:00
|
|
|
static void get_expected_panose(IDWriteFont1 *font, DWRITE_PANOSE *panose)
|
|
|
|
{
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
const TT_OS2_V2 *tt_os2;
|
|
|
|
void *os2_context;
|
|
|
|
UINT32 size;
|
|
|
|
BOOL exists;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
memset(panose, 0, sizeof(*panose));
|
|
|
|
|
|
|
|
hr = IDWriteFont1_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_TryGetFontTable(fontface, MS_0S2_TAG, (const void **)&tt_os2, &size, &os2_context, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
if (tt_os2) {
|
|
|
|
memcpy(panose, &tt_os2->panose, sizeof(*panose));
|
|
|
|
IDWriteFontFace_ReleaseFontTable(fontface, os2_context);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
}
|
|
|
|
|
2015-07-06 22:08:37 +02:00
|
|
|
static void test_GetPanose(void)
|
|
|
|
{
|
2016-12-15 04:48:58 +01:00
|
|
|
IDWriteFontCollection *syscollection;
|
2015-07-06 22:08:37 +02:00
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFont1 *font1;
|
|
|
|
IDWriteFont *font;
|
2016-12-15 04:48:58 +01:00
|
|
|
UINT count, i;
|
2015-07-06 22:08:37 +02:00
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2015-07-06 22:08:37 +02:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
font = get_tahoma_instance(factory, DWRITE_FONT_STYLE_NORMAL);
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFont1, (void **)&font1);
|
2015-07-06 22:08:37 +02:00
|
|
|
IDWriteFont_Release(font);
|
2016-12-15 04:48:58 +01:00
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2016-12-15 04:48:58 +01:00
|
|
|
win_skip("GetPanose() is not supported.\n");
|
|
|
|
return;
|
|
|
|
}
|
2017-04-11 13:21:32 +02:00
|
|
|
IDWriteFont1_Release(font1);
|
2016-12-15 04:48:58 +01:00
|
|
|
|
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
count = IDWriteFontCollection_GetFontFamilyCount(syscollection);
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
DWRITE_PANOSE panose, expected_panose;
|
|
|
|
IDWriteLocalizedStrings *names;
|
2016-07-05 11:55:53 +02:00
|
|
|
IDWriteFontFace3 *fontface3;
|
|
|
|
IDWriteFontFace *fontface;
|
2016-12-15 04:48:58 +01:00
|
|
|
IDWriteFontFamily *family;
|
|
|
|
IDWriteFont1 *font1;
|
|
|
|
IDWriteFont *font;
|
|
|
|
WCHAR nameW[256];
|
2015-07-06 22:08:37 +02:00
|
|
|
|
2016-12-15 04:48:58 +01:00
|
|
|
hr = IDWriteFontCollection_GetFontFamily(syscollection, i, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2015-07-06 22:08:37 +02:00
|
|
|
|
2016-12-15 04:48:58 +01:00
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
|
|
|
|
DWRITE_FONT_STYLE_NORMAL, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2015-07-06 22:08:37 +02:00
|
|
|
|
2016-12-15 04:48:58 +01:00
|
|
|
hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFont1, (void **)&font1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFamilyNames(family, &names);
|
2016-07-05 11:55:53 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
get_enus_string(names, nameW, ARRAY_SIZE(nameW));
|
2016-07-05 11:55:53 +02:00
|
|
|
|
2016-12-15 04:48:58 +01:00
|
|
|
IDWriteLocalizedStrings_Release(names);
|
2016-07-05 11:55:53 +02:00
|
|
|
|
2016-12-15 04:48:58 +01:00
|
|
|
IDWriteFont1_GetPanose(font1, &panose);
|
|
|
|
get_expected_panose(font1, &expected_panose);
|
|
|
|
|
|
|
|
ok(panose.values[0] == expected_panose.values[0], "%s: values[0] %#x, expected %#x.\n", wine_dbgstr_w(nameW),
|
|
|
|
panose.values[0], expected_panose.values[0]);
|
|
|
|
ok(panose.values[1] == expected_panose.values[1], "%s: values[1] %#x, expected %#x.\n", wine_dbgstr_w(nameW),
|
|
|
|
panose.values[1], expected_panose.values[1]);
|
|
|
|
ok(panose.values[2] == expected_panose.values[2], "%s: values[2] %#x, expected %#x.\n", wine_dbgstr_w(nameW),
|
|
|
|
panose.values[2], expected_panose.values[2]);
|
|
|
|
ok(panose.values[3] == expected_panose.values[3], "%s: values[3] %#x, expected %#x.\n", wine_dbgstr_w(nameW),
|
|
|
|
panose.values[3], expected_panose.values[3]);
|
|
|
|
ok(panose.values[4] == expected_panose.values[4], "%s: values[4] %#x, expected %#x.\n", wine_dbgstr_w(nameW),
|
|
|
|
panose.values[4], expected_panose.values[4]);
|
|
|
|
ok(panose.values[5] == expected_panose.values[5], "%s: values[5] %#x, expected %#x.\n", wine_dbgstr_w(nameW),
|
|
|
|
panose.values[5], expected_panose.values[5]);
|
|
|
|
ok(panose.values[6] == expected_panose.values[6], "%s: values[6] %#x, expected %#x.\n", wine_dbgstr_w(nameW),
|
|
|
|
panose.values[6], expected_panose.values[6]);
|
|
|
|
ok(panose.values[7] == expected_panose.values[7], "%s: values[7] %#x, expected %#x.\n", wine_dbgstr_w(nameW),
|
|
|
|
panose.values[7], expected_panose.values[7]);
|
|
|
|
ok(panose.values[8] == expected_panose.values[8], "%s: values[8] %#x, expected %#x.\n", wine_dbgstr_w(nameW),
|
|
|
|
panose.values[8], expected_panose.values[8]);
|
|
|
|
ok(panose.values[9] == expected_panose.values[9], "%s: values[9] %#x, expected %#x.\n", wine_dbgstr_w(nameW),
|
|
|
|
panose.values[9], expected_panose.values[9]);
|
|
|
|
|
|
|
|
hr = IDWriteFont1_CreateFontFace(font1, &fontface);
|
|
|
|
ok(hr == S_OK, "Failed to create a font face, %#x.\n", hr);
|
|
|
|
if (IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace3, (void **)&fontface3) == S_OK) {
|
|
|
|
ok(!memcmp(&panose, &expected_panose, sizeof(panose)), "%s: Unexpected panose from font face.\n",
|
|
|
|
wine_dbgstr_w(nameW));
|
2016-07-05 11:55:53 +02:00
|
|
|
IDWriteFontFace3_Release(fontface3);
|
|
|
|
}
|
2016-12-15 04:48:58 +01:00
|
|
|
IDWriteFontFace_Release(fontface);
|
2016-07-05 11:55:53 +02:00
|
|
|
|
2015-07-06 22:08:37 +02:00
|
|
|
IDWriteFont1_Release(font1);
|
2016-12-15 04:48:58 +01:00
|
|
|
IDWriteFontFamily_Release(family);
|
2015-07-06 22:08:37 +02:00
|
|
|
}
|
|
|
|
|
2016-12-15 04:48:58 +01:00
|
|
|
IDWriteFontCollection_Release(syscollection);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-07-06 22:08:37 +02:00
|
|
|
}
|
|
|
|
|
2015-07-20 14:13:58 +02:00
|
|
|
static INT32 get_gdi_font_advance(HDC hdc, FLOAT emsize)
|
|
|
|
{
|
|
|
|
LOGFONTW logfont;
|
|
|
|
HFONT hfont;
|
|
|
|
BOOL ret;
|
|
|
|
ABC abc;
|
|
|
|
|
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = (LONG)-emsize;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
|
|
|
logfont.lfQuality = CLEARTYPE_QUALITY;
|
|
|
|
lstrcpyW(logfont.lfFaceName, tahomaW);
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectW(&logfont);
|
|
|
|
SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
ret = GetCharABCWidthsW(hdc, 'A', 'A', &abc);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
DeleteObject(hfont);
|
|
|
|
|
|
|
|
return abc.abcA + abc.abcB + abc.abcC;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_GetGdiCompatibleGlyphAdvances(void)
|
|
|
|
{
|
|
|
|
IDWriteFontFace1 *fontface1;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFont *font;
|
|
|
|
HRESULT hr;
|
|
|
|
HDC hdc;
|
|
|
|
UINT32 codepoint;
|
|
|
|
UINT16 glyph;
|
|
|
|
FLOAT emsize;
|
|
|
|
DWRITE_FONT_METRICS1 fm;
|
|
|
|
INT32 advance;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2015-07-20 14:13:58 +02:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
font = get_tahoma_instance(factory, DWRITE_FONT_STYLE_NORMAL);
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void **)&fontface1);
|
2015-07-20 14:13:58 +02:00
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
|
|
|
|
if (hr != S_OK) {
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-07-20 14:13:58 +02:00
|
|
|
win_skip("GetGdiCompatibleGlyphAdvances() is not supported\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
codepoint = 'A';
|
|
|
|
glyph = 0;
|
|
|
|
hr = IDWriteFontFace1_GetGlyphIndices(fontface1, &codepoint, 1, &glyph);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(glyph > 0, "got %u\n", glyph);
|
|
|
|
|
|
|
|
/* zero emsize */
|
|
|
|
advance = 1;
|
|
|
|
hr = IDWriteFontFace1_GetGdiCompatibleGlyphAdvances(fontface1, 0.0,
|
|
|
|
1.0, NULL, FALSE, FALSE, 1, &glyph, &advance);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(advance == 0, "got %d\n", advance);
|
|
|
|
|
|
|
|
/* negative emsize */
|
|
|
|
advance = 1;
|
|
|
|
hr = IDWriteFontFace1_GetGdiCompatibleGlyphAdvances(fontface1, -1.0,
|
|
|
|
1.0, NULL, FALSE, FALSE, 1, &glyph, &advance);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(advance == 0, "got %d\n", advance);
|
|
|
|
|
|
|
|
/* zero ppdip */
|
|
|
|
advance = 1;
|
|
|
|
hr = IDWriteFontFace1_GetGdiCompatibleGlyphAdvances(fontface1, 1.0,
|
|
|
|
0.0, NULL, FALSE, FALSE, 1, &glyph, &advance);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(advance == 0, "got %d\n", advance);
|
|
|
|
|
|
|
|
/* negative ppdip */
|
|
|
|
advance = 1;
|
|
|
|
hr = IDWriteFontFace1_GetGdiCompatibleGlyphAdvances(fontface1, 1.0,
|
|
|
|
-1.0, NULL, FALSE, FALSE, 1, &glyph, &advance);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(advance == 0, "got %d\n", advance);
|
|
|
|
|
|
|
|
IDWriteFontFace1_GetMetrics(fontface1, &fm);
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
|
|
|
|
for (emsize = 1.0; emsize <= fm.designUnitsPerEm; emsize += 1.0) {
|
|
|
|
INT32 gdi_advance;
|
|
|
|
|
|
|
|
gdi_advance = get_gdi_font_advance(hdc, emsize);
|
|
|
|
hr = IDWriteFontFace1_GetGdiCompatibleGlyphAdvances(fontface1, emsize,
|
|
|
|
1.0, NULL, FALSE, FALSE, 1, &glyph, &advance);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
/* advance is in design units */
|
|
|
|
advance = (int)floorf(emsize * advance / fm.designUnitsPerEm + 0.5f);
|
2015-08-24 09:43:19 +02:00
|
|
|
ok((advance - gdi_advance) <= 2, "%.0f: got advance %d, expected %d\n", emsize, advance, gdi_advance);
|
2015-07-20 14:13:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DeleteObject(hdc);
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
IDWriteFontFace1_Release(fontface1);
|
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-07-20 14:13:58 +02:00
|
|
|
}
|
|
|
|
|
2015-10-26 18:38:56 +01:00
|
|
|
static WORD get_gasp_flags(IDWriteFontFace *fontface, FLOAT emsize, FLOAT ppdip)
|
2015-07-27 10:10:04 +02:00
|
|
|
{
|
|
|
|
WORD num_recs, version;
|
|
|
|
const WORD *ptr;
|
|
|
|
WORD flags = 0;
|
|
|
|
UINT32 size;
|
|
|
|
BOOL exists;
|
|
|
|
void *ctxt;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2015-10-26 18:38:56 +01:00
|
|
|
emsize *= ppdip;
|
|
|
|
|
2015-07-27 10:10:04 +02:00
|
|
|
exists = FALSE;
|
|
|
|
hr = IDWriteFontFace_TryGetFontTable(fontface, MS_GASP_TAG,
|
|
|
|
(const void**)&ptr, &size, &ctxt, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
if (!exists)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
version = GET_BE_WORD( *ptr++ );
|
|
|
|
num_recs = GET_BE_WORD( *ptr++ );
|
|
|
|
if (version > 1 || size < (num_recs * 2 + 2) * sizeof(WORD)) {
|
|
|
|
ok(0, "unsupported gasp table: ver %d size %d recs %d\n", version, size, num_recs);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (num_recs--)
|
|
|
|
{
|
|
|
|
flags = GET_BE_WORD( *(ptr + 1) );
|
|
|
|
if (emsize <= GET_BE_WORD( *ptr )) break;
|
|
|
|
ptr += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
IDWriteFontFace_ReleaseFontTable(fontface, ctxt);
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GASP_GRIDFIT 0x0001
|
|
|
|
#define GASP_DOGRAY 0x0002
|
|
|
|
#define GASP_SYMMETRIC_GRIDFIT 0x0004
|
|
|
|
#define GASP_SYMMETRIC_SMOOTHING 0x0008
|
|
|
|
|
|
|
|
static BOOL g_is_vista;
|
|
|
|
static DWRITE_RENDERING_MODE get_expected_rendering_mode(FLOAT emsize, WORD gasp, DWRITE_MEASURING_MODE mode,
|
|
|
|
DWRITE_OUTLINE_THRESHOLD threshold)
|
|
|
|
{
|
|
|
|
static const FLOAT aa_threshold = 100.0f;
|
|
|
|
static const FLOAT a_threshold = 350.0f;
|
|
|
|
static const FLOAT naturalemsize = 20.0f;
|
|
|
|
FLOAT v;
|
|
|
|
|
|
|
|
/* outline threshold */
|
|
|
|
if (g_is_vista)
|
|
|
|
v = mode == DWRITE_MEASURING_MODE_NATURAL ? aa_threshold : a_threshold;
|
|
|
|
else
|
|
|
|
v = threshold == DWRITE_OUTLINE_THRESHOLD_ANTIALIASED ? aa_threshold : a_threshold;
|
|
|
|
|
|
|
|
if (emsize >= v)
|
|
|
|
return DWRITE_RENDERING_MODE_OUTLINE;
|
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case DWRITE_MEASURING_MODE_NATURAL:
|
|
|
|
if (!(gasp & GASP_SYMMETRIC_SMOOTHING) && (emsize <= naturalemsize))
|
|
|
|
return DWRITE_RENDERING_MODE_NATURAL;
|
|
|
|
else
|
|
|
|
return DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC;
|
|
|
|
case DWRITE_MEASURING_MODE_GDI_CLASSIC:
|
|
|
|
return DWRITE_RENDERING_MODE_GDI_CLASSIC;
|
|
|
|
case DWRITE_MEASURING_MODE_GDI_NATURAL:
|
|
|
|
return DWRITE_RENDERING_MODE_GDI_NATURAL;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* should be unreachable */
|
|
|
|
return DWRITE_RENDERING_MODE_DEFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_GRID_FIT_MODE get_expected_gridfit_mode(FLOAT emsize, WORD gasp, DWRITE_MEASURING_MODE mode,
|
|
|
|
DWRITE_OUTLINE_THRESHOLD threshold)
|
|
|
|
{
|
|
|
|
static const FLOAT aa_threshold = 100.0f;
|
|
|
|
static const FLOAT a_threshold = 350.0f;
|
|
|
|
FLOAT v;
|
|
|
|
|
|
|
|
v = threshold == DWRITE_OUTLINE_THRESHOLD_ANTIALIASED ? aa_threshold : a_threshold;
|
|
|
|
if (emsize >= v)
|
|
|
|
return DWRITE_GRID_FIT_MODE_DISABLED;
|
|
|
|
|
|
|
|
if (mode == DWRITE_MEASURING_MODE_GDI_CLASSIC || mode == DWRITE_MEASURING_MODE_GDI_NATURAL)
|
|
|
|
return DWRITE_GRID_FIT_MODE_ENABLED;
|
|
|
|
|
|
|
|
return (gasp & (GASP_GRIDFIT|GASP_SYMMETRIC_GRIDFIT)) ? DWRITE_GRID_FIT_MODE_ENABLED : DWRITE_GRID_FIT_MODE_DISABLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct recommendedmode_test
|
|
|
|
{
|
|
|
|
DWRITE_MEASURING_MODE measuring;
|
|
|
|
DWRITE_OUTLINE_THRESHOLD threshold;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct recommendedmode_test recmode_tests[] = {
|
|
|
|
{ DWRITE_MEASURING_MODE_NATURAL, DWRITE_OUTLINE_THRESHOLD_ANTIALIASED },
|
|
|
|
{ DWRITE_MEASURING_MODE_GDI_CLASSIC, DWRITE_OUTLINE_THRESHOLD_ANTIALIASED },
|
|
|
|
{ DWRITE_MEASURING_MODE_GDI_NATURAL, DWRITE_OUTLINE_THRESHOLD_ANTIALIASED },
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct recommendedmode_test recmode_tests1[] = {
|
|
|
|
{ DWRITE_MEASURING_MODE_NATURAL, DWRITE_OUTLINE_THRESHOLD_ANTIALIASED },
|
|
|
|
{ DWRITE_MEASURING_MODE_GDI_CLASSIC, DWRITE_OUTLINE_THRESHOLD_ANTIALIASED },
|
|
|
|
{ DWRITE_MEASURING_MODE_GDI_NATURAL, DWRITE_OUTLINE_THRESHOLD_ANTIALIASED },
|
|
|
|
{ DWRITE_MEASURING_MODE_NATURAL, DWRITE_OUTLINE_THRESHOLD_ALIASED },
|
|
|
|
{ DWRITE_MEASURING_MODE_GDI_CLASSIC, DWRITE_OUTLINE_THRESHOLD_ALIASED },
|
|
|
|
{ DWRITE_MEASURING_MODE_GDI_NATURAL, DWRITE_OUTLINE_THRESHOLD_ALIASED },
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_GetRecommendedRenderingMode(void)
|
|
|
|
{
|
|
|
|
IDWriteRenderingParams *params;
|
2016-06-06 19:31:30 +02:00
|
|
|
IDWriteFontFace3 *fontface3;
|
2015-07-27 10:10:04 +02:00
|
|
|
IDWriteFontFace2 *fontface2;
|
|
|
|
IDWriteFontFace1 *fontface1;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
DWRITE_RENDERING_MODE mode;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
FLOAT emsize;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2015-07-27 10:10:04 +02:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
fontface = create_fontface(factory);
|
|
|
|
|
|
|
|
fontface1 = NULL;
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
|
|
|
|
if (hr != S_OK)
|
|
|
|
win_skip("IDWriteFontFace1::GetRecommendedRenderingMode() is not supported.\n");
|
|
|
|
|
|
|
|
fontface2 = NULL;
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace2, (void**)&fontface2);
|
|
|
|
if (hr != S_OK)
|
|
|
|
win_skip("IDWriteFontFace2::GetRecommendedRenderingMode() is not supported.\n");
|
|
|
|
|
2016-06-06 19:31:30 +02:00
|
|
|
fontface3 = NULL;
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace3, (void**)&fontface3);
|
|
|
|
if (hr != S_OK)
|
|
|
|
win_skip("IDWriteFontFace3::GetRecommendedRenderingMode() is not supported.\n");
|
|
|
|
|
2016-08-09 14:59:46 +02:00
|
|
|
if (0) /* crashes on native */
|
|
|
|
hr = IDWriteFontFace_GetRecommendedRenderingMode(fontface, 3.0, 1.0,
|
|
|
|
DWRITE_MEASURING_MODE_GDI_CLASSIC, NULL, NULL);
|
2015-07-27 10:10:04 +02:00
|
|
|
|
|
|
|
mode = 10;
|
|
|
|
hr = IDWriteFontFace_GetRecommendedRenderingMode(fontface, 3.0, 1.0,
|
|
|
|
DWRITE_MEASURING_MODE_GDI_CLASSIC, NULL, &mode);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(mode == DWRITE_RENDERING_MODE_DEFAULT, "got %d\n", mode);
|
2015-07-27 10:10:32 +02:00
|
|
|
|
2015-07-27 10:10:04 +02:00
|
|
|
hr = IDWriteFactory_CreateRenderingParams(factory, ¶ms);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
/* detect old dwrite version, that is using higher threshold value */
|
|
|
|
g_is_vista = fontface1 == NULL;
|
|
|
|
|
|
|
|
for (emsize = 1.0; emsize < 500.0; emsize += 1.0) {
|
|
|
|
DWRITE_RENDERING_MODE expected;
|
2015-10-27 20:42:10 +01:00
|
|
|
FLOAT ppdip;
|
2015-10-26 18:38:56 +01:00
|
|
|
WORD gasp;
|
2015-07-27 10:10:32 +02:00
|
|
|
int i;
|
2015-07-27 10:10:04 +02:00
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(recmode_tests); i++) {
|
2015-10-26 18:38:56 +01:00
|
|
|
ppdip = 1.0f;
|
|
|
|
mode = 10;
|
|
|
|
gasp = get_gasp_flags(fontface, emsize, ppdip);
|
|
|
|
expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests[i].measuring, recmode_tests[i].threshold);
|
|
|
|
hr = IDWriteFontFace_GetRecommendedRenderingMode(fontface, emsize, ppdip, recmode_tests[i].measuring, params, &mode);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(mode == expected, "%.2f/%d: got %d, ppdip %f, flags 0x%04x, expected %d\n", emsize, i, mode, ppdip, gasp, expected);
|
|
|
|
|
|
|
|
/* some ppdip variants */
|
|
|
|
ppdip = 0.5f;
|
2015-07-27 10:10:04 +02:00
|
|
|
mode = 10;
|
2015-10-26 18:38:56 +01:00
|
|
|
gasp = get_gasp_flags(fontface, emsize, ppdip);
|
|
|
|
expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests[i].measuring, recmode_tests[i].threshold);
|
|
|
|
hr = IDWriteFontFace_GetRecommendedRenderingMode(fontface, emsize, ppdip, recmode_tests[i].measuring, params, &mode);
|
2015-07-27 10:10:04 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2015-10-26 18:38:56 +01:00
|
|
|
ok(mode == expected, "%.2f/%d: got %d, ppdip %f, flags 0x%04x, expected %d\n", emsize, i, mode, ppdip, gasp, expected);
|
|
|
|
|
|
|
|
/* Only test larger sizes to workaround Win7 differences, where unscaled natural emsize threshold is used;
|
|
|
|
Win8 and Win10 handle this as expected. */
|
|
|
|
if (emsize > 20.0f) {
|
|
|
|
ppdip = 1.5f;
|
|
|
|
mode = 10;
|
|
|
|
gasp = get_gasp_flags(fontface, emsize, ppdip);
|
|
|
|
expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests[i].measuring, recmode_tests[i].threshold);
|
|
|
|
hr = IDWriteFontFace_GetRecommendedRenderingMode(fontface, emsize, ppdip, recmode_tests[i].measuring, params, &mode);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(mode == expected, "%.2f/%d: got %d, ppdip %f, flags 0x%04x, expected %d\n", emsize, i, mode, ppdip, gasp, expected);
|
|
|
|
|
|
|
|
ppdip = 2.0f;
|
|
|
|
mode = 10;
|
|
|
|
gasp = get_gasp_flags(fontface, emsize, ppdip);
|
|
|
|
expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests[i].measuring, recmode_tests[i].threshold);
|
|
|
|
hr = IDWriteFontFace_GetRecommendedRenderingMode(fontface, emsize, ppdip, recmode_tests[i].measuring, params, &mode);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(mode == expected, "%.2f/%d: got %d, ppdip %f, flags 0x%04x, expected %d\n", emsize, i, mode, ppdip, gasp, expected);
|
|
|
|
}
|
2015-07-27 10:10:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* IDWriteFontFace1 offers another variant of this method */
|
|
|
|
if (fontface1) {
|
2018-05-22 10:50:42 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(recmode_tests1); i++) {
|
2015-10-27 20:42:10 +01:00
|
|
|
FLOAT dpi;
|
|
|
|
|
|
|
|
ppdip = 1.0f;
|
|
|
|
dpi = 96.0f * ppdip;
|
2015-07-27 10:10:04 +02:00
|
|
|
mode = 10;
|
2015-10-27 20:42:10 +01:00
|
|
|
gasp = get_gasp_flags(fontface, emsize, ppdip);
|
|
|
|
expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
|
|
|
|
hr = IDWriteFontFace1_GetRecommendedRenderingMode(fontface1, emsize, dpi, dpi,
|
2015-07-27 10:10:04 +02:00
|
|
|
NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, &mode);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2015-10-27 20:42:10 +01:00
|
|
|
ok(mode == expected, "%.2f/%d: got %d, dpi %f, flags 0x%04x, expected %d\n", emsize, i, mode, dpi, gasp, expected);
|
|
|
|
|
|
|
|
/* Only test larger sizes to workaround Win7 differences, where unscaled natural emsize threshold is used;
|
|
|
|
Win8 and Win10 handle this as expected. */
|
|
|
|
if (emsize > 20.0f) {
|
|
|
|
ppdip = 2.0f;
|
|
|
|
dpi = 96.0f * ppdip;
|
|
|
|
mode = 10;
|
|
|
|
gasp = get_gasp_flags(fontface, emsize, ppdip);
|
|
|
|
expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
|
|
|
|
hr = IDWriteFontFace1_GetRecommendedRenderingMode(fontface1, emsize, dpi, dpi,
|
|
|
|
NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, &mode);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(mode == expected, "%.2f/%d: got %d, dpi %f, flags 0x%04x, expected %d\n", emsize, i, mode, dpi, gasp, expected);
|
|
|
|
|
|
|
|
ppdip = 0.5f;
|
|
|
|
dpi = 96.0f * ppdip;
|
|
|
|
mode = 10;
|
|
|
|
gasp = get_gasp_flags(fontface, emsize, ppdip);
|
|
|
|
expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
|
|
|
|
hr = IDWriteFontFace1_GetRecommendedRenderingMode(fontface1, emsize, dpi, dpi,
|
|
|
|
NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, &mode);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(mode == expected, "%.2f/%d: got %d, dpi %f, flags 0x%04x, expected %d\n", emsize, i, mode, dpi, gasp, expected);
|
|
|
|
|
|
|
|
/* try different dpis for X and Y direction */
|
|
|
|
ppdip = 1.0f;
|
|
|
|
dpi = 96.0f * ppdip;
|
|
|
|
mode = 10;
|
|
|
|
gasp = get_gasp_flags(fontface, emsize, ppdip);
|
|
|
|
expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
|
|
|
|
hr = IDWriteFontFace1_GetRecommendedRenderingMode(fontface1, emsize, dpi * 0.5f, dpi,
|
|
|
|
NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, &mode);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(mode == expected, "%.2f/%d: got %d, dpi %f, flags 0x%04x, expected %d\n", emsize, i, mode, dpi, gasp, expected);
|
|
|
|
|
|
|
|
ppdip = 1.0f;
|
|
|
|
dpi = 96.0f * ppdip;
|
|
|
|
mode = 10;
|
|
|
|
gasp = get_gasp_flags(fontface, emsize, ppdip);
|
|
|
|
expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
|
|
|
|
hr = IDWriteFontFace1_GetRecommendedRenderingMode(fontface1, emsize, dpi, dpi * 0.5f,
|
|
|
|
NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, &mode);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(mode == expected, "%.2f/%d: got %d, dpi %f, flags 0x%04x, expected %d\n", emsize, i, mode, dpi, gasp, expected);
|
|
|
|
|
|
|
|
ppdip = 2.0f;
|
|
|
|
dpi = 96.0f * ppdip;
|
|
|
|
mode = 10;
|
|
|
|
gasp = get_gasp_flags(fontface, emsize, ppdip);
|
|
|
|
expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
|
|
|
|
hr = IDWriteFontFace1_GetRecommendedRenderingMode(fontface1, emsize, dpi * 0.5f, dpi,
|
|
|
|
NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, &mode);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(mode == expected, "%.2f/%d: got %d, dpi %f, flags 0x%04x, expected %d\n", emsize, i, mode, dpi, gasp, expected);
|
|
|
|
|
|
|
|
ppdip = 2.0f;
|
|
|
|
dpi = 96.0f * ppdip;
|
|
|
|
mode = 10;
|
|
|
|
gasp = get_gasp_flags(fontface, emsize, ppdip);
|
|
|
|
expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
|
|
|
|
hr = IDWriteFontFace1_GetRecommendedRenderingMode(fontface1, emsize, dpi, dpi * 0.5f,
|
|
|
|
NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, &mode);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(mode == expected, "%.2f/%d: got %d, dpi %f, flags 0x%04x, expected %d\n", emsize, i, mode, dpi, gasp, expected);
|
|
|
|
}
|
2015-07-27 10:10:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IDWriteFontFace2 - another one */
|
|
|
|
if (fontface2) {
|
|
|
|
DWRITE_GRID_FIT_MODE gridfit, expected_gridfit;
|
|
|
|
|
2015-10-27 20:42:10 +01:00
|
|
|
gasp = get_gasp_flags(fontface, emsize, 1.0f);
|
2018-05-22 10:50:42 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(recmode_tests1); i++) {
|
2015-07-27 10:10:04 +02:00
|
|
|
mode = 10;
|
2016-06-06 19:31:30 +02:00
|
|
|
expected = get_expected_rendering_mode(emsize, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
|
|
|
|
expected_gridfit = get_expected_gridfit_mode(emsize, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
|
|
|
|
hr = IDWriteFontFace2_GetRecommendedRenderingMode(fontface2, emsize, 96.0f, 96.0f,
|
|
|
|
NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, params, &mode, &gridfit);
|
2015-07-27 10:10:04 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(mode == expected, "%.2f: got %d, flags 0x%04x, expected %d\n", emsize, mode, gasp, expected);
|
|
|
|
ok(gridfit == expected_gridfit, "%.2f/%d: gridfit: got %d, flags 0x%04x, expected %d\n", emsize, i, gridfit,
|
|
|
|
gasp, expected_gridfit);
|
|
|
|
}
|
|
|
|
}
|
2016-06-06 19:31:30 +02:00
|
|
|
|
|
|
|
/* IDWriteFontFace3 - and another one */
|
|
|
|
if (fontface3) {
|
|
|
|
DWRITE_GRID_FIT_MODE gridfit, expected_gridfit;
|
|
|
|
DWRITE_RENDERING_MODE1 mode1, expected1;
|
|
|
|
|
|
|
|
gasp = get_gasp_flags(fontface, emsize, 1.0f);
|
2018-05-22 10:50:42 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(recmode_tests1); i++) {
|
2016-06-06 19:31:30 +02:00
|
|
|
mode1 = 10;
|
|
|
|
expected1 = get_expected_rendering_mode(emsize, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
|
|
|
|
expected_gridfit = get_expected_gridfit_mode(emsize, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
|
|
|
|
hr = IDWriteFontFace3_GetRecommendedRenderingMode(fontface3, emsize, 96.0f, 96.0f,
|
|
|
|
NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, params, &mode1, &gridfit);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(mode1 == expected1, "%.2f: got %d, flags 0x%04x, expected %d\n", emsize, mode1, gasp, expected1);
|
|
|
|
ok(gridfit == expected_gridfit, "%.2f/%d: gridfit: got %d, flags 0x%04x, expected %d\n", emsize, i, gridfit,
|
|
|
|
gasp, expected_gridfit);
|
|
|
|
}
|
|
|
|
}
|
2015-07-27 10:10:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteRenderingParams_Release(params);
|
|
|
|
|
|
|
|
/* test how parameters override returned modes */
|
|
|
|
hr = IDWriteFactory_CreateCustomRenderingParams(factory, 1.0, 0.0, 0.0, DWRITE_PIXEL_GEOMETRY_FLAT,
|
|
|
|
DWRITE_RENDERING_MODE_GDI_CLASSIC, ¶ms);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
mode = 10;
|
|
|
|
hr = IDWriteFontFace_GetRecommendedRenderingMode(fontface, 500.0, 1.0, DWRITE_MEASURING_MODE_NATURAL, params, &mode);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(mode == DWRITE_RENDERING_MODE_GDI_CLASSIC, "got %d\n", mode);
|
2015-07-27 10:10:32 +02:00
|
|
|
|
2015-07-27 10:10:04 +02:00
|
|
|
IDWriteRenderingParams_Release(params);
|
|
|
|
|
|
|
|
if (fontface2) {
|
|
|
|
IDWriteRenderingParams2 *params2;
|
|
|
|
IDWriteFactory2 *factory2;
|
|
|
|
DWRITE_GRID_FIT_MODE gridfit;
|
|
|
|
|
|
|
|
hr = IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory2, (void**)&factory2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory2_CreateCustomRenderingParams(factory2, 1.0, 0.0, 0.0, 0.5, DWRITE_PIXEL_GEOMETRY_FLAT,
|
|
|
|
DWRITE_RENDERING_MODE_OUTLINE, DWRITE_GRID_FIT_MODE_ENABLED, ¶ms2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2015-07-27 10:10:32 +02:00
|
|
|
mode = 10;
|
|
|
|
gridfit = 10;
|
|
|
|
hr = IDWriteFontFace2_GetRecommendedRenderingMode(fontface2, 5.0, 96.0, 96.0,
|
|
|
|
NULL, FALSE, DWRITE_OUTLINE_THRESHOLD_ANTIALIASED, DWRITE_MEASURING_MODE_GDI_CLASSIC,
|
|
|
|
NULL, &mode, &gridfit);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(mode == DWRITE_RENDERING_MODE_GDI_CLASSIC, "got %d\n", mode);
|
|
|
|
ok(gridfit == DWRITE_GRID_FIT_MODE_ENABLED, "got %d\n", gridfit);
|
|
|
|
|
2015-07-27 10:10:04 +02:00
|
|
|
mode = 10;
|
|
|
|
gridfit = 10;
|
|
|
|
hr = IDWriteFontFace2_GetRecommendedRenderingMode(fontface2, 5.0, 96.0, 96.0,
|
|
|
|
NULL, FALSE, DWRITE_OUTLINE_THRESHOLD_ANTIALIASED, DWRITE_MEASURING_MODE_GDI_CLASSIC,
|
|
|
|
(IDWriteRenderingParams*)params2, &mode, &gridfit);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(mode == DWRITE_RENDERING_MODE_OUTLINE, "got %d\n", mode);
|
|
|
|
ok(gridfit == DWRITE_GRID_FIT_MODE_ENABLED, "got %d\n", gridfit);
|
2015-07-27 10:10:32 +02:00
|
|
|
|
2015-07-27 10:10:04 +02:00
|
|
|
IDWriteRenderingParams2_Release(params2);
|
|
|
|
IDWriteFactory2_Release(factory2);
|
|
|
|
}
|
|
|
|
|
2016-06-06 19:31:30 +02:00
|
|
|
if (fontface3) {
|
|
|
|
IDWriteRenderingParams3 *params3;
|
|
|
|
IDWriteRenderingParams2 *params2;
|
|
|
|
IDWriteRenderingParams *params;
|
|
|
|
IDWriteFactory3 *factory3;
|
|
|
|
DWRITE_GRID_FIT_MODE gridfit;
|
|
|
|
DWRITE_RENDERING_MODE1 mode1;
|
|
|
|
|
|
|
|
hr = IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory3, (void**)&factory3);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory3_CreateCustomRenderingParams(factory3, 1.0f, 0.0f, 0.0f, 0.5f, DWRITE_PIXEL_GEOMETRY_FLAT,
|
|
|
|
DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED, DWRITE_GRID_FIT_MODE_ENABLED, ¶ms3);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
mode1 = IDWriteRenderingParams3_GetRenderingMode1(params3);
|
|
|
|
ok(mode1 == DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED, "got %d\n", mode1);
|
|
|
|
|
2017-05-15 06:09:56 +02:00
|
|
|
mode = IDWriteRenderingParams3_GetRenderingMode(params3);
|
|
|
|
ok(mode == DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC, "got %d\n", mode);
|
2016-06-06 19:31:30 +02:00
|
|
|
|
|
|
|
hr = IDWriteRenderingParams3_QueryInterface(params3, &IID_IDWriteRenderingParams, (void**)¶ms);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(params == (IDWriteRenderingParams*)params3, "got %p, %p\n", params3, params);
|
|
|
|
mode = IDWriteRenderingParams_GetRenderingMode(params);
|
|
|
|
ok(mode == DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC, "got %d\n", mode);
|
|
|
|
IDWriteRenderingParams_Release(params);
|
|
|
|
|
|
|
|
hr = IDWriteRenderingParams3_QueryInterface(params3, &IID_IDWriteRenderingParams2, (void**)¶ms2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(params2 == (IDWriteRenderingParams2*)params3, "got %p, %p\n", params3, params2);
|
|
|
|
mode = IDWriteRenderingParams2_GetRenderingMode(params2);
|
|
|
|
ok(mode == DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC, "got %d\n", mode);
|
|
|
|
IDWriteRenderingParams2_Release(params2);
|
|
|
|
|
|
|
|
mode = 10;
|
|
|
|
gridfit = 10;
|
|
|
|
hr = IDWriteFontFace2_GetRecommendedRenderingMode(fontface2, 5.0f, 96.0f, 96.0f,
|
|
|
|
NULL, FALSE, DWRITE_OUTLINE_THRESHOLD_ANTIALIASED, DWRITE_MEASURING_MODE_GDI_CLASSIC,
|
|
|
|
NULL, &mode, &gridfit);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(mode == DWRITE_RENDERING_MODE_GDI_CLASSIC, "got %d\n", mode);
|
|
|
|
ok(gridfit == DWRITE_GRID_FIT_MODE_ENABLED, "got %d\n", gridfit);
|
|
|
|
|
|
|
|
mode = 10;
|
|
|
|
gridfit = 10;
|
|
|
|
hr = IDWriteFontFace2_GetRecommendedRenderingMode(fontface2, 5.0f, 96.0f, 96.0f,
|
|
|
|
NULL, FALSE, DWRITE_OUTLINE_THRESHOLD_ANTIALIASED, DWRITE_MEASURING_MODE_GDI_CLASSIC,
|
|
|
|
(IDWriteRenderingParams*)params3, &mode, &gridfit);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(mode == DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC, "got %d\n", mode);
|
|
|
|
ok(gridfit == DWRITE_GRID_FIT_MODE_ENABLED, "got %d\n", gridfit);
|
|
|
|
|
|
|
|
IDWriteRenderingParams3_Release(params3);
|
|
|
|
IDWriteFactory3_Release(factory3);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fontface3)
|
|
|
|
IDWriteFontFace3_Release(fontface3);
|
2015-07-27 10:10:04 +02:00
|
|
|
if (fontface2)
|
|
|
|
IDWriteFontFace2_Release(fontface2);
|
|
|
|
if (fontface1)
|
|
|
|
IDWriteFontFace1_Release(fontface1);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-07-27 10:10:04 +02:00
|
|
|
}
|
|
|
|
|
2015-07-29 10:58:24 +02:00
|
|
|
static inline BOOL float_eq(FLOAT left, FLOAT right)
|
|
|
|
{
|
|
|
|
int x = *(int *)&left;
|
|
|
|
int y = *(int *)&right;
|
|
|
|
|
|
|
|
if (x < 0)
|
|
|
|
x = INT_MIN - x;
|
|
|
|
if (y < 0)
|
|
|
|
y = INT_MIN - y;
|
|
|
|
|
|
|
|
return abs(x - y) <= 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_GetAlphaBlendParams(void)
|
|
|
|
{
|
|
|
|
static const DWRITE_RENDERING_MODE rendermodes[] = {
|
|
|
|
DWRITE_RENDERING_MODE_ALIASED,
|
|
|
|
DWRITE_RENDERING_MODE_GDI_CLASSIC,
|
|
|
|
DWRITE_RENDERING_MODE_GDI_NATURAL,
|
|
|
|
DWRITE_RENDERING_MODE_NATURAL,
|
|
|
|
DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC,
|
|
|
|
};
|
|
|
|
|
|
|
|
IDWriteGlyphRunAnalysis *analysis;
|
|
|
|
FLOAT gamma, contrast, ctlevel;
|
|
|
|
IDWriteRenderingParams *params;
|
|
|
|
DWRITE_GLYPH_METRICS metrics;
|
|
|
|
DWRITE_GLYPH_OFFSET offset;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
DWRITE_GLYPH_RUN run;
|
|
|
|
FLOAT advance, expected_gdi_gamma;
|
|
|
|
UINT value = 0;
|
|
|
|
UINT16 glyph;
|
|
|
|
UINT32 ch, i;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2015-07-29 10:58:24 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
fontface = create_fontface(factory);
|
|
|
|
|
|
|
|
ch = 'A';
|
|
|
|
glyph = 0;
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(fontface, &ch, 1, &glyph);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(glyph > 0, "got %u\n", glyph);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_GetDesignGlyphMetrics(fontface, &glyph, 1, &metrics, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
advance = metrics.advanceWidth;
|
|
|
|
|
|
|
|
offset.advanceOffset = 0.0;
|
|
|
|
offset.ascenderOffset = 0.0;
|
|
|
|
|
|
|
|
run.fontFace = fontface;
|
|
|
|
run.fontEmSize = 24.0;
|
|
|
|
run.glyphCount = 1;
|
|
|
|
run.glyphIndices = &glyph;
|
|
|
|
run.glyphAdvances = &advance;
|
|
|
|
run.glyphOffsets = &offset;
|
|
|
|
run.isSideways = FALSE;
|
|
|
|
run.bidiLevel = 0;
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateCustomRenderingParams(factory, 0.9, 0.3, 0.1, DWRITE_PIXEL_GEOMETRY_RGB,
|
|
|
|
DWRITE_RENDERING_MODE_DEFAULT, ¶ms);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
value = 0;
|
|
|
|
ret = SystemParametersInfoW(SPI_GETFONTSMOOTHINGCONTRAST, 0, &value, 0);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
expected_gdi_gamma = (FLOAT)(value / 1000.0);
|
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(rendermodes); i++) {
|
2015-07-29 10:58:24 +02:00
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
|
|
|
|
rendermodes[i], DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
gamma = contrast = ctlevel = -1.0;
|
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaBlendParams(analysis, NULL, &gamma, &contrast, &ctlevel);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(gamma == -1.0, "got %.2f\n", gamma);
|
|
|
|
ok(contrast == -1.0, "got %.2f\n", contrast);
|
|
|
|
ok(ctlevel == -1.0, "got %.2f\n", ctlevel);
|
|
|
|
|
|
|
|
gamma = contrast = ctlevel = -1.0;
|
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaBlendParams(analysis, params, &gamma, &contrast, &ctlevel);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
if (rendermodes[i] == DWRITE_RENDERING_MODE_GDI_CLASSIC || rendermodes[i] == DWRITE_RENDERING_MODE_GDI_NATURAL) {
|
|
|
|
ok(float_eq(gamma, expected_gdi_gamma), "got %.2f, expected %.2f\n", gamma, expected_gdi_gamma);
|
|
|
|
ok(contrast == 0.0f, "got %.2f\n", contrast);
|
|
|
|
ok(ctlevel == 1.0f, "got %.2f\n", ctlevel);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ok(gamma == 0.9f, "got %.2f\n", gamma);
|
|
|
|
ok(contrast == 0.3f, "got %.2f\n", contrast);
|
|
|
|
ok(ctlevel == 0.1f, "got %.2f\n", ctlevel);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteRenderingParams_Release(params);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-07-29 10:58:24 +02:00
|
|
|
}
|
|
|
|
|
2015-07-29 11:00:26 +02:00
|
|
|
static void test_CreateAlphaTexture(void)
|
|
|
|
{
|
|
|
|
IDWriteGlyphRunAnalysis *analysis;
|
|
|
|
DWRITE_GLYPH_METRICS metrics;
|
|
|
|
DWRITE_GLYPH_OFFSET offset;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
DWRITE_GLYPH_RUN run;
|
|
|
|
UINT32 ch, size;
|
|
|
|
BYTE buff[1024];
|
|
|
|
RECT bounds, r;
|
|
|
|
FLOAT advance;
|
|
|
|
UINT16 glyph;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2015-07-29 11:00:26 +02:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
fontface = create_fontface(factory);
|
|
|
|
|
|
|
|
ch = 'A';
|
|
|
|
glyph = 0;
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(fontface, &ch, 1, &glyph);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(glyph > 0, "got %u\n", glyph);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_GetDesignGlyphMetrics(fontface, &glyph, 1, &metrics, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
advance = metrics.advanceWidth;
|
|
|
|
|
|
|
|
offset.advanceOffset = 0.0;
|
|
|
|
offset.ascenderOffset = 0.0;
|
|
|
|
|
|
|
|
run.fontFace = fontface;
|
|
|
|
run.fontEmSize = 24.0;
|
|
|
|
run.glyphCount = 1;
|
|
|
|
run.glyphIndices = &glyph;
|
|
|
|
run.glyphAdvances = &advance;
|
|
|
|
run.glyphOffsets = &offset;
|
|
|
|
run.isSideways = FALSE;
|
|
|
|
run.bidiLevel = 0;
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
|
|
|
|
DWRITE_RENDERING_MODE_NATURAL, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
SetRectEmpty(&bounds);
|
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &bounds);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!IsRectEmpty(&bounds), "got empty rect\n");
|
|
|
|
size = (bounds.right - bounds.left)*(bounds.bottom - bounds.top)*3;
|
|
|
|
ok(sizeof(buff) >= size, "required %u\n", size);
|
|
|
|
|
|
|
|
/* invalid type value */
|
|
|
|
memset(buff, 0xcf, sizeof(buff));
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1+1, &bounds, buff, sizeof(buff));
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(buff[0] == 0xcf, "got %1x\n", buff[0]);
|
|
|
|
|
|
|
|
memset(buff, 0xcf, sizeof(buff));
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &bounds, buff, 2);
|
|
|
|
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr);
|
|
|
|
ok(buff[0] == 0xcf, "got %1x\n", buff[0]);
|
|
|
|
|
|
|
|
/* vista version allows texture type mismatch, mark it broken for now */
|
|
|
|
memset(buff, 0xcf, sizeof(buff));
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &bounds, buff, sizeof(buff));
|
|
|
|
ok(hr == DWRITE_E_UNSUPPORTEDOPERATION || broken(hr == S_OK), "got 0x%08x\n", hr);
|
|
|
|
ok(buff[0] == 0xcf || broken(buff[0] == 0), "got %1x\n", buff[0]);
|
|
|
|
|
|
|
|
memset(buff, 0xcf, sizeof(buff));
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &bounds, buff, size-1);
|
|
|
|
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr);
|
|
|
|
ok(buff[0] == 0xcf, "got %1x\n", buff[0]);
|
|
|
|
|
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
|
|
|
|
DWRITE_RENDERING_MODE_ALIASED, DWRITE_MEASURING_MODE_GDI_CLASSIC,
|
|
|
|
0.0, 0.0, &analysis);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
SetRectEmpty(&bounds);
|
|
|
|
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &bounds);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!IsRectEmpty(&bounds), "got empty rect\n");
|
|
|
|
size = (bounds.right - bounds.left)*(bounds.bottom - bounds.top);
|
|
|
|
ok(sizeof(buff) >= size, "required %u\n", size);
|
|
|
|
|
|
|
|
memset(buff, 0xcf, sizeof(buff));
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, NULL, buff, sizeof(buff));
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(buff[0] == 0xcf, "got %1x\n", buff[0]);
|
|
|
|
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, NULL, NULL, sizeof(buff));
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
memset(buff, 0xcf, sizeof(buff));
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, NULL, buff, 0);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(buff[0] == 0xcf, "got %1x\n", buff[0]);
|
|
|
|
|
|
|
|
/* buffer size is not enough */
|
|
|
|
memset(buff, 0xcf, sizeof(buff));
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &bounds, buff, size-1);
|
|
|
|
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr);
|
|
|
|
ok(buff[0] == 0xcf, "got %1x\n", buff[0]);
|
|
|
|
|
|
|
|
/* request texture for rectangle that doesn't intersect */
|
|
|
|
memset(buff, 0xcf, sizeof(buff));
|
|
|
|
r = bounds;
|
|
|
|
OffsetRect(&r, (bounds.right - bounds.left)*2, 0);
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &r, buff, sizeof(buff));
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(buff[0] == 0, "got %1x\n", buff[0]);
|
|
|
|
|
|
|
|
memset(buff, 0xcf, sizeof(buff));
|
|
|
|
r = bounds;
|
|
|
|
OffsetRect(&r, (bounds.right - bounds.left)*2, 0);
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &r, buff, sizeof(buff));
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(buff[0] == 0, "got %1x\n", buff[0]);
|
|
|
|
|
|
|
|
/* request texture for rectangle that doesn't intersect, small buffer */
|
|
|
|
memset(buff, 0xcf, sizeof(buff));
|
|
|
|
r = bounds;
|
|
|
|
OffsetRect(&r, (bounds.right - bounds.left)*2, 0);
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &r, buff, size-1);
|
|
|
|
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr);
|
|
|
|
ok(buff[0] == 0xcf, "got %1x\n", buff[0]);
|
|
|
|
|
|
|
|
/* vista version allows texture type mismatch, mark it broken for now */
|
|
|
|
memset(buff, 0xcf, sizeof(buff));
|
|
|
|
hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &bounds, buff, sizeof(buff));
|
|
|
|
ok(hr == DWRITE_E_UNSUPPORTEDOPERATION || broken(hr == S_OK), "got 0x%08x\n", hr);
|
|
|
|
ok(buff[0] == 0xcf || broken(buff[0] == 0), "got %1x\n", buff[0]);
|
|
|
|
|
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-07-29 11:00:26 +02:00
|
|
|
}
|
|
|
|
|
2015-08-06 17:02:43 +02:00
|
|
|
static void test_IsSymbolFont(void)
|
|
|
|
{
|
|
|
|
static const WCHAR symbolW[] = {'S','y','m','b','o','l',0};
|
|
|
|
IDWriteFontCollection *collection;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFont *font;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2015-08-06 17:02:43 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
|
|
|
/* Tahoma */
|
|
|
|
fontface = create_fontface(factory);
|
|
|
|
ret = IDWriteFontFace_IsSymbolFont(fontface);
|
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFromFontFace(collection, fontface, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
ret = IDWriteFont_IsSymbolFont(font);
|
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
IDWriteFontCollection_Release(collection);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
|
|
|
|
/* Symbol */
|
|
|
|
font = get_font(factory, symbolW, DWRITE_FONT_STYLE_NORMAL);
|
|
|
|
ret = IDWriteFont_IsSymbolFont(font);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ret = IDWriteFontFace_IsSymbolFont(fontface);
|
|
|
|
ok(ret, "got %d\n", ret);
|
2017-04-11 13:21:32 +02:00
|
|
|
IDWriteFontFace_Release(fontface);
|
2015-08-06 17:02:43 +02:00
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-08-06 17:02:43 +02:00
|
|
|
}
|
|
|
|
|
2015-08-06 18:43:58 +02:00
|
|
|
struct CPAL_Header_0
|
|
|
|
{
|
|
|
|
USHORT version;
|
|
|
|
USHORT numPaletteEntries;
|
|
|
|
USHORT numPalette;
|
|
|
|
USHORT numColorRecords;
|
|
|
|
ULONG offsetFirstColorRecord;
|
|
|
|
USHORT colorRecordIndices[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_GetPaletteEntries(void)
|
|
|
|
{
|
|
|
|
IDWriteFontFace2 *fontface2;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFont *font;
|
|
|
|
DWRITE_COLOR_F color;
|
|
|
|
UINT32 palettecount, entrycount, size, colorrecords;
|
|
|
|
void *ctxt;
|
|
|
|
const struct CPAL_Header_0 *cpal_header;
|
|
|
|
HRESULT hr;
|
|
|
|
BOOL exists;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2015-08-06 18:43:58 +02:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
|
|
|
/* Tahoma, no color support */
|
|
|
|
fontface = create_fontface(factory);
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace2, (void**)&fontface2);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
if (hr != S_OK) {
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-08-06 18:43:58 +02:00
|
|
|
win_skip("GetPaletteEntries() is not supported.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDWriteFontFace2_GetPaletteEntries(fontface2, 0, 0, 1, &color);
|
|
|
|
ok(hr == DWRITE_E_NOCOLOR, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFace2_Release(fontface2);
|
|
|
|
|
|
|
|
/* Segoe UI Emoji, with color support */
|
|
|
|
font = get_font(factory, emojiW, DWRITE_FONT_STYLE_NORMAL);
|
|
|
|
if (!font) {
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-08-06 18:43:58 +02:00
|
|
|
skip("Segoe UI Emoji font not found.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace2, (void**)&fontface2);
|
2015-10-27 20:42:11 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2015-08-06 18:43:58 +02:00
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
|
|
|
|
palettecount = IDWriteFontFace2_GetColorPaletteCount(fontface2);
|
|
|
|
ok(palettecount >= 1, "got %u\n", palettecount);
|
|
|
|
|
|
|
|
entrycount = IDWriteFontFace2_GetPaletteEntryCount(fontface2);
|
|
|
|
ok(entrycount >= 1, "got %u\n", entrycount);
|
|
|
|
|
|
|
|
exists = FALSE;
|
|
|
|
hr = IDWriteFontFace2_TryGetFontTable(fontface2, MS_CPAL_TAG, (const void**)&cpal_header, &size, &ctxt, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(exists, "got %d\n", exists);
|
|
|
|
colorrecords = GET_BE_WORD(cpal_header->numColorRecords);
|
|
|
|
ok(colorrecords >= 1, "got %u\n", colorrecords);
|
|
|
|
|
|
|
|
/* invalid palette index */
|
|
|
|
color.r = color.g = color.b = color.a = 123.0;
|
|
|
|
hr = IDWriteFontFace2_GetPaletteEntries(fontface2, palettecount, 0, 1, &color);
|
|
|
|
ok(hr == DWRITE_E_NOCOLOR, "got 0x%08x\n", hr);
|
|
|
|
ok(color.r == 123.0 && color.g == 123.0 && color.b == 123.0 && color.a == 123.0,
|
|
|
|
"got wrong color %.2fx%.2fx%.2fx%.2f\n", color.r, color.g, color.b, color.a);
|
|
|
|
|
|
|
|
/* invalid entry index */
|
|
|
|
color.r = color.g = color.b = color.a = 123.0;
|
|
|
|
hr = IDWriteFontFace2_GetPaletteEntries(fontface2, 0, entrycount, 1, &color);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
ok(color.r == 123.0 && color.g == 123.0 && color.b == 123.0 && color.a == 123.0,
|
|
|
|
"got wrong color %.2fx%.2fx%.2fx%.2f\n", color.r, color.g, color.b, color.a);
|
|
|
|
|
|
|
|
color.r = color.g = color.b = color.a = 123.0;
|
|
|
|
hr = IDWriteFontFace2_GetPaletteEntries(fontface2, 0, entrycount - 1, 1, &color);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(color.r != 123.0 && color.g != 123.0 && color.b != 123.0 && color.a != 123.0,
|
|
|
|
"got wrong color %.2fx%.2fx%.2fx%.2f\n", color.r, color.g, color.b, color.a);
|
|
|
|
|
|
|
|
/* zero return length */
|
|
|
|
color.r = color.g = color.b = color.a = 123.0;
|
|
|
|
hr = IDWriteFontFace2_GetPaletteEntries(fontface2, 0, 0, 0, &color);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(color.r == 123.0 && color.g == 123.0 && color.b == 123.0 && color.a == 123.0,
|
|
|
|
"got wrong color %.2fx%.2fx%.2fx%.2f\n", color.r, color.g, color.b, color.a);
|
|
|
|
|
|
|
|
IDWriteFontFace2_Release(fontface2);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-08-06 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
2015-09-09 16:48:12 +02:00
|
|
|
static void test_TranslateColorGlyphRun(void)
|
|
|
|
{
|
|
|
|
IDWriteColorGlyphRunEnumerator *layers;
|
|
|
|
const DWRITE_COLOR_GLYPH_RUN *colorrun;
|
2016-02-08 10:31:17 +01:00
|
|
|
IDWriteFontFace2 *fontface2;
|
2015-09-09 16:48:12 +02:00
|
|
|
IDWriteFontFace *fontface;
|
2017-10-09 09:47:02 +02:00
|
|
|
IDWriteFactory2 *factory;
|
2015-09-09 16:48:12 +02:00
|
|
|
DWRITE_GLYPH_RUN run;
|
|
|
|
UINT32 codepoints[2];
|
|
|
|
IDWriteFont *font;
|
|
|
|
UINT16 glyphs[2];
|
|
|
|
BOOL hasrun;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2015-09-09 16:48:12 +02:00
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
factory = create_factory_iid(&IID_IDWriteFactory2);
|
|
|
|
if (!factory) {
|
2015-09-09 16:48:12 +02:00
|
|
|
win_skip("TranslateColorGlyphRun() is not supported.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Tahoma, no color support */
|
2017-10-09 09:47:02 +02:00
|
|
|
fontface = create_fontface((IDWriteFactory *)factory);
|
2015-09-09 16:48:12 +02:00
|
|
|
|
|
|
|
codepoints[0] = 'A';
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(fontface, codepoints, 1, glyphs);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
run.fontFace = fontface;
|
|
|
|
run.fontEmSize = 20.0f;
|
|
|
|
run.glyphCount = 1;
|
|
|
|
run.glyphIndices = glyphs;
|
|
|
|
run.glyphAdvances = NULL;
|
|
|
|
run.glyphOffsets = NULL;
|
|
|
|
run.isSideways = FALSE;
|
|
|
|
run.bidiLevel = 0;
|
|
|
|
|
|
|
|
layers = (void*)0xdeadbeef;
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory2_TranslateColorGlyphRun(factory, 0.0f, 0.0f, &run, NULL,
|
2015-09-09 16:48:12 +02:00
|
|
|
DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers);
|
|
|
|
ok(hr == DWRITE_E_NOCOLOR, "got 0x%08x\n", hr);
|
|
|
|
ok(layers == NULL, "got %p\n", layers);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
|
|
|
|
/* Segoe UI Emoji, with color support */
|
2017-10-09 09:47:02 +02:00
|
|
|
font = get_font((IDWriteFactory *)factory, emojiW, DWRITE_FONT_STYLE_NORMAL);
|
2015-09-09 16:48:12 +02:00
|
|
|
if (!font) {
|
2017-10-09 09:47:02 +02:00
|
|
|
IDWriteFactory2_Release(factory);
|
2015-09-09 16:48:12 +02:00
|
|
|
skip("Segoe UI Emoji font not found.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
codepoints[0] = 0x26c4;
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(fontface, codepoints, 1, glyphs);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
run.fontFace = fontface;
|
|
|
|
|
|
|
|
layers = NULL;
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory2_TranslateColorGlyphRun(factory, 0.0f, 0.0f, &run, NULL,
|
2015-09-09 16:48:12 +02:00
|
|
|
DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(layers != NULL, "got %p\n", layers);
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
for (;;) {
|
2015-09-09 16:48:12 +02:00
|
|
|
hasrun = FALSE;
|
|
|
|
hr = IDWriteColorGlyphRunEnumerator_MoveNext(layers, &hasrun);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
if (!hasrun)
|
|
|
|
break;
|
2016-11-05 22:12:38 +01:00
|
|
|
|
|
|
|
hr = IDWriteColorGlyphRunEnumerator_GetCurrentRun(layers, &colorrun);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(colorrun->glyphRun.fontFace != NULL, "got fontface %p\n", colorrun->glyphRun.fontFace);
|
|
|
|
ok(colorrun->glyphRun.fontEmSize == 20.0f, "got wrong font size %f\n", colorrun->glyphRun.fontEmSize);
|
|
|
|
ok(colorrun->glyphRun.glyphCount > 0, "got wrong glyph count %u\n", colorrun->glyphRun.glyphCount);
|
|
|
|
ok(colorrun->glyphRun.glyphIndices != NULL, "got null glyph indices %p\n", colorrun->glyphRun.glyphIndices);
|
|
|
|
ok(colorrun->glyphRun.glyphAdvances != NULL, "got null glyph advances %p\n", colorrun->glyphRun.glyphAdvances);
|
2015-09-09 16:48:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* iterated all way through */
|
|
|
|
hr = IDWriteColorGlyphRunEnumerator_GetCurrentRun(layers, &colorrun);
|
|
|
|
ok(hr == E_NOT_VALID_STATE, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IDWriteColorGlyphRunEnumerator_Release(layers);
|
2016-02-08 10:31:26 +01:00
|
|
|
|
2016-02-08 10:31:17 +01:00
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace2, (void**)&fontface2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
/* invalid palette index */
|
|
|
|
layers = (void*)0xdeadbeef;
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory2_TranslateColorGlyphRun(factory, 0.0f, 0.0f, &run, NULL,
|
2016-02-08 10:31:17 +01:00
|
|
|
DWRITE_MEASURING_MODE_NATURAL, NULL, IDWriteFontFace2_GetColorPaletteCount(fontface2),
|
|
|
|
&layers);
|
|
|
|
ok(hr == DWRITE_E_NOCOLOR, "got 0x%08x\n", hr);
|
|
|
|
ok(layers == NULL, "got %p\n", layers);
|
|
|
|
|
|
|
|
layers = NULL;
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory2_TranslateColorGlyphRun(factory, 0.0f, 0.0f, &run, NULL,
|
2016-02-08 10:31:17 +01:00
|
|
|
DWRITE_MEASURING_MODE_NATURAL, NULL, IDWriteFontFace2_GetColorPaletteCount(fontface2) - 1,
|
|
|
|
&layers);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteColorGlyphRunEnumerator_Release(layers);
|
2015-09-09 16:48:12 +02:00
|
|
|
|
|
|
|
/* color font, glyph without color info */
|
|
|
|
codepoints[0] = 'A';
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(fontface, codepoints, 1, glyphs);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
layers = (void*)0xdeadbeef;
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory2_TranslateColorGlyphRun(factory, 0.0f, 0.0f, &run, NULL,
|
2015-09-09 16:48:12 +02:00
|
|
|
DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers);
|
|
|
|
ok(hr == DWRITE_E_NOCOLOR, "got 0x%08x\n", hr);
|
|
|
|
ok(layers == NULL, "got %p\n", layers);
|
2016-02-08 10:31:35 +01:00
|
|
|
|
2015-09-09 16:48:12 +02:00
|
|
|
/* one glyph with, one without */
|
|
|
|
codepoints[0] = 'A';
|
|
|
|
codepoints[1] = 0x26c4;
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_GetGlyphIndices(fontface, codepoints, 2, glyphs);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
run.glyphCount = 2;
|
|
|
|
|
|
|
|
layers = NULL;
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory2_TranslateColorGlyphRun(factory, 0.0f, 0.0f, &run, NULL,
|
2015-09-09 16:48:12 +02:00
|
|
|
DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(layers != NULL, "got %p\n", layers);
|
|
|
|
IDWriteColorGlyphRunEnumerator_Release(layers);
|
|
|
|
|
2016-02-08 10:31:17 +01:00
|
|
|
IDWriteFontFace2_Release(fontface2);
|
2015-09-09 16:48:12 +02:00
|
|
|
IDWriteFontFace_Release(fontface);
|
2017-10-09 09:47:02 +02:00
|
|
|
ref = IDWriteFactory2_Release(factory);
|
2017-04-11 13:21:32 +02:00
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2015-09-09 16:48:12 +02:00
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static void test_HasCharacter(void)
|
|
|
|
{
|
|
|
|
IDWriteFactory3 *factory3;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
IDWriteFont3 *font3;
|
|
|
|
IDWriteFont *font;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2016-03-07 15:10:17 +01:00
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
|
|
|
font = get_tahoma_instance(factory, DWRITE_FONT_STYLE_NORMAL);
|
|
|
|
ok(font != NULL, "failed to create font\n");
|
|
|
|
|
|
|
|
/* Win8 is broken, QI claims to support IDWriteFont3, but in fact it does not */
|
|
|
|
hr = IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory3, (void**)&factory3);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFont3, (void**)&font3);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
ret = IDWriteFont3_HasCharacter(font3, 'A');
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
IDWriteFont3_Release(font3);
|
|
|
|
IDWriteFactory3_Release(factory3);
|
|
|
|
}
|
|
|
|
else
|
2016-03-28 12:33:57 +02:00
|
|
|
win_skip("IDWriteFont3 is not supported.\n");
|
2016-03-07 15:10:17 +01:00
|
|
|
|
|
|
|
IDWriteFont_Release(font);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2016-03-07 15:10:17 +01:00
|
|
|
}
|
|
|
|
|
2016-04-19 08:39:27 +02:00
|
|
|
static void test_CreateFontFaceReference(void)
|
|
|
|
{
|
|
|
|
static const WCHAR dummyW[] = {'d','u','m','m','y',0};
|
2016-04-20 09:50:58 +02:00
|
|
|
IDWriteFontFace3 *fontface, *fontface1;
|
|
|
|
IDWriteFontFaceReference *ref, *ref1;
|
|
|
|
IDWriteFontFile *file, *file1;
|
2017-10-09 09:47:02 +02:00
|
|
|
IDWriteFactory3 *factory;
|
2016-04-20 20:38:20 +02:00
|
|
|
IDWriteFont3 *font3;
|
|
|
|
IDWriteFont *font;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG refcount;
|
2016-04-19 08:39:27 +02:00
|
|
|
UINT32 index;
|
|
|
|
WCHAR *path;
|
|
|
|
HRESULT hr;
|
2016-05-05 13:35:23 +02:00
|
|
|
BOOL ret;
|
2016-04-19 08:39:27 +02:00
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
factory = create_factory_iid(&IID_IDWriteFactory3);
|
|
|
|
if (!factory) {
|
2016-04-19 08:39:27 +02:00
|
|
|
win_skip("CreateFontFaceReference() is not supported.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
path = create_testfontfile(test_fontfile);
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory3_CreateFontFaceReference(factory, NULL, NULL, 0, DWRITE_FONT_SIMULATIONS_NONE, &ref);
|
2016-04-19 08:39:27 +02:00
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
2016-05-05 13:35:24 +02:00
|
|
|
/* out of range simulation flags */
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory3_CreateFontFaceReference(factory, path, NULL, 0, ~0u, &ref);
|
2016-05-05 13:35:24 +02:00
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
/* test file is not a collection, but reference could still be created with non-zero face index */
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory3_CreateFontFaceReference(factory, path, NULL, 1, DWRITE_FONT_SIMULATIONS_NONE, &ref);
|
2016-04-19 08:39:27 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2016-04-19 08:39:27 +02:00
|
|
|
index = IDWriteFontFaceReference_GetFontFaceIndex(ref);
|
|
|
|
ok(index == 1, "got %u\n", index);
|
2016-04-20 09:50:58 +02:00
|
|
|
|
|
|
|
hr = IDWriteFontFaceReference_GetFontFile(ref, &file);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
|
|
|
|
hr = IDWriteFontFaceReference_CreateFontFace(ref, &fontface);
|
2016-04-20 09:51:01 +02:00
|
|
|
todo_wine
|
2016-04-20 09:50:58 +02:00
|
|
|
ok(hr == DWRITE_E_FILEFORMAT, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IDWriteFontFaceReference_Release(ref);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2016-04-19 08:39:27 +02:00
|
|
|
/* path however has to be valid */
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory3_CreateFontFaceReference(factory, dummyW, NULL, 0, DWRITE_FONT_SIMULATIONS_NONE, &ref);
|
2016-04-19 08:39:27 +02:00
|
|
|
todo_wine
|
|
|
|
ok(hr == DWRITE_E_FILENOTFOUND, "got 0x%08x\n", hr);
|
2016-04-20 09:51:01 +02:00
|
|
|
if (hr == S_OK)
|
|
|
|
IDWriteFontFaceReference_Release(ref);
|
2016-04-19 08:39:27 +02:00
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
EXPECT_REF(factory, 1);
|
|
|
|
hr = IDWriteFactory3_CreateFontFaceReference(factory, path, NULL, 0, DWRITE_FONT_SIMULATIONS_NONE, &ref);
|
2016-04-19 08:39:27 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2017-10-09 09:47:02 +02:00
|
|
|
EXPECT_REF(factory, 2);
|
2016-04-20 09:50:58 +02:00
|
|
|
|
|
|
|
/* new file is returned */
|
|
|
|
hr = IDWriteFontFaceReference_GetFontFile(ref, &file);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFaceReference_GetFontFile(ref, &file1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(file != file1, "got %p, previous file %p\n", file1, file);
|
|
|
|
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
IDWriteFontFile_Release(file1);
|
|
|
|
|
|
|
|
/* references are not reused */
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory3_CreateFontFaceReference(factory, path, NULL, 0, DWRITE_FONT_SIMULATIONS_NONE, &ref1);
|
2016-04-20 09:50:58 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(ref1 != ref, "got %p, previous ref %p\n", ref1, ref);
|
|
|
|
|
|
|
|
/* created fontfaces are cached */
|
|
|
|
hr = IDWriteFontFaceReference_CreateFontFace(ref, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFaceReference_CreateFontFace(ref1, &fontface1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(fontface == fontface1, "got %p, expected %p\n", fontface1, fontface);
|
|
|
|
IDWriteFontFace3_Release(fontface);
|
|
|
|
IDWriteFontFace3_Release(fontface1);
|
|
|
|
|
2016-05-05 13:35:23 +02:00
|
|
|
/* reference equality */
|
|
|
|
ret = IDWriteFontFaceReference_Equals(ref, ref1);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
IDWriteFontFaceReference_Release(ref1);
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory3_CreateFontFaceReference(factory, path, NULL, 1, DWRITE_FONT_SIMULATIONS_NONE, &ref1);
|
2016-05-05 13:35:23 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ret = IDWriteFontFaceReference_Equals(ref, ref1);
|
|
|
|
ok(!ret, "got %d\n", ret);
|
2016-04-20 09:50:58 +02:00
|
|
|
IDWriteFontFaceReference_Release(ref1);
|
2016-05-05 13:35:23 +02:00
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory3_CreateFontFaceReference(factory, path, NULL, 0, DWRITE_FONT_SIMULATIONS_BOLD, &ref1);
|
2016-05-05 13:35:23 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ret = IDWriteFontFaceReference_Equals(ref, ref1);
|
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
IDWriteFontFaceReference_Release(ref1);
|
|
|
|
|
2016-04-19 08:39:27 +02:00
|
|
|
IDWriteFontFaceReference_Release(ref);
|
|
|
|
|
2016-04-20 09:50:58 +02:00
|
|
|
/* create reference from a file */
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory3_CreateFontFileReference(factory, path, NULL, &file);
|
2016-04-20 09:50:58 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory3_CreateFontFaceReference_(factory, file, 0, DWRITE_FONT_SIMULATIONS_NONE, &ref);
|
2016-04-20 09:50:58 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFaceReference_GetFontFile(ref, &file1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(file != file1, "got %p, previous file %p\n", file1, file);
|
|
|
|
|
|
|
|
IDWriteFontFaceReference_Release(ref);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
IDWriteFontFile_Release(file1);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2016-04-20 20:38:20 +02:00
|
|
|
/* references returned from IDWriteFont3 */
|
2017-10-09 09:47:02 +02:00
|
|
|
font = get_tahoma_instance((IDWriteFactory *)factory, DWRITE_FONT_STYLE_NORMAL);
|
2016-04-20 20:38:20 +02:00
|
|
|
hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFont3, (void**)&font3);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
hr = IDWriteFont3_GetFontFaceReference(font3, &ref);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFont3_GetFontFaceReference(font3, &ref1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(ref != ref1, "got %p, %p\n", ref1, ref);
|
|
|
|
|
|
|
|
IDWriteFontFaceReference_Release(ref);
|
|
|
|
IDWriteFontFaceReference_Release(ref1);
|
2016-05-05 13:35:22 +02:00
|
|
|
|
|
|
|
/* references returned from IDWriteFontFace3 */
|
|
|
|
hr = IDWriteFont3_CreateFontFace(font3, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace3_GetFontFaceReference(fontface, &ref);
|
2016-07-05 11:55:55 +02:00
|
|
|
todo_wine
|
2016-05-05 13:35:22 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace3_GetFontFaceReference(fontface, &ref1);
|
2016-07-05 11:55:55 +02:00
|
|
|
todo_wine
|
2016-05-05 13:35:22 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2016-07-05 11:55:55 +02:00
|
|
|
if (hr == S_OK)
|
2016-05-05 13:35:22 +02:00
|
|
|
ok(ref == ref1, "got %p, %p\n", ref1, ref);
|
|
|
|
|
2016-07-05 11:55:55 +02:00
|
|
|
if (hr == S_OK) {
|
2016-05-05 13:35:22 +02:00
|
|
|
hr = IDWriteFontFaceReference_CreateFontFace(ref, &fontface1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(fontface1 == fontface, "got %p, %p\n", fontface1, fontface);
|
|
|
|
IDWriteFontFace3_Release(fontface1);
|
|
|
|
|
|
|
|
IDWriteFontFaceReference_Release(ref);
|
|
|
|
IDWriteFontFaceReference_Release(ref1);
|
|
|
|
}
|
2016-07-05 11:55:55 +02:00
|
|
|
IDWriteFontFace3_Release(fontface);
|
2016-04-20 20:38:20 +02:00
|
|
|
IDWriteFont3_Release(font3);
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
refcount = IDWriteFactory3_Release(factory);
|
2017-04-11 13:21:32 +02:00
|
|
|
ok(refcount == 0, "factory not released, %u\n", refcount);
|
2016-04-19 08:39:27 +02:00
|
|
|
DELETE_FONTFILE(path);
|
|
|
|
}
|
|
|
|
|
2016-04-20 09:50:57 +02:00
|
|
|
static void get_expected_fontsig(IDWriteFont *font, FONTSIGNATURE *fontsig)
|
|
|
|
{
|
|
|
|
void *os2_context;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
const TT_OS2_V2 *tt_os2;
|
|
|
|
UINT32 size;
|
|
|
|
BOOL exists;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
memset(fontsig, 0, sizeof(*fontsig));
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_TryGetFontTable(fontface, MS_0S2_TAG, (const void**)&tt_os2, &size, &os2_context, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
if (tt_os2) {
|
|
|
|
fontsig->fsUsb[0] = GET_BE_DWORD(tt_os2->ulUnicodeRange1);
|
|
|
|
fontsig->fsUsb[1] = GET_BE_DWORD(tt_os2->ulUnicodeRange2);
|
|
|
|
fontsig->fsUsb[2] = GET_BE_DWORD(tt_os2->ulUnicodeRange3);
|
|
|
|
fontsig->fsUsb[3] = GET_BE_DWORD(tt_os2->ulUnicodeRange4);
|
|
|
|
|
2016-12-04 17:22:12 +01:00
|
|
|
if (GET_BE_WORD(tt_os2->version) == 0) {
|
|
|
|
fontsig->fsCsb[0] = 0;
|
|
|
|
fontsig->fsCsb[1] = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fontsig->fsCsb[0] = GET_BE_DWORD(tt_os2->ulCodePageRange1);
|
|
|
|
fontsig->fsCsb[1] = GET_BE_DWORD(tt_os2->ulCodePageRange2);
|
|
|
|
}
|
2016-04-20 09:50:57 +02:00
|
|
|
|
|
|
|
IDWriteFontFace_ReleaseFontTable(fontface, os2_context);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_GetFontSignature(void)
|
|
|
|
{
|
|
|
|
IDWriteFontCollection *syscollection;
|
|
|
|
IDWriteGdiInterop1 *interop1;
|
|
|
|
IDWriteGdiInterop *interop;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
FONTSIGNATURE fontsig;
|
|
|
|
UINT count, i;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2016-04-20 09:50:57 +02:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteGdiInterop_QueryInterface(interop, &IID_IDWriteGdiInterop1, (void**)&interop1);
|
|
|
|
IDWriteGdiInterop_Release(interop);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
win_skip("GetFontSignature() is not supported.\n");
|
|
|
|
IDWriteGdiInterop_Release(interop);
|
|
|
|
IDWriteFactory_Release(factory);
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteGdiInterop1_GetFontSignature(interop1, NULL, &fontsig);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
count = IDWriteFontCollection_GetFontFamilyCount(syscollection);
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
FONTSIGNATURE expected_signature;
|
|
|
|
IDWriteLocalizedStrings *names;
|
|
|
|
IDWriteFontFamily *family;
|
|
|
|
IDWriteFont *font;
|
|
|
|
WCHAR nameW[256];
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(syscollection, i, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
|
|
|
|
DWRITE_FONT_STYLE_NORMAL, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFamilyNames(family, &names);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
get_enus_string(names, nameW, ARRAY_SIZE(nameW));
|
2016-04-20 09:50:57 +02:00
|
|
|
|
|
|
|
IDWriteLocalizedStrings_Release(names);
|
|
|
|
|
|
|
|
hr = IDWriteGdiInterop1_GetFontSignature(interop1, font, &fontsig);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
get_expected_fontsig(font, &expected_signature);
|
|
|
|
|
|
|
|
ok(fontsig.fsUsb[0] == expected_signature.fsUsb[0], "%s: fsUsb[0] %#x, expected %#x\n", wine_dbgstr_w(nameW),
|
|
|
|
fontsig.fsUsb[0], expected_signature.fsUsb[0]);
|
|
|
|
ok(fontsig.fsUsb[1] == expected_signature.fsUsb[1], "%s: fsUsb[1] %#x, expected %#x\n", wine_dbgstr_w(nameW),
|
|
|
|
fontsig.fsUsb[1], expected_signature.fsUsb[1]);
|
|
|
|
ok(fontsig.fsUsb[2] == expected_signature.fsUsb[2], "%s: fsUsb[2] %#x, expected %#x\n", wine_dbgstr_w(nameW),
|
|
|
|
fontsig.fsUsb[2], expected_signature.fsUsb[2]);
|
|
|
|
ok(fontsig.fsUsb[3] == expected_signature.fsUsb[3], "%s: fsUsb[3] %#x, expected %#x\n", wine_dbgstr_w(nameW),
|
|
|
|
fontsig.fsUsb[3], expected_signature.fsUsb[3]);
|
|
|
|
|
|
|
|
ok(fontsig.fsCsb[0] == expected_signature.fsCsb[0], "%s: fsCsb[0] %#x, expected %#x\n", wine_dbgstr_w(nameW),
|
|
|
|
fontsig.fsCsb[0], expected_signature.fsCsb[0]);
|
|
|
|
ok(fontsig.fsCsb[1] == expected_signature.fsCsb[1], "%s: fsCsb[1] %#x, expected %#x\n", wine_dbgstr_w(nameW),
|
|
|
|
fontsig.fsCsb[1], expected_signature.fsCsb[1]);
|
2016-05-03 20:26:47 +02:00
|
|
|
|
2016-04-20 09:50:57 +02:00
|
|
|
IDWriteFont_Release(font);
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteGdiInterop1_Release(interop1);
|
|
|
|
IDWriteFontCollection_Release(syscollection);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2016-04-20 09:50:57 +02:00
|
|
|
}
|
|
|
|
|
2016-07-05 11:55:53 +02:00
|
|
|
static void test_font_properties(void)
|
|
|
|
{
|
|
|
|
IDWriteFontFace3 *fontface3;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
DWRITE_FONT_STYLE style;
|
|
|
|
IDWriteFont *font;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2016-07-05 11:55:53 +02:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
|
|
|
/* this creates simulated font */
|
|
|
|
font = get_tahoma_instance(factory, DWRITE_FONT_STYLE_ITALIC);
|
|
|
|
|
|
|
|
style = IDWriteFont_GetStyle(font);
|
|
|
|
ok(style == DWRITE_FONT_STYLE_OBLIQUE, "got %u\n", style);
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace3, (void**)&fontface3);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
style = IDWriteFontFace3_GetStyle(fontface3);
|
|
|
|
ok(style == DWRITE_FONT_STYLE_OBLIQUE, "got %u\n", style);
|
|
|
|
|
|
|
|
IDWriteFontFace3_Release(fontface3);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFont_Release(font);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2016-07-05 11:55:53 +02:00
|
|
|
}
|
|
|
|
|
2016-07-05 11:55:54 +02:00
|
|
|
static BOOL has_vertical_glyph_variants(IDWriteFontFace1 *fontface)
|
|
|
|
{
|
|
|
|
const OT_FeatureList *featurelist;
|
|
|
|
const OT_LookupList *lookup_list;
|
|
|
|
BOOL exists = FALSE, ret = FALSE;
|
|
|
|
const GSUB_Header *header;
|
|
|
|
const void *data;
|
|
|
|
void *context;
|
|
|
|
UINT32 size;
|
|
|
|
HRESULT hr;
|
|
|
|
UINT16 i;
|
|
|
|
|
|
|
|
hr = IDWriteFontFace1_TryGetFontTable(fontface, MS_GSUB_TAG, &data, &size, &context, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
if (!exists)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
header = data;
|
|
|
|
featurelist = (OT_FeatureList*)((BYTE*)header + GET_BE_WORD(header->FeatureList));
|
|
|
|
lookup_list = (const OT_LookupList*)((BYTE*)header + GET_BE_WORD(header->LookupList));
|
|
|
|
|
|
|
|
for (i = 0; i < GET_BE_WORD(featurelist->FeatureCount); i++) {
|
|
|
|
if (*(UINT32*)featurelist->FeatureRecord[i].FeatureTag == DWRITE_FONT_FEATURE_TAG_VERTICAL_WRITING) {
|
|
|
|
const OT_Feature *feature = (const OT_Feature*)((BYTE*)featurelist + GET_BE_WORD(featurelist->FeatureRecord[i].Feature));
|
2016-07-06 22:16:42 +02:00
|
|
|
UINT16 lookup_count = GET_BE_WORD(feature->LookupCount), i, index, count, type;
|
2016-07-05 11:55:54 +02:00
|
|
|
const GSUB_SingleSubstFormat2 *subst2;
|
|
|
|
const OT_LookupTable *lookup_table;
|
|
|
|
UINT32 offset;
|
|
|
|
|
|
|
|
if (lookup_count == 0)
|
|
|
|
continue;
|
|
|
|
|
2016-07-06 22:16:42 +02:00
|
|
|
for (i = 0; i < lookup_count; i++) {
|
|
|
|
/* check if lookup is empty */
|
|
|
|
index = GET_BE_WORD(feature->LookupListIndex[i]);
|
|
|
|
lookup_table = (const OT_LookupTable*)((BYTE*)lookup_list + GET_BE_WORD(lookup_list->Lookup[index]));
|
2016-07-05 11:55:54 +02:00
|
|
|
|
2016-07-06 22:16:42 +02:00
|
|
|
type = GET_BE_WORD(lookup_table->LookupType);
|
|
|
|
ok(type == 1 || type == 7, "got unexpected lookup type %u\n", type);
|
2016-07-05 11:55:54 +02:00
|
|
|
|
2016-07-06 22:16:42 +02:00
|
|
|
count = GET_BE_WORD(lookup_table->SubTableCount);
|
|
|
|
if (count == 0)
|
|
|
|
continue;
|
2016-07-05 11:55:54 +02:00
|
|
|
|
2016-07-06 22:16:42 +02:00
|
|
|
ok(count > 0, "got unexpected subtable count %u\n", count);
|
2016-07-05 11:55:54 +02:00
|
|
|
|
2016-07-06 22:16:42 +02:00
|
|
|
offset = GET_BE_WORD(lookup_table->SubTable[0]);
|
|
|
|
if (type == 7) {
|
|
|
|
const GSUB_ExtensionPosFormat1 *ext = (const GSUB_ExtensionPosFormat1 *)((const BYTE *)lookup_table + offset);
|
|
|
|
if (GET_BE_WORD(ext->SubstFormat) == 1)
|
|
|
|
offset += GET_BE_DWORD(ext->ExtensionOffset);
|
|
|
|
else
|
|
|
|
ok(0, "Unhandled Extension Substitution Format %u\n", GET_BE_WORD(ext->SubstFormat));
|
|
|
|
}
|
2016-07-05 11:55:54 +02:00
|
|
|
|
2016-07-06 22:16:42 +02:00
|
|
|
subst2 = (const GSUB_SingleSubstFormat2*)((BYTE*)lookup_table + offset);
|
|
|
|
index = GET_BE_WORD(subst2->SubstFormat);
|
|
|
|
if (index == 1)
|
|
|
|
ok(0, "validate Single Substitution Format 1\n");
|
|
|
|
else if (index == 2) {
|
|
|
|
/* SimSun-ExtB has 0 glyph count for this substitution */
|
|
|
|
if (GET_BE_WORD(subst2->GlyphCount) > 0) {
|
|
|
|
ret = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2016-07-05 11:55:54 +02:00
|
|
|
}
|
2016-07-06 22:16:42 +02:00
|
|
|
else
|
|
|
|
ok(0, "unknown Single Substitution Format, %u\n", index);
|
2016-07-05 11:55:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontFace1_ReleaseFontTable(fontface, context);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_HasVerticalGlyphVariants(void)
|
|
|
|
{
|
|
|
|
IDWriteFontCollection *syscollection;
|
|
|
|
IDWriteFontFace1 *fontface1;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
UINT32 count, i;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2016-07-05 11:55:54 +02:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
fontface = create_fontface(factory);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
if (hr != S_OK) {
|
|
|
|
win_skip("HasVerticalGlyphVariants() is not supported.\n");
|
|
|
|
IDWriteFactory_Release(factory);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
IDWriteFontFace1_Release(fontface1);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
count = IDWriteFontCollection_GetFontFamilyCount(syscollection);
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
IDWriteLocalizedStrings *names;
|
|
|
|
BOOL expected_vert, has_vert;
|
|
|
|
IDWriteFontFamily *family;
|
|
|
|
IDWriteFont *font;
|
|
|
|
WCHAR nameW[256];
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(syscollection, i, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
|
|
|
|
DWRITE_FONT_STYLE_NORMAL, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFamilyNames(family, &names);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
get_enus_string(names, nameW, ARRAY_SIZE(nameW));
|
2016-07-05 11:55:54 +02:00
|
|
|
|
|
|
|
expected_vert = has_vertical_glyph_variants(fontface1);
|
|
|
|
has_vert = IDWriteFontFace1_HasVerticalGlyphVariants(fontface1);
|
|
|
|
|
|
|
|
ok(expected_vert == has_vert, "%s: expected vertical feature %d, got %d\n",
|
|
|
|
wine_dbgstr_w(nameW), expected_vert, has_vert);
|
|
|
|
|
|
|
|
IDWriteLocalizedStrings_Release(names);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
IDWriteFontFace1_Release(fontface1);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontCollection_Release(syscollection);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2016-07-05 11:55:54 +02:00
|
|
|
}
|
|
|
|
|
2017-03-17 19:29:34 +01:00
|
|
|
static void test_HasKerningPairs(void)
|
|
|
|
{
|
|
|
|
IDWriteFontCollection *syscollection;
|
|
|
|
IDWriteFontFace1 *fontface1;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
UINT32 count, i;
|
|
|
|
HRESULT hr;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2017-03-17 19:29:34 +01:00
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
fontface = create_fontface(factory);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
if (hr != S_OK) {
|
|
|
|
win_skip("HasKerningPairs() is not supported.\n");
|
|
|
|
IDWriteFactory_Release(factory);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
IDWriteFontFace1_Release(fontface1);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
count = IDWriteFontCollection_GetFontFamilyCount(syscollection);
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
IDWriteLocalizedStrings *names;
|
|
|
|
BOOL exists, has_kerningpairs;
|
|
|
|
IDWriteFontFamily *family;
|
|
|
|
IDWriteFont *font;
|
|
|
|
WCHAR nameW[256];
|
|
|
|
const void *data;
|
|
|
|
void *context;
|
|
|
|
UINT32 size;
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(syscollection, i, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
|
|
|
|
DWRITE_FONT_STYLE_NORMAL, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void **)&fontface1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFamilyNames(family, &names);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
get_enus_string(names, nameW, ARRAY_SIZE(nameW));
|
2017-03-17 19:29:34 +01:00
|
|
|
|
|
|
|
exists = FALSE;
|
|
|
|
hr = IDWriteFontFace1_TryGetFontTable(fontface1, MS_KERN_TAG, &data, &size, &context, &exists);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IDWriteFontFace1_ReleaseFontTable(fontface1, context);
|
|
|
|
|
|
|
|
has_kerningpairs = IDWriteFontFace1_HasKerningPairs(fontface1);
|
|
|
|
if (!exists)
|
|
|
|
ok(!has_kerningpairs, "%s: expected %d, got %d\n", wine_dbgstr_w(nameW), exists, has_kerningpairs);
|
|
|
|
|
|
|
|
IDWriteLocalizedStrings_Release(names);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
IDWriteFontFace1_Release(fontface1);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontCollection_Release(syscollection);
|
2017-04-11 13:21:32 +02:00
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2017-03-17 19:29:34 +01:00
|
|
|
}
|
|
|
|
|
2019-01-27 06:55:24 +01:00
|
|
|
static void get_expected_glyph_origins(D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *run,
|
|
|
|
D2D1_POINT_2F *origins)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (run->bidiLevel & 1)
|
|
|
|
{
|
|
|
|
DWRITE_GLYPH_METRICS glyph_metrics[2];
|
|
|
|
DWRITE_FONT_METRICS metrics;
|
|
|
|
float advance;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_GetDesignGlyphMetrics(run->fontFace, run->glyphIndices, run->glyphCount, glyph_metrics, FALSE);
|
|
|
|
ok(hr == S_OK, "Failed to get glyph metrics, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
IDWriteFontFace_GetMetrics(run->fontFace, &metrics);
|
|
|
|
|
|
|
|
advance = run->fontEmSize * glyph_metrics[0].advanceWidth / metrics.designUnitsPerEm;
|
|
|
|
|
|
|
|
baseline_origin.x -= advance;
|
|
|
|
|
|
|
|
for (i = 0; i < run->glyphCount; ++i)
|
|
|
|
{
|
|
|
|
origins[i].x = baseline_origin.x - run->glyphOffsets[i].advanceOffset;
|
|
|
|
origins[i].y = baseline_origin.y - run->glyphOffsets[i].ascenderOffset;
|
|
|
|
|
|
|
|
baseline_origin.x -= run->glyphAdvances[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < run->glyphCount; ++i)
|
|
|
|
{
|
|
|
|
origins[i].x = baseline_origin.x + run->glyphOffsets[i].advanceOffset;
|
|
|
|
origins[i].y = baseline_origin.y - run->glyphOffsets[i].ascenderOffset;
|
|
|
|
|
|
|
|
baseline_origin.x += run->glyphAdvances[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-07 13:06:12 +02:00
|
|
|
static void test_ComputeGlyphOrigins(void)
|
|
|
|
{
|
2019-01-27 06:55:24 +01:00
|
|
|
static const struct origins_test
|
|
|
|
{
|
|
|
|
D2D1_POINT_2F baseline_origin;
|
|
|
|
float advances[2];
|
|
|
|
DWRITE_GLYPH_OFFSET offsets[2];
|
|
|
|
unsigned int bidi_level;
|
|
|
|
}
|
|
|
|
origins_tests[] =
|
|
|
|
{
|
|
|
|
{ { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0 } } },
|
|
|
|
{ { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0.3f, 0.5f }, { -0.1f, 0.9f } } },
|
|
|
|
{ { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0 } }, 1 },
|
|
|
|
};
|
2017-10-09 09:47:02 +02:00
|
|
|
IDWriteFactory4 *factory;
|
2017-04-07 13:06:12 +02:00
|
|
|
DWRITE_GLYPH_RUN run;
|
|
|
|
HRESULT hr;
|
2019-01-27 06:55:24 +01:00
|
|
|
D2D1_POINT_2F origins[2], expected_origins[2];
|
2017-04-07 13:06:12 +02:00
|
|
|
D2D1_POINT_2F baseline_origin;
|
2019-01-27 06:55:24 +01:00
|
|
|
UINT16 glyphs[2] = { 0 };
|
2017-04-07 13:06:12 +02:00
|
|
|
FLOAT advances[2];
|
|
|
|
DWRITE_MATRIX m;
|
2017-04-11 13:21:32 +02:00
|
|
|
ULONG ref;
|
2019-01-27 06:55:24 +01:00
|
|
|
unsigned int i, j;
|
|
|
|
IDWriteFontFace *fontface;
|
2017-04-07 13:06:12 +02:00
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
factory = create_factory_iid(&IID_IDWriteFactory4);
|
|
|
|
if (!factory) {
|
2017-04-07 13:06:12 +02:00
|
|
|
win_skip("ComputeGlyphOrigins() is not supported.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-27 06:55:24 +01:00
|
|
|
fontface = create_fontface((IDWriteFactory *)factory);
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(origins_tests); ++i)
|
|
|
|
{
|
|
|
|
run.fontFace = fontface;
|
|
|
|
run.fontEmSize = 32.0f;
|
|
|
|
run.glyphCount = 2;
|
|
|
|
run.glyphIndices = glyphs;
|
|
|
|
run.glyphAdvances = origins_tests[i].advances;
|
|
|
|
run.glyphOffsets = origins_tests[i].offsets;
|
|
|
|
run.isSideways = FALSE;
|
|
|
|
run.bidiLevel = origins_tests[i].bidi_level;
|
|
|
|
|
|
|
|
get_expected_glyph_origins(origins_tests[i].baseline_origin, &run, expected_origins);
|
|
|
|
|
|
|
|
memset(origins, 0, sizeof(origins));
|
|
|
|
hr = IDWriteFactory4_ComputeGlyphOrigins_(factory, &run, origins_tests[i].baseline_origin, origins);
|
|
|
|
ok(hr == S_OK, "%u: failed to compute glyph origins, hr %#x.\n", i, hr);
|
|
|
|
for (j = 0; j < run.glyphCount; ++j)
|
|
|
|
{
|
|
|
|
todo_wine_if(run.bidiLevel & 1)
|
|
|
|
ok(!memcmp(&origins[j], &expected_origins[j], sizeof(origins[j])),
|
|
|
|
"%u: unexpected origin[%u] (%f, %f) - (%f, %f).\n", i, j, origins[j].x, origins[j].y,
|
|
|
|
expected_origins[j].x, expected_origins[j].y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
|
2017-04-07 13:06:12 +02:00
|
|
|
advances[0] = 10.0f;
|
|
|
|
advances[1] = 20.0f;
|
|
|
|
|
|
|
|
run.fontFace = NULL;
|
|
|
|
run.fontEmSize = 16.0f;
|
|
|
|
run.glyphCount = 2;
|
|
|
|
run.glyphIndices = glyphs;
|
|
|
|
run.glyphAdvances = advances;
|
|
|
|
run.glyphOffsets = NULL;
|
|
|
|
run.isSideways = FALSE;
|
|
|
|
run.bidiLevel = 0;
|
|
|
|
|
|
|
|
baseline_origin.x = 123.0f;
|
|
|
|
baseline_origin.y = 321.0f;
|
|
|
|
|
|
|
|
memset(origins, 0, sizeof(origins));
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory4_ComputeGlyphOrigins_(factory, &run, baseline_origin, origins);
|
2017-04-07 13:06:12 +02:00
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(origins[0].x == 123.0f && origins[0].y == 321.0f, "origins[0] %f,%f\n", origins[0].x, origins[0].y);
|
|
|
|
ok(origins[1].x == 133.0f && origins[1].y == 321.0f, "origins[1] %f,%f\n", origins[1].x, origins[1].y);
|
|
|
|
|
|
|
|
memset(origins, 0, sizeof(origins));
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory4_ComputeGlyphOrigins(factory, &run, DWRITE_MEASURING_MODE_NATURAL, baseline_origin,
|
2017-04-07 13:06:12 +02:00
|
|
|
NULL, origins);
|
|
|
|
ok(origins[0].x == 123.0f && origins[0].y == 321.0f, "origins[0] %f,%f\n", origins[0].x, origins[0].y);
|
|
|
|
ok(origins[1].x == 133.0f && origins[1].y == 321.0f, "origins[1] %f,%f\n", origins[1].x, origins[1].y);
|
|
|
|
|
|
|
|
/* transform is not applied to returned origins */
|
|
|
|
m.m11 = 2.0f;
|
|
|
|
m.m12 = 0.0f;
|
|
|
|
m.m21 = 0.0f;
|
|
|
|
m.m22 = 1.0f;
|
|
|
|
m.dx = 0.0f;
|
|
|
|
m.dy = 0.0f;
|
|
|
|
|
|
|
|
memset(origins, 0, sizeof(origins));
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory4_ComputeGlyphOrigins(factory, &run, DWRITE_MEASURING_MODE_NATURAL, baseline_origin,
|
2017-04-07 13:06:12 +02:00
|
|
|
&m, origins);
|
|
|
|
ok(origins[0].x == 123.0f && origins[0].y == 321.0f, "origins[0] %f,%f\n", origins[0].x, origins[0].y);
|
|
|
|
ok(origins[1].x == 133.0f && origins[1].y == 321.0f, "origins[1] %f,%f\n", origins[1].x, origins[1].y);
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
ref = IDWriteFactory4_Release(factory);
|
2017-04-11 13:21:32 +02:00
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_object_lifetime(void)
|
|
|
|
{
|
|
|
|
IDWriteFontCollection *collection, *collection2;
|
|
|
|
IDWriteFontList *fontlist, *fontlist2;
|
|
|
|
IDWriteGdiInterop *interop, *interop2;
|
|
|
|
IDWriteFontFamily *family, *family2;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFont *font, *font2;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
HRESULT hr;
|
|
|
|
ULONG ref;
|
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
EXPECT_REF(factory, 1);
|
|
|
|
|
|
|
|
/* system collection takes factory reference */
|
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
|
|
|
EXPECT_REF(collection, 1);
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &collection2, FALSE);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
ok(collection2 == collection, "expected same collection\n");
|
|
|
|
|
|
|
|
EXPECT_REF(collection, 2);
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
|
|
|
|
IDWriteFontCollection_Release(collection2);
|
|
|
|
|
|
|
|
IDWriteFontCollection_AddRef(collection);
|
|
|
|
EXPECT_REF(collection, 2);
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
IDWriteFontCollection_Release(collection);
|
|
|
|
|
|
|
|
EXPECT_REF(collection, 1);
|
|
|
|
|
|
|
|
/* family takes collection reference */
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
|
|
|
EXPECT_REF(family, 1);
|
|
|
|
EXPECT_REF(collection, 2);
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family2);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
|
|
|
EXPECT_REF(family2, 1);
|
|
|
|
EXPECT_REF(collection, 3);
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
|
|
|
|
IDWriteFontFamily_Release(family2);
|
|
|
|
|
|
|
|
EXPECT_REF(family, 1);
|
|
|
|
EXPECT_REF(collection, 2);
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
|
|
|
|
/* font takes family reference */
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
|
|
|
|
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &font);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
|
|
|
EXPECT_REF(family, 2);
|
|
|
|
EXPECT_REF(collection, 2);
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
|
|
|
|
hr = IDWriteFont_GetFontFamily(font, &family2);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
ok(family2 == family, "unexpected family pointer\n");
|
|
|
|
IDWriteFontFamily_Release(family2);
|
|
|
|
|
|
|
|
EXPECT_REF(font, 1);
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
|
|
|
|
/* Fontface takes factory reference and nothing else. */
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
|
|
|
EXPECT_REF(font, 1);
|
|
|
|
EXPECT_REF_BROKEN(fontface, 1, 2);
|
|
|
|
EXPECT_REF(family, 2);
|
|
|
|
EXPECT_REF(collection, 2);
|
|
|
|
EXPECT_REF_BROKEN(factory, 3, 2);
|
|
|
|
|
|
|
|
/* get font from fontface */
|
|
|
|
hr = IDWriteFontCollection_GetFontFromFontFace(collection, fontface, &font2);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
|
|
|
EXPECT_REF(font, 1);
|
|
|
|
EXPECT_REF(font2, 1);
|
|
|
|
EXPECT_REF_BROKEN(fontface, 1, 2);
|
|
|
|
EXPECT_REF(family, 2);
|
|
|
|
EXPECT_REF(collection, 3);
|
|
|
|
EXPECT_REF_BROKEN(factory, 3, 2);
|
|
|
|
|
|
|
|
IDWriteFont_Release(font2);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
|
|
|
|
EXPECT_REF(font, 1);
|
|
|
|
EXPECT_REF(family, 2);
|
|
|
|
EXPECT_REF(collection, 2);
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
|
|
|
|
EXPECT_REF(family, 1);
|
|
|
|
EXPECT_REF(collection, 2);
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
|
|
|
|
/* Matching fonts list takes family reference. */
|
|
|
|
hr = IDWriteFontFamily_GetMatchingFonts(family, DWRITE_FONT_WEIGHT_NORMAL,
|
|
|
|
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &fontlist);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
|
|
|
EXPECT_REF(family, 2);
|
|
|
|
EXPECT_REF(collection, 2);
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetMatchingFonts(family, DWRITE_FONT_WEIGHT_NORMAL,
|
|
|
|
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &fontlist2);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
ok(fontlist2 != fontlist, "unexpected font list\n");
|
|
|
|
IDWriteFontList_Release(fontlist2);
|
|
|
|
|
|
|
|
IDWriteFontList_Release(fontlist);
|
|
|
|
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
EXPECT_REF(collection, 1);
|
|
|
|
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
ref = IDWriteFontCollection_Release(collection);
|
|
|
|
ok(ref == 0, "collection not released, %u\n", ref);
|
|
|
|
EXPECT_REF(factory, 1);
|
|
|
|
|
|
|
|
/* GDI interop object takes factory reference */
|
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
EXPECT_REF(interop, 1);
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_GetGdiInterop(factory, &interop2);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
ok(interop == interop2, "got unexpected interop pointer\n");
|
|
|
|
|
|
|
|
EXPECT_REF(interop, 2);
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
|
|
|
|
IDWriteGdiInterop_Release(interop2);
|
|
|
|
ref = IDWriteGdiInterop_Release(interop);
|
|
|
|
ok(ref == 0, "interop not released, %u\n", ref);
|
|
|
|
|
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2017-04-07 13:06:12 +02:00
|
|
|
}
|
|
|
|
|
2017-10-05 12:00:00 +02:00
|
|
|
struct testowner_object
|
|
|
|
{
|
|
|
|
IUnknown IUnknown_iface;
|
|
|
|
LONG ref;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct testowner_object *impl_from_IUnknown(IUnknown *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct testowner_object, IUnknown_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testowner_QueryInterface(IUnknown *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown)) {
|
|
|
|
*obj = iface;
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI testowner_AddRef(IUnknown *iface)
|
|
|
|
{
|
|
|
|
struct testowner_object *object = impl_from_IUnknown(iface);
|
|
|
|
return InterlockedIncrement(&object->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI testowner_Release(IUnknown *iface)
|
|
|
|
{
|
|
|
|
struct testowner_object *object = impl_from_IUnknown(iface);
|
|
|
|
return InterlockedDecrement(&object->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IUnknownVtbl testownervtbl = {
|
|
|
|
testowner_QueryInterface,
|
|
|
|
testowner_AddRef,
|
|
|
|
testowner_Release,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void testowner_init(struct testowner_object *object)
|
|
|
|
{
|
|
|
|
object->IUnknown_iface.lpVtbl = &testownervtbl;
|
|
|
|
object->ref = 1;
|
|
|
|
}
|
|
|
|
|
2017-04-19 14:15:26 +02:00
|
|
|
static void test_inmemory_file_loader(void)
|
|
|
|
{
|
2017-10-05 12:00:00 +02:00
|
|
|
IDWriteFontFileStream *stream, *stream2, *stream3;
|
2017-04-19 14:15:26 +02:00
|
|
|
IDWriteFontFileLoader *loader, *loader2;
|
|
|
|
IDWriteInMemoryFontFileLoader *inmemory;
|
2017-10-05 12:00:00 +02:00
|
|
|
struct testowner_object ownerobject;
|
2017-10-06 11:45:20 +02:00
|
|
|
const void *key, *data, *frag_start;
|
|
|
|
UINT64 file_size, size, writetime;
|
2017-04-19 14:15:26 +02:00
|
|
|
IDWriteFontFile *file, *file2;
|
|
|
|
IDWriteFontFace *fontface;
|
2017-10-06 11:45:20 +02:00
|
|
|
void *context, *context2;
|
2017-10-09 09:47:02 +02:00
|
|
|
IDWriteFactory5 *factory;
|
2017-04-19 14:15:26 +02:00
|
|
|
UINT32 count, key_size;
|
2017-10-06 11:45:20 +02:00
|
|
|
DWORD ref_key;
|
2017-04-19 14:15:26 +02:00
|
|
|
HRESULT hr;
|
|
|
|
ULONG ref;
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
factory = create_factory_iid(&IID_IDWriteFactory5);
|
|
|
|
if (!factory) {
|
|
|
|
win_skip("CreateInMemoryFontFileLoader() is not supported\n");
|
2017-04-19 14:15:26 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
EXPECT_REF(factory, 1);
|
|
|
|
hr = IDWriteFactory5_CreateInMemoryFontFileLoader(factory, &loader);
|
2017-04-19 14:15:26 +02:00
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
2017-10-09 09:47:02 +02:00
|
|
|
EXPECT_REF(factory, 1);
|
2017-04-19 14:15:26 +02:00
|
|
|
|
2017-10-05 12:00:00 +02:00
|
|
|
testowner_init(&ownerobject);
|
2017-10-09 09:47:02 +02:00
|
|
|
fontface = create_fontface((IDWriteFactory *)factory);
|
2017-05-07 21:38:15 +02:00
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory5_CreateInMemoryFontFileLoader(factory, &loader2);
|
2017-04-19 14:15:26 +02:00
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
ok(loader != loader2, "unexpected pointer\n");
|
|
|
|
IDWriteFontFileLoader_Release(loader2);
|
|
|
|
|
|
|
|
hr = IDWriteFontFileLoader_QueryInterface(loader, &IID_IDWriteInMemoryFontFileLoader, (void **)&inmemory);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
IDWriteFontFileLoader_Release(loader);
|
2017-10-05 12:00:00 +02:00
|
|
|
EXPECT_REF(inmemory, 1);
|
2017-04-19 14:15:26 +02:00
|
|
|
|
2017-10-06 11:45:20 +02:00
|
|
|
count = IDWriteInMemoryFontFileLoader_GetFileCount(inmemory);
|
|
|
|
ok(!count, "Unexpected file count %u.\n", count);
|
|
|
|
|
2017-04-19 14:15:26 +02:00
|
|
|
/* Use whole font blob to construct in-memory file. */
|
|
|
|
count = 1;
|
|
|
|
hr = IDWriteFontFace_GetFiles(fontface, &count, &file);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetLoader(file, &loader);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetReferenceKey(file, &key, &key_size);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFileLoader_CreateStreamFromKey(loader, key, key_size, &stream);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
IDWriteFontFileLoader_Release(loader);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
|
|
|
|
hr = IDWriteFontFileStream_GetFileSize(stream, &file_size);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFileStream_ReadFileFragment(stream, &data, 0, file_size, &context);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
2017-10-05 12:00:00 +02:00
|
|
|
/* Not registered yet. */
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteInMemoryFontFileLoader_CreateInMemoryFontFileReference(inmemory, (IDWriteFactory *)factory, data,
|
2017-04-19 14:15:26 +02:00
|
|
|
file_size, NULL, &file);
|
|
|
|
ok(hr == E_INVALIDARG, "got %#x\n", hr);
|
|
|
|
|
2017-10-06 11:45:20 +02:00
|
|
|
count = IDWriteInMemoryFontFileLoader_GetFileCount(inmemory);
|
|
|
|
ok(count == 1, "Unexpected file count %u.\n", count);
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory5_RegisterFontFileLoader(factory, (IDWriteFontFileLoader *)inmemory);
|
2017-04-19 14:15:26 +02:00
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
2017-10-05 12:00:00 +02:00
|
|
|
EXPECT_REF(inmemory, 2);
|
2017-04-19 14:15:26 +02:00
|
|
|
|
2017-10-05 12:00:00 +02:00
|
|
|
EXPECT_REF(&ownerobject.IUnknown_iface, 1);
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteInMemoryFontFileLoader_CreateInMemoryFontFileReference(inmemory, (IDWriteFactory *)factory, data,
|
2017-10-05 12:00:00 +02:00
|
|
|
file_size, &ownerobject.IUnknown_iface, &file);
|
2017-04-19 14:15:26 +02:00
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
2017-10-05 12:00:00 +02:00
|
|
|
EXPECT_REF(&ownerobject.IUnknown_iface, 2);
|
|
|
|
EXPECT_REF(inmemory, 3);
|
2017-04-19 14:15:26 +02:00
|
|
|
|
2017-10-06 11:45:20 +02:00
|
|
|
count = IDWriteInMemoryFontFileLoader_GetFileCount(inmemory);
|
|
|
|
ok(count == 2, "Unexpected file count %u.\n", count);
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteInMemoryFontFileLoader_CreateInMemoryFontFileReference(inmemory, (IDWriteFactory *)factory, data,
|
2017-10-05 12:00:00 +02:00
|
|
|
file_size, &ownerobject.IUnknown_iface, &file2);
|
2017-04-19 14:15:26 +02:00
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
ok(file2 != file, "got unexpected file\n");
|
2017-10-05 12:00:00 +02:00
|
|
|
EXPECT_REF(&ownerobject.IUnknown_iface, 3);
|
|
|
|
EXPECT_REF(inmemory, 4);
|
2017-04-19 14:15:26 +02:00
|
|
|
|
2017-10-06 11:45:20 +02:00
|
|
|
count = IDWriteInMemoryFontFileLoader_GetFileCount(inmemory);
|
|
|
|
ok(count == 3, "Unexpected file count %u.\n", count);
|
|
|
|
|
2017-04-19 14:15:26 +02:00
|
|
|
/* Check in-memory reference key format. */
|
|
|
|
hr = IDWriteFontFile_GetReferenceKey(file, &key, &key_size);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
|
|
|
ok(key && *(DWORD*)key == 1, "got wrong ref key\n");
|
|
|
|
ok(key_size == 4, "ref key size %u\n", key_size);
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetReferenceKey(file2, &key, &key_size);
|
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
|
|
|
|
|
|
|
ok(key && *(DWORD*)key == 2, "got wrong ref key\n");
|
|
|
|
ok(key_size == 4, "ref key size %u\n", key_size);
|
|
|
|
|
2017-10-05 12:00:00 +02:00
|
|
|
EXPECT_REF(inmemory, 4);
|
|
|
|
hr = IDWriteInMemoryFontFileLoader_CreateStreamFromKey(inmemory, key, key_size, &stream2);
|
|
|
|
ok(hr == S_OK, "Failed to create a stream, hr %#x.\n", hr);
|
|
|
|
EXPECT_REF(stream2, 1);
|
|
|
|
EXPECT_REF(inmemory, 4);
|
2017-04-19 14:15:26 +02:00
|
|
|
|
2017-10-05 12:00:00 +02:00
|
|
|
hr = IDWriteInMemoryFontFileLoader_CreateStreamFromKey(inmemory, key, key_size, &stream3);
|
|
|
|
ok(hr == S_OK, "Failed to create a stream, hr %#x.\n", hr);
|
2017-04-19 14:15:26 +02:00
|
|
|
|
2017-10-05 12:00:00 +02:00
|
|
|
ok(stream2 != stream3, "Unexpected stream.\n");
|
2017-04-19 14:15:26 +02:00
|
|
|
|
2017-10-05 12:00:00 +02:00
|
|
|
IDWriteFontFileStream_Release(stream2);
|
|
|
|
IDWriteFontFileStream_Release(stream3);
|
2017-04-19 14:15:26 +02:00
|
|
|
|
2017-10-05 12:00:00 +02:00
|
|
|
/* Release file at index 1, create new one to see if index is reused. */
|
|
|
|
EXPECT_REF(&ownerobject.IUnknown_iface, 3);
|
2017-10-06 11:45:20 +02:00
|
|
|
ref = IDWriteFontFile_Release(file);
|
|
|
|
ok(ref == 0, "File object not released, %u.\n", ref);
|
2017-10-05 12:00:00 +02:00
|
|
|
EXPECT_REF(&ownerobject.IUnknown_iface, 3);
|
|
|
|
|
2017-10-06 11:45:20 +02:00
|
|
|
count = IDWriteInMemoryFontFileLoader_GetFileCount(inmemory);
|
|
|
|
ok(count == 3, "Unexpected file count %u.\n", count);
|
|
|
|
|
2017-10-05 12:00:00 +02:00
|
|
|
EXPECT_REF(&ownerobject.IUnknown_iface, 3);
|
2017-10-06 11:45:20 +02:00
|
|
|
ref = IDWriteFontFile_Release(file2);
|
|
|
|
ok(ref == 0, "File object not released, %u.\n", ref);
|
2017-10-05 12:00:00 +02:00
|
|
|
EXPECT_REF(&ownerobject.IUnknown_iface, 3);
|
2017-04-19 14:15:26 +02:00
|
|
|
|
2017-10-06 11:45:20 +02:00
|
|
|
count = IDWriteInMemoryFontFileLoader_GetFileCount(inmemory);
|
|
|
|
ok(count == 3, "Unexpected file count %u.\n", count);
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory5_UnregisterFontFileLoader(factory, (IDWriteFontFileLoader *)inmemory);
|
2017-04-19 14:15:26 +02:00
|
|
|
ok(hr == S_OK, "got %#x\n", hr);
|
2017-10-05 12:00:00 +02:00
|
|
|
EXPECT_REF(&ownerobject.IUnknown_iface, 3);
|
2017-04-19 14:15:26 +02:00
|
|
|
|
2017-10-05 12:00:00 +02:00
|
|
|
EXPECT_REF(&ownerobject.IUnknown_iface, 3);
|
|
|
|
ref = IDWriteInMemoryFontFileLoader_Release(inmemory);
|
|
|
|
ok(ref == 0, "loader not released, %u.\n", ref);
|
|
|
|
EXPECT_REF(&ownerobject.IUnknown_iface, 1);
|
2017-04-19 14:15:26 +02:00
|
|
|
|
2017-10-06 11:45:20 +02:00
|
|
|
/* Test reference key for first added file. */
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory5_CreateInMemoryFontFileLoader(factory, &loader);
|
2017-10-06 11:45:20 +02:00
|
|
|
ok(hr == S_OK, "Failed to create loader, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFileLoader_QueryInterface(loader, &IID_IDWriteInMemoryFontFileLoader, (void **)&inmemory);
|
|
|
|
ok(hr == S_OK, "Failed to get in-memory interface, hr %#x.\n", hr);
|
|
|
|
IDWriteFontFileLoader_Release(loader);
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory5_RegisterFontFileLoader(factory, (IDWriteFontFileLoader *)inmemory);
|
2017-10-06 11:45:20 +02:00
|
|
|
ok(hr == S_OK, "Failed to register loader, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
ref_key = 0;
|
|
|
|
hr = IDWriteInMemoryFontFileLoader_CreateStreamFromKey(inmemory, &ref_key, sizeof(ref_key), &stream2);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
2018-11-19 10:27:36 +01:00
|
|
|
/* With owner object. */
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteInMemoryFontFileLoader_CreateInMemoryFontFileReference(inmemory, (IDWriteFactory *)factory, data,
|
2017-10-06 11:45:20 +02:00
|
|
|
file_size, &ownerobject.IUnknown_iface, &file);
|
|
|
|
ok(hr == S_OK, "Failed to create in-memory file reference, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
ref_key = 0;
|
|
|
|
hr = IDWriteInMemoryFontFileLoader_CreateStreamFromKey(inmemory, &ref_key, sizeof(ref_key), &stream2);
|
|
|
|
ok(hr == S_OK, "Failed to create a stream, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
context2 = (void *)0xdeadbeef;
|
|
|
|
hr = IDWriteFontFileStream_ReadFileFragment(stream2, &frag_start, 0, file_size, &context2);
|
|
|
|
ok(hr == S_OK, "Failed to read a fragment, hr %#x.\n", hr);
|
2018-11-19 10:27:36 +01:00
|
|
|
ok(context2 == NULL, "Unexpected context %p.\n", context2);
|
2017-10-06 11:45:20 +02:00
|
|
|
ok(frag_start == data, "Unexpected fragment pointer %p.\n", frag_start);
|
|
|
|
|
|
|
|
hr = IDWriteFontFileStream_GetFileSize(stream2, &size);
|
|
|
|
ok(hr == S_OK, "Failed to get file size, hr %#x.\n", hr);
|
|
|
|
ok(size == file_size, "Unexpected file size.\n");
|
|
|
|
|
|
|
|
IDWriteFontFileStream_ReleaseFileFragment(stream2, context2);
|
|
|
|
|
|
|
|
writetime = 1;
|
|
|
|
hr = IDWriteFontFileStream_GetLastWriteTime(stream2, &writetime);
|
|
|
|
ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
|
|
|
|
ok(writetime == 0, "Unexpected writetime.\n");
|
|
|
|
|
|
|
|
IDWriteFontFileStream_Release(stream2);
|
|
|
|
|
2018-11-19 10:27:36 +01:00
|
|
|
/* Without owner object. */
|
|
|
|
hr = IDWriteInMemoryFontFileLoader_CreateInMemoryFontFileReference(inmemory, (IDWriteFactory *)factory, data,
|
|
|
|
file_size, NULL, &file2);
|
|
|
|
ok(hr == S_OK, "Failed to create in-memory file reference, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
ref_key = 1;
|
|
|
|
hr = IDWriteInMemoryFontFileLoader_CreateStreamFromKey(inmemory, &ref_key, sizeof(ref_key), &stream2);
|
|
|
|
ok(hr == S_OK, "Failed to create a stream, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
context2 = (void *)0xdeadbeef;
|
|
|
|
hr = IDWriteFontFileStream_ReadFileFragment(stream2, &frag_start, 0, file_size, &context2);
|
|
|
|
ok(hr == S_OK, "Failed to read a fragment, hr %#x.\n", hr);
|
|
|
|
ok(context2 == NULL, "Unexpected context %p.\n", context2);
|
|
|
|
ok(frag_start != data, "Unexpected fragment pointer %p.\n", frag_start);
|
|
|
|
|
|
|
|
hr = IDWriteFontFileStream_GetFileSize(stream2, &size);
|
|
|
|
ok(hr == S_OK, "Failed to get file size, hr %#x.\n", hr);
|
|
|
|
ok(size == file_size, "Unexpected file size.\n");
|
|
|
|
|
|
|
|
IDWriteFontFileStream_ReleaseFileFragment(stream2, context2);
|
|
|
|
|
|
|
|
writetime = 1;
|
|
|
|
hr = IDWriteFontFileStream_GetLastWriteTime(stream2, &writetime);
|
|
|
|
ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
|
|
|
|
ok(writetime == 0, "Unexpected writetime.\n");
|
|
|
|
|
|
|
|
IDWriteFontFileStream_Release(stream2);
|
|
|
|
IDWriteFontFile_Release(file2);
|
|
|
|
|
|
|
|
/* Key size validation. */
|
2017-10-06 11:45:20 +02:00
|
|
|
ref_key = 0;
|
|
|
|
hr = IDWriteInMemoryFontFileLoader_CreateStreamFromKey(inmemory, NULL, sizeof(ref_key) - 1, &stream2);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
ref_key = 0;
|
|
|
|
hr = IDWriteInMemoryFontFileLoader_CreateStreamFromKey(inmemory, &ref_key, sizeof(ref_key) - 1, &stream2);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
ref_key = 0;
|
|
|
|
hr = IDWriteInMemoryFontFileLoader_CreateStreamFromKey(inmemory, &ref_key, sizeof(ref_key) + 1, &stream2);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
count = IDWriteInMemoryFontFileLoader_GetFileCount(inmemory);
|
2018-11-19 10:27:36 +01:00
|
|
|
ok(count == 2, "Unexpected file count %u.\n", count);
|
2017-10-06 11:45:20 +02:00
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetReferenceKey(file, &key, &key_size);
|
|
|
|
ok(hr == S_OK, "Failed to get reference key, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
ok(key && *(DWORD*)key == 0, "Unexpected reference key.\n");
|
|
|
|
ok(key_size == 4, "Unexpected key size %u.\n", key_size);
|
|
|
|
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
|
|
|
|
count = IDWriteInMemoryFontFileLoader_GetFileCount(inmemory);
|
2018-11-19 10:27:36 +01:00
|
|
|
ok(count == 2, "Unexpected file count %u.\n", count);
|
2017-10-06 11:45:20 +02:00
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
hr = IDWriteFactory5_UnregisterFontFileLoader(factory, (IDWriteFontFileLoader *)inmemory);
|
2017-10-06 11:45:20 +02:00
|
|
|
ok(hr == S_OK, "Failed to unregister loader, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
IDWriteFontFileStream_ReleaseFileFragment(stream, context);
|
|
|
|
IDWriteFontFileStream_Release(stream);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
|
2017-10-16 10:55:39 +02:00
|
|
|
ref = IDWriteInMemoryFontFileLoader_Release(inmemory);
|
|
|
|
ok(ref == 0, "loader not released, %u.\n", ref);
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
ref = IDWriteFactory5_Release(factory);
|
2017-04-19 14:15:26 +02:00
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
|
|
|
}
|
|
|
|
|
2017-04-19 14:15:28 +02:00
|
|
|
static BOOL face_has_table(IDWriteFontFace4 *fontface, UINT32 tag)
|
|
|
|
{
|
|
|
|
BOOL exists = FALSE;
|
|
|
|
const void *data;
|
|
|
|
void *context;
|
|
|
|
UINT32 size;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IDWriteFontFace4_TryGetFontTable(fontface, tag, &data, &size, &context, &exists);
|
|
|
|
ok(hr == S_OK, "TryGetFontTable() failed, %#x\n", hr);
|
|
|
|
if (exists)
|
|
|
|
IDWriteFontFace4_ReleaseFontTable(fontface, context);
|
|
|
|
|
|
|
|
return exists;
|
|
|
|
}
|
|
|
|
|
2017-04-25 07:54:42 +02:00
|
|
|
static DWORD get_sbix_formats(IDWriteFontFace4 *fontface)
|
|
|
|
{
|
|
|
|
UINT32 size, s, num_strikes;
|
|
|
|
const sbix_header *header;
|
|
|
|
UINT16 g, num_glyphs;
|
|
|
|
BOOL exists = FALSE;
|
|
|
|
const maxp *maxp;
|
|
|
|
const void *data;
|
|
|
|
DWORD ret = 0;
|
|
|
|
void *context;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IDWriteFontFace4_TryGetFontTable(fontface, MS_MAXP_TAG, &data, &size, &context, &exists);
|
|
|
|
ok(hr == S_OK, "TryGetFontTable() failed, %#x\n", hr);
|
|
|
|
ok(exists, "Expected maxp table\n");
|
|
|
|
|
|
|
|
if (!exists)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
maxp = data;
|
|
|
|
num_glyphs = GET_BE_WORD(maxp->numGlyphs);
|
|
|
|
|
|
|
|
hr = IDWriteFontFace4_TryGetFontTable(fontface, MS_SBIX_TAG, &data, &size, &context, &exists);
|
|
|
|
ok(hr == S_OK, "TryGetFontTable() failed, %#x\n", hr);
|
|
|
|
ok(exists, "Expected sbix table\n");
|
|
|
|
|
|
|
|
header = data;
|
|
|
|
num_strikes = GET_BE_DWORD(header->numStrikes);
|
|
|
|
|
|
|
|
for (s = 0; s < num_strikes; s++) {
|
|
|
|
sbix_strike *strike = (sbix_strike *)((BYTE *)header + GET_BE_DWORD(header->strikeOffset[s]));
|
|
|
|
|
|
|
|
for (g = 0; g < num_glyphs; g++) {
|
|
|
|
DWORD offset = GET_BE_DWORD(strike->glyphDataOffsets[g]);
|
|
|
|
DWORD offset_next = GET_BE_DWORD(strike->glyphDataOffsets[g + 1]);
|
|
|
|
sbix_glyph_data *glyph_data;
|
|
|
|
DWORD format;
|
|
|
|
|
|
|
|
if (offset == offset_next)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
glyph_data = (sbix_glyph_data *)((BYTE *)strike + offset);
|
|
|
|
switch (format = glyph_data->graphicType)
|
|
|
|
{
|
|
|
|
case MS_PNG__TAG:
|
|
|
|
ret |= DWRITE_GLYPH_IMAGE_FORMATS_PNG;
|
|
|
|
break;
|
|
|
|
case MS_JPG__TAG:
|
|
|
|
ret |= DWRITE_GLYPH_IMAGE_FORMATS_JPEG;
|
|
|
|
break;
|
|
|
|
case MS_TIFF_TAG:
|
|
|
|
ret |= DWRITE_GLYPH_IMAGE_FORMATS_TIFF;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ok(0, "unexpected format, %#x\n", GET_BE_DWORD(format));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontFace4_ReleaseFontTable(fontface, context);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-10-09 09:47:04 +02:00
|
|
|
static DWORD get_cblc_formats(IDWriteFontFace4 *fontface)
|
|
|
|
{
|
|
|
|
CBLCBitmapSizeTable *sizes;
|
|
|
|
UINT32 num_sizes, size, s;
|
|
|
|
BOOL exists = FALSE;
|
|
|
|
CBLCHeader *header;
|
|
|
|
DWORD ret = 0;
|
|
|
|
void *context;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IDWriteFontFace4_TryGetFontTable(fontface, MS_CBLC_TAG, (const void **)&header, &size, &context, &exists);
|
|
|
|
ok(hr == S_OK, "TryGetFontTable() failed, %#x\n", hr);
|
|
|
|
ok(exists, "Expected CBLC table\n");
|
|
|
|
|
|
|
|
if (!exists)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
num_sizes = GET_BE_DWORD(header->numSizes);
|
|
|
|
sizes = (CBLCBitmapSizeTable *)(header + 1);
|
|
|
|
|
|
|
|
for (s = 0; s < num_sizes; s++) {
|
2019-01-29 08:06:43 +01:00
|
|
|
BYTE bpp = sizes[s].bitDepth;
|
2017-10-09 09:47:04 +02:00
|
|
|
|
|
|
|
if (bpp == 1 || bpp == 2 || bpp == 4 || bpp == 8)
|
|
|
|
ret |= DWRITE_GLYPH_IMAGE_FORMATS_PNG;
|
|
|
|
else if (bpp == 32)
|
|
|
|
ret |= DWRITE_GLYPH_IMAGE_FORMATS_PREMULTIPLIED_B8G8R8A8;
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontFace4_ReleaseFontTable(fontface, context);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-04-19 14:15:28 +02:00
|
|
|
static DWORD get_face_glyph_image_formats(IDWriteFontFace4 *fontface)
|
|
|
|
{
|
|
|
|
DWORD ret = DWRITE_GLYPH_IMAGE_FORMATS_NONE;
|
|
|
|
|
|
|
|
if (face_has_table(fontface, MS_GLYF_TAG))
|
|
|
|
ret |= DWRITE_GLYPH_IMAGE_FORMATS_TRUETYPE;
|
|
|
|
|
2017-10-09 09:47:05 +02:00
|
|
|
if (face_has_table(fontface, MS_CFF__TAG) ||
|
|
|
|
face_has_table(fontface, MS_CFF2_TAG))
|
2017-04-19 14:15:28 +02:00
|
|
|
ret |= DWRITE_GLYPH_IMAGE_FORMATS_CFF;
|
|
|
|
|
|
|
|
if (face_has_table(fontface, MS_COLR_TAG))
|
|
|
|
ret |= DWRITE_GLYPH_IMAGE_FORMATS_COLR;
|
|
|
|
|
2017-04-24 07:50:46 +02:00
|
|
|
if (face_has_table(fontface, MS_SVG__TAG))
|
|
|
|
ret |= DWRITE_GLYPH_IMAGE_FORMATS_SVG;
|
|
|
|
|
2017-04-25 07:54:42 +02:00
|
|
|
if (face_has_table(fontface, MS_SBIX_TAG))
|
|
|
|
ret |= get_sbix_formats(fontface);
|
|
|
|
|
2017-10-09 09:47:04 +02:00
|
|
|
if (face_has_table(fontface, MS_CBLC_TAG))
|
|
|
|
ret |= get_cblc_formats(fontface);
|
|
|
|
|
2017-04-19 14:15:28 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_GetGlyphImageFormats(void)
|
|
|
|
{
|
|
|
|
IDWriteFontCollection *syscollection;
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
UINT32 i, count;
|
|
|
|
HRESULT hr;
|
|
|
|
ULONG ref;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
IDWriteFontFace4 *fontface4;
|
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
|
|
|
fontface = create_fontface(factory);
|
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace4, (void **)&fontface4);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
win_skip("GetGlyphImageFormats() is not supported\n");
|
|
|
|
IDWriteFactory_Release(factory);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
IDWriteFontFace4_Release(fontface4);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
count = IDWriteFontCollection_GetFontFamilyCount(syscollection);
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
WCHAR familynameW[256], facenameW[128];
|
|
|
|
IDWriteLocalizedStrings *names;
|
|
|
|
IDWriteFontFamily *family;
|
|
|
|
UINT32 j, fontcount;
|
|
|
|
IDWriteFont *font;
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(syscollection, i, &family);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFamilyNames(family, &names);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
get_enus_string(names, familynameW, ARRAY_SIZE(familynameW));
|
2017-04-19 14:15:28 +02:00
|
|
|
IDWriteLocalizedStrings_Release(names);
|
|
|
|
|
|
|
|
fontcount = IDWriteFontFamily_GetFontCount(family);
|
|
|
|
for (j = 0; j < fontcount; j++) {
|
|
|
|
DWORD formats, expected_formats;
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFont(family, j, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFont_GetFaceNames(font, &names);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
get_enus_string(names, facenameW, ARRAY_SIZE(facenameW));
|
2017-04-19 14:15:28 +02:00
|
|
|
|
|
|
|
IDWriteLocalizedStrings_Release(names);
|
|
|
|
|
|
|
|
IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace4, (void **)&fontface4);
|
|
|
|
|
|
|
|
/* Mask describes font as a whole. */
|
|
|
|
formats = IDWriteFontFace4_GetGlyphImageFormats(fontface4);
|
|
|
|
expected_formats = get_face_glyph_image_formats(fontface4);
|
|
|
|
ok(formats == expected_formats, "%s - %s, expected formats %#x, got formats %#x.\n",
|
|
|
|
wine_dbgstr_w(familynameW), wine_dbgstr_w(facenameW), expected_formats, formats);
|
|
|
|
|
|
|
|
IDWriteFontFace4_Release(fontface4);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontCollection_Release(syscollection);
|
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
|
|
|
}
|
|
|
|
|
2017-07-17 22:18:43 +02:00
|
|
|
static void test_CreateCustomRenderingParams(void)
|
|
|
|
{
|
|
|
|
static const struct custom_params_test
|
|
|
|
{
|
|
|
|
FLOAT gamma;
|
|
|
|
FLOAT contrast;
|
|
|
|
FLOAT cleartype_level;
|
|
|
|
DWRITE_PIXEL_GEOMETRY geometry;
|
|
|
|
DWRITE_RENDERING_MODE rendering_mode;
|
|
|
|
HRESULT hr;
|
|
|
|
} params_tests[] =
|
|
|
|
{
|
|
|
|
{ 0.0f, 0.0f, 0.0f, DWRITE_PIXEL_GEOMETRY_FLAT, DWRITE_RENDERING_MODE_NATURAL, E_INVALIDARG },
|
|
|
|
{ 0.0f, 0.1f, 0.0f, DWRITE_PIXEL_GEOMETRY_FLAT, DWRITE_RENDERING_MODE_NATURAL, E_INVALIDARG },
|
|
|
|
{ 0.0f, 0.0f, 0.1f, DWRITE_PIXEL_GEOMETRY_FLAT, DWRITE_RENDERING_MODE_NATURAL, E_INVALIDARG },
|
|
|
|
{ -0.1f, 0.0f, 0.0f, DWRITE_PIXEL_GEOMETRY_FLAT, DWRITE_RENDERING_MODE_NATURAL, E_INVALIDARG },
|
|
|
|
{ 0.1f, -0.1f, 0.0f, DWRITE_PIXEL_GEOMETRY_FLAT, DWRITE_RENDERING_MODE_NATURAL, E_INVALIDARG },
|
|
|
|
{ 0.1f, 0.0f, -0.1f, DWRITE_PIXEL_GEOMETRY_FLAT, DWRITE_RENDERING_MODE_NATURAL, E_INVALIDARG },
|
|
|
|
{ 0.1f, 0.0f, 0.0f, DWRITE_PIXEL_GEOMETRY_FLAT, DWRITE_RENDERING_MODE_NATURAL },
|
|
|
|
{ 0.01f, 0.0f, 0.0f, DWRITE_PIXEL_GEOMETRY_FLAT, DWRITE_RENDERING_MODE_NATURAL },
|
|
|
|
{ 0.1f, 0.0f, 0.0f, DWRITE_PIXEL_GEOMETRY_BGR + 1, DWRITE_RENDERING_MODE_NATURAL, E_INVALIDARG },
|
|
|
|
{ 0.1f, 0.0f, 0.0f, DWRITE_PIXEL_GEOMETRY_BGR, DWRITE_RENDERING_MODE_OUTLINE + 1, E_INVALIDARG },
|
|
|
|
{ 0.1f, 0.0f, 2.0f, DWRITE_PIXEL_GEOMETRY_BGR, DWRITE_RENDERING_MODE_NATURAL },
|
|
|
|
};
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
unsigned int i;
|
|
|
|
HRESULT hr;
|
|
|
|
ULONG ref;
|
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
|
2018-05-22 10:50:42 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(params_tests); i++) {
|
2017-07-17 22:18:43 +02:00
|
|
|
IDWriteRenderingParams *params;
|
|
|
|
|
|
|
|
params = (void *)0xdeadbeef;
|
|
|
|
hr = IDWriteFactory_CreateCustomRenderingParams(factory, params_tests[i].gamma, params_tests[i].contrast,
|
|
|
|
params_tests[i].cleartype_level, params_tests[i].geometry, params_tests[i].rendering_mode, ¶ms);
|
|
|
|
ok(hr == params_tests[i].hr, "%u: unexpected hr %#x, expected %#x.\n", i, hr, params_tests[i].hr);
|
|
|
|
|
|
|
|
if (hr == S_OK) {
|
|
|
|
ok(params_tests[i].gamma == IDWriteRenderingParams_GetGamma(params), "%u: unexpected gamma %f, expected %f.\n",
|
|
|
|
i, IDWriteRenderingParams_GetGamma(params), params_tests[i].gamma);
|
|
|
|
ok(params_tests[i].contrast == IDWriteRenderingParams_GetEnhancedContrast(params),
|
|
|
|
"%u: unexpected contrast %f, expected %f.\n",
|
|
|
|
i, IDWriteRenderingParams_GetEnhancedContrast(params), params_tests[i].contrast);
|
|
|
|
ok(params_tests[i].cleartype_level == IDWriteRenderingParams_GetClearTypeLevel(params),
|
|
|
|
"%u: unexpected ClearType level %f, expected %f.\n",
|
|
|
|
i, IDWriteRenderingParams_GetClearTypeLevel(params), params_tests[i].cleartype_level);
|
|
|
|
ok(params_tests[i].geometry == IDWriteRenderingParams_GetPixelGeometry(params),
|
|
|
|
"%u: unexpected pixel geometry %u, expected %u.\n", i, IDWriteRenderingParams_GetPixelGeometry(params),
|
|
|
|
params_tests[i].geometry);
|
|
|
|
ok(params_tests[i].rendering_mode == IDWriteRenderingParams_GetRenderingMode(params),
|
|
|
|
"%u: unexpected rendering mode %u, expected %u.\n", i, IDWriteRenderingParams_GetRenderingMode(params),
|
|
|
|
params_tests[i].rendering_mode);
|
|
|
|
IDWriteRenderingParams_Release(params);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok(params == NULL, "%u: expected NULL interface pointer on failure.\n", i);
|
|
|
|
}
|
|
|
|
|
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
|
|
|
}
|
|
|
|
|
2017-09-24 23:08:40 +02:00
|
|
|
static void test_localfontfileloader(void)
|
|
|
|
{
|
|
|
|
IDWriteFontFileLoader *loader, *loader2;
|
|
|
|
IDWriteFactory *factory, *factory2;
|
|
|
|
IDWriteFontFile *file, *file2;
|
|
|
|
WCHAR *path;
|
|
|
|
HRESULT hr;
|
|
|
|
ULONG ref;
|
|
|
|
|
|
|
|
factory = create_factory();
|
|
|
|
factory2 = create_factory();
|
|
|
|
|
|
|
|
path = create_testfontfile(test_fontfile);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
|
|
|
|
ok(hr == S_OK, "Failed to create file reference, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateFontFileReference(factory2, path, NULL, &file2);
|
|
|
|
ok(hr == S_OK, "Failed to create file reference, hr %#x.\n", hr);
|
|
|
|
ok(file != file2, "Unexpected file instance.\n");
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetLoader(file, &loader);
|
|
|
|
ok(hr == S_OK, "Failed to get loader, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetLoader(file2, &loader2);
|
|
|
|
ok(hr == S_OK, "Failed to get loader, hr %#x.\n", hr);
|
|
|
|
ok(loader == loader2, "Unexpected loader instance\n");
|
|
|
|
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
IDWriteFontFile_Release(file2);
|
|
|
|
IDWriteFontFileLoader_Release(loader);
|
|
|
|
IDWriteFontFileLoader_Release(loader2);
|
|
|
|
ref = IDWriteFactory_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2018-12-17 06:16:12 +01:00
|
|
|
ref = IDWriteFactory_Release(factory2);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
2017-09-24 23:08:40 +02:00
|
|
|
DELETE_FONTFILE(path);
|
|
|
|
}
|
|
|
|
|
2017-10-09 09:47:02 +02:00
|
|
|
static void test_AnalyzeContainerType(void)
|
|
|
|
{
|
|
|
|
struct WOFFHeader2 woff2_header;
|
|
|
|
struct WOFFHeader woff_header;
|
|
|
|
DWRITE_CONTAINER_TYPE type;
|
|
|
|
IDWriteFactory5 *factory;
|
|
|
|
|
|
|
|
factory = create_factory_iid(&IID_IDWriteFactory5);
|
|
|
|
if (!factory) {
|
|
|
|
win_skip("AnalyzeContainerType() is not supported.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
type = IDWriteFactory5_AnalyzeContainerType(factory, NULL, 0);
|
|
|
|
ok(type == DWRITE_CONTAINER_TYPE_UNKNOWN, "Unexpected container type %u.\n", type);
|
|
|
|
|
|
|
|
type = IDWriteFactory5_AnalyzeContainerType(factory, (void const *)0xdeadbeef, 0);
|
|
|
|
ok(type == DWRITE_CONTAINER_TYPE_UNKNOWN, "Unexpected container type %u.\n", type);
|
|
|
|
|
|
|
|
memset(&woff_header, 0xff, sizeof(woff_header));
|
|
|
|
woff_header.signature = GET_LE_DWORD(MS_WOFF_TAG);
|
|
|
|
woff_header.length = 0;
|
|
|
|
type = IDWriteFactory5_AnalyzeContainerType(factory, &woff_header, sizeof(woff_header));
|
|
|
|
ok(type == DWRITE_CONTAINER_TYPE_WOFF, "Unexpected container type %u.\n", type);
|
|
|
|
|
|
|
|
memset(&woff_header, 0xff, sizeof(woff_header));
|
|
|
|
woff_header.signature = GET_LE_DWORD(MS_WOFF_TAG);
|
|
|
|
type = IDWriteFactory5_AnalyzeContainerType(factory, &woff_header, sizeof(woff_header.signature));
|
|
|
|
ok(type == DWRITE_CONTAINER_TYPE_WOFF, "Unexpected container type %u.\n", type);
|
|
|
|
|
|
|
|
memset(&woff_header, 0xff, sizeof(woff_header));
|
|
|
|
woff_header.signature = GET_LE_DWORD(MS_WOFF_TAG);
|
|
|
|
type = IDWriteFactory5_AnalyzeContainerType(factory, &woff_header, sizeof(woff_header.signature) - 1);
|
|
|
|
ok(type == DWRITE_CONTAINER_TYPE_UNKNOWN, "Unexpected container type %u.\n", type);
|
|
|
|
|
|
|
|
memset(&woff2_header, 0xff, sizeof(woff2_header));
|
|
|
|
woff2_header.signature = GET_LE_DWORD(MS_WOF2_TAG);
|
|
|
|
type = IDWriteFactory5_AnalyzeContainerType(factory, &woff2_header, sizeof(woff2_header));
|
|
|
|
ok(type == DWRITE_CONTAINER_TYPE_WOFF2, "Unexpected container type %u.\n", type);
|
|
|
|
|
|
|
|
memset(&woff2_header, 0xff, sizeof(woff2_header));
|
|
|
|
woff2_header.signature = GET_LE_DWORD(MS_WOF2_TAG);
|
|
|
|
type = IDWriteFactory5_AnalyzeContainerType(factory, &woff2_header, sizeof(woff2_header.signature));
|
|
|
|
ok(type == DWRITE_CONTAINER_TYPE_WOFF2, "Unexpected container type %u.\n", type);
|
|
|
|
|
|
|
|
memset(&woff2_header, 0xff, sizeof(woff2_header));
|
|
|
|
woff2_header.signature = GET_LE_DWORD(MS_WOF2_TAG);
|
|
|
|
type = IDWriteFactory5_AnalyzeContainerType(factory, &woff2_header, sizeof(woff2_header.signature) - 1);
|
|
|
|
ok(type == DWRITE_CONTAINER_TYPE_UNKNOWN, "Unexpected container type %u.\n", type);
|
|
|
|
|
|
|
|
IDWriteFactory5_Release(factory);
|
|
|
|
}
|
|
|
|
|
2017-10-19 23:25:16 +02:00
|
|
|
static void test_fontsetbuilder(void)
|
|
|
|
{
|
|
|
|
IDWriteFontCollection1 *collection;
|
|
|
|
IDWriteFontSetBuilder *builder;
|
|
|
|
IDWriteFactory3 *factory;
|
|
|
|
UINT32 count, i, ref;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
factory = create_factory_iid(&IID_IDWriteFactory3);
|
|
|
|
if (!factory) {
|
|
|
|
skip("IDWriteFontSetBuilder is not supported.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPECT_REF(factory, 1);
|
|
|
|
hr = IDWriteFactory3_CreateFontSetBuilder(factory, &builder);
|
|
|
|
todo_wine
|
|
|
|
ok(hr == S_OK, "Failed to create font set builder, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
IDWriteFactory3_Release(factory);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPECT_REF(factory, 2);
|
|
|
|
IDWriteFontSetBuilder_Release(builder);
|
|
|
|
|
|
|
|
hr = IDWriteFactory3_GetSystemFontCollection(factory, FALSE, &collection, FALSE);
|
|
|
|
ok(hr == S_OK, "Failed to get system collection, hr %#x.\n", hr);
|
|
|
|
count = IDWriteFontCollection1_GetFontFamilyCount(collection);
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
IDWriteFontFamily1 *family;
|
|
|
|
UINT32 j, fontcount;
|
|
|
|
IDWriteFont3 *font;
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection1_GetFontFamily(collection, i, &family);
|
|
|
|
ok(hr == S_OK, "Failed to get family, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
fontcount = IDWriteFontFamily1_GetFontCount(family);
|
|
|
|
for (j = 0; j < fontcount; j++) {
|
|
|
|
IDWriteFontFaceReference *ref, *ref2;
|
|
|
|
IDWriteFontSet *fontset;
|
|
|
|
UINT32 setcount, id;
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily1_GetFont(family, j, &font);
|
|
|
|
ok(hr == S_OK, "Failed to get font, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
/* Create a set with a single font reference, test set properties. */
|
|
|
|
hr = IDWriteFactory3_CreateFontSetBuilder(factory, &builder);
|
|
|
|
ok(hr == S_OK, "Failed to create font set builder, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDWriteFont3_GetFontFaceReference(font, &ref);
|
|
|
|
ok(hr == S_OK, "Failed to get fontface reference, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
EXPECT_REF(ref, 1);
|
|
|
|
hr = IDWriteFontSetBuilder_AddFontFaceReference(builder, ref);
|
|
|
|
ok(hr == S_OK, "Failed to add fontface reference, hr %#x.\n", hr);
|
|
|
|
EXPECT_REF(ref, 1);
|
|
|
|
|
|
|
|
hr = IDWriteFontSetBuilder_CreateFontSet(builder, &fontset);
|
|
|
|
ok(hr == S_OK, "Failed to create a font set, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
setcount = IDWriteFontSet_GetFontCount(fontset);
|
|
|
|
ok(setcount == 1, "Unexpected font count %u.\n", setcount);
|
|
|
|
|
|
|
|
hr = IDWriteFontSet_GetFontFaceReference(fontset, 0, &ref2);
|
|
|
|
ok(hr == S_OK, "Failed to get font face reference, hr %#x.\n", hr);
|
|
|
|
ok(ref2 != ref, "Unexpected reference.\n");
|
|
|
|
IDWriteFontFaceReference_Release(ref2);
|
|
|
|
|
|
|
|
for (id = DWRITE_FONT_PROPERTY_ID_FAMILY_NAME; id < DWRITE_FONT_PROPERTY_ID_TOTAL; id++) {
|
|
|
|
static const WCHAR fmtW[] = {'%','u',0};
|
|
|
|
IDWriteLocalizedStrings *values;
|
|
|
|
WCHAR buffW[255], buff2W[255];
|
|
|
|
UINT32 c, ivalue;
|
|
|
|
BOOL exists;
|
|
|
|
|
|
|
|
hr = IDWriteFontSet_GetPropertyValues(fontset, 0, id, &exists, &values);
|
|
|
|
ok(hr == S_OK, "Failed to get property value, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
if (!exists)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch (id)
|
|
|
|
{
|
|
|
|
case DWRITE_FONT_PROPERTY_ID_WEIGHT:
|
|
|
|
ivalue = IDWriteFont3_GetWeight(font);
|
|
|
|
break;
|
|
|
|
case DWRITE_FONT_PROPERTY_ID_STRETCH:
|
|
|
|
ivalue = IDWriteFont3_GetStretch(font);
|
|
|
|
break;
|
|
|
|
case DWRITE_FONT_PROPERTY_ID_STYLE:
|
|
|
|
ivalue = IDWriteFont3_GetStyle(font);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (id)
|
|
|
|
{
|
|
|
|
case DWRITE_FONT_PROPERTY_ID_WEIGHT:
|
|
|
|
case DWRITE_FONT_PROPERTY_ID_STRETCH:
|
|
|
|
case DWRITE_FONT_PROPERTY_ID_STYLE:
|
|
|
|
c = IDWriteLocalizedStrings_GetCount(values);
|
|
|
|
ok(c == 1, "Unexpected string count %u.\n", c);
|
|
|
|
|
|
|
|
buffW[0] = 'a';
|
2018-05-22 10:50:42 +02:00
|
|
|
hr = IDWriteLocalizedStrings_GetLocaleName(values, 0, buffW, ARRAY_SIZE(buffW));
|
2017-10-19 23:25:16 +02:00
|
|
|
ok(hr == S_OK, "Failed to get locale name, hr %#x.\n", hr);
|
|
|
|
ok(!*buffW, "Unexpected locale %s.\n", wine_dbgstr_w(buffW));
|
|
|
|
|
|
|
|
buff2W[0] = 0;
|
2018-05-22 10:50:42 +02:00
|
|
|
hr = IDWriteLocalizedStrings_GetString(values, 0, buff2W, ARRAY_SIZE(buff2W));
|
2017-10-19 23:25:16 +02:00
|
|
|
ok(hr == S_OK, "Failed to get property string, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
wsprintfW(buffW, fmtW, ivalue);
|
|
|
|
ok(!lstrcmpW(buffW, buff2W), "Unexpected property value %s, expected %s.\n", wine_dbgstr_w(buff2W),
|
|
|
|
wine_dbgstr_w(buffW));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteLocalizedStrings_Release(values);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontSet_Release(fontset);
|
|
|
|
IDWriteFontFaceReference_Release(ref);
|
|
|
|
IDWriteFontSetBuilder_Release(builder);
|
|
|
|
|
|
|
|
IDWriteFont3_Release(font);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontFamily1_Release(family);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontCollection1_Release(collection);
|
|
|
|
|
|
|
|
ref = IDWriteFactory3_Release(factory);
|
|
|
|
ok(ref == 0, "factory not released, %u\n", ref);
|
|
|
|
}
|
|
|
|
|
2012-07-31 06:18:02 +02:00
|
|
|
START_TEST(font)
|
|
|
|
{
|
2014-10-22 13:42:30 +02:00
|
|
|
IDWriteFactory *factory;
|
2012-07-31 06:18:02 +02:00
|
|
|
|
2014-10-22 13:42:30 +02:00
|
|
|
if (!(factory = create_factory())) {
|
2012-07-31 06:18:02 +02:00
|
|
|
win_skip("failed to create factory\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
test_object_lifetime();
|
2012-07-31 06:18:02 +02:00
|
|
|
test_CreateFontFromLOGFONT();
|
2012-08-13 05:49:19 +02:00
|
|
|
test_CreateBitmapRenderTarget();
|
2012-08-25 11:11:31 +02:00
|
|
|
test_GetFontFamily();
|
2012-10-07 19:11:04 +02:00
|
|
|
test_GetFamilyNames();
|
2012-10-07 21:03:52 +02:00
|
|
|
test_CreateFontFace();
|
2012-10-16 18:56:23 +02:00
|
|
|
test_GetMetrics();
|
2012-10-21 06:24:35 +02:00
|
|
|
test_system_fontcollection();
|
2014-01-05 22:24:17 +01:00
|
|
|
test_ConvertFontFaceToLOGFONT();
|
2014-08-07 00:01:09 +02:00
|
|
|
test_CustomFontCollection();
|
2014-10-22 09:06:15 +02:00
|
|
|
test_CreateCustomFontFileReference();
|
2014-08-26 17:11:59 +02:00
|
|
|
test_CreateFontFileReference();
|
2014-10-09 07:05:27 +02:00
|
|
|
test_shared_isolated();
|
2014-10-16 05:33:51 +02:00
|
|
|
test_GetUnicodeRanges();
|
2014-10-17 06:39:41 +02:00
|
|
|
test_GetFontFromFontFace();
|
|
|
|
test_GetFirstMatchingFont();
|
2016-03-08 20:46:55 +01:00
|
|
|
test_GetMatchingFonts();
|
2014-10-19 21:57:53 +02:00
|
|
|
test_GetInformationalStrings();
|
|
|
|
test_GetGdiInterop();
|
2014-10-20 06:55:39 +02:00
|
|
|
test_CreateFontFaceFromHdc();
|
2014-10-27 15:37:49 +01:00
|
|
|
test_GetSimulations();
|
2014-11-04 20:53:19 +01:00
|
|
|
test_GetFaceNames();
|
2014-11-06 21:23:26 +01:00
|
|
|
test_TryGetFontTable();
|
2014-11-07 11:17:38 +01:00
|
|
|
test_ConvertFontToLOGFONT();
|
2014-11-17 10:30:25 +01:00
|
|
|
test_CreateStreamFromKey();
|
2014-11-18 11:18:46 +01:00
|
|
|
test_ReadFileFragment();
|
2014-12-08 11:24:39 +01:00
|
|
|
test_GetDesignGlyphMetrics();
|
2014-12-09 08:00:45 +01:00
|
|
|
test_GetDesignGlyphAdvances();
|
2014-12-09 07:58:14 +01:00
|
|
|
test_IsMonospacedFont();
|
2014-12-15 07:39:26 +01:00
|
|
|
test_GetGlyphRunOutline();
|
2014-12-17 07:54:13 +01:00
|
|
|
test_GetEudcFontCollection();
|
2015-02-03 11:27:24 +01:00
|
|
|
test_GetCaretMetrics();
|
2015-02-05 13:54:05 +01:00
|
|
|
test_GetGlyphCount();
|
2015-03-13 21:19:18 +01:00
|
|
|
test_GetKerningPairAdjustments();
|
2015-03-31 10:39:59 +02:00
|
|
|
test_CreateRenderingParams();
|
2015-05-19 14:23:57 +02:00
|
|
|
test_CreateGlyphRunAnalysis();
|
2015-07-03 16:53:07 +02:00
|
|
|
test_GetGdiCompatibleMetrics();
|
2015-07-06 22:08:37 +02:00
|
|
|
test_GetPanose();
|
2015-07-20 14:13:58 +02:00
|
|
|
test_GetGdiCompatibleGlyphAdvances();
|
2015-07-27 10:10:04 +02:00
|
|
|
test_GetRecommendedRenderingMode();
|
2015-07-29 10:58:24 +02:00
|
|
|
test_GetAlphaBlendParams();
|
2015-07-29 11:00:26 +02:00
|
|
|
test_CreateAlphaTexture();
|
2015-08-06 17:02:43 +02:00
|
|
|
test_IsSymbolFont();
|
2015-08-06 18:43:58 +02:00
|
|
|
test_GetPaletteEntries();
|
2015-09-09 16:48:12 +02:00
|
|
|
test_TranslateColorGlyphRun();
|
2016-03-07 15:10:17 +01:00
|
|
|
test_HasCharacter();
|
2016-04-19 08:39:27 +02:00
|
|
|
test_CreateFontFaceReference();
|
2016-04-20 09:50:57 +02:00
|
|
|
test_GetFontSignature();
|
2016-07-05 11:55:53 +02:00
|
|
|
test_font_properties();
|
2016-07-05 11:55:54 +02:00
|
|
|
test_HasVerticalGlyphVariants();
|
2017-03-17 19:29:34 +01:00
|
|
|
test_HasKerningPairs();
|
2017-04-07 13:06:12 +02:00
|
|
|
test_ComputeGlyphOrigins();
|
2017-04-19 14:15:26 +02:00
|
|
|
test_inmemory_file_loader();
|
2017-04-19 14:15:28 +02:00
|
|
|
test_GetGlyphImageFormats();
|
2017-07-17 22:18:43 +02:00
|
|
|
test_CreateCustomRenderingParams();
|
2017-09-24 23:08:40 +02:00
|
|
|
test_localfontfileloader();
|
2017-10-09 09:47:02 +02:00
|
|
|
test_AnalyzeContainerType();
|
2017-10-19 23:25:16 +02:00
|
|
|
test_fontsetbuilder();
|
2012-07-31 06:18:02 +02:00
|
|
|
|
|
|
|
IDWriteFactory_Release(factory);
|
|
|
|
}
|