ReactOS 0.4.17-dev-970-gcf0f1a6
font.c File Reference
#include <math.h>
#include <limits.h>
#include "windows.h"
#include "winternl.h"
#include "dwrite_3.h"
#include "initguid.h"
#include "d2d1.h"
#include "wine/test.h"
#include "pshpack2.h"
#include "poppack.h"
Include dependency graph for font.c:

Go to the source code of this file.

Classes

struct  TT_HEAD
 
struct  tt_os2
 
struct  TT_POST
 
struct  TT_HHEA
 
struct  GSUB_Header
 
struct  OT_FeatureRecord
 
struct  OT_FeatureList
 
struct  OT_Feature
 
struct  OT_LookupList
 
struct  OT_LookupTable
 
struct  GSUB_SingleSubstFormat1
 
struct  GSUB_SingleSubstFormat2
 
struct  GSUB_ExtensionPosFormat1
 
struct  sbix_header
 
struct  sbix_strike
 
struct  sbix_glyph_data
 
struct  cblc_header
 
struct  sbitLineMetrics
 
struct  CBLCBitmapSizeTable
 
struct  maxp
 
struct  WOFFHeader
 
struct  WOFFHeader2
 
struct  cmap_encoding_record
 
struct  cmap_header
 
struct  cmap_segmented_coverage_group
 
struct  cmap_segmented_coverage
 
struct  cmap_segmented_mapping_0
 
struct  test_fontenumerator
 
struct  test_fontcollectionloader
 
struct  test_fontdatastream
 
struct  collection_loader
 
struct  dwrite_fonttable
 
struct  font_realization_info
 
struct  local_refkey
 
struct  VDMX_Header
 
struct  VDMX_Ratio
 
struct  VDMX_group
 
struct  VDMX_vTable
 
struct  compatmetrics_test
 
struct  recommendedmode_test
 
struct  CPAL_Header_0
 
struct  testowner_object
 

Macros

#define COBJMACROS
 
#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_OS2_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')
 
#define MS_GSUB_TAG   DWRITE_MAKE_OPENTYPE_TAG('G','S','U','B')
 
#define MS_KERN_TAG   DWRITE_MAKE_OPENTYPE_TAG('k','e','r','n')
 
#define MS_GLYF_TAG   DWRITE_MAKE_OPENTYPE_TAG('g','l','y','f')
 
#define MS_CFF__TAG   DWRITE_MAKE_OPENTYPE_TAG('C','F','F',' ')
 
#define MS_CFF2_TAG   DWRITE_MAKE_OPENTYPE_TAG('C','F','F','2')
 
#define MS_COLR_TAG   DWRITE_MAKE_OPENTYPE_TAG('C','O','L','R')
 
#define MS_SVG__TAG   DWRITE_MAKE_OPENTYPE_TAG('S','V','G',' ')
 
#define MS_SBIX_TAG   DWRITE_MAKE_OPENTYPE_TAG('s','b','i','x')
 
#define MS_MAXP_TAG   DWRITE_MAKE_OPENTYPE_TAG('m','a','x','p')
 
#define MS_CBLC_TAG   DWRITE_MAKE_OPENTYPE_TAG('C','B','L','C')
 
#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')
 
#define MS_WOFF_TAG   DWRITE_MAKE_OPENTYPE_TAG('w','O','F','F')
 
#define MS_WOF2_TAG   DWRITE_MAKE_OPENTYPE_TAG('w','O','F','2')
 
#define GET_BE_WORD(x)   RtlUshortByteSwap(x)
 
#define GET_BE_DWORD(x)   RtlUlongByteSwap(x)
 
#define GET_LE_WORD(x)   (x)
 
#define GET_LE_DWORD(x)   (x)
 
#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)
 
#define CHECK_EXPECT(func)
 
#define CHECK_CALLED(func)
 
#define CLEAR_CALLED(func)    expect_ ## func = called_ ## func = FALSE
 
#define EXPECT_REF(obj, ref)   _expect_ref((IUnknown*)obj, ref, __LINE__)
 
#define EXPECT_REF_BROKEN(obj, ref, brokenref)   _expect_ref_broken((IUnknown*)obj, ref, brokenref, __LINE__)
 
#define DELETE_FONTFILE(filename)   _delete_testfontfile(filename, __LINE__)
 
#define check_familymodel(a, b)   _check_familymodel(a,b,__LINE__)
 
#define round(x)   ((int)floor((x) + 0.5))
 
#define GASP_GRIDFIT   0x0001
 
#define GASP_DOGRAY   0x0002
 
#define GASP_SYMMETRIC_GRIDFIT   0x0004
 
#define GASP_SYMMETRIC_SMOOTHING   0x0008
 

Enumerations

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
}
 
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 , 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
}
 
enum  opentype_cmap_table_platform { OPENTYPE_CMAP_TABLE_PLATFORM_WIN = 3 , OPENTYPE_CMAP_TABLE_PLATFORM_WIN = 3 }
 
enum  opentype_cmap_table_encoding {
  OPENTYPE_CMAP_TABLE_ENCODING_SYMBOL = 0 , OPENTYPE_CMAP_TABLE_ENCODING_UNICODE_BMP = 1 , OPENTYPE_CMAP_TABLE_ENCODING_UNICODE_FULL = 10 , OPENTYPE_CMAP_TABLE_ENCODING_SYMBOL = 0 ,
  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 }
 

Functions

 DEFINE_EXPECT (setfillmode)
 
static void _expect_ref (IUnknown *obj, ULONG ref, int line)
 
static void _expect_ref_broken (IUnknown *obj, ULONG ref, ULONG brokenref, int line)
 
static BOOL (WINAPI *pGetFontRealizationInfo)(HDC hdc
 
static void * create_factory_iid (REFIID riid)
 
static IDWriteFactory * create_factory (void)
 
static IDWriteFontFace * create_fontface (IDWriteFactory *factory)
 
static IDWriteFont * get_font (IDWriteFactory *factory, const WCHAR *name, DWRITE_FONT_STYLE style)
 
static IDWriteFont * get_tahoma_instance (IDWriteFactory *factory, DWRITE_FONT_STYLE style)
 
static WCHAR * create_testfontfile (const WCHAR *filename)
 
static void _delete_testfontfile (const WCHAR *filename, int line)
 
static void get_combined_font_name (const WCHAR *familyW, const WCHAR *faceW, WCHAR *nameW)
 
static BOOL has_face_variations (IDWriteFontFace *fontface)
 
static void _check_familymodel (void *iface_ptr, DWRITE_FONT_FAMILY_MODEL expected_model, unsigned int line)
 
static struct test_fontenumerator * impl_from_IDWriteFontFileEnumerator (IDWriteFontFileEnumerator *iface)
 
static HRESULT WINAPI singlefontfileenumerator_QueryInterface (IDWriteFontFileEnumerator *iface, REFIID riid, void **obj)
 
static ULONG WINAPI singlefontfileenumerator_AddRef (IDWriteFontFileEnumerator *iface)
 
static ULONG WINAPI singlefontfileenumerator_Release (IDWriteFontFileEnumerator *iface)
 
static HRESULT WINAPI singlefontfileenumerator_GetCurrentFontFile (IDWriteFontFileEnumerator *iface, IDWriteFontFile **font_file)
 
static HRESULT WINAPI singlefontfileenumerator_MoveNext (IDWriteFontFileEnumerator *iface, BOOL *current)
 
static HRESULT create_enumerator (IDWriteFontFile *font_file, IDWriteFontFileEnumerator **ret)
 
static struct test_fontcollectionloader * impl_from_IDWriteFontFileCollectionLoader (IDWriteFontCollectionLoader *iface)
 
static HRESULT WINAPI resourcecollectionloader_QueryInterface (IDWriteFontCollectionLoader *iface, REFIID riid, void **obj)
 
static ULONG WINAPI resourcecollectionloader_AddRef (IDWriteFontCollectionLoader *iface)
 
static ULONG WINAPI resourcecollectionloader_Release (IDWriteFontCollectionLoader *iface)
 
static HRESULT WINAPI resourcecollectionloader_CreateEnumeratorFromKey (IDWriteFontCollectionLoader *iface, IDWriteFactory *factory, const void *collectionKey, UINT32 collectionKeySize, IDWriteFontFileEnumerator **fontFileEnumerator)
 
static struct test_fontdatastream * impl_from_IDWriteFontFileStream (IDWriteFontFileStream *iface)
 
static HRESULT WINAPI fontdatastream_QueryInterface (IDWriteFontFileStream *iface, REFIID riid, void **obj)
 
static ULONG WINAPI fontdatastream_AddRef (IDWriteFontFileStream *iface)
 
static ULONG WINAPI fontdatastream_Release (IDWriteFontFileStream *iface)
 
static HRESULT WINAPI fontdatastream_ReadFileFragment (IDWriteFontFileStream *iface, void const **fragment_start, UINT64 offset, UINT64 fragment_size, void **fragment_context)
 
static void WINAPI fontdatastream_ReleaseFileFragment (IDWriteFontFileStream *iface, void *fragment_context)
 
static HRESULT WINAPI fontdatastream_GetFileSize (IDWriteFontFileStream *iface, UINT64 *size)
 
static HRESULT WINAPI fontdatastream_GetLastWriteTime (IDWriteFontFileStream *iface, UINT64 *last_writetime)
 
static HRESULT create_fontdatastream (LPVOID data, UINT size, IDWriteFontFileStream **iface)
 
static HRESULT WINAPI resourcefontfileloader_QueryInterface (IDWriteFontFileLoader *iface, REFIID riid, void **obj)
 
static ULONG WINAPI resourcefontfileloader_AddRef (IDWriteFontFileLoader *iface)
 
static ULONG WINAPI resourcefontfileloader_Release (IDWriteFontFileLoader *iface)
 
static HRESULT WINAPI resourcefontfileloader_CreateStreamFromKey (IDWriteFontFileLoader *iface, const void *ref_key, UINT32 key_size, IDWriteFontFileStream **stream)
 
static HRESULT WINAPI test_geometrysink_QueryInterface (ID2D1SimplifiedGeometrySink *iface, REFIID riid, void **ret)
 
static ULONG WINAPI test_geometrysink_AddRef (ID2D1SimplifiedGeometrySink *iface)
 
static ULONG WINAPI test_geometrysink_Release (ID2D1SimplifiedGeometrySink *iface)
 
static void WINAPI test_geometrysink_SetFillMode (ID2D1SimplifiedGeometrySink *iface, D2D1_FILL_MODE mode)
 
static void WINAPI test_geometrysink_SetSegmentFlags (ID2D1SimplifiedGeometrySink *iface, D2D1_PATH_SEGMENT flags)
 
static void WINAPI test_geometrysink_BeginFigure (ID2D1SimplifiedGeometrySink *iface, D2D1_POINT_2F startPoint, D2D1_FIGURE_BEGIN figureBegin)
 
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)
 
static HRESULT WINAPI test_geometrysink_Close (ID2D1SimplifiedGeometrySink *iface)
 
static void WINAPI test_geometrysink2_BeginFigure (ID2D1SimplifiedGeometrySink *iface, D2D1_POINT_2F startPoint, D2D1_FIGURE_BEGIN figureBegin)
 
static void WINAPI test_geometrysink2_AddLines (ID2D1SimplifiedGeometrySink *iface, const D2D1_POINT_2F *points, UINT32 count)
 
static void WINAPI test_geometrysink2_AddBeziers (ID2D1SimplifiedGeometrySink *iface, const D2D1_BEZIER_SEGMENT *beziers, UINT32 count)
 
static void WINAPI test_geometrysink2_EndFigure (ID2D1SimplifiedGeometrySink *iface, D2D1_FIGURE_END figureEnd)
 
static void test_CreateFontFromLOGFONT (void)
 
static void test_CreateBitmapRenderTarget (void)
 
static void test_GetFontFamily (void)
 
static void test_GetFamilyNames (void)
 
static void test_CreateFontFace (void)
 
static void get_expected_font_metrics (IDWriteFontFace *fontface, DWRITE_FONT_METRICS1 *metrics)
 
static void check_font_metrics (const WCHAR *nameW, IDWriteFontFace *fontface, const DWRITE_FONT_METRICS1 *expected)
 
static void get_enus_string (IDWriteLocalizedStrings *strings, WCHAR *buff, UINT32 size)
 
static void test_GetMetrics (void)
 
static void test_system_fontcollection (void)
 
static void get_logfont_from_font (IDWriteFont *font, LOGFONTW *logfont)
 
static void test_ConvertFontFaceToLOGFONT (void)
 
static HRESULT WINAPI fontfileenumerator_QueryInterface (IDWriteFontFileEnumerator *iface, REFIID riid, void **obj)
 
static ULONG WINAPI fontfileenumerator_AddRef (IDWriteFontFileEnumerator *iface)
 
static ULONG WINAPI fontfileenumerator_Release (IDWriteFontFileEnumerator *iface)
 
static HRESULT WINAPI fontfileenumerator_GetCurrentFontFile (IDWriteFontFileEnumerator *iface, IDWriteFontFile **file)
 
static HRESULT WINAPI fontfileenumerator_MoveNext (IDWriteFontFileEnumerator *iface, BOOL *current)
 
static struct collection_loader * impl_from_IDWriteFontCollectionLoader (IDWriteFontCollectionLoader *iface)
 
static HRESULT WINAPI fontcollectionloader_QueryInterface (IDWriteFontCollectionLoader *iface, REFIID riid, void **obj)
 
static ULONG WINAPI fontcollectionloader_AddRef (IDWriteFontCollectionLoader *iface)
 
static ULONG WINAPI fontcollectionloader_Release (IDWriteFontCollectionLoader *iface)
 
static HRESULT WINAPI fontcollectionloader_CreateEnumeratorFromKey (IDWriteFontCollectionLoader *iface, IDWriteFactory *factory, const void *key, UINT32 key_size, IDWriteFontFileEnumerator **ret)
 
static IDWriteFontCollectionLoader * create_collection_loader (void)
 
static void test_CustomFontCollection (void)
 
static HRESULT WINAPI fontfileloader_QueryInterface (IDWriteFontFileLoader *iface, REFIID riid, void **obj)
 
static ULONG WINAPI fontfileloader_AddRef (IDWriteFontFileLoader *iface)
 
static ULONG WINAPI fontfileloader_Release (IDWriteFontFileLoader *iface)
 
static HRESULT WINAPI fontfileloader_CreateStreamFromKey (IDWriteFontFileLoader *iface, const void *ref_key, UINT32 key_size, IDWriteFontFileStream **stream)
 
static void test_CreateCustomFontFileReference (void)
 
static void test_CreateFontFileReference (void)
 
static void test_shared_isolated (void)
 
static const void * table_read_ensure (const struct dwrite_fonttable *table, unsigned int offset, unsigned int size)
 
static WORD table_read_be_word (const struct dwrite_fonttable *table, void *ptr, DWORD offset)
 
static DWORD table_read_be_dword (const struct dwrite_fonttable *table, void *ptr, DWORD offset)
 
static void array_reserve (void **elements, size_t *capacity, size_t count, size_t size)
 
static void opentype_cmap_read_table (const struct dwrite_fonttable *table, UINT16 cmap_index, UINT32 *count, size_t *capacity, DWRITE_UNICODE_RANGE **ranges)
 
static UINT32 opentype_cmap_get_unicode_ranges (const struct dwrite_fonttable *table, DWRITE_UNICODE_RANGE **ranges)
 
static UINT32 fontface_get_expected_unicode_ranges (IDWriteFontFace1 *fontface, DWRITE_UNICODE_RANGE **out)
 
static void test_GetUnicodeRanges (void)
 
static void test_GetFontFromFontFace (void)
 
static void test_GetFirstMatchingFont (void)
 
static void test_GetMatchingFonts (void)
 
static void test_GetInformationalStrings (void)
 
static void test_GetGdiInterop (void)
 
static void * map_font_file (const WCHAR *filename, DWORD *file_size)
 
static void test_CreateFontFaceFromHdc (void)
 
static void test_GetSimulations (void)
 
static void test_GetFaceNames (void)
 
static void test_TryGetFontTable (void)
 
static void test_ConvertFontToLOGFONT (void)
 
static void test_CreateStreamFromKey (void)
 
static void test_ReadFileFragment (void)
 
static void test_GetDesignGlyphMetrics (void)
 
static BOOL get_expected_is_monospaced (IDWriteFontFace1 *fontface, const DWRITE_PANOSE *panose)
 
static void test_IsMonospacedFont (void)
 
static void test_GetDesignGlyphAdvances (void)
 
static void test_GetGlyphRunOutline (void)
 
static void test_GetEudcFontCollection (void)
 
static void test_GetCaretMetrics (void)
 
static void test_GetGlyphCount (void)
 
static void test_GetKerningPairAdjustments (void)
 
static void test_CreateRenderingParams (void)
 
static void test_CreateGlyphRunAnalysis (void)
 
static const struct VDMX_group * find_vdmx_group (const struct VDMX_Header *hdr)
 
static BOOL get_vdmx_size (const struct VDMX_group *group, int emsize, int *a, int *d)
 
static void test_metrics_cmp (FLOAT emsize, const DWRITE_FONT_METRICS *metrics, const DWRITE_FONT_METRICS1 *expected)
 
static void test_metrics1_cmp (FLOAT emsize, const DWRITE_FONT_METRICS1 *metrics, const DWRITE_FONT_METRICS1 *expected)
 
static void get_expected_metrics (IDWriteFontFace *fontface, struct compatmetrics_test *ptr, DWRITE_FONT_METRICS *expected)
 
static void test_gdicompat_metrics (IDWriteFontFace *face)
 
static void test_GetGdiCompatibleMetrics (void)
 
static void get_expected_panose (IDWriteFont1 *font, DWRITE_PANOSE *panose)
 
static void test_GetPanose (void)
 
static INT32 get_gdi_font_advance (HDC hdc, FLOAT emsize)
 
static void test_GetGdiCompatibleGlyphAdvances (void)
 
static WORD get_gasp_flags (IDWriteFontFace *fontface, FLOAT emsize, FLOAT ppdip)
 
static DWRITE_RENDERING_MODE get_expected_rendering_mode (FLOAT emsize, WORD gasp, DWRITE_MEASURING_MODE mode, DWRITE_OUTLINE_THRESHOLD threshold)
 
static DWRITE_GRID_FIT_MODE get_expected_gridfit_mode (FLOAT emsize, WORD gasp, DWRITE_MEASURING_MODE mode, DWRITE_OUTLINE_THRESHOLD threshold)
 
static void test_GetRecommendedRenderingMode (void)
 
static BOOL float_eq (FLOAT left, FLOAT right)
 
static void test_GetAlphaBlendParams (void)
 
static void test_CreateAlphaTexture (void)
 
static BOOL get_expected_is_symbol (IDWriteFontFace *fontface)
 
static void test_IsSymbolFont (void)
 
static void test_GetPaletteEntries (void)
 
static void test_TranslateColorGlyphRun (void)
 
static void test_HasCharacter (void)
 
static BOOL has_main_axis_values (const DWRITE_FONT_AXIS_VALUE *values, unsigned int count)
 
static void test_CreateFontFaceReference (void)
 
static void get_expected_fontsig (IDWriteFont *font, FONTSIGNATURE *fontsig)
 
static void test_GetFontSignature (void)
 
static void test_font_properties (void)
 
static BOOL has_vertical_glyph_variants (IDWriteFontFace1 *fontface)
 
static void test_HasVerticalGlyphVariants (void)
 
static void test_HasKerningPairs (void)
 
static float get_scaled_metric (const DWRITE_GLYPH_RUN *run, float metric, const DWRITE_FONT_METRICS *m)
 
static void get_expected_glyph_origins (D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *run, D2D1_POINT_2F *origins)
 
static void test_ComputeGlyphOrigins (void)
 
static void test_object_lifetime (void)
 
static struct testowner_object * impl_from_IUnknown (IUnknown *iface)
 
static HRESULT WINAPI testowner_QueryInterface (IUnknown *iface, REFIID riid, void **obj)
 
static ULONG WINAPI testowner_AddRef (IUnknown *iface)
 
static ULONG WINAPI testowner_Release (IUnknown *iface)
 
static void testowner_init (struct testowner_object *object)
 
static void test_inmemory_file_loader (void)
 
static BOOL face_has_table (IDWriteFontFace4 *fontface, UINT32 tag)
 
static DWORD get_sbix_formats (IDWriteFontFace4 *fontface)
 
static DWORD get_cblc_formats (IDWriteFontFace4 *fontface)
 
static DWORD get_face_glyph_image_formats (IDWriteFontFace4 *fontface)
 
static void test_GetGlyphImageFormats (void)
 
static void test_CreateCustomRenderingParams (void)
 
static void test_localfontfileloader (void)
 
static void test_AnalyzeContainerType (void)
 
static void test_fontsetbuilder (void)
 
static void test_font_resource (void)
 
static BOOL get_expected_is_color (IDWriteFontFace2 *fontface)
 
static void test_IsColorFont (void)
 
static void test_GetVerticalGlyphVariants (void)
 
static HANDLE get_collection_expiration_event (IDWriteFontCollection *collection)
 
static void test_expiration_event (void)
 
static void test_family_font_set (void)
 
static void test_system_font_set (void)
 
static void test_CreateFontCollectionFromFontSet (void)
 
static void test_GetMatchingFontsByLOGFONT (void)
 
 START_TEST (font)
 

Variables

static void *static const WCHAR test_fontfile [] = L"wine_test_font.ttf"
 
static const struct IDWriteFontFileEnumeratorVtbl singlefontfileenumeratorvtbl
 
static const struct IDWriteFontCollectionLoaderVtbl resourcecollectionloadervtbl
 
static const IDWriteFontFileStreamVtbl fontdatastreamvtbl
 
static const struct IDWriteFontFileLoaderVtbl resourcefontfileloadervtbl
 
static IDWriteFontFileLoader rloader = { &resourcefontfileloadervtbl }
 
static D2D1_POINT_2F g_startpoints [2]
 
static int g_startpoint_count
 
static const ID2D1SimplifiedGeometrySinkVtbl test_geometrysink_vtbl
 
static const ID2D1SimplifiedGeometrySinkVtbl test_geometrysink2_vtbl
 
static ID2D1SimplifiedGeometrySink test_geomsink = { &test_geometrysink_vtbl }
 
static ID2D1SimplifiedGeometrySink test_geomsink2 = { &test_geometrysink2_vtbl }
 
static const struct IDWriteFontFileEnumeratorVtbl dwritefontfileenumeratorvtbl
 
static const struct IDWriteFontCollectionLoaderVtbl dwritefontcollectionloadervtbl
 
static const struct IDWriteFontFileLoaderVtbl dwritefontfileloadervtbl
 
static struct compatmetrics_test compatmetrics_tests []
 
static BOOL g_is_vista
 
static const struct recommendedmode_test recmode_tests []
 
static const struct recommendedmode_test recmode_tests1 []
 
static const IUnknownVtbl testownervtbl
 

Macro Definition Documentation

◆ CHECK_CALLED

#define CHECK_CALLED (   func)
Value:
do { \
ok(called_ ## func, "expected " #func "\n"); \
expect_ ## func = called_ ## func = FALSE; \
}while(0)
#define FALSE
Definition: types.h:117
GLenum func
Definition: glext.h:6028
#define expect_(expected, got, precision)
Definition: font.c:34

Definition at line 92 of file font.c.

◆ CHECK_EXPECT

#define CHECK_EXPECT (   func)
Value:
do { \
CHECK_EXPECT2(func); \
expect_ ## func = FALSE; \
}while(0)

Definition at line 86 of file font.c.

◆ CHECK_EXPECT2

#define CHECK_EXPECT2 (   func)
Value:
do { \
ok(expect_ ##func, "unexpected call " #func "\n"); \
called_ ## func = TRUE; \
}while(0)
#define TRUE
Definition: types.h:120

Definition at line 80 of file font.c.

◆ check_familymodel

#define check_familymodel (   a,
  b 
)    _check_familymodel(a,b,__LINE__)

Definition at line 587 of file font.c.

◆ CLEAR_CALLED

#define CLEAR_CALLED (   func)     expect_ ## func = called_ ## func = FALSE

Definition at line 98 of file font.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 25 of file font.c.

◆ DEFINE_EXPECT

#define DEFINE_EXPECT (   func)     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE

Definition at line 74 of file font.c.

◆ DELETE_FONTFILE

#define DELETE_FONTFILE (   filename)    _delete_testfontfile(filename, __LINE__)

Definition at line 560 of file font.c.

◆ EXPECT_REF

#define EXPECT_REF (   obj,
  ref 
)    _expect_ref((IUnknown*)obj, ref, __LINE__)

Definition at line 103 of file font.c.

◆ EXPECT_REF_BROKEN

#define EXPECT_REF_BROKEN (   obj,
  ref,
  brokenref 
)    _expect_ref_broken((IUnknown*)obj, ref, brokenref, __LINE__)

Definition at line 112 of file font.c.

◆ GASP_DOGRAY

#define GASP_DOGRAY   0x0002

Definition at line 6775 of file font.c.

◆ GASP_GRIDFIT

#define GASP_GRIDFIT   0x0001

Definition at line 6774 of file font.c.

◆ GASP_SYMMETRIC_GRIDFIT

#define GASP_SYMMETRIC_GRIDFIT   0x0004

Definition at line 6776 of file font.c.

◆ GASP_SYMMETRIC_SMOOTHING

#define GASP_SYMMETRIC_SMOOTHING   0x0008

Definition at line 6777 of file font.c.

◆ GET_BE_DWORD

#define GET_BE_DWORD (   x)    RtlUlongByteSwap(x)

Definition at line 69 of file font.c.

◆ GET_BE_WORD

#define GET_BE_WORD (   x)    RtlUshortByteSwap(x)

Definition at line 68 of file font.c.

◆ GET_LE_DWORD

#define GET_LE_DWORD (   x)    (x)

Definition at line 71 of file font.c.

◆ GET_LE_WORD

#define GET_LE_WORD (   x)    (x)

Definition at line 70 of file font.c.

◆ MS_CBLC_TAG

#define MS_CBLC_TAG   DWRITE_MAKE_OPENTYPE_TAG('C','B','L','C')

Definition at line 52 of file font.c.

◆ MS_CFF2_TAG

#define MS_CFF2_TAG   DWRITE_MAKE_OPENTYPE_TAG('C','F','F','2')

Definition at line 47 of file font.c.

◆ MS_CFF__TAG

#define MS_CFF__TAG   DWRITE_MAKE_OPENTYPE_TAG('C','F','F',' ')

Definition at line 46 of file font.c.

◆ MS_CMAP_TAG

#define MS_CMAP_TAG   DWRITE_MAKE_OPENTYPE_TAG('c','m','a','p')

Definition at line 35 of file font.c.

◆ MS_COLR_TAG

#define MS_COLR_TAG   DWRITE_MAKE_OPENTYPE_TAG('C','O','L','R')

Definition at line 48 of file font.c.

◆ MS_CPAL_TAG

#define MS_CPAL_TAG   DWRITE_MAKE_OPENTYPE_TAG('C','P','A','L')

Definition at line 38 of file font.c.

◆ MS_GASP_TAG

#define MS_GASP_TAG   DWRITE_MAKE_OPENTYPE_TAG('g','a','s','p')

Definition at line 37 of file font.c.

◆ MS_GLYF_TAG

#define MS_GLYF_TAG   DWRITE_MAKE_OPENTYPE_TAG('g','l','y','f')

Definition at line 45 of file font.c.

◆ MS_GSUB_TAG

#define MS_GSUB_TAG   DWRITE_MAKE_OPENTYPE_TAG('G','S','U','B')

Definition at line 43 of file font.c.

◆ MS_HEAD_TAG

#define MS_HEAD_TAG   DWRITE_MAKE_OPENTYPE_TAG('h','e','a','d')

Definition at line 40 of file font.c.

◆ MS_HHEA_TAG

#define MS_HHEA_TAG   DWRITE_MAKE_OPENTYPE_TAG('h','h','e','a')

Definition at line 41 of file font.c.

◆ MS_JPG__TAG

#define MS_JPG__TAG   DWRITE_MAKE_OPENTYPE_TAG('j','p','g',' ')

Definition at line 56 of file font.c.

◆ MS_KERN_TAG

#define MS_KERN_TAG   DWRITE_MAKE_OPENTYPE_TAG('k','e','r','n')

Definition at line 44 of file font.c.

◆ MS_MAXP_TAG

#define MS_MAXP_TAG   DWRITE_MAKE_OPENTYPE_TAG('m','a','x','p')

Definition at line 51 of file font.c.

◆ MS_OS2_TAG

#define MS_OS2_TAG   DWRITE_MAKE_OPENTYPE_TAG('O','S','/','2')

Definition at line 39 of file font.c.

◆ MS_PNG__TAG

#define MS_PNG__TAG   DWRITE_MAKE_OPENTYPE_TAG('p','n','g',' ')

Definition at line 55 of file font.c.

◆ MS_POST_TAG

#define MS_POST_TAG   DWRITE_MAKE_OPENTYPE_TAG('p','o','s','t')

Definition at line 42 of file font.c.

◆ MS_SBIX_TAG

#define MS_SBIX_TAG   DWRITE_MAKE_OPENTYPE_TAG('s','b','i','x')

Definition at line 50 of file font.c.

◆ MS_SVG__TAG

#define MS_SVG__TAG   DWRITE_MAKE_OPENTYPE_TAG('S','V','G',' ')

Definition at line 49 of file font.c.

◆ MS_TIFF_TAG

#define MS_TIFF_TAG   DWRITE_MAKE_OPENTYPE_TAG('t','i','f','f')

Definition at line 57 of file font.c.

◆ MS_VDMX_TAG

#define MS_VDMX_TAG   DWRITE_MAKE_OPENTYPE_TAG('V','D','M','X')

Definition at line 36 of file font.c.

◆ MS_WOF2_TAG

#define MS_WOF2_TAG   DWRITE_MAKE_OPENTYPE_TAG('w','O','F','2')

Definition at line 60 of file font.c.

◆ MS_WOFF_TAG

#define MS_WOFF_TAG   DWRITE_MAKE_OPENTYPE_TAG('w','O','F','F')

Definition at line 59 of file font.c.

◆ round

#define round (   x)    ((int)floor((x) + 0.5))

Definition at line 6139 of file font.c.

◆ SET_EXPECT

#define SET_EXPECT (   func)     do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)

Definition at line 77 of file font.c.

Enumeration Type Documentation

◆ opentype_cmap_table_encoding

Enumerator
OPENTYPE_CMAP_TABLE_ENCODING_SYMBOL 
OPENTYPE_CMAP_TABLE_ENCODING_UNICODE_BMP 
OPENTYPE_CMAP_TABLE_ENCODING_UNICODE_FULL 
OPENTYPE_CMAP_TABLE_ENCODING_SYMBOL 
OPENTYPE_CMAP_TABLE_ENCODING_UNICODE_BMP 
OPENTYPE_CMAP_TABLE_ENCODING_UNICODE_FULL 

Definition at line 438 of file font.c.

439{
443};
@ OPENTYPE_CMAP_TABLE_ENCODING_UNICODE_BMP
Definition: font.c:441
@ OPENTYPE_CMAP_TABLE_ENCODING_SYMBOL
Definition: font.c:440
@ OPENTYPE_CMAP_TABLE_ENCODING_UNICODE_FULL
Definition: font.c:442

◆ opentype_cmap_table_format

Enumerator
OPENTYPE_CMAP_TABLE_SEGMENT_MAPPING 
OPENTYPE_CMAP_TABLE_SEGMENTED_COVERAGE 

Definition at line 445 of file font.c.

446{
449};
@ OPENTYPE_CMAP_TABLE_SEGMENT_MAPPING
Definition: font.c:447
@ OPENTYPE_CMAP_TABLE_SEGMENTED_COVERAGE
Definition: font.c:448

◆ opentype_cmap_table_platform

Enumerator
OPENTYPE_CMAP_TABLE_PLATFORM_WIN 
OPENTYPE_CMAP_TABLE_PLATFORM_WIN 

Definition at line 433 of file font.c.

434{
436};
@ OPENTYPE_CMAP_TABLE_PLATFORM_WIN
Definition: font.c:435

◆ OS2_FSSELECTION

Enumerator
OS2_FSSELECTION_ITALIC 
OS2_FSSELECTION_UNDERSCORE 
OS2_FSSELECTION_NEGATIVE 
OS2_FSSELECTION_OUTLINED 
OS2_FSSELECTION_STRIKEOUT 
OS2_FSSELECTION_BOLD 
OS2_FSSELECTION_REGULAR 
OS2_FSSELECTION_USE_TYPO_METRICS 
OS2_FSSELECTION_WWS 
OS2_FSSELECTION_OBLIQUE 
OS2_FSSELECTION_ITALIC 
OS2_FSSELECTION_UNDERSCORE 
OS2_FSSELECTION_NEGATIVE 
OS2_FSSELECTION_OUTLINED 
OS2_FSSELECTION_STRIKEOUT 
OS2_FSSELECTION_BOLD 
OS2_FSSELECTION_REGULAR 
OS2_FSSELECTION_USE_TYPO_METRICS 
OS2_FSSELECTION_WWS 
OS2_FSSELECTION_OBLIQUE 

Definition at line 207 of file font.c.

207 {
208 OS2_FSSELECTION_ITALIC = 1 << 0,
213 OS2_FSSELECTION_BOLD = 1 << 5,
216 OS2_FSSELECTION_WWS = 1 << 8,
218};
@ OS2_FSSELECTION_STRIKEOUT
Definition: font.c:212
@ OS2_FSSELECTION_NEGATIVE
Definition: font.c:210
@ OS2_FSSELECTION_ITALIC
Definition: font.c:208
@ OS2_FSSELECTION_REGULAR
Definition: font.c:214
@ OS2_FSSELECTION_USE_TYPO_METRICS
Definition: font.c:215
@ OS2_FSSELECTION_OBLIQUE
Definition: font.c:217
@ OS2_FSSELECTION_WWS
Definition: font.c:216
@ OS2_FSSELECTION_UNDERSCORE
Definition: font.c:209
@ OS2_FSSELECTION_BOLD
Definition: font.c:213
@ OS2_FSSELECTION_OUTLINED
Definition: font.c:211

◆ TT_HEAD_MACSTYLE

Enumerator
TT_HEAD_MACSTYLE_BOLD 
TT_HEAD_MACSTYLE_ITALIC 
TT_HEAD_MACSTYLE_UNDERLINE 
TT_HEAD_MACSTYLE_OUTLINE 
TT_HEAD_MACSTYLE_SHADOW 
TT_HEAD_MACSTYLE_CONDENSED 
TT_HEAD_MACSTYLE_EXTENDED 

Definition at line 149 of file font.c.

150{
151 TT_HEAD_MACSTYLE_BOLD = 1 << 0,
158};
@ TT_HEAD_MACSTYLE_EXTENDED
Definition: font.c:157
@ TT_HEAD_MACSTYLE_UNDERLINE
Definition: font.c:153
@ TT_HEAD_MACSTYLE_ITALIC
Definition: font.c:152
@ TT_HEAD_MACSTYLE_OUTLINE
Definition: font.c:154
@ TT_HEAD_MACSTYLE_BOLD
Definition: font.c:151
@ TT_HEAD_MACSTYLE_SHADOW
Definition: font.c:155
@ TT_HEAD_MACSTYLE_CONDENSED
Definition: font.c:156

Function Documentation

◆ _check_familymodel()

static void _check_familymodel ( void *  iface_ptr,
DWRITE_FONT_FAMILY_MODEL  expected_model,
unsigned int  line 
)
static

Definition at line 588 of file font.c.

589{
592
593 if (SUCCEEDED(IUnknown_QueryInterface((IUnknown *)iface_ptr, &IID_IDWriteFontCollection2, (void **)&collection)))
594 {
595 model = IDWriteFontCollection2_GetFontFamilyModel(collection);
596 ok_(__FILE__,line)(model == expected_model, "Unexpected family model %d, expected %d.\n", model, expected_model);
597 IDWriteFontCollection2_Release(collection);
598 }
599}
#define ok_(x1, x2)
Definition: atltest.h:61
DWRITE_FONT_FAMILY_MODEL
Definition: dwrite_3.idl:169
#define SUCCEEDED(hr)
Definition: intsafe.h:50
Definition: parser.c:49

◆ _delete_testfontfile()

static void _delete_testfontfile ( const WCHAR *  filename,
int  line 
)
static

Definition at line 561 of file font.c.

562{
564 ok_(__FILE__,line)(ret, "failed to delete file %s, error %ld\n", wine_dbgstr_w(filename), GetLastError());
565}
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
return ret
Definition: mutex.c:147
unsigned int BOOL
Definition: ntddk_ex.h:94
const char * filename
Definition: ioapi.h:137
#define wine_dbgstr_w
Definition: kernel32.h:34
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

◆ _expect_ref()

static void _expect_ref ( IUnknown *  obj,
ULONG  ref,
int  line 
)
static

Definition at line 104 of file font.c.

105{
106 ULONG rc;
107 IUnknown_AddRef(obj);
108 rc = IUnknown_Release(obj);
109 ok_(__FILE__,line)(rc == ref, "expected refcount %ld, got %ld\n", ref, rc);
110}
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ _expect_ref_broken()

static void _expect_ref_broken ( IUnknown *  obj,
ULONG  ref,
ULONG  brokenref,
int  line 
)
static

Definition at line 113 of file font.c.

114{
115 ULONG rc;
116 IUnknown_AddRef(obj);
117 rc = IUnknown_Release(obj);
118 ok_(__FILE__,line)(rc == ref || broken(rc == brokenref), "expected refcount %ld, got %ld\n", ref, rc);
119}
#define broken(x)
Definition: atltest.h:178

◆ array_reserve()

static void array_reserve ( void **  elements,
size_t *  capacity,
size_t  count,
size_t  size 
)
static

Definition at line 3571 of file font.c.

3572{
3573 size_t new_capacity, max_capacity;
3574 void *new_elements;
3575
3576 if (count <= *capacity)
3577 return;
3578
3579 max_capacity = ~(SIZE_T)0 / size;
3580 if (count > max_capacity)
3581 return;
3582
3583 new_capacity = max(4, *capacity);
3584 while (new_capacity < count && new_capacity <= max_capacity / 2)
3585 new_capacity *= 2;
3586 if (new_capacity < count)
3587 new_capacity = max_capacity;
3588
3589 if (!(new_elements = realloc(*elements, new_capacity * size)))
3590 return;
3591
3592 *elements = new_elements;
3593 *capacity = new_capacity;
3594}
#define realloc
Definition: debug_ros.c:6
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
#define max(a, b)
Definition: svc.c:63
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by opentype_cmap_read_table().

◆ BOOL()

static BOOL ( WINAPI *  pGetFontRealizationInfo)
static

◆ check_font_metrics()

static void check_font_metrics ( const WCHAR *  nameW,
IDWriteFontFace *  fontface,
const DWRITE_FONT_METRICS1 *  expected 
)
static

Definition at line 2127 of file font.c.

2128{
2129 IDWriteFontFace1 *fontface1 = NULL;
2131 DWORD simulations;
2132 BOOL has_metrics1;
2133
2134 has_metrics1 = SUCCEEDED(IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void **)&fontface1));
2135 simulations = IDWriteFontFace_GetSimulations(fontface);
2136
2137 if (fontface1) {
2138 IDWriteFontFace1_GetMetrics(fontface1, &metrics);
2139 IDWriteFontFace1_Release(fontface1);
2140 }
2141 else
2142 IDWriteFontFace_GetMetrics(fontface, (DWRITE_FONT_METRICS *)&metrics);
2143
2145
2146 ok(metrics.designUnitsPerEm == expected->designUnitsPerEm, "designUnitsPerEm %u, expected %u.\n",
2147 metrics.designUnitsPerEm, expected->designUnitsPerEm);
2148 ok(metrics.ascent == expected->ascent, "ascent %u, expected %u.\n", metrics.ascent, expected->ascent);
2149 ok(metrics.descent == expected->descent, "descent %u, expected %u.\n", metrics.descent, expected->descent);
2150 ok(metrics.lineGap == expected->lineGap, "lineGap %d, expected %d.\n", metrics.lineGap, expected->lineGap);
2151 ok(metrics.underlinePosition == expected->underlinePosition, "underlinePosition %d, expected %d.\n",
2152 metrics.underlinePosition, expected->underlinePosition);
2153 ok(metrics.underlineThickness == expected->underlineThickness, "underlineThickness %u, expected %u.\n",
2154 metrics.underlineThickness, expected->underlineThickness);
2155 ok(metrics.strikethroughPosition == expected->strikethroughPosition, "strikethroughPosition %d, expected %d.\n",
2156 metrics.strikethroughPosition, expected->strikethroughPosition);
2157 ok(metrics.strikethroughThickness == expected->strikethroughThickness, "strikethroughThickness %u, "
2158 "expected %u.\n", metrics.strikethroughThickness, expected->strikethroughThickness);
2159
2160 if (has_metrics1)
2161 {
2162 /* For simulated faces metrics are adjusted. Enable tests when exact pattern is understood. */
2163 if (simulations & DWRITE_FONT_SIMULATIONS_OBLIQUE)
2164 {
2166 return;
2167 }
2168
2169 ok(metrics.hasTypographicMetrics == expected->hasTypographicMetrics, "hasTypographicMetrics %d, "
2170 "expected %d.\n", metrics.hasTypographicMetrics, expected->hasTypographicMetrics);
2171 ok(metrics.glyphBoxLeft == expected->glyphBoxLeft, "glyphBoxLeft %d, expected %d.\n",
2172 metrics.glyphBoxLeft, expected->glyphBoxLeft);
2173 ok(metrics.glyphBoxTop == expected->glyphBoxTop, "glyphBoxTop %d, expected %d.\n",
2174 metrics.glyphBoxTop, expected->glyphBoxTop);
2175 ok(metrics.glyphBoxRight == expected->glyphBoxRight, "glyphBoxRight %d, expected %d.\n",
2176 metrics.glyphBoxRight, expected->glyphBoxRight);
2177 ok(metrics.glyphBoxBottom == expected->glyphBoxBottom, "glyphBoxBottom %d, expected %d.\n",
2178 metrics.glyphBoxBottom, expected->glyphBoxBottom);
2179
2180 ok(metrics.subscriptPositionX == expected->subscriptPositionX, "subscriptPositionX %d, expected %d.\n",
2181 metrics.subscriptPositionX, expected->subscriptPositionX);
2182 ok(metrics.subscriptPositionY == expected->subscriptPositionY, "subscriptPositionY %d, expected %d.\n",
2183 metrics.subscriptPositionY, expected->subscriptPositionY);
2184 ok(metrics.subscriptSizeX == expected->subscriptSizeX, "subscriptSizeX %d, expected %d.\n",
2185 metrics.subscriptSizeX, expected->subscriptSizeX);
2186 ok(metrics.subscriptSizeY == expected->subscriptSizeY, "subscriptSizeY %d, expected %d.\n",
2187 metrics.subscriptSizeY, expected->subscriptSizeY);
2188 ok(metrics.superscriptPositionX == expected->superscriptPositionX, "superscriptPositionX %d, expected %d.\n",
2189 metrics.superscriptPositionX, expected->superscriptPositionX);
2190 ok(metrics.superscriptPositionY == expected->superscriptPositionY, "superscriptPositionY %d, expected %d.\n",
2191 metrics.superscriptPositionY, expected->superscriptPositionY);
2192 ok(metrics.superscriptSizeX == expected->superscriptSizeX, "superscriptSizeX %d, expected %d.\n",
2193 metrics.superscriptSizeX, expected->superscriptSizeX);
2194 ok(metrics.superscriptSizeY == expected->superscriptSizeY, "superscriptSizeY %d, expected %d.\n",
2195 metrics.superscriptSizeY, expected->superscriptSizeY);
2196 }
2197
2199}
#define ok(value,...)
Definition: atltest.h:57
static const WCHAR nameW[]
Definition: main.c:49
#define NULL
Definition: types.h:112
@ DWRITE_FONT_SIMULATIONS_OBLIQUE
Definition: dwrite.idl:148
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
Definition: glext.h:11745
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
Definition: test.h:539
BOOL expected
Definition: store.c:2000

Referenced by test_GetMetrics().

◆ create_collection_loader()

static IDWriteFontCollectionLoader * create_collection_loader ( void  )
static

Definition at line 3017 of file font.c.

3018{
3019 struct collection_loader *loader = malloc(sizeof(*loader));
3020
3021 loader->IDWriteFontCollectionLoader_iface.lpVtbl = &dwritefontcollectionloadervtbl;
3022 loader->ref = 1;
3023
3024 return &loader->IDWriteFontCollectionLoader_iface;
3025}
#define malloc
Definition: debug_ros.c:4
static const struct IDWriteFontCollectionLoaderVtbl dwritefontcollectionloadervtbl
Definition: font.c:3010
Definition: loader.c:72
LONG ref
Definition: loader.c:74

Referenced by test_CustomFontCollection().

◆ create_enumerator()

static HRESULT create_enumerator ( IDWriteFontFile *  font_file,
IDWriteFontFileEnumerator **  ret 
)
static

Definition at line 675 of file font.c.

676{
677 struct test_fontenumerator *enumerator;
678
679 if (!(enumerator = calloc(1, sizeof(*enumerator))))
680 return E_OUTOFMEMORY;
681
683 enumerator->ref = 1;
684 enumerator->index = 0;
685 enumerator->font_file = font_file;
686 IDWriteFontFile_AddRef(font_file);
687
688 *ret = &enumerator->IDWriteFontFileEnumerator_iface;
689 return S_OK;
690}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define S_OK
Definition: intsafe.h:52
static const struct IDWriteFontFileEnumeratorVtbl singlefontfileenumeratorvtbl
Definition: font.c:666
#define calloc
Definition: rosglue.h:14
IDWriteFontFileEnumerator IDWriteFontFileEnumerator_iface
Definition: font.c:603
IDWriteFontFile * font_file
Definition: font.c:607

Referenced by resourcecollectionloader_CreateEnumeratorFromKey().

◆ create_factory()

static IDWriteFactory * create_factory ( void  )
static

Definition at line 460 of file font.c.

461{
462 IDWriteFactory *factory = create_factory_iid(&IID_IDWriteFactory);
463 ok(factory != NULL, "Failed to create factory.\n");
464 return factory;
465}
static void * create_factory_iid(REFIID riid)
Definition: font.c:453
Definition: main.c:439

Referenced by START_TEST(), test_ConvertFontFaceToLOGFONT(), test_ConvertFontToLOGFONT(), test_CreateAlphaTexture(), test_CreateBitmapRenderTarget(), test_CreateCustomFontFileReference(), test_CreateCustomRenderingParams(), test_CreateFontFace(), test_CreateFontFaceFromHdc(), test_CreateFontFileReference(), test_CreateFontFromLOGFONT(), test_CreateGlyphRunAnalysis(), test_CreateRenderingParams(), test_CreateStreamFromKey(), test_CustomFontCollection(), test_expiration_event(), test_family_font_set(), test_font_properties(), test_GetAlphaBlendParams(), test_GetCaretMetrics(), test_GetDesignGlyphAdvances(), test_GetDesignGlyphMetrics(), test_GetFaceNames(), test_GetFamilyNames(), test_GetFirstMatchingFont(), test_GetFontFamily(), test_GetFontFromFontFace(), test_GetFontSignature(), test_GetGdiCompatibleGlyphAdvances(), test_GetGdiCompatibleMetrics(), test_GetGdiInterop(), test_GetGlyphCount(), test_GetGlyphImageFormats(), test_GetGlyphRunOutline(), test_GetInformationalStrings(), test_GetKerningPairAdjustments(), test_GetMatchingFonts(), test_GetMetrics(), test_GetPaletteEntries(), test_GetPanose(), test_GetRecommendedRenderingMode(), test_GetSimulations(), test_GetUnicodeRanges(), test_GetVerticalGlyphVariants(), test_HasCharacter(), test_HasKerningPairs(), test_HasVerticalGlyphVariants(), test_IsSymbolFont(), test_localfontfileloader(), test_object_lifetime(), test_ReadFileFragment(), test_system_fontcollection(), and test_TryGetFontTable().

◆ create_factory_iid()

◆ create_fontdatastream()

static HRESULT create_fontdatastream ( LPVOID  data,
UINT  size,
IDWriteFontFileStream **  iface 
)
static

Definition at line 837 of file font.c.

838{
839 struct test_fontdatastream *object = calloc(1, sizeof(*object));
840 if (!object)
841 return E_OUTOFMEMORY;
842
843 object->IDWriteFontFileStream_iface.lpVtbl = &fontdatastreamvtbl;
844 object->ref = 1;
845 object->data = data;
846 object->size = size;
847
848 *iface = &object->IDWriteFontFileStream_iface;
849
850 return S_OK;
851}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static const IDWriteFontFileStreamVtbl fontdatastreamvtbl
Definition: font.c:826

Referenced by resourcefontfileloader_CreateStreamFromKey().

◆ create_fontface()

static IDWriteFontFace * create_fontface ( IDWriteFactory *  factory)
static

Definition at line 467 of file font.c.

468{
469 IDWriteGdiInterop *interop;
470 IDWriteFontFace *fontface;
472 LOGFONTW logfont;
473 HRESULT hr;
474
475 hr = IDWriteFactory_GetGdiInterop(factory, &interop);
476 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
477
478 memset(&logfont, 0, sizeof(logfont));
479 logfont.lfHeight = 12;
480 logfont.lfWidth = 12;
481 logfont.lfWeight = FW_NORMAL;
482 logfont.lfItalic = 1;
483 lstrcpyW(logfont.lfFaceName, L"Tahoma");
484
485 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
486 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
487
488 hr = IDWriteFont_CreateFontFace(font, &fontface);
489 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
490
491 IDWriteFont_Release(font);
492 IDWriteGdiInterop_Release(interop);
493
494 return fontface;
495}
HRESULT hr
Definition: delayimp.cpp:582
#define lstrcpyW
Definition: compat.h:749
#define L(x)
Definition: resources.c:13
Definition: mk_font.cpp:20
#define memset(x, y, z)
Definition: compat.h:39
BYTE lfItalic
Definition: dimm.idl:64
LONG lfHeight
Definition: dimm.idl:59
LONG lfWeight
Definition: dimm.idl:63
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
LONG lfWidth
Definition: dimm.idl:60
#define FW_NORMAL
Definition: wingdi.h:373

◆ create_testfontfile()

static WCHAR * create_testfontfile ( const WCHAR *  filename)
static

Definition at line 535 of file font.c.

536{
537 static WCHAR pathW[MAX_PATH];
538 DWORD written;
539 HANDLE file;
540 HRSRC res;
541 void *ptr;
542
545
547 ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %ld\n", wine_dbgstr_w(pathW),
548 GetLastError());
549
551 ok( res != 0, "couldn't find resource\n" );
554 ok( written == SizeofResource( GetModuleHandleA(NULL), res ), "couldn't write resource\n" );
555 CloseHandle( file );
556
557 return pathW;
558}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
Definition: rw.c:25
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2098
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
GLuint res
Definition: glext.h:9613
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define CREATE_ALWAYS
Definition: disk.h:72
static PVOID ptr
Definition: dispmode.c:27
static const WCHAR pathW[]
Definition: path.c:2368
#define GENERIC_WRITE
Definition: nt_native.h:90
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
short WCHAR
Definition: pedump.c:58
#define RT_RCDATA
Definition: pedump.c:372
Definition: fci.c:123
const char * LPCSTR
Definition: typedefs.h:52

Referenced by test_CreateCustomFontFileReference(), test_CreateFontCollectionFromFontSet(), test_CreateFontFace(), test_CreateFontFaceFromHdc(), test_CreateFontFaceReference(), test_CreateFontFileReference(), test_CreateStreamFromKey(), test_fontsetbuilder(), test_GetCaretMetrics(), test_GetDesignGlyphAdvances(), test_GetDesignGlyphMetrics(), test_GetFontFromFontFace(), test_GetGlyphCount(), test_GetGlyphRunOutline(), test_GetKerningPairAdjustments(), test_localfontfileloader(), test_long_name(), test_ReadFileFragment(), and test_TryGetFontTable().

◆ DEFINE_EXPECT()

DEFINE_EXPECT ( setfillmode  )

◆ face_has_table()

static BOOL face_has_table ( IDWriteFontFace4 *  fontface,
UINT32  tag 
)
static

Definition at line 9239 of file font.c.

9240{
9241 BOOL exists = FALSE;
9242 const void *data;
9243 void *context;
9244 UINT32 size;
9245 HRESULT hr;
9246
9247 hr = IDWriteFontFace4_TryGetFontTable(fontface, tag, &data, &size, &context, &exists);
9248 ok(hr == S_OK, "TryGetFontTable() failed, %#lx\n", hr);
9249 if (exists)
9250 IDWriteFontFace4_ReleaseFontTable(fontface, context);
9251
9252 return exists;
9253}
Definition: http.c:7252
Definition: ecma_167.h:138
uint32_t UINT32
Definition: typedefs.h:59

Referenced by get_face_glyph_image_formats().

◆ find_vdmx_group()

static const struct VDMX_group * find_vdmx_group ( const struct VDMX_Header *  hdr)
static

Definition at line 6170 of file font.c.

6171{
6172 WORD num_ratios, i, group_offset = 0;
6173 struct VDMX_Ratio *ratios = (struct VDMX_Ratio*)(hdr + 1);
6174 BYTE dev_x_ratio = 1, dev_y_ratio = 1;
6175
6176 num_ratios = GET_BE_WORD(hdr->numRatios);
6177
6178 for (i = 0; i < num_ratios; i++)
6179 {
6180 if (!ratios[i].bCharSet) continue;
6181
6182 if ((ratios[i].xRatio == 0 && ratios[i].yStartRatio == 0 &&
6183 ratios[i].yEndRatio == 0) ||
6184 (ratios[i].xRatio == dev_x_ratio && ratios[i].yStartRatio <= dev_y_ratio &&
6185 ratios[i].yEndRatio >= dev_y_ratio))
6186 {
6187 group_offset = GET_BE_WORD(*((WORD *)(ratios + num_ratios) + i));
6188 break;
6189 }
6190 }
6191 if (group_offset)
6192 return (const struct VDMX_group *)((BYTE *)hdr + group_offset);
6193 return NULL;
6194}
#define GET_BE_WORD(x)
Definition: font.c:108
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
char hdr[14]
Definition: iptest.cpp:33
BYTE bCharSet
Definition: font.c:6150
BYTE yStartRatio
Definition: font.c:6152
BYTE xRatio
Definition: font.c:6151
BYTE yEndRatio
Definition: font.c:6153
unsigned char BYTE
Definition: xxhash.c:193

Referenced by test_gdicompat_metrics().

◆ float_eq()

static BOOL float_eq ( FLOAT  left,
FLOAT  right 
)
inlinestatic

Definition at line 7209 of file font.c.

7210{
7211 int x = *(int *)&left;
7212 int y = *(int *)&right;
7213
7214 if (x < 0)
7215 x = INT_MIN - x;
7216 if (y < 0)
7217 y = INT_MIN - y;
7218
7219 return abs(x - y) <= 8;
7220}
#define INT_MIN
Definition: limits.h:25
#define abs(i)
Definition: fconv.c:206
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726

Referenced by test_GetAlphaBlendParams().

◆ fontcollectionloader_AddRef()

static ULONG WINAPI fontcollectionloader_AddRef ( IDWriteFontCollectionLoader *  iface)
static

Definition at line 2985 of file font.c.

2986{
2989}
#define InterlockedIncrement
Definition: armddk.h:53
static struct collection_loader * impl_from_IDWriteFontCollectionLoader(IDWriteFontCollectionLoader *iface)
Definition: font.c:2964

◆ fontcollectionloader_CreateEnumeratorFromKey()

static HRESULT WINAPI fontcollectionloader_CreateEnumeratorFromKey ( IDWriteFontCollectionLoader *  iface,
IDWriteFactory *  factory,
const void *  key,
UINT32  key_size,
IDWriteFontFileEnumerator **  ret 
)
static

Definition at line 3002 of file font.c.

3004{
3006 *ret = &enumerator;
3007 return S_OK;
3008}
static const struct IDWriteFontFileEnumeratorVtbl dwritefontfileenumeratorvtbl
Definition: font.c:2949

◆ fontcollectionloader_QueryInterface()

static HRESULT WINAPI fontcollectionloader_QueryInterface ( IDWriteFontCollectionLoader *  iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 2969 of file font.c.

2970{
2972
2973 if (IsEqualIID(&IID_IDWriteFontCollectionLoader, riid) ||
2975 {
2976 *obj = &loader->IDWriteFontCollectionLoader_iface;
2977 IDWriteFontCollectionLoader_AddRef(iface);
2978 return S_OK;
2979 }
2980
2981 *obj = NULL;
2982 return E_NOINTERFACE;
2983}
const GUID IID_IUnknown
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ fontcollectionloader_Release()

static ULONG WINAPI fontcollectionloader_Release ( IDWriteFontCollectionLoader *  iface)
static

Definition at line 2991 of file font.c.

2992{
2995
2996 if (!ref)
2997 free(loader);
2998
2999 return ref;
3000}
#define InterlockedDecrement
Definition: armddk.h:52
#define free
Definition: debug_ros.c:5

◆ fontdatastream_AddRef()

static ULONG WINAPI fontdatastream_AddRef ( IDWriteFontFileStream *  iface)
static

Definition at line 775 of file font.c.

776{
779 return ref;
780}
static struct dwrite_localfontfilestream * impl_from_IDWriteFontFileStream(IDWriteFontFileStream *iface)
Definition: font.c:5637

◆ fontdatastream_GetFileSize()

static HRESULT WINAPI fontdatastream_GetFileSize ( IDWriteFontFileStream *  iface,
UINT64 *  size 
)
static

Definition at line 814 of file font.c.

815{
817 *size = This->size;
818 return S_OK;
819}

◆ fontdatastream_GetLastWriteTime()

static HRESULT WINAPI fontdatastream_GetLastWriteTime ( IDWriteFontFileStream *  iface,
UINT64 *  last_writetime 
)
static

Definition at line 821 of file font.c.

822{
823 return E_NOTIMPL;
824}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ fontdatastream_QueryInterface()

static HRESULT WINAPI fontdatastream_QueryInterface ( IDWriteFontFileStream *  iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 763 of file font.c.

764{
765 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteFontFileStream))
766 {
767 *obj = iface;
768 IDWriteFontFileStream_AddRef(iface);
769 return S_OK;
770 }
771 *obj = NULL;
772 return E_NOINTERFACE;
773}

◆ fontdatastream_ReadFileFragment()

static HRESULT WINAPI fontdatastream_ReadFileFragment ( IDWriteFontFileStream *  iface,
void const **  fragment_start,
UINT64  offset,
UINT64  fragment_size,
void **  fragment_context 
)
static

Definition at line 793 of file font.c.

794{
796 *fragment_context = NULL;
797 if (offset+fragment_size > This->size)
798 {
799 *fragment_start = NULL;
800 return E_FAIL;
801 }
802 else
803 {
804 *fragment_start = (BYTE*)This->data + offset;
805 return S_OK;
806 }
807}
#define E_FAIL
Definition: ddrawi.h:102
GLintptr offset
Definition: glext.h:5920

◆ fontdatastream_Release()

static ULONG WINAPI fontdatastream_Release ( IDWriteFontFileStream *  iface)
static

Definition at line 782 of file font.c.

783{
786
787 if (!refcount)
788 free(stream);
789
790 return refcount;
791}
Definition: parse.h:23

◆ fontdatastream_ReleaseFileFragment()

static void WINAPI fontdatastream_ReleaseFileFragment ( IDWriteFontFileStream *  iface,
void *  fragment_context 
)
static

Definition at line 809 of file font.c.

810{
811 /* Do Nothing */
812}

◆ fontface_get_expected_unicode_ranges()

static UINT32 fontface_get_expected_unicode_ranges ( IDWriteFontFace1 *  fontface,
DWRITE_UNICODE_RANGE **  out 
)
static

Definition at line 3703 of file font.c.

3704{
3705 struct dwrite_fonttable cmap;
3706 DWRITE_UNICODE_RANGE *ranges;
3707 UINT32 i, j, count;
3708 BOOL exists;
3709 HRESULT hr;
3710
3711 *out = NULL;
3712
3713 hr = IDWriteFontFace1_TryGetFontTable(fontface, MS_CMAP_TAG, (const void **)&cmap.data,
3714 &cmap.size, &cmap.context, &exists);
3715 if (FAILED(hr) || !exists)
3716 return 0;
3717
3718 count = opentype_cmap_get_unicode_ranges(&cmap, &ranges);
3719 IDWriteFontFace1_ReleaseFontTable(fontface, cmap.context);
3720
3721 *out = malloc(count * sizeof(**out));
3722
3723 /* Eliminate duplicates and merge ranges together. */
3724 for (i = 0, j = 0; i < count; ++i) {
3725 if (j) {
3726 DWRITE_UNICODE_RANGE *prev = &(*out)[j-1];
3727 /* Merge adjacent ranges. */
3728 if (ranges[i].first == prev->last + 1) {
3729 prev->last = ranges[i].last;
3730 continue;
3731 }
3732 }
3733 (*out)[j++] = ranges[i];
3734 }
3735
3736 free(ranges);
3737
3738 return j;
3739}
HRESULT opentype_cmap_get_unicode_ranges(const struct dwrite_cmap *cmap, unsigned int max_count, DWRITE_UNICODE_RANGE *ranges, unsigned int *count)
Definition: opentype.c:1943
const GLint * first
Definition: glext.h:5794
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define FAILED(hr)
Definition: intsafe.h:51
#define MS_CMAP_TAG
Definition: font.c:35
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

Referenced by test_GetUnicodeRanges().

◆ fontfileenumerator_AddRef()

static ULONG WINAPI fontfileenumerator_AddRef ( IDWriteFontFileEnumerator *  iface)
static

Definition at line 2927 of file font.c.

2928{
2929 return 2;
2930}

◆ fontfileenumerator_GetCurrentFontFile()

static HRESULT WINAPI fontfileenumerator_GetCurrentFontFile ( IDWriteFontFileEnumerator *  iface,
IDWriteFontFile **  file 
)
static

Definition at line 2937 of file font.c.

2938{
2939 *file = NULL;
2940 return E_FAIL;
2941}

◆ fontfileenumerator_MoveNext()

static HRESULT WINAPI fontfileenumerator_MoveNext ( IDWriteFontFileEnumerator *  iface,
BOOL *  current 
)
static

Definition at line 2943 of file font.c.

2944{
2945 *current = FALSE;
2946 return S_OK;
2947}
struct task_struct * current
Definition: linux.c:32

◆ fontfileenumerator_QueryInterface()

static HRESULT WINAPI fontfileenumerator_QueryInterface ( IDWriteFontFileEnumerator *  iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 2916 of file font.c.

2917{
2918 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteFontFileEnumerator))
2919 {
2920 *obj = iface;
2921 IDWriteFontFileEnumerator_AddRef(iface);
2922 return S_OK;
2923 }
2924 return E_NOINTERFACE;
2925}

◆ fontfileenumerator_Release()

static ULONG WINAPI fontfileenumerator_Release ( IDWriteFontFileEnumerator *  iface)
static

Definition at line 2932 of file font.c.

2933{
2934 return 1;
2935}

◆ fontfileloader_AddRef()

static ULONG WINAPI fontfileloader_AddRef ( IDWriteFontFileLoader *  iface)
static

Definition at line 3221 of file font.c.

3222{
3223 return 2;
3224}

◆ fontfileloader_CreateStreamFromKey()

static HRESULT WINAPI fontfileloader_CreateStreamFromKey ( IDWriteFontFileLoader *  iface,
const void *  ref_key,
UINT32  key_size,
IDWriteFontFileStream **  stream 
)
static

Definition at line 3231 of file font.c.

3233{
3234 return 0x8faecafe;
3235}

◆ fontfileloader_QueryInterface()

static HRESULT WINAPI fontfileloader_QueryInterface ( IDWriteFontFileLoader *  iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 3208 of file font.c.

3209{
3210 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteFontFileLoader))
3211 {
3212 *obj = iface;
3213 IDWriteFontFileLoader_AddRef(iface);
3214 return S_OK;
3215 }
3216
3217 *obj = NULL;
3218 return E_NOINTERFACE;
3219}

◆ fontfileloader_Release()

static ULONG WINAPI fontfileloader_Release ( IDWriteFontFileLoader *  iface)
static

Definition at line 3226 of file font.c.

3227{
3228 return 1;
3229}

◆ get_cblc_formats()

static DWORD get_cblc_formats ( IDWriteFontFace4 *  fontface)
static

Definition at line 9322 of file font.c.

9323{
9325 struct dwrite_fonttable cblc;
9326 unsigned int i, num_sizes;
9327 BOOL exists = FALSE;
9328 DWORD ret = 0;
9329 HRESULT hr;
9330
9331 hr = IDWriteFontFace4_TryGetFontTable(fontface, MS_CBLC_TAG, (const void **)&cblc.data, &cblc.size, &cblc.context, &exists);
9332 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
9333 ok(exists, "Expected CBLC table.\n");
9334
9335 if (!exists)
9336 return 0;
9337
9338 num_sizes = table_read_be_dword(&cblc, NULL, FIELD_OFFSET(struct cblc_header, numSizes));
9339 if (!(sizes = table_read_ensure(&cblc, sizeof(struct cblc_header), num_sizes * sizeof(*sizes))))
9340 {
9341 skip("Malformed CBLC table.\n");
9342 num_sizes = 0;
9343 }
9344
9345 for (i = 0; i < num_sizes; ++i)
9346 {
9347 BYTE bpp = sizes[i].bitDepth;
9348 if (bpp == 1 || bpp == 2 || bpp == 4 || bpp == 8)
9350 else if (bpp == 32)
9352
9354 break;
9355 }
9356
9357 IDWriteFontFace4_ReleaseFontTable(fontface, cblc.context);
9358
9359 return ret;
9360}
#define skip(...)
Definition: atltest.h:64
@ DWRITE_GLYPH_IMAGE_FORMATS_PREMULTIPLIED_B8G8R8A8
Definition: dcommon.idl:52
@ DWRITE_GLYPH_IMAGE_FORMATS_PNG
Definition: dcommon.idl:49
static DWORD table_read_be_dword(const struct dwrite_fonttable *table, void *ptr, DWORD offset)
Definition: font.c:3557
#define MS_CBLC_TAG
Definition: font.c:52
static const void * table_read_ensure(const struct dwrite_fonttable *table, unsigned int offset, unsigned int size)
Definition: font.c:3535
static const struct @663 sizes[]
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
ULONG bpp[]
Definition: xlate.c:19

Referenced by get_face_glyph_image_formats().

◆ get_collection_expiration_event()

static HANDLE get_collection_expiration_event ( IDWriteFontCollection *  collection)
static

Definition at line 10171 of file font.c.

10172{
10173 IDWriteFontCollection3 *collection3;
10174 HANDLE event;
10175 HRESULT hr;
10176
10177 hr = IDWriteFontCollection_QueryInterface(collection, &IID_IDWriteFontCollection3, (void **)&collection3);
10178 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10179 event = IDWriteFontCollection3_GetExpirationEvent(collection3);
10180 IDWriteFontCollection3_Release(collection3);
10181
10182 return event;
10183}
Definition: filter.c:185

Referenced by test_expiration_event().

◆ get_combined_font_name()

static void get_combined_font_name ( const WCHAR *  familyW,
const WCHAR *  faceW,
WCHAR *  nameW 
)
static

Definition at line 567 of file font.c.

568{
569 lstrcpyW(nameW, familyW);
570 lstrcatW(nameW, L" ");
571 lstrcatW(nameW, faceW);
572}

Referenced by test_ConvertFontFaceToLOGFONT(), and test_GetMetrics().

◆ get_enus_string()

static void get_enus_string ( IDWriteLocalizedStrings *  strings,
WCHAR *  buff,
UINT32  size 
)
static

Definition at line 2201 of file font.c.

2202{
2203 BOOL exists = FALSE;
2204 UINT32 index;
2205 HRESULT hr;
2206
2207 hr = IDWriteLocalizedStrings_FindLocaleName(strings, L"en-us", &index, &exists);
2208 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2209 if (!exists)
2210 index = 0;
2211 hr = IDWriteLocalizedStrings_GetString(strings, index, buff, size);
2212 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2213}
#define index(s, c)
Definition: various.h:29
GLsizei const GLchar *const * strings
Definition: glext.h:7622
GLuint index
Definition: glext.h:6031
static const char *static const char const char DWORD void DWORD *static const char const char DWORD void DWORD *static const char DWORD DWORD void * buff
Definition: shcore.c:41

Referenced by test_ConvertFontFaceToLOGFONT(), test_ConvertFontToLOGFONT(), test_GetFontSignature(), test_GetGlyphImageFormats(), test_GetMetrics(), test_GetPanose(), test_GetUnicodeRanges(), test_HasKerningPairs(), test_HasVerticalGlyphVariants(), test_IsColorFont(), test_IsMonospacedFont(), and test_IsSymbolFont().

◆ get_expected_font_metrics()

static void get_expected_font_metrics ( IDWriteFontFace *  fontface,
DWRITE_FONT_METRICS1 *  metrics 
)
static

Definition at line 2033 of file font.c.

2034{
2035 void *os2_context, *head_context, *post_context, *hhea_context;
2036 const struct tt_os2 *tt_os2;
2037 const TT_HEAD *tt_head;
2038 const TT_POST *tt_post;
2039 const TT_HHEA *tt_hhea;
2040 UINT32 size;
2041 BOOL exists;
2042 HRESULT hr;
2043
2044 memset(metrics, 0, sizeof(*metrics));
2045
2046 hr = IDWriteFontFace_TryGetFontTable(fontface, MS_OS2_TAG, (const void **)&tt_os2, &size, &os2_context, &exists);
2047 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2048 hr = IDWriteFontFace_TryGetFontTable(fontface, MS_HEAD_TAG, (const void**)&tt_head, &size, &head_context, &exists);
2049 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2050 hr = IDWriteFontFace_TryGetFontTable(fontface, MS_HHEA_TAG, (const void**)&tt_hhea, &size, &hhea_context, &exists);
2051 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2052 hr = IDWriteFontFace_TryGetFontTable(fontface, MS_POST_TAG, (const void**)&tt_post, &size, &post_context, &exists);
2053 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2054
2055 if (tt_head) {
2056 metrics->designUnitsPerEm = GET_BE_WORD(tt_head->unitsPerEm);
2057 metrics->glyphBoxLeft = GET_BE_WORD(tt_head->xMin);
2058 metrics->glyphBoxTop = GET_BE_WORD(tt_head->yMax);
2059 metrics->glyphBoxRight = GET_BE_WORD(tt_head->xMax);
2060 metrics->glyphBoxBottom = GET_BE_WORD(tt_head->yMin);
2061 }
2062
2063 if (tt_os2) {
2067 metrics->descent = descent < 0 ? -descent : 0;
2069 metrics->hasTypographicMetrics = TRUE;
2070 }
2071 else {
2073 /* Some fonts have usWinDescent value stored as signed short, which could be wrongly
2074 interpreted as large unsigned value. */
2076
2077 if (tt_hhea) {
2078 SHORT descender = (SHORT)GET_BE_WORD(tt_hhea->descender);
2079 INT32 linegap;
2080
2081 linegap = GET_BE_WORD(tt_hhea->ascender) + abs(descender) + GET_BE_WORD(tt_hhea->linegap) -
2082 metrics->ascent - metrics->descent;
2083 metrics->lineGap = linegap > 0 ? linegap : 0;
2084 }
2085 }
2086
2087 metrics->strikethroughPosition = GET_BE_WORD(tt_os2->yStrikeoutPosition);
2088 metrics->strikethroughThickness = GET_BE_WORD(tt_os2->yStrikeoutSize);
2089
2090 metrics->subscriptPositionX = GET_BE_WORD(tt_os2->ySubscriptXOffset);
2091 metrics->subscriptPositionY = -GET_BE_WORD(tt_os2->ySubscriptYOffset);
2092 metrics->subscriptSizeX = GET_BE_WORD(tt_os2->ySubscriptXSize);
2093 metrics->subscriptSizeY = GET_BE_WORD(tt_os2->ySubscriptYSize);
2094 metrics->superscriptPositionX = GET_BE_WORD(tt_os2->ySuperscriptXOffset);
2095 metrics->superscriptPositionY = GET_BE_WORD(tt_os2->ySuperscriptYOffset);
2096 metrics->superscriptSizeX = GET_BE_WORD(tt_os2->ySuperscriptXSize);
2097 metrics->superscriptSizeY = GET_BE_WORD(tt_os2->ySuperscriptYSize);
2098 }
2099 else {
2100 metrics->strikethroughPosition = metrics->designUnitsPerEm / 3;
2101 if (tt_hhea) {
2102 metrics->ascent = GET_BE_WORD(tt_hhea->ascender);
2104 }
2105 }
2106
2107 if (tt_post) {
2108 metrics->underlinePosition = GET_BE_WORD(tt_post->underlinePosition);
2109 metrics->underlineThickness = GET_BE_WORD(tt_post->underlineThickness);
2110 }
2111
2112 if (metrics->underlineThickness == 0)
2113 metrics->underlineThickness = metrics->designUnitsPerEm / 14;
2114 if (metrics->strikethroughThickness == 0)
2115 metrics->strikethroughThickness = metrics->underlineThickness;
2116
2117 if (tt_os2)
2118 IDWriteFontFace_ReleaseFontTable(fontface, os2_context);
2119 if (tt_head)
2120 IDWriteFontFace_ReleaseFontTable(fontface, head_context);
2121 if (tt_hhea)
2122 IDWriteFontFace_ReleaseFontTable(fontface, hhea_context);
2123 if (tt_post)
2124 IDWriteFontFace_ReleaseFontTable(fontface, post_context);
2125}
#define MS_HHEA_TAG
Definition: font.c:116
#define MS_OS2_TAG
Definition: font.c:115
#define MS_POST_TAG
Definition: font.c:42
#define MS_HEAD_TAG
Definition: font.c:40
short SHORT
Definition: pedump.c:59
Definition: font.c:128
Definition: font.c:86
Definition: font.c:220
SHORT yMin
Definition: opentype.c:147
SHORT yMax
Definition: opentype.c:149
SHORT xMin
Definition: opentype.c:146
USHORT unitsPerEm
Definition: opentype.c:143
SHORT xMax
Definition: opentype.c:148
int16_t descender
Definition: opentype.c:233
int16_t linegap
Definition: opentype.c:234
int16_t ascender
Definition: opentype.c:232
USHORT sTypoAscender
Definition: opentype.c:212
USHORT fsSelection
Definition: opentype.c:205
SHORT yStrikeoutPosition
Definition: opentype.c:197
USHORT usWinAscent
Definition: opentype.c:215
SHORT ySubscriptYOffset
Definition: opentype.c:191
SHORT ySuperscriptXSize
Definition: opentype.c:192
USHORT sTypoLineGap
Definition: opentype.c:214
SHORT ySubscriptYSize
Definition: opentype.c:189
SHORT ySubscriptXSize
Definition: opentype.c:188
USHORT sTypoDescender
Definition: opentype.c:213
SHORT ySuperscriptXOffset
Definition: opentype.c:194
SHORT ySubscriptXOffset
Definition: opentype.c:190
USHORT usWinDescent
Definition: opentype.c:216
SHORT ySuperscriptYOffset
Definition: opentype.c:195
SHORT ySuperscriptYSize
Definition: opentype.c:193
SHORT yStrikeoutSize
Definition: opentype.c:196
Definition: opentype.c:169
int16_t underlinePosition
Definition: opentype.c:172
int16_t underlineThickness
Definition: opentype.c:173
int32_t INT32
Definition: typedefs.h:58

Referenced by test_GetMetrics().

◆ get_expected_fontsig()

static void get_expected_fontsig ( IDWriteFont *  font,
FONTSIGNATURE *  fontsig 
)
static

Definition at line 8210 of file font.c.

8211{
8212 struct dwrite_fonttable os2;
8213 IDWriteFontFace *fontface;
8214 WORD version;
8215 BOOL exists;
8216 HRESULT hr;
8217
8218 memset(fontsig, 0, sizeof(*fontsig));
8219
8220 hr = IDWriteFont_CreateFontFace(font, &fontface);
8221 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8222
8223 hr = IDWriteFontFace_TryGetFontTable(fontface, MS_OS2_TAG, (const void **)&os2.data, &os2.size, &os2.context, &exists);
8224 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8225
8226 if (os2.data)
8227 {
8228 fontsig->fsUsb[0] = table_read_be_dword(&os2, NULL, FIELD_OFFSET(struct tt_os2, ulUnicodeRange1));
8229 fontsig->fsUsb[1] = table_read_be_dword(&os2, NULL, FIELD_OFFSET(struct tt_os2, ulUnicodeRange2));
8230 fontsig->fsUsb[2] = table_read_be_dword(&os2, NULL, FIELD_OFFSET(struct tt_os2, ulUnicodeRange3));
8231 fontsig->fsUsb[3] = table_read_be_dword(&os2, NULL, FIELD_OFFSET(struct tt_os2, ulUnicodeRange4));
8232
8234 if (version == 0)
8235 {
8236 fontsig->fsCsb[0] = 0;
8237 fontsig->fsCsb[1] = 0;
8238 }
8239 else
8240 {
8241 fontsig->fsCsb[0] = table_read_be_dword(&os2, NULL, FIELD_OFFSET(struct tt_os2, ulCodePageRange1));
8242 fontsig->fsCsb[1] = table_read_be_dword(&os2, NULL, FIELD_OFFSET(struct tt_os2, ulCodePageRange2));
8243 }
8244
8245 IDWriteFontFace_ReleaseFontTable(fontface, os2.context);
8246 }
8247
8248 IDWriteFontFace_Release(fontface);
8249}
static const WCHAR version[]
Definition: asmname.c:66
static WORD table_read_be_word(const struct dwrite_fonttable *table, void *ptr, DWORD offset)
Definition: font.c:3543

Referenced by test_GetFontSignature().

◆ get_expected_glyph_origins()

static void get_expected_glyph_origins ( D2D1_POINT_2F  baseline_origin,
const DWRITE_GLYPH_RUN *  run,
D2D1_POINT_2F *  origins 
)
static

Definition at line 8603 of file font.c.

8605{
8606 DWRITE_GLYPH_METRICS glyph_metrics[2];
8608 unsigned int i;
8609 HRESULT hr;
8610
8611 IDWriteFontFace_GetMetrics(run->fontFace, &metrics);
8612
8613 hr = IDWriteFontFace_GetDesignGlyphMetrics(run->fontFace, run->glyphIndices, run->glyphCount, glyph_metrics,
8614 run->isSideways);
8615 ok(hr == S_OK, "Failed to get glyph metrics, hr %#lx.\n", hr);
8616
8617 if (run->bidiLevel & 1)
8618 {
8619 float advance;
8620
8621 advance = get_scaled_metric(run, run->isSideways ? glyph_metrics[0].advanceHeight :
8622 glyph_metrics[0].advanceWidth, &metrics);
8623
8624 baseline_origin.x -= advance;
8625
8626 for (i = 0; i < run->glyphCount; ++i)
8627 {
8628 origins[i] = baseline_origin;
8629
8630 if (run->isSideways)
8631 {
8632 origins[i].x += get_scaled_metric(run, glyph_metrics[i].verticalOriginY, &metrics);
8633 origins[i].y += metrics.designUnitsPerEm / (4.0f * run->fontEmSize);
8634 }
8635
8636 origins[i].x -= run->glyphOffsets[i].advanceOffset;
8637 origins[i].y -= run->glyphOffsets[i].ascenderOffset;
8638
8639 baseline_origin.x -= run->glyphAdvances[i];
8640 }
8641 }
8642 else
8643 {
8644 for (i = 0; i < run->glyphCount; ++i)
8645 {
8646 origins[i] = baseline_origin;
8647
8648 if (run->isSideways)
8649 {
8650 origins[i].x += get_scaled_metric(run, glyph_metrics[i].verticalOriginY, &metrics);
8651 origins[i].y += metrics.designUnitsPerEm / (4.0f * run->fontEmSize);
8652 }
8653
8654 origins[i].x += run->glyphOffsets[i].advanceOffset;
8655 origins[i].y -= run->glyphOffsets[i].ascenderOffset;
8656
8657 baseline_origin.x += run->glyphAdvances[i];
8658 }
8659 }
8660}
_STLP_MOVE_TO_STD_NAMESPACE void _STLP_CALL advance(_InputIterator &__i, _Distance __n)
static float get_scaled_metric(const DWRITE_GLYPH_RUN *run, float metric, const DWRITE_FONT_METRICS *m)
Definition: font.c:8598
IDWriteFontFace * fontFace
Definition: dwrite.idl:405
DWRITE_GLYPH_OFFSET const * glyphOffsets
Definition: dwrite.idl:410
UINT32 bidiLevel
Definition: dwrite.idl:412
FLOAT fontEmSize
Definition: dwrite.idl:406
UINT16 const * glyphIndices
Definition: dwrite.idl:408
FLOAT const * glyphAdvances
Definition: dwrite.idl:409
UINT32 glyphCount
Definition: dwrite.idl:407

Referenced by test_ComputeGlyphOrigins().

◆ get_expected_gridfit_mode()

static DWRITE_GRID_FIT_MODE get_expected_gridfit_mode ( FLOAT  emsize,
WORD  gasp,
DWRITE_MEASURING_MODE  mode,
DWRITE_OUTLINE_THRESHOLD  threshold 
)
static

Definition at line 6816 of file font.c.

6818{
6819 static const FLOAT aa_threshold = 100.0f;
6820 static const FLOAT a_threshold = 350.0f;
6821 FLOAT v;
6822
6823 v = threshold == DWRITE_OUTLINE_THRESHOLD_ANTIALIASED ? aa_threshold : a_threshold;
6824 if (emsize >= v)
6826
6829
6831}
@ DWRITE_MEASURING_MODE_GDI_CLASSIC
Definition: dcommon.idl:38
@ DWRITE_MEASURING_MODE_GDI_NATURAL
Definition: dcommon.idl:39
@ DWRITE_OUTLINE_THRESHOLD_ANTIALIASED
Definition: dwrite_1.idl:408
@ DWRITE_GRID_FIT_MODE_DISABLED
Definition: dwrite_2.idl:30
@ DWRITE_GRID_FIT_MODE_ENABLED
Definition: dwrite_2.idl:31
const GLdouble * v
Definition: gl.h:2040
GLenum mode
Definition: glext.h:6217
#define GASP_SYMMETRIC_GRIDFIT
Definition: font.c:6776
#define GASP_GRIDFIT
Definition: font.c:6774
float FLOAT
Definition: typedefs.h:69

Referenced by test_GetRecommendedRenderingMode().

◆ get_expected_is_color()

static BOOL get_expected_is_color ( IDWriteFontFace2 *  fontface)
static

Definition at line 10026 of file font.c.

10027{
10028 void *context;
10029 UINT32 size;
10030 BOOL exists;
10031 void *data;
10032 HRESULT hr;
10033
10034 hr = IDWriteFontFace2_TryGetFontTable(fontface, MS_CPAL_TAG, (const void **)&data, &size, &context, &exists);
10035 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10036 if (context)
10037 IDWriteFontFace2_ReleaseFontTable(fontface, context);
10038
10039 if (exists)
10040 {
10041 hr = IDWriteFontFace2_TryGetFontTable(fontface, MS_COLR_TAG, (const void **)&data, &size, &context, &exists);
10042 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10043 if (context)
10044 IDWriteFontFace2_ReleaseFontTable(fontface, context);
10045 }
10046
10047 return exists;
10048}
#define MS_CPAL_TAG
Definition: font.c:40
#define MS_COLR_TAG
Definition: font.c:41

Referenced by test_IsColorFont().

◆ get_expected_is_monospaced()

static BOOL get_expected_is_monospaced ( IDWriteFontFace1 *  fontface,
const DWRITE_PANOSE *  panose 
)
static

Definition at line 5092 of file font.c.

5093{
5094 BOOL exists, is_monospaced = FALSE;
5095 const TT_POST *tt_post;
5096 void *post_context;
5097 UINT32 size;
5098 HRESULT hr;
5099
5100 hr = IDWriteFontFace1_TryGetFontTable(fontface, MS_POST_TAG, (const void **)&tt_post, &size,
5101 &post_context, &exists);
5102 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5103
5104 if (tt_post)
5105 {
5106 is_monospaced = !!tt_post->fixed_pitch;
5107 IDWriteFontFace1_ReleaseFontTable(fontface, post_context);
5108 }
5109
5110 if (!is_monospaced)
5111 is_monospaced |= panose->text.proportion == DWRITE_PANOSE_PROPORTION_MONOSPACED;
5112
5113 return is_monospaced;
5114}
@ DWRITE_PANOSE_PROPORTION_MONOSPACED
Definition: dwrite_1.idl:83
uint32_t fixed_pitch
Definition: opentype.c:174
struct DWRITE_PANOSE::@3545 text

Referenced by test_IsMonospacedFont().

◆ get_expected_is_symbol()

static BOOL get_expected_is_symbol ( IDWriteFontFace *  fontface)
static

Definition at line 7462 of file font.c.

7463{
7464 BOOL exists, is_symbol = FALSE;
7465 struct dwrite_fonttable cmap;
7466 const struct tt_os2 *tt_os2;
7467 const BYTE *tables;
7468 void *os2_context;
7469 WORD num_tables;
7470 unsigned int i;
7471 UINT32 size;
7472 HRESULT hr;
7473
7474 hr = IDWriteFontFace_TryGetFontTable(fontface, MS_OS2_TAG, (const void **)&tt_os2, &size, &os2_context, &exists);
7475 ok(hr == S_OK, "Failed to get OS/2 table, hr %#lx.\n", hr);
7476
7477 if (tt_os2)
7478 {
7480 IDWriteFontFace_ReleaseFontTable(fontface, os2_context);
7481 }
7482
7483 if (is_symbol)
7484 return is_symbol;
7485
7486 hr = IDWriteFontFace_TryGetFontTable(fontface, MS_CMAP_TAG, (const void **)&cmap.data,
7487 &cmap.size, &cmap.context, &exists);
7488 if (FAILED(hr) || !exists)
7489 return is_symbol;
7490
7491 num_tables = table_read_be_word(&cmap, 0, FIELD_OFFSET(struct cmap_header, num_tables));
7492 tables = cmap.data + FIELD_OFFSET(struct cmap_header, tables);
7493
7494 for (i = 0; i < num_tables; ++i)
7495 {
7496 struct cmap_encoding_record *record = (struct cmap_encoding_record *)(tables + i * sizeof(*record));
7497 WORD platform, encoding;
7498
7501
7503 {
7504 is_symbol = TRUE;
7505 break;
7506 }
7507 }
7508
7509 IDWriteFontFace_ReleaseFontTable(fontface, cmap.context);
7510
7511 return is_symbol;
7512}
struct nls_table * tables
Definition: nls_base.c:22
platform
Definition: msipriv.h:364
uint16_t platformID
Definition: opentype.c:103
uint16_t encodingID
Definition: opentype.c:104
BYTE bFamilyType
Definition: wingdi.h:2315
PANOSE panose
Definition: opentype.c:199
#define PAN_FAMILY_PICTORIAL
Definition: wingdi.h:470

Referenced by test_IsSymbolFont().

◆ get_expected_metrics()

static void get_expected_metrics ( IDWriteFontFace *  fontface,
struct compatmetrics_test *  ptr,
DWRITE_FONT_METRICS *  expected 
)
static

Definition at line 6319 of file font.c.

6321{
6322 HRESULT hr;
6323
6324 memset(expected, 0, sizeof(*expected));
6325 hr = IDWriteFontFace_GetGdiCompatibleMetrics(fontface, ptr->ppdip * fabsf(ptr->m.m22) * ptr->emsize, 1.0, NULL, expected);
6326 ok(hr == S_OK, "got %08lx\n", hr);
6327}
_ACRTIMP float __cdecl fabsf(float)

Referenced by test_gdicompat_metrics().

◆ get_expected_panose()

static void get_expected_panose ( IDWriteFont1 *  font,
DWRITE_PANOSE *  panose 
)
static

Definition at line 6494 of file font.c.

6495{
6496 const struct tt_os2 *tt_os2;
6497 IDWriteFontFace *fontface;
6498 void *os2_context;
6499 UINT32 size;
6500 BOOL exists;
6501 HRESULT hr;
6502
6503 memset(panose, 0, sizeof(*panose));
6504
6505 hr = IDWriteFont1_CreateFontFace(font, &fontface);
6506 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6507
6508 hr = IDWriteFontFace_TryGetFontTable(fontface, MS_OS2_TAG, (const void **)&tt_os2, &size, &os2_context, &exists);
6509 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6510
6511 if (tt_os2) {
6512 memcpy(panose, &tt_os2->panose, sizeof(*panose));
6513 IDWriteFontFace_ReleaseFontTable(fontface, os2_context);
6514 }
6515
6516 IDWriteFontFace_Release(fontface);
6517}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by test_GetPanose().

◆ get_expected_rendering_mode()

static DWRITE_RENDERING_MODE get_expected_rendering_mode ( FLOAT  emsize,
WORD  gasp,
DWRITE_MEASURING_MODE  mode,
DWRITE_OUTLINE_THRESHOLD  threshold 
)
static

Definition at line 6780 of file font.c.

6782{
6783 static const FLOAT aa_threshold = 100.0f;
6784 static const FLOAT a_threshold = 350.0f;
6785 static const FLOAT naturalemsize = 20.0f;
6786 FLOAT v;
6787
6788 /* outline threshold */
6789 if (g_is_vista)
6790 v = mode == DWRITE_MEASURING_MODE_NATURAL ? aa_threshold : a_threshold;
6791 else
6792 v = threshold == DWRITE_OUTLINE_THRESHOLD_ANTIALIASED ? aa_threshold : a_threshold;
6793
6794 if (emsize >= v)
6796
6797 switch (mode)
6798 {
6800 if (!(gasp & GASP_SYMMETRIC_SMOOTHING) && (emsize <= naturalemsize))
6802 else
6808 default:
6809 ;
6810 }
6811
6812 /* should be unreachable */
6814}
@ DWRITE_MEASURING_MODE_NATURAL
Definition: dcommon.idl:37
@ DWRITE_RENDERING_MODE_GDI_NATURAL
Definition: dwrite.idl:164
@ DWRITE_RENDERING_MODE_OUTLINE
Definition: dwrite.idl:167
@ DWRITE_RENDERING_MODE_GDI_CLASSIC
Definition: dwrite.idl:163
@ DWRITE_RENDERING_MODE_NATURAL
Definition: dwrite.idl:165
@ DWRITE_RENDERING_MODE_DEFAULT
Definition: dwrite.idl:161
@ DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC
Definition: dwrite.idl:166
static BOOL g_is_vista
Definition: font.c:6779
#define GASP_SYMMETRIC_SMOOTHING
Definition: font.c:6777

Referenced by test_GetRecommendedRenderingMode().

◆ get_face_glyph_image_formats()

static DWORD get_face_glyph_image_formats ( IDWriteFontFace4 *  fontface)
static

Definition at line 9362 of file font.c.

9363{
9365
9366 if (face_has_table(fontface, MS_GLYF_TAG))
9368
9369 if (face_has_table(fontface, MS_CFF__TAG) ||
9370 face_has_table(fontface, MS_CFF2_TAG))
9372
9373 if (face_has_table(fontface, MS_COLR_TAG))
9375
9376 if (face_has_table(fontface, MS_SVG__TAG))
9378
9379 if (face_has_table(fontface, MS_SBIX_TAG))
9380 ret |= get_sbix_formats(fontface);
9381
9382 if (face_has_table(fontface, MS_CBLC_TAG))
9383 ret |= get_cblc_formats(fontface);
9384
9385 return ret;
9386}
@ DWRITE_GLYPH_IMAGE_FORMATS_COLR
Definition: dcommon.idl:47
@ DWRITE_GLYPH_IMAGE_FORMATS_NONE
Definition: dcommon.idl:44
@ DWRITE_GLYPH_IMAGE_FORMATS_CFF
Definition: dcommon.idl:46
@ DWRITE_GLYPH_IMAGE_FORMATS_SVG
Definition: dcommon.idl:48
@ DWRITE_GLYPH_IMAGE_FORMATS_TRUETYPE
Definition: dcommon.idl:45
static BOOL face_has_table(IDWriteFontFace4 *fontface, UINT32 tag)
Definition: font.c:9239
#define MS_CFF__TAG
Definition: font.c:46
#define MS_SVG__TAG
Definition: font.c:49
#define MS_SBIX_TAG
Definition: font.c:50
#define MS_GLYF_TAG
Definition: font.c:45
static DWORD get_cblc_formats(IDWriteFontFace4 *fontface)
Definition: font.c:9322
static DWORD get_sbix_formats(IDWriteFontFace4 *fontface)
Definition: font.c:9255
#define MS_CFF2_TAG
Definition: font.c:47

Referenced by test_GetGlyphImageFormats().

◆ get_font()

static IDWriteFont * get_font ( IDWriteFactory *  factory,
const WCHAR *  name,
DWRITE_FONT_STYLE  style 
)
static

Definition at line 497 of file font.c.

498{
500 IDWriteFontFamily *family;
503 BOOL exists;
504 HRESULT hr;
505
506 hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
507 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
508
509 index = ~0;
510 exists = FALSE;
511 hr = IDWriteFontCollection_FindFamilyName(collection, name, &index, &exists);
512 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
513 if (!exists) goto not_found;
514
515 hr = IDWriteFontCollection_GetFontFamily(collection, index, &family);
516 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
517
518 hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
520 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
521
522 IDWriteFontFamily_Release(family);
523not_found:
524 IDWriteFontCollection_Release(collection);
525 return font;
526}
@ DWRITE_FONT_WEIGHT_NORMAL
Definition: dwrite.idl:79
@ DWRITE_FONT_STRETCH_NORMAL
Definition: dwrite.idl:100
Definition: name.c:39
Definition: style.c:91

Referenced by get_tahoma_instance(), test_GetGdiCompatibleMetrics(), test_GetPaletteEntries(), and test_TranslateColorGlyphRun().

◆ get_gasp_flags()

static WORD get_gasp_flags ( IDWriteFontFace *  fontface,
FLOAT  emsize,
FLOAT  ppdip 
)
static

Definition at line 6735 of file font.c.

6736{
6737 WORD num_recs, version;
6738 const WORD *ptr;
6739 WORD flags = 0;
6740 UINT32 size;
6741 BOOL exists;
6742 void *ctxt;
6743 HRESULT hr;
6744
6745 emsize *= ppdip;
6746
6747 exists = FALSE;
6748 hr = IDWriteFontFace_TryGetFontTable(fontface, MS_GASP_TAG,
6749 (const void**)&ptr, &size, &ctxt, &exists);
6750 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6751
6752 if (!exists)
6753 goto done;
6754
6755 version = GET_BE_WORD( *ptr++ );
6756 num_recs = GET_BE_WORD( *ptr++ );
6757 if (version > 1 || size < (num_recs * 2 + 2) * sizeof(WORD)) {
6758 ok(0, "unsupported gasp table: ver %d size %d recs %d\n", version, size, num_recs);
6759 goto done;
6760 }
6761
6762 while (num_recs--)
6763 {
6764 flags = GET_BE_WORD( *(ptr + 1) );
6765 if (emsize <= GET_BE_WORD( *ptr )) break;
6766 ptr += 2;
6767 }
6768
6769done:
6770 IDWriteFontFace_ReleaseFontTable(fontface, ctxt);
6771 return flags;
6772}
#define MS_GASP_TAG
Definition: font.c:39
GLbitfield flags
Definition: glext.h:7161

Referenced by test_GetRecommendedRenderingMode().

◆ get_gdi_font_advance()

static INT32 get_gdi_font_advance ( HDC  hdc,
FLOAT  emsize 
)
static

Definition at line 6621 of file font.c.

6622{
6623 LOGFONTW logfont;
6624 HFONT hfont;
6625 BOOL ret;
6626 ABC abc;
6627
6628 memset(&logfont, 0, sizeof(logfont));
6629 logfont.lfHeight = (LONG)-emsize;
6630 logfont.lfWeight = FW_NORMAL;
6631 logfont.lfQuality = CLEARTYPE_QUALITY;
6632 lstrcpyW(logfont.lfFaceName, L"Tahoma");
6633
6634 hfont = CreateFontIndirectW(&logfont);
6636
6637 ret = GetCharABCWidthsW(hdc, 'A', 'A', &abc);
6638 ok(ret, "got %d\n", ret);
6639
6641
6642 return abc.abcA + abc.abcB + abc.abcC;
6643}
static HFONT hfont
pKey DeleteObject()
HDC hdc
Definition: main.c:9
long LONG
Definition: pedump.c:60
BYTE lfQuality
Definition: dimm.idl:70
Definition: wingdi.h:1856
int abcA
Definition: wingdi.h:1857
UINT abcB
Definition: wingdi.h:1858
int abcC
Definition: wingdi.h:1859
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
#define CLEARTYPE_QUALITY
Definition: wingdi.h:441
BOOL WINAPI GetCharABCWidthsW(_In_ HDC hdc, _In_ UINT wFirst, _In_ UINT wLast, _Out_writes_(wLast - wFirst+1) LPABC lpABC)

Referenced by test_GetGdiCompatibleGlyphAdvances().

◆ get_logfont_from_font()

static void get_logfont_from_font ( IDWriteFont *  font,
LOGFONTW *  logfont 
)
static

Definition at line 2688 of file font.c.

2689{
2690 void *os2_context, *head_context;
2693 const struct tt_os2 *tt_os2;
2694 IDWriteFontFace *fontface;
2696 const TT_HEAD *tt_head;
2697 LONG weight;
2698 UINT32 size;
2699 BOOL exists;
2700 HRESULT hr;
2701
2702 /* These are rendering time properties. */
2703 logfont->lfHeight = 0;
2704 logfont->lfWidth = 0;
2705 logfont->lfEscapement = 0;
2706 logfont->lfOrientation = 0;
2707 logfont->lfUnderline = 0;
2708 logfont->lfStrikeOut = 0;
2709
2710 logfont->lfWeight = 0;
2711 logfont->lfItalic = 0;
2712
2713 hr = IDWriteFont_CreateFontFace(font, &fontface);
2714 ok(hr == S_OK, "Failed to create font face, %#lx\n", hr);
2715
2716 hr = IDWriteFontFace_TryGetFontTable(fontface, MS_OS2_TAG, (const void **)&tt_os2, &size,
2717 &os2_context, &exists);
2718 ok(hr == S_OK, "Failed to get OS/2 table, %#lx\n", hr);
2719
2720 hr = IDWriteFontFace_TryGetFontTable(fontface, MS_HEAD_TAG, (const void **)&tt_head, &size,
2721 &head_context, &exists);
2722 ok(hr == S_OK, "Failed to get head table, %#lx\n", hr);
2723
2724 sim = IDWriteFont_GetSimulations(font);
2725
2726 /* lfWeight */
2728 if (tt_os2) {
2730
2731 if (usWeightClass >= 1 && usWeightClass <= 9)
2732 usWeightClass *= 100;
2733
2736 else if (usWeightClass > 0)
2738 }
2739 else if (tt_head) {
2740 USHORT macStyle = GET_BE_WORD(tt_head->macStyle);
2741 if (macStyle & TT_HEAD_MACSTYLE_BOLD)
2743 }
2745 weight += (FW_BOLD - FW_REGULAR) / 2 + 1;
2746 logfont->lfWeight = weight;
2747
2748 /* lfItalic */
2749 if (IDWriteFont_GetSimulations(font) & DWRITE_FONT_SIMULATIONS_OBLIQUE)
2750 logfont->lfItalic = 1;
2751
2752 style = IDWriteFont_GetStyle(font);
2753 if (!logfont->lfItalic && ((style == DWRITE_FONT_STYLE_ITALIC) || (style == DWRITE_FONT_STYLE_OBLIQUE))) {
2754 if (tt_os2) {
2757 }
2758 else if (tt_head) {
2759 USHORT macStyle = GET_BE_WORD(tt_head->macStyle);
2760 logfont->lfItalic = !!(macStyle & TT_HEAD_MACSTYLE_ITALIC);
2761 }
2762 }
2763
2764 /* lfFaceName */
2765 exists = FALSE;
2766 logfont->lfFaceName[0] = 0;
2767 hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &names, &exists);
2768 if (SUCCEEDED(hr))
2769 {
2770 if (exists)
2771 {
2773 WCHAR nameW[256];
2774 UINT32 index;
2775
2776 /* Fallback to en-us if there's no string for user locale. */
2777 exists = FALSE;
2779 IDWriteLocalizedStrings_FindLocaleName(names, localeW, &index, &exists);
2780
2781 if (!exists)
2782 IDWriteLocalizedStrings_FindLocaleName(names, L"en-us", &index, &exists);
2783
2784 if (exists) {
2785 nameW[0] = 0;
2786 hr = IDWriteLocalizedStrings_GetString(names, index, nameW, ARRAY_SIZE(nameW));
2787 ok(hr == S_OK, "Failed to get name string, hr %#lx.\n", hr);
2788 lstrcpynW(logfont->lfFaceName, nameW, ARRAY_SIZE(logfont->lfFaceName));
2789 }
2790 }
2791
2792 IDWriteLocalizedStrings_Release(names);
2793 }
2794
2795 if (tt_os2)
2796 IDWriteFontFace_ReleaseFontTable(fontface, os2_context);
2797 if (tt_head)
2798 IDWriteFontFace_ReleaseFontTable(fontface, head_context);
2799 IDWriteFontFace_Release(fontface);
2800}
INT WINAPI GetSystemDefaultLocaleName(LPWSTR localename, INT len)
#define lstrcpynW
Definition: compat.h:738
@ DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES
Definition: dwrite.idl:128
@ DWRITE_FONT_WEIGHT_BOLD
Definition: dwrite.idl:84
@ DWRITE_FONT_WEIGHT_ULTRA_BLACK
Definition: dwrite.idl:90
DWRITE_FONT_SIMULATIONS
Definition: dwrite.idl:145
@ DWRITE_FONT_SIMULATIONS_BOLD
Definition: dwrite.idl:147
DWRITE_FONT_STYLE
Definition: dwrite.idl:109
@ DWRITE_FONT_STYLE_ITALIC
Definition: dwrite.idl:112
@ DWRITE_FONT_STYLE_OBLIQUE
Definition: dwrite.idl:111
GLuint GLuint * names
Definition: glext.h:11545
static const WCHAR localeW[]
Definition: locale.c:49
#define LOCALE_NAME_MAX_LENGTH
unsigned short USHORT
Definition: pedump.c:61
weight
Definition: sortkey.c:157
BYTE lfStrikeOut
Definition: dimm.idl:66
LONG lfOrientation
Definition: dimm.idl:62
BYTE lfUnderline
Definition: dimm.idl:65
LONG lfEscapement
Definition: dimm.idl:61
USHORT macStyle
Definition: opentype.c:150
USHORT usWeightClass
Definition: opentype.c:185
#define FW_REGULAR
Definition: wingdi.h:374
#define FW_BOLD
Definition: wingdi.h:378

◆ get_sbix_formats()

static DWORD get_sbix_formats ( IDWriteFontFace4 *  fontface)
static

Definition at line 9255 of file font.c.

9256{
9257 UINT32 size, s, num_strikes;
9258 const sbix_header *header;
9259 UINT16 g, num_glyphs;
9260 BOOL exists = FALSE;
9261 const maxp *maxp;
9262 const void *data;
9263 DWORD ret = 0;
9264 void *context;
9265 HRESULT hr;
9266
9267 hr = IDWriteFontFace4_TryGetFontTable(fontface, MS_MAXP_TAG, &data, &size, &context, &exists);
9268 ok(hr == S_OK, "TryGetFontTable() failed, %#lx\n", hr);
9269 ok(exists, "Expected maxp table\n");
9270
9271 if (!exists)
9272 return 0;
9273
9274 maxp = data;
9275 num_glyphs = GET_BE_WORD(maxp->numGlyphs);
9276
9277 hr = IDWriteFontFace4_TryGetFontTable(fontface, MS_SBIX_TAG, &data, &size, &context, &exists);
9278 ok(hr == S_OK, "TryGetFontTable() failed, %#lx\n", hr);
9279 ok(exists, "Expected sbix table\n");
9280
9281 header = data;
9282 num_strikes = GET_BE_DWORD(header->numStrikes);
9283
9284 for (s = 0; s < num_strikes; s++) {
9285 sbix_strike *strike = (sbix_strike *)((BYTE *)header + GET_BE_DWORD(header->strikeOffset[s]));
9286
9287 for (g = 0; g < num_glyphs; g++) {
9289 DWORD offset_next = GET_BE_DWORD(strike->glyphDataOffsets[g + 1]);
9290 sbix_glyph_data *glyph_data;
9291 DWORD format;
9292
9293 if (offset == offset_next)
9294 continue;
9295
9296 glyph_data = (sbix_glyph_data *)((BYTE *)strike + offset);
9297 switch (format = glyph_data->graphicType)
9298 {
9299 case MS_PNG__TAG:
9301 break;
9302 case MS_JPG__TAG:
9304 break;
9305 case MS_TIFF_TAG:
9307 break;
9308 case DWRITE_MAKE_OPENTYPE_TAG('f','l','i','p'):
9309 /* ignore macOS-specific tag */
9310 break;
9311 default:
9312 ok(0, "unexpected format, %#lx\n", GET_BE_DWORD(format));
9313 }
9314 }
9315 }
9316
9317 IDWriteFontFace4_ReleaseFontTable(fontface, context);
9318
9319 return ret;
9320}
unsigned short UINT16
Definition: actypes.h:129
@ DWRITE_GLYPH_IMAGE_FORMATS_JPEG
Definition: dcommon.idl:50
@ DWRITE_GLYPH_IMAGE_FORMATS_TIFF
Definition: dcommon.idl:51
#define GET_BE_DWORD(x)
Definition: font.c:109
GLdouble s
Definition: gl.h:2039
GLboolean GLboolean g
Definition: glext.h:6204
#define MS_TIFF_TAG
Definition: font.c:57
#define MS_PNG__TAG
Definition: font.c:55
#define MS_JPG__TAG
Definition: font.c:56
#define MS_MAXP_TAG
Definition: font.c:51
Definition: opentype.c:271
WORD numGlyphs
Definition: font.c:352
DWORD graphicType
Definition: font.c:320
DWORD glyphDataOffsets[1]
Definition: font.c:314

Referenced by get_face_glyph_image_formats().

◆ get_scaled_metric()

static float get_scaled_metric ( const DWRITE_GLYPH_RUN *  run,
float  metric,
const DWRITE_FONT_METRICS *  m 
)
static

Definition at line 8598 of file font.c.

8599{
8600 return run->fontEmSize * metric / m->designUnitsPerEm;
8601}
const GLfloat * m
Definition: glext.h:10848

Referenced by get_expected_glyph_origins().

◆ get_tahoma_instance()

static IDWriteFont * get_tahoma_instance ( IDWriteFactory *  factory,
DWRITE_FONT_STYLE  style 
)
static

Definition at line 528 of file font.c.

529{
530 IDWriteFont *font = get_font(factory, L"Tahoma", style);
531 ok(font != NULL, "failed to get Tahoma\n");
532 return font;
533}
static IDWriteFont * get_font(IDWriteFactory *factory, const WCHAR *name, DWRITE_FONT_STYLE style)
Definition: font.c:497

Referenced by test_font_properties(), test_GetCaretMetrics(), test_GetFirstMatchingFont(), test_GetGdiCompatibleGlyphAdvances(), test_GetMetrics(), test_GetPanose(), and test_HasCharacter().

◆ get_vdmx_size()

static BOOL get_vdmx_size ( const struct VDMX_group *  group,
int  emsize,
int *  a,
int *  d 
)
static

Definition at line 6196 of file font.c.

6197{
6198 WORD recs, i;
6199 const struct VDMX_vTable *tables;
6200
6201 if (!group) return FALSE;
6202
6203 recs = GET_BE_WORD(group->recs);
6204 if (emsize < group->startsz || emsize >= group->endsz) return FALSE;
6205
6206 tables = (const struct VDMX_vTable *)(group + 1);
6207 for (i = 0; i < recs; i++)
6208 {
6210 if (ppem > emsize)
6211 {
6212 /* FIXME: Supposed to interpolate */
6213 trace("FIXME interpolate %d\n", emsize);
6214 return FALSE;
6215 }
6216
6217 if (ppem == emsize)
6218 {
6220 *d = -(SHORT)GET_BE_WORD(tables[i].yMin);
6221 return TRUE;
6222 }
6223 }
6224 return FALSE;
6225}
#define trace
Definition: atltest.h:70
GLboolean GLuint group
Definition: glext.h:11120
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define d
Definition: ke_i.h:81
SHORT yMax
Definition: font.c:6166
WORD yPelHeight
Definition: font.c:6165
SHORT yMin
Definition: font.c:6167

Referenced by test_gdicompat_metrics().

◆ has_face_variations()

static BOOL has_face_variations ( IDWriteFontFace *  fontface)
static

Definition at line 574 of file font.c.

575{
576 IDWriteFontFace5 *fontface5;
577 BOOL ret = FALSE;
578
579 if (SUCCEEDED(IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace5, (void **)&fontface5))) {
580 ret = IDWriteFontFace5_HasVariations(fontface5);
581 IDWriteFontFace5_Release(fontface5);
582 }
583
584 return ret;
585}

Referenced by test_ConvertFontFaceToLOGFONT(), test_ConvertFontToLOGFONT(), and test_GetMetrics().

◆ has_main_axis_values()

static BOOL has_main_axis_values ( const DWRITE_FONT_AXIS_VALUE *  values,
unsigned int  count 
)
static

Definition at line 7974 of file font.c.

7975{
7976 BOOL has_wght = FALSE, has_wdth = FALSE, has_ital = FALSE, has_slnt = FALSE;
7977 unsigned int i;
7978
7979 for (i = 0; i < count; ++i)
7980 {
7981 if (values[i].axisTag == DWRITE_FONT_AXIS_TAG_WEIGHT)
7982 has_wght = TRUE;
7983 else if (values[i].axisTag == DWRITE_FONT_AXIS_TAG_WIDTH)
7984 has_wdth = TRUE;
7985 else if (values[i].axisTag == DWRITE_FONT_AXIS_TAG_ITALIC)
7986 has_ital = TRUE;
7987 else if (values[i].axisTag == DWRITE_FONT_AXIS_TAG_SLANT)
7988 has_slnt = TRUE;
7989 }
7990
7991 return has_wght && has_wdth && has_ital && has_slnt;
7992}
@ DWRITE_FONT_AXIS_TAG_WEIGHT
Definition: dwrite_3.idl:126
@ DWRITE_FONT_AXIS_TAG_WIDTH
Definition: dwrite_3.idl:127
@ DWRITE_FONT_AXIS_TAG_ITALIC
Definition: dwrite_3.idl:130
@ DWRITE_FONT_AXIS_TAG_SLANT
Definition: dwrite_3.idl:128
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666

Referenced by test_CreateFontFaceReference().

◆ has_vertical_glyph_variants()

static BOOL has_vertical_glyph_variants ( IDWriteFontFace1 *  fontface)
static

Definition at line 8373 of file font.c.

8374{
8375 const OT_FeatureList *featurelist;
8376 const OT_LookupList *lookup_list;
8377 BOOL exists = FALSE, ret = FALSE;
8378 const GSUB_Header *header;
8379 const void *data;
8380 void *context;
8381 UINT32 size;
8382 HRESULT hr;
8383 UINT16 i;
8384
8385 hr = IDWriteFontFace1_TryGetFontTable(fontface, MS_GSUB_TAG, &data, &size, &context, &exists);
8386 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8387
8388 if (!exists)
8389 return FALSE;
8390
8391 header = data;
8392 featurelist = (OT_FeatureList*)((BYTE*)header + GET_BE_WORD(header->FeatureList));
8393 lookup_list = (const OT_LookupList*)((BYTE*)header + GET_BE_WORD(header->LookupList));
8394
8395 for (i = 0; i < GET_BE_WORD(featurelist->FeatureCount); i++) {
8397 const OT_Feature *feature = (const OT_Feature*)((BYTE*)featurelist + GET_BE_WORD(featurelist->FeatureRecord[i].Feature));
8398 UINT16 lookup_count = GET_BE_WORD(feature->LookupCount), i, index, count, type;
8399 const GSUB_SingleSubstFormat2 *subst2;
8400 const OT_LookupTable *lookup_table;
8401 UINT32 offset;
8402
8403 if (lookup_count == 0)
8404 continue;
8405
8406 for (i = 0; i < lookup_count; i++) {
8407 /* check if lookup is empty */
8408 index = GET_BE_WORD(feature->LookupListIndex[i]);
8409 lookup_table = (const OT_LookupTable*)((BYTE*)lookup_list + GET_BE_WORD(lookup_list->Lookup[index]));
8410
8411 type = GET_BE_WORD(lookup_table->LookupType);
8412 ok(type == 1 || type == 7, "got unexpected lookup type %u\n", type);
8413
8414 count = GET_BE_WORD(lookup_table->SubTableCount);
8415 if (count == 0)
8416 continue;
8417
8418 ok(count > 0, "got unexpected subtable count %u\n", count);
8419
8420 offset = GET_BE_WORD(lookup_table->SubTable[0]);
8421 if (type == 7) {
8422 const GSUB_ExtensionPosFormat1 *ext = (const GSUB_ExtensionPosFormat1 *)((const BYTE *)lookup_table + offset);
8423 if (GET_BE_WORD(ext->SubstFormat) == 1)
8424 offset += GET_BE_DWORD(ext->ExtensionOffset);
8425 else
8426 ok(0, "Unhandled Extension Substitution Format %u\n", GET_BE_WORD(ext->SubstFormat));
8427 }
8428
8429 subst2 = (const GSUB_SingleSubstFormat2*)((BYTE*)lookup_table + offset);
8430 index = GET_BE_WORD(subst2->SubstFormat);
8431 if (index == 1)
8432 ret = TRUE;
8433 else if (index == 2) {
8434 /* SimSun-ExtB has 0 glyph count for this substitution */
8435 if (GET_BE_WORD(subst2->GlyphCount) > 0)
8436 ret = TRUE;
8437 }
8438 else
8439 ok(0, "unknown Single Substitution Format, %u\n", index);
8440
8441 if (ret)
8442 break;
8443 }
8444 }
8445 }
8446
8447 IDWriteFontFace1_ReleaseFontTable(fontface, context);
8448
8449 return ret;
8450}
static const WCHAR *const ext[]
Definition: module.c:53
@ DWRITE_FONT_FEATURE_TAG_VERTICAL_WRITING
Definition: dwrite.idl:322
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define MS_GSUB_TAG
Definition: font.c:43
INTERNETFEATURELIST feature
Definition: misc.c:1807
WORD FeatureCount
Definition: opentype.c:181
OT_FeatureRecord FeatureRecord[1]
Definition: opentype.c:182
CHAR FeatureTag[4]
Definition: opentype.c:176
WORD Lookup[1]
Definition: opentype.c:193
WORD SubTable[1]
Definition: opentype.c:200
WORD SubTableCount
Definition: opentype.c:199
WORD LookupType
Definition: opentype.c:197

Referenced by test_HasVerticalGlyphVariants().

◆ impl_from_IDWriteFontCollectionLoader()

static struct collection_loader * impl_from_IDWriteFontCollectionLoader ( IDWriteFontCollectionLoader *  iface)
inlinestatic

Definition at line 2964 of file font.c.

2965{
2966 return CONTAINING_RECORD(iface, struct collection_loader, IDWriteFontCollectionLoader_iface);
2967}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by fontcollectionloader_AddRef(), fontcollectionloader_QueryInterface(), and fontcollectionloader_Release().

◆ impl_from_IDWriteFontFileCollectionLoader()

static struct test_fontcollectionloader * impl_from_IDWriteFontFileCollectionLoader ( IDWriteFontCollectionLoader *  iface)
inlinestatic

Definition at line 698 of file font.c.

699{
700 return CONTAINING_RECORD(iface, struct test_fontcollectionloader, IDWriteFontFileCollectionLoader_iface);
701}

Referenced by resourcecollectionloader_CreateEnumeratorFromKey().

◆ impl_from_IDWriteFontFileEnumerator()

static struct test_fontenumerator * impl_from_IDWriteFontFileEnumerator ( IDWriteFontFileEnumerator *  iface)
inlinestatic

Definition at line 610 of file font.c.

611{
612 return CONTAINING_RECORD(iface, struct test_fontenumerator, IDWriteFontFileEnumerator_iface);
613}

◆ impl_from_IDWriteFontFileStream()

static struct test_fontdatastream * impl_from_IDWriteFontFileStream ( IDWriteFontFileStream *  iface)
inlinestatic

Definition at line 758 of file font.c.

759{
760 return CONTAINING_RECORD(iface, struct test_fontdatastream, IDWriteFontFileStream_iface);
761}

◆ impl_from_IUnknown()

static struct testowner_object * impl_from_IUnknown ( IUnknown *  iface)
inlinestatic

Definition at line 8938 of file font.c.

8939{
8940 return CONTAINING_RECORD(iface, struct testowner_object, IUnknown_iface);
8941}

Referenced by testowner_AddRef(), and testowner_Release().

◆ map_font_file()

static void * map_font_file ( const WCHAR *  filename,
DWORD *  file_size 
)
static

Definition at line 4268 of file font.c.

4269{
4271 void *ptr;
4272
4274 if (file == INVALID_HANDLE_VALUE) return NULL;
4275
4277
4279 if (!mapping)
4280 {
4282 return NULL;
4283 }
4284
4286
4289 return ptr;
4290}
#define PAGE_READONLY
Definition: compat.h:138
#define OPEN_EXISTING
Definition: compat.h:775
#define FILE_MAP_READ
Definition: compat.h:776
#define MapViewOfFile
Definition: compat.h:745
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
HANDLE NTAPI CreateFileMappingA(IN HANDLE hFile, IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes, IN DWORD flProtect, IN DWORD dwMaximumSizeHigh, IN DWORD dwMaximumSizeLow, IN LPCSTR lpName)
Definition: filemap.c:23
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
static unsigned int file_size
Definition: regtests2xml.c:47

Referenced by test_CreateFontFaceFromHdc().

◆ opentype_cmap_get_unicode_ranges()

static UINT32 opentype_cmap_get_unicode_ranges ( const struct dwrite_fonttable *  table,
DWRITE_UNICODE_RANGE **  ranges 
)
static

Definition at line 3662 of file font.c.

3663{
3664 int index_full = -1, index_bmp = -1;
3665 unsigned int i, count = 0;
3666 size_t capacity = 0;
3667 const BYTE *tables;
3668 WORD num_tables;
3669
3670 *ranges = NULL;
3671
3672 num_tables = table_read_be_word(table, 0, FIELD_OFFSET(struct cmap_header, num_tables));
3674
3675 for (i = 0; i < num_tables; ++i)
3676 {
3677 struct cmap_encoding_record *record = (struct cmap_encoding_record *)(tables + i * sizeof(*record));
3678 WORD platform, encoding;
3679
3682
3684 {
3686 {
3687 index_full = i;
3688 break;
3689 }
3690 else if (encoding == OPENTYPE_CMAP_TABLE_ENCODING_UNICODE_BMP)
3691 index_bmp = i;
3692 }
3693 }
3694
3695 if (index_full != -1)
3696 opentype_cmap_read_table(table, index_full, &count, &capacity, ranges);
3697 else if (index_bmp != -1)
3698 opentype_cmap_read_table(table, index_bmp, &count, &capacity, ranges);
3699
3700 return count;
3701}
static void opentype_cmap_read_table(const struct dwrite_fonttable *table, UINT16 cmap_index, UINT32 *count, size_t *capacity, DWRITE_UNICODE_RANGE **ranges)
Definition: font.c:3596
BYTE * data

◆ opentype_cmap_read_table()

static void opentype_cmap_read_table ( const struct dwrite_fonttable *  table,
UINT16  cmap_index,
UINT32 *  count,
size_t *  capacity,
DWRITE_UNICODE_RANGE **  ranges 
)
static

Definition at line 3596 of file font.c.

3598{
3599 const BYTE *tables = table->data + FIELD_OFFSET(struct cmap_header, tables);
3601 DWORD table_offset;
3602 WORD format;
3603 int j;
3604
3605 record = (struct cmap_encoding_record *)(tables + cmap_index * sizeof(*record));
3606
3607 if (!(table_offset = table_read_be_dword(table, record, FIELD_OFFSET(struct cmap_encoding_record, offset))))
3608 return;
3609
3610 format = table_read_be_word(table, NULL, table_offset);
3611 switch (format)
3612 {
3614 {
3615 UINT16 segment_count = table_read_be_word(table, NULL, table_offset +
3616 FIELD_OFFSET(struct cmap_segmented_mapping_0, segCountX2)) / 2;
3617 DWORD start_code_offset = table_offset + sizeof(struct cmap_segmented_mapping_0) +
3618 sizeof(WORD) * segment_count;
3619
3620 for (j = 0; j < segment_count; ++j) {
3621 WORD endcode = table_read_be_word(table, NULL, table_offset +
3622 FIELD_OFFSET(struct cmap_segmented_mapping_0, endCode) + j * sizeof(WORD));
3623 WORD first;
3624
3625 if (endcode == 0xffff)
3626 break;
3627
3628 first = table_read_be_word(table, NULL, start_code_offset + j * sizeof(WORD));
3629
3630 array_reserve((void **)ranges, capacity, *count + 1, sizeof(**ranges));
3631 (*ranges)[*count].first = first;
3632 (*ranges)[*count].last = endcode;
3633 (*count)++;
3634 }
3635 break;
3636 }
3638 {
3639 DWORD num_groups = table_read_be_dword(table, NULL, table_offset +
3640 FIELD_OFFSET(struct cmap_segmented_coverage, nGroups));
3641
3642 for (j = 0; j < num_groups; ++j) {
3643 DWORD group_offset = table_offset + FIELD_OFFSET(struct cmap_segmented_coverage, groups) +
3644 j * sizeof(struct cmap_segmented_coverage_group);
3645 DWORD first = table_read_be_dword(table, NULL, group_offset +
3647 DWORD last = table_read_be_dword(table, NULL, group_offset +
3649
3650 array_reserve((void **)ranges, capacity, *count + 1, sizeof(**ranges));
3651 (*ranges)[*count].first = first;
3652 (*ranges)[*count].last = last;
3653 (*count)++;
3654 }
3655 break;
3656 }
3657 default:
3658 ok(0, "%u table format %#x unhandled.\n", cmap_index, format);
3659 }
3660}
GLsizei GLuint * groups
Definition: glext.h:11113
static void array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
Definition: font.c:3571
static const LARGE_INTEGER *static const HANDLE const LARGE_INTEGER *static PSLIST_ENTRY PSLIST_ENTRY last
Definition: sync.c:64
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by opentype_cmap_get_unicode_ranges().

◆ resourcecollectionloader_AddRef()

static ULONG WINAPI resourcecollectionloader_AddRef ( IDWriteFontCollectionLoader *  iface)
static

Definition at line 714 of file font.c.

715{
716 return 2;
717}

◆ resourcecollectionloader_CreateEnumeratorFromKey()

static HRESULT WINAPI resourcecollectionloader_CreateEnumeratorFromKey ( IDWriteFontCollectionLoader *  iface,
IDWriteFactory *  factory,
const void *  collectionKey,
UINT32  collectionKeySize,
IDWriteFontFileEnumerator **  fontFileEnumerator 
)
static

Definition at line 724 of file font.c.

726{
728 IDWriteFontFile *font_file;
729 HRESULT hr;
730
731 hr = IDWriteFactory_CreateCustomFontFileReference(factory, collectionKey, collectionKeySize, This->loader, &font_file);
732 ok(hr == S_OK, "Failed to create custom file reference, hr %#lx.\n", hr);
733
734 hr = create_enumerator(font_file, fontFileEnumerator);
735 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
736
737 IDWriteFontFile_Release(font_file);
738 return hr;
739}
static struct test_fontcollectionloader * impl_from_IDWriteFontFileCollectionLoader(IDWriteFontCollectionLoader *iface)
Definition: font.c:698
static HRESULT create_enumerator(IDWriteFontFile *font_file, IDWriteFontFileEnumerator **ret)
Definition: font.c:675

◆ resourcecollectionloader_QueryInterface()

static HRESULT WINAPI resourcecollectionloader_QueryInterface ( IDWriteFontCollectionLoader *  iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 703 of file font.c.

704{
705 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteFontCollectionLoader))
706 {
707 *obj = iface;
708 IDWriteFontCollectionLoader_AddRef(iface);
709 return S_OK;
710 }
711 return E_NOINTERFACE;
712}

◆ resourcecollectionloader_Release()

static ULONG WINAPI resourcecollectionloader_Release ( IDWriteFontCollectionLoader *  iface)
static

Definition at line 719 of file font.c.

720{
721 return 1;
722}

◆ resourcefontfileloader_AddRef()

static ULONG WINAPI resourcefontfileloader_AddRef ( IDWriteFontFileLoader *  iface)
static

Definition at line 864 of file font.c.

865{
866 return 2;
867}

◆ resourcefontfileloader_CreateStreamFromKey()

static HRESULT WINAPI resourcefontfileloader_CreateStreamFromKey ( IDWriteFontFileLoader *  iface,
const void *  ref_key,
UINT32  key_size,
IDWriteFontFileStream **  stream 
)
static

Definition at line 874 of file font.c.

876{
877 LPVOID data;
878 DWORD size;
879 HGLOBAL mem;
880
881 mem = LoadResource(GetModuleHandleA(NULL), *(HRSRC*)ref_key);
882 ok(mem != NULL, "Failed to lock font resource\n");
883 if (mem)
884 {
885 size = SizeofResource(GetModuleHandleA(NULL), *(HRSRC*)ref_key);
888 }
889 return E_FAIL;
890}
static HRESULT create_fontdatastream(LPVOID data, UINT size, IDWriteFontFileStream **iface)
Definition: font.c:837
Definition: mem.c:349

◆ resourcefontfileloader_QueryInterface()

static HRESULT WINAPI resourcefontfileloader_QueryInterface ( IDWriteFontFileLoader *  iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 853 of file font.c.

854{
855 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteFontFileLoader))
856 {
857 *obj = iface;
858 return S_OK;
859 }
860 *obj = NULL;
861 return E_NOINTERFACE;
862}

◆ resourcefontfileloader_Release()

static ULONG WINAPI resourcefontfileloader_Release ( IDWriteFontFileLoader *  iface)
static

Definition at line 869 of file font.c.

870{
871 return 1;
872}

◆ singlefontfileenumerator_AddRef()

static ULONG WINAPI singlefontfileenumerator_AddRef ( IDWriteFontFileEnumerator *  iface)
static

Definition at line 626 of file font.c.

627{
629 return InterlockedIncrement(&This->ref);
630}
static struct system_fontfile_enumerator * impl_from_IDWriteFontFileEnumerator(IDWriteFontFileEnumerator *iface)
Definition: font.c:4930

◆ singlefontfileenumerator_GetCurrentFontFile()

static HRESULT WINAPI singlefontfileenumerator_GetCurrentFontFile ( IDWriteFontFileEnumerator *  iface,
IDWriteFontFile **  font_file 
)
static

Definition at line 644 of file font.c.

645{
647 IDWriteFontFile_AddRef(This->font_file);
648 *font_file = This->font_file;
649 return S_OK;
650}

◆ singlefontfileenumerator_MoveNext()

static HRESULT WINAPI singlefontfileenumerator_MoveNext ( IDWriteFontFileEnumerator *  iface,
BOOL *  current 
)
static

Definition at line 652 of file font.c.

653{
655
656 if (This->index > 1) {
657 *current = FALSE;
658 return S_OK;
659 }
660
661 This->index++;
662 *current = TRUE;
663 return S_OK;
664}

◆ singlefontfileenumerator_QueryInterface()

static HRESULT WINAPI singlefontfileenumerator_QueryInterface ( IDWriteFontFileEnumerator *  iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 615 of file font.c.

616{
617 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteFontFileEnumerator))
618 {
619 *obj = iface;
620 IDWriteFontFileEnumerator_AddRef(iface);
621 return S_OK;
622 }
623 return E_NOINTERFACE;
624}

◆ singlefontfileenumerator_Release()

static ULONG WINAPI singlefontfileenumerator_Release ( IDWriteFontFileEnumerator *  iface)
static

Definition at line 632 of file font.c.

633{
635 ULONG ref = InterlockedDecrement(&enumerator->ref);
636 if (!ref)
637 {
638 IDWriteFontFile_Release(enumerator->font_file);
639 free(enumerator);
640 }
641 return ref;
642}

◆ START_TEST()

START_TEST ( font  )

Definition at line 10489 of file font.c.

10490{
10492
10493 if (!(factory = create_factory())) {
10494 win_skip("failed to create factory\n");
10495 return;
10496 }
10497
10564
10565 IDWriteFactory_Release(factory);
10566}
#define win_skip
Definition: minitest.h:67
static void test_CreateFontFaceReference(void)
Definition: font.c:7994
static void test_inmemory_file_loader(void)
Definition: font.c:8979
static void test_ConvertFontFaceToLOGFONT(void)
Definition: font.c:2802
static void test_AnalyzeContainerType(void)
Definition: font.c:9575
static void test_GetGlyphCount(void)
Definition: font.c:5515
static void test_TranslateColorGlyphRun(void)
Definition: font.c:7681
static void test_expiration_event(void)
Definition: font.c:10185
static void test_ComputeGlyphOrigins(void)
Definition: font.c:8662
static void test_GetFontFamily(void)
Definition: font.c:1542
static void test_font_properties(void)
Definition: font.c:8338
static void test_GetFaceNames(void)
Definition: font.c:4568
static void test_GetFamilyNames(void)
Definition: font.c:1727
static void test_GetRecommendedRenderingMode(void)
Definition: font.c:6854
static void test_IsMonospacedFont(void)
Definition: font.c:5116
static void test_system_font_set(void)
Definition: font.c:10317
static void test_GetPanose(void)
Definition: font.c:6519
static void test_CreateCustomRenderingParams(void)
Definition: font.c:9468
static void test_CreateFontFaceFromHdc(void)
Definition: font.c:4303
static void test_GetMetrics(void)
Definition: font.c:2215
static void test_HasCharacter(void)
Definition: font.c:7939
static void test_HasVerticalGlyphVariants(void)
Definition: font.c:8452
static void test_GetAlphaBlendParams(void)
Definition: font.c:7222
static void test_CreateFontFromLOGFONT(void)
Definition: font.c:1021
static void test_ReadFileFragment(void)
Definition: font.c:4958
static void test_TryGetFontTable(void)
Definition: font.c:4670
static void test_GetInformationalStrings(void)
Definition: font.c:4141
static void test_GetGdiCompatibleMetrics(void)
Definition: font.c:6460
static void test_GetCaretMetrics(void)
Definition: font.c:5434
static void test_CreateBitmapRenderTarget(void)
Definition: font.c:1208
static void test_GetMatchingFonts(void)
Definition: font.c:4032
static void test_GetFontFromFontFace(void)
Definition: font.c:3902
static void test_CreateFontCollectionFromFontSet(void)
Definition: font.c:10363
static void test_CreateAlphaTexture(void)
Definition: font.c:7319
static void test_GetUnicodeRanges(void)
Definition: font.c:3741
static void test_GetPaletteEntries(void)
Definition: font.c:7588
static void test_CreateStreamFromKey(void)
Definition: font.c:4896
static void test_font_resource(void)
Definition: font.c:9869
static void test_system_fontcollection(void)
Definition: font.c:2463
static void test_GetVerticalGlyphVariants(void)
Definition: font.c:10129
static void test_GetDesignGlyphAdvances(void)
Definition: font.c:5198
static void test_GetDesignGlyphMetrics(void)
Definition: font.c:5039
static void test_object_lifetime(void)
Definition: font.c:8775
static void test_GetSimulations(void)
Definition: font.c:4509
static void test_GetGlyphImageFormats(void)
Definition: font.c:9388
static void test_CreateGlyphRunAnalysis(void)
Definition: font.c:5666
static void test_GetFontSignature(void)
Definition: font.c:8251
static void test_GetKerningPairAdjustments(void)
Definition: font.c:5544
static IDWriteFactory * create_factory(void)
Definition: font.c:460
static void test_shared_isolated(void)
Definition: font.c:3476
static void test_GetEudcFontCollection(void)
Definition: font.c:5406
static void test_CreateFontFace(void)
Definition: font.c:1849
static void test_IsSymbolFont(void)
Definition: font.c:7514
static void test_GetMatchingFontsByLOGFONT(void)
Definition: font.c:10433
static void test_fontsetbuilder(void)
Definition: font.c:9628
static void test_IsColorFont(void)
Definition: font.c:10050
static void test_HasKerningPairs(void)
Definition: font.c:8522
static void test_GetFirstMatchingFont(void)
Definition: font.c:3977
static void test_GetGdiInterop(void)
Definition: font.c:4218
static void test_CreateFontFileReference(void)
Definition: font.c:3430
static void test_CustomFontCollection(void)
Definition: font.c:3027
static void test_CreateRenderingParams(void)
Definition: font.c:5590
static void test_family_font_set(void)
Definition: font.c:10233
static void test_localfontfileloader(void)
Definition: font.c:9536
static void test_GetGdiCompatibleGlyphAdvances(void)
Definition: font.c:6645
static void test_CreateCustomFontFileReference(void)
Definition: font.c:3244
static void test_GetGlyphRunOutline(void)
Definition: font.c:5254
static void test_ConvertFontToLOGFONT(void)
Definition: font.c:4757

◆ table_read_be_dword()

static DWORD table_read_be_dword ( const struct dwrite_fonttable *  table,
void *  ptr,
DWORD  offset 
)
static

Definition at line 3557 of file font.c.

3558{
3559 if (!ptr)
3560 ptr = table->data;
3561
3562 if ((BYTE *)ptr < table->data || (BYTE *)ptr - table->data >= table->size)
3563 return 0;
3564
3565 if (offset > table->size - sizeof(WORD))
3566 return 0;
3567
3568 return GET_BE_DWORD(*(DWORD *)((BYTE *)ptr + offset));
3569}

Referenced by get_cblc_formats(), get_expected_fontsig(), and opentype_cmap_read_table().

◆ table_read_be_word()

static WORD table_read_be_word ( const struct dwrite_fonttable *  table,
void *  ptr,
DWORD  offset 
)
static

Definition at line 3543 of file font.c.

3544{
3545 if (!ptr)
3546 ptr = table->data;
3547
3548 if ((BYTE *)ptr < table->data || (BYTE *)ptr - table->data >= table->size)
3549 return 0;
3550
3551 if (offset > table->size - sizeof(WORD))
3552 return 0;
3553
3554 return GET_BE_WORD(*(WORD *)((BYTE *)ptr + offset));
3555}

Referenced by get_expected_fontsig(), get_expected_is_symbol(), opentype_cmap_get_unicode_ranges(), and opentype_cmap_read_table().

◆ table_read_ensure()

static const void * table_read_ensure ( const struct dwrite_fonttable *  table,
unsigned int  offset,
unsigned int  size 
)
static

Definition at line 3535 of file font.c.

3536{
3537 if (size > table->size || offset > table->size - size)
3538 return NULL;
3539
3540 return table->data + offset;
3541}

Referenced by get_cblc_formats().

◆ test_AnalyzeContainerType()

static void test_AnalyzeContainerType ( void  )
static

Definition at line 9575 of file font.c.

9576{
9577 struct WOFFHeader2 woff2_header;
9578 struct WOFFHeader woff_header;
9581
9582 factory = create_factory_iid(&IID_IDWriteFactory5);
9583 if (!factory) {
9584 win_skip("AnalyzeContainerType() is not supported.\n");
9585 return;
9586 }
9587
9588 type = IDWriteFactory5_AnalyzeContainerType(factory, NULL, 0);
9589 ok(type == DWRITE_CONTAINER_TYPE_UNKNOWN, "Unexpected container type %u.\n", type);
9590
9591 type = IDWriteFactory5_AnalyzeContainerType(factory, (void const *)0xdeadbeef, 0);
9592 ok(type == DWRITE_CONTAINER_TYPE_UNKNOWN, "Unexpected container type %u.\n", type);
9593
9594 memset(&woff_header, 0xff, sizeof(woff_header));
9595 woff_header.signature = GET_LE_DWORD(MS_WOFF_TAG);
9596 woff_header.length = 0;
9597 type = IDWriteFactory5_AnalyzeContainerType(factory, &woff_header, sizeof(woff_header));
9598 ok(type == DWRITE_CONTAINER_TYPE_WOFF, "Unexpected container type %u.\n", type);
9599
9600 memset(&woff_header, 0xff, sizeof(woff_header));
9601 woff_header.signature = GET_LE_DWORD(MS_WOFF_TAG);
9602 type = IDWriteFactory5_AnalyzeContainerType(factory, &woff_header, sizeof(woff_header.signature));
9603 ok(type == DWRITE_CONTAINER_TYPE_WOFF, "Unexpected container type %u.\n", type);
9604
9605 memset(&woff_header, 0xff, sizeof(woff_header));
9606 woff_header.signature = GET_LE_DWORD(MS_WOFF_TAG);
9607 type = IDWriteFactory5_AnalyzeContainerType(factory, &woff_header, sizeof(woff_header.signature) - 1);
9608 ok(type == DWRITE_CONTAINER_TYPE_UNKNOWN, "Unexpected container type %u.\n", type);
9609
9610 memset(&woff2_header, 0xff, sizeof(woff2_header));
9611 woff2_header.signature = GET_LE_DWORD(MS_WOF2_TAG);
9612 type = IDWriteFactory5_AnalyzeContainerType(factory, &woff2_header, sizeof(woff2_header));
9613 ok(type == DWRITE_CONTAINER_TYPE_WOFF2, "Unexpected container type %u.\n", type);
9614
9615 memset(&woff2_header, 0xff, sizeof(woff2_header));
9616 woff2_header.signature = GET_LE_DWORD(MS_WOF2_TAG);
9617 type = IDWriteFactory5_AnalyzeContainerType(factory, &woff2_header, sizeof(woff2_header.signature));
9618 ok(type == DWRITE_CONTAINER_TYPE_WOFF2, "Unexpected container type %u.\n", type);
9619
9620 memset(&woff2_header, 0xff, sizeof(woff2_header));
9621 woff2_header.signature = GET_LE_DWORD(MS_WOF2_TAG);
9622 type = IDWriteFactory5_AnalyzeContainerType(factory, &woff2_header, sizeof(woff2_header.signature) - 1);
9623 ok(type == DWRITE_CONTAINER_TYPE_UNKNOWN, "Unexpected container type %u.\n", type);
9624
9625 IDWriteFactory5_Release(factory);
9626}
#define MS_WOFF_TAG
Definition: font.c:59
#define MS_WOF2_TAG
Definition: font.c:60
#define GET_LE_DWORD(x)
Definition: font.c:71

Referenced by START_TEST().

◆ test_ComputeGlyphOrigins()

static void test_ComputeGlyphOrigins ( void  )
static

Definition at line 8662 of file font.c.

8663{
8664 static const struct origins_test
8665 {
8666 D2D1_POINT_2F baseline_origin;
8667 float advances[2];
8669 unsigned int bidi_level;
8670 unsigned int sideways;
8671 }
8672 origins_tests[] =
8673 {
8674 { { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0 } } },
8675 { { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0.3f, 0.5f }, { -0.1f, 0.9f } } },
8676 { { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0 } }, 1 },
8677
8678 { { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0 } }, 0, 1 },
8679 { { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0.3f, 0.5f }, { -0.1f, 0.9f } }, 0, 1 },
8680 { { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0 } }, 1, 1 },
8681 { { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0.3f, 0.5f }, { -0.1f, 0.9f } }, 1, 1 },
8682 };
8684 DWRITE_GLYPH_RUN run;
8685 HRESULT hr;
8686 D2D1_POINT_2F origins[2], expected_origins[2];
8687 D2D1_POINT_2F baseline_origin;
8688 UINT16 glyphs[2] = { 0 };
8689 FLOAT advances[2];
8691 ULONG ref;
8692 unsigned int i, j;
8693 IDWriteFontFace *fontface;
8694
8695 factory = create_factory_iid(&IID_IDWriteFactory4);
8696 if (!factory) {
8697 win_skip("ComputeGlyphOrigins() is not supported.\n");
8698 return;
8699 }
8700
8701 fontface = create_fontface((IDWriteFactory *)factory);
8702
8703 for (i = 0; i < ARRAY_SIZE(origins_tests); ++i)
8704 {
8705 run.fontFace = fontface;
8706 run.fontEmSize = 32.0f;
8707 run.glyphCount = 2;
8708 run.glyphIndices = glyphs;
8709 run.glyphAdvances = origins_tests[i].advances;
8710 run.glyphOffsets = origins_tests[i].offsets;
8711 run.isSideways = !!origins_tests[i].sideways;
8712 run.bidiLevel = origins_tests[i].bidi_level;
8713
8714 get_expected_glyph_origins(origins_tests[i].baseline_origin, &run, expected_origins);
8715
8716 memset(origins, 0, sizeof(origins));
8717 hr = IDWriteFactory4_ComputeGlyphOrigins_(factory, &run, origins_tests[i].baseline_origin, origins);
8718 ok(hr == S_OK, "%u: failed to compute glyph origins, hr %#lx.\n", i, hr);
8719 for (j = 0; j < run.glyphCount; ++j)
8720 {
8722 ok(!memcmp(&origins[j], &expected_origins[j], sizeof(origins[j])),
8723 "%u: unexpected origin[%u] (%f, %f) - (%f, %f).\n", i, j, origins[j].x, origins[j].y,
8724 expected_origins[j].x, expected_origins[j].y);
8725 }
8726 }
8727
8728 IDWriteFontFace_Release(fontface);
8729
8730 advances[0] = 10.0f;
8731 advances[1] = 20.0f;
8732
8733 run.fontFace = NULL;
8734 run.fontEmSize = 16.0f;
8735 run.glyphCount = 2;
8736 run.glyphIndices = glyphs;
8737 run.glyphAdvances = advances;
8738 run.glyphOffsets = NULL;
8739 run.isSideways = FALSE;
8740 run.bidiLevel = 0;
8741
8742 baseline_origin.x = 123.0f;
8743 baseline_origin.y = 321.0f;
8744
8745 memset(origins, 0, sizeof(origins));
8746 hr = IDWriteFactory4_ComputeGlyphOrigins_(factory, &run, baseline_origin, origins);
8747 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8748 ok(origins[0].x == 123.0f && origins[0].y == 321.0f, "origins[0] %f,%f\n", origins[0].x, origins[0].y);
8749 ok(origins[1].x == 133.0f && origins[1].y == 321.0f, "origins[1] %f,%f\n", origins[1].x, origins[1].y);
8750
8751 memset(origins, 0, sizeof(origins));
8752 hr = IDWriteFactory4_ComputeGlyphOrigins(factory, &run, DWRITE_MEASURING_MODE_NATURAL, baseline_origin,
8753 NULL, origins);
8754 ok(origins[0].x == 123.0f && origins[0].y == 321.0f, "origins[0] %f,%f\n", origins[0].x, origins[0].y);
8755 ok(origins[1].x == 133.0f && origins[1].y == 321.0f, "origins[1] %f,%f\n", origins[1].x, origins[1].y);
8756
8757 /* transform is not applied to returned origins */
8758 m.m11 = 2.0f;
8759 m.m12 = 0.0f;
8760 m.m21 = 0.0f;
8761 m.m22 = 1.0f;
8762 m.dx = 0.0f;
8763 m.dy = 0.0f;
8764
8765 memset(origins, 0, sizeof(origins));
8766 hr = IDWriteFactory4_ComputeGlyphOrigins(factory, &run, DWRITE_MEASURING_MODE_NATURAL, baseline_origin,
8767 &m, origins);
8768 ok(origins[0].x == 123.0f && origins[0].y == 321.0f, "origins[0] %f,%f\n", origins[0].x, origins[0].y);
8769 ok(origins[1].x == 133.0f && origins[1].y == 321.0f, "origins[1] %f,%f\n", origins[1].x, origins[1].y);
8770
8771 ref = IDWriteFactory4_Release(factory);
8772 ok(ref == 0, "factory not released, %lu\n", ref);
8773}
void CDECL unexpected(void)
Definition: cpp.c:711
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
static const FxOffsetAndName offsets[]
GLdouble n
Definition: glext.h:7729
GLfloat f
Definition: glext.h:7540
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
voidpf uLong int origin
Definition: ioapi.h:144
#define todo_wine_if(is_todo)
Definition: minitest.h:81
static IDWriteFontFace * create_fontface(void)
Definition: analyzer.c:496
static void get_expected_glyph_origins(D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *run, D2D1_POINT_2F *origins)
Definition: font.c:8603

Referenced by START_TEST().

◆ test_ConvertFontFaceToLOGFONT()

static void test_ConvertFontFaceToLOGFONT ( void  )
static

Definition at line 2802 of file font.c.

2803{
2805 IDWriteGdiInterop *interop;
2806 IDWriteFontFace *fontface;
2808 LOGFONTW logfont;
2809 UINT32 count, i;
2810 HRESULT hr;
2811 ULONG ref;
2812
2814
2815 hr = IDWriteFactory_GetGdiInterop(factory, &interop);
2816 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2817
2818if (0) /* crashes on native */
2819{
2820 hr = IDWriteGdiInterop_ConvertFontFaceToLOGFONT(interop, NULL, NULL);
2821 hr = IDWriteGdiInterop_ConvertFontFaceToLOGFONT(interop, fontface, NULL);
2822}
2823 memset(&logfont, 0xcc, sizeof(logfont));
2824 hr = IDWriteGdiInterop_ConvertFontFaceToLOGFONT(interop, NULL, &logfont);
2825 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
2826 ok(logfont.lfFaceName[0] == 0, "got face name %s\n", wine_dbgstr_w(logfont.lfFaceName));
2827
2828 hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
2829 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2830
2831 count = IDWriteFontCollection_GetFontFamilyCount(collection);
2832 for (i = 0; i < count; i++) {
2833 WCHAR nameW[128], familynameW[64], facenameW[64];
2836 IDWriteFontFamily *family;
2837 UINT32 font_count, j;
2839 LOGFONTW lf;
2840
2841 hr = IDWriteFontCollection_GetFontFamily(collection, i, &family);
2842 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2843
2844 hr = IDWriteFontFamily_GetFamilyNames(family, &names);
2845 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2846
2847 get_enus_string(names, familynameW, ARRAY_SIZE(familynameW));
2848 IDWriteLocalizedStrings_Release(names);
2849
2850 font_count = IDWriteFontFamily_GetFontCount(family);
2851
2852 for (j = 0; j < font_count; j++) {
2853 IDWriteFontFace *fontface;
2854
2855 hr = IDWriteFontFamily_GetFont(family, j, &font);
2856 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2857
2858 hr = IDWriteFont_GetFaceNames(font, &names);
2859 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2860
2861 get_enus_string(names, facenameW, ARRAY_SIZE(facenameW));
2862 IDWriteLocalizedStrings_Release(names);
2863
2864 get_combined_font_name(familynameW, facenameW, nameW);
2865
2866 hr = IDWriteFont_CreateFontFace(font, &fontface);
2867 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2868
2869 if (has_face_variations(fontface))
2870 {
2871 static int once;
2872 if (!once++)
2873 skip("ConvertFontFaceToLOGFONT() test does not support variable fonts.\n");
2874 IDWriteFontFace_Release(fontface);
2875 IDWriteFont_Release(font);
2876 continue;
2877 }
2878
2879 memset(&logfont, 0xcc, sizeof(logfont));
2880 hr = IDWriteGdiInterop_ConvertFontFaceToLOGFONT(interop, fontface, &logfont);
2881 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2882
2883 sim = IDWriteFontFace_GetSimulations(fontface);
2885
2887
2888 ok(logfont.lfWeight == lf.lfWeight, "Unexpected lfWeight %ld, expected lfWeight %ld, font weight %d, "
2889 "bold simulation %s.\n", logfont.lfWeight, lf.lfWeight, IDWriteFont_GetWeight(font),
2890 sim & DWRITE_FONT_SIMULATIONS_BOLD ? "yes" : "no");
2891 ok(logfont.lfItalic == lf.lfItalic, "Unexpected italic flag %d, oblique simulation %s.\n",
2892 logfont.lfItalic, sim & DWRITE_FONT_SIMULATIONS_OBLIQUE ? "yes" : "no");
2893 ok(!lstrcmpW(logfont.lfFaceName, lf.lfFaceName), "Unexpected facename %s, expected %s\n",
2895
2896 ok(logfont.lfOutPrecision == OUT_OUTLINE_PRECIS, "Unexpected output precision %d.\n", logfont.lfOutPrecision);
2897 ok(logfont.lfClipPrecision == CLIP_DEFAULT_PRECIS, "Unexpected clipping precision %d.\n", logfont.lfClipPrecision);
2898 ok(logfont.lfQuality == DEFAULT_QUALITY, "Unexpected quality %d.\n", logfont.lfQuality);
2899 ok(logfont.lfPitchAndFamily == DEFAULT_PITCH, "Unexpected pitch %d.\n", logfont.lfPitchAndFamily);
2900
2902
2903 IDWriteFontFace_Release(fontface);
2904 IDWriteFont_Release(font);
2905 }
2906
2907 IDWriteFontFamily_Release(family);
2908 }
2909
2910 IDWriteFontCollection_Release(collection);
2911 IDWriteGdiInterop_Release(interop);
2912 ref = IDWriteFactory_Release(factory);
2913 ok(ref == 0, "factory not released, %lu\n", ref);
2914}
#define E_INVALIDARG
Definition: ddrawi.h:101
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
static void get_enus_string(IDWriteLocalizedStrings *strings, WCHAR *buff, UINT32 size)
Definition: font.c:2201
static void get_combined_font_name(const WCHAR *familyW, const WCHAR *faceW, WCHAR *nameW)
Definition: font.c:567
static BOOL has_face_variations(IDWriteFontFace *fontface)
Definition: font.c:574
static void get_logfont_from_font(IDWriteFont *font, LOGFONTW *logfont)
Definition: font.c:2688
BYTE lfOutPrecision
Definition: dimm.idl:68
BYTE lfClipPrecision
Definition: dimm.idl:69
BYTE lfPitchAndFamily
Definition: dimm.idl:71
#define DEFAULT_PITCH
Definition: wingdi.h:443
#define DEFAULT_QUALITY
Definition: wingdi.h:436
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
#define OUT_OUTLINE_PRECIS
Definition: wingdi.h:423

Referenced by START_TEST().

◆ test_ConvertFontToLOGFONT()

static void test_ConvertFontToLOGFONT ( void  )
static

Definition at line 4757 of file font.c.

4758{
4759 IDWriteFactory *factory, *factory2;
4761 IDWriteGdiInterop *interop;
4762 IDWriteFontFamily *family;
4764 LOGFONTW logfont;
4765 UINT32 i, count;
4766 BOOL system;
4767 HRESULT hr;
4768 ULONG ref;
4769
4771 factory2 = create_factory();
4772
4773 interop = NULL;
4774 hr = IDWriteFactory_GetGdiInterop(factory, &interop);
4775 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4776
4777 hr = IDWriteFactory_GetSystemFontCollection(factory2, &collection, FALSE);
4778 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4779
4780 hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
4781 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4782
4783 hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
4785 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4786
4787if (0) { /* crashes on native */
4788 IDWriteGdiInterop_ConvertFontToLOGFONT(interop, NULL, NULL, NULL);
4789 IDWriteGdiInterop_ConvertFontToLOGFONT(interop, NULL, &logfont, NULL);
4790 IDWriteGdiInterop_ConvertFontToLOGFONT(interop, font, NULL, &system);
4791}
4792
4793 memset(&logfont, 0xcc, sizeof(logfont));
4794 system = TRUE;
4795 hr = IDWriteGdiInterop_ConvertFontToLOGFONT(interop, NULL, &logfont, &system);
4796 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
4797 ok(!system, "got %d\n", system);
4798 ok(logfont.lfFaceName[0] == 0, "got face name %s\n", wine_dbgstr_w(logfont.lfFaceName));
4799
4800 count = IDWriteFontCollection_GetFontFamilyCount(collection);
4801 for (i = 0; i < count; i++) {
4802 WCHAR nameW[128], familynameW[64], facenameW[64];
4805 IDWriteFontFamily *family;
4806 UINT32 font_count, j;
4808 LOGFONTW lf;
4809
4810 hr = IDWriteFontCollection_GetFontFamily(collection, i, &family);
4811 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4812
4813 hr = IDWriteFontFamily_GetFamilyNames(family, &names);
4814 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4815
4816 get_enus_string(names, familynameW, ARRAY_SIZE(familynameW));
4817 IDWriteLocalizedStrings_Release(names);
4818
4819 font_count = IDWriteFontFamily_GetFontCount(family);
4820
4821 for (j = 0; j < font_count; ++j)
4822 {
4823 IDWriteFontFace *fontface;
4824 BOOL has_variations;
4825
4826 hr = IDWriteFontFamily_GetFont(family, j, &font);
4827 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4828
4829 hr = IDWriteFont_GetFaceNames(font, &names);
4830 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4831
4832 get_enus_string(names, facenameW, ARRAY_SIZE(facenameW));
4833 IDWriteLocalizedStrings_Release(names);
4834
4835 lstrcpyW(nameW, familynameW);
4836 lstrcatW(nameW, L" ");
4837 lstrcatW(nameW, facenameW);
4838
4839 hr = IDWriteFont_CreateFontFace(font, &fontface);
4840 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4841
4842 has_variations = has_face_variations(fontface);
4843 IDWriteFontFace_Release(fontface);
4844
4845 if (has_variations)
4846 {
4847 static int once;
4848 if (!once++)
4849 skip("ConvertFontToLOGFONT() test does not support variable fonts.\n");
4850 IDWriteFont_Release(font);
4851 continue;
4852 }
4853
4854 system = FALSE;
4855 memset(&logfont, 0xcc, sizeof(logfont));
4856 hr = IDWriteGdiInterop_ConvertFontToLOGFONT(interop, font, &logfont, &system);
4857 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4858 ok(system, "got %d\n", system);
4859
4860 sim = IDWriteFont_GetSimulations(font);
4861
4863
4865 ok(logfont.lfWeight == lf.lfWeight, "Unexpected lfWeight %ld, expected lfWeight %ld, font weight %d, "
4866 "bold simulation %s.\n", logfont.lfWeight, lf.lfWeight, IDWriteFont_GetWeight(font),
4867 sim & DWRITE_FONT_SIMULATIONS_BOLD ? "yes" : "no");
4868 ok(logfont.lfItalic == lf.lfItalic, "Unexpected italic flag %d, oblique simulation %s.\n",
4869 logfont.lfItalic, sim & DWRITE_FONT_SIMULATIONS_OBLIQUE ? "yes" : "no");
4870 ok(!lstrcmpW(logfont.lfFaceName, lf.lfFaceName), "Unexpected facename %s, expected %s.\n",
4872
4873 ok(logfont.lfOutPrecision == OUT_OUTLINE_PRECIS, "Unexpected output precision %d.\n", logfont.lfOutPrecision);
4874 ok(logfont.lfClipPrecision == CLIP_DEFAULT_PRECIS, "Unexpected clipping precision %d.\n", logfont.lfClipPrecision);
4875 ok(logfont.lfQuality == DEFAULT_QUALITY, "Unexpected quality %d.\n", logfont.lfQuality);
4876 ok(logfont.lfPitchAndFamily == DEFAULT_PITCH, "Unexpected pitch %d.\n", logfont.lfPitchAndFamily);
4877
4879
4880 IDWriteFont_Release(font);
4881 }
4882
4883 IDWriteFontFamily_Release(family);
4884 }
4885
4886 IDWriteFactory_Release(factory2);
4887
4888 IDWriteFontCollection_Release(collection);
4889 IDWriteFontFamily_Release(family);
4890 IDWriteFont_Release(font);
4891 IDWriteGdiInterop_Release(interop);
4892 ref = IDWriteFactory_Release(factory);
4893 ok(ref == 0, "factory not released, %lu\n", ref);
4894}
_ACRTIMP int __cdecl system(const char *)
Definition: process.c:1297
@ DWRITE_FONT_STYLE_NORMAL
Definition: dwrite.idl:110

Referenced by START_TEST().

◆ test_CreateAlphaTexture()

static void test_CreateAlphaTexture ( void  )
static

Definition at line 7319 of file font.c.

7320{
7321 IDWriteGlyphRunAnalysis *analysis;
7324 IDWriteFontFace *fontface;
7326 DWRITE_GLYPH_RUN run;
7327 UINT32 ch, size;
7328 BYTE buff[1024];
7329 RECT bounds, r;
7330 FLOAT advance;
7331 UINT16 glyph;
7332 HRESULT hr;
7333 ULONG ref;
7334
7336 fontface = create_fontface(factory);
7337
7338 ch = 'A';
7339 glyph = 0;
7340 hr = IDWriteFontFace_GetGlyphIndices(fontface, &ch, 1, &glyph);
7341 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7342 ok(glyph > 0, "got %u\n", glyph);
7343
7344 hr = IDWriteFontFace_GetDesignGlyphMetrics(fontface, &glyph, 1, &metrics, FALSE);
7345 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7346 advance = metrics.advanceWidth;
7347
7348 offset.advanceOffset = 0.0;
7349 offset.ascenderOffset = 0.0;
7350
7351 run.fontFace = fontface;
7352 run.fontEmSize = 24.0;
7353 run.glyphCount = 1;
7354 run.glyphIndices = &glyph;
7355 run.glyphAdvances = &advance;
7356 run.glyphOffsets = &offset;
7357 run.isSideways = FALSE;
7358 run.bidiLevel = 0;
7359
7360 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
7362 0.0, 0.0, &analysis);
7363 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7364
7365 SetRectEmpty(&bounds);
7366 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &bounds);
7367 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7368 ok(!IsRectEmpty(&bounds), "got empty rect\n");
7369 size = (bounds.right - bounds.left)*(bounds.bottom - bounds.top)*3;
7370 ok(sizeof(buff) >= size, "required %u\n", size);
7371
7372 /* invalid type value */
7373 memset(buff, 0xcf, sizeof(buff));
7374 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1+1, &bounds, buff, sizeof(buff));
7375 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
7376 ok(buff[0] == 0xcf, "got %1x\n", buff[0]);
7377
7378 memset(buff, 0xcf, sizeof(buff));
7379 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &bounds, buff, 2);
7380 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#lx.\n", hr);
7381 ok(buff[0] == 0xcf, "got %1x\n", buff[0]);
7382
7383 /* vista version allows texture type mismatch, mark it broken for now */
7384 memset(buff, 0xcf, sizeof(buff));
7385 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &bounds, buff, sizeof(buff));
7386 ok(hr == DWRITE_E_UNSUPPORTEDOPERATION || broken(hr == S_OK), "Unexpected hr %#lx.\n", hr);
7387 ok(buff[0] == 0xcf || broken(buff[0] == 0), "got %1x\n", buff[0]);
7388
7389 memset(buff, 0xcf, sizeof(buff));
7390 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &bounds, buff, size-1);
7391 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#lx.\n", hr);
7392 ok(buff[0] == 0xcf, "got %1x\n", buff[0]);
7393
7394 IDWriteGlyphRunAnalysis_Release(analysis);
7395
7396 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
7398 0.0, 0.0, &analysis);
7399 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7400
7401 SetRectEmpty(&bounds);
7402 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &bounds);
7403 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7404 ok(!IsRectEmpty(&bounds), "got empty rect\n");
7405 size = (bounds.right - bounds.left)*(bounds.bottom - bounds.top);
7406 ok(sizeof(buff) >= size, "required %u\n", size);
7407
7408 memset(buff, 0xcf, sizeof(buff));
7409 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, NULL, buff, sizeof(buff));
7410 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
7411 ok(buff[0] == 0xcf, "got %1x\n", buff[0]);
7412
7413 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, NULL, NULL, sizeof(buff));
7414 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
7415
7416 memset(buff, 0xcf, sizeof(buff));
7417 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, NULL, buff, 0);
7418 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
7419 ok(buff[0] == 0xcf, "got %1x\n", buff[0]);
7420
7421 /* buffer size is not enough */
7422 memset(buff, 0xcf, sizeof(buff));
7423 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &bounds, buff, size-1);
7424 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#lx.\n", hr);
7425 ok(buff[0] == 0xcf, "got %1x\n", buff[0]);
7426
7427 /* request texture for rectangle that doesn't intersect */
7428 memset(buff, 0xcf, sizeof(buff));
7429 r = bounds;
7430 OffsetRect(&r, (bounds.right - bounds.left)*2, 0);
7431 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &r, buff, sizeof(buff));
7432 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7433 ok(buff[0] == 0, "got %1x\n", buff[0]);
7434
7435 memset(buff, 0xcf, sizeof(buff));
7436 r = bounds;
7437 OffsetRect(&r, (bounds.right - bounds.left)*2, 0);
7438 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &r, buff, sizeof(buff));
7439 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7440 ok(buff[0] == 0, "got %1x\n", buff[0]);
7441
7442 /* request texture for rectangle that doesn't intersect, small buffer */
7443 memset(buff, 0xcf, sizeof(buff));
7444 r = bounds;
7445 OffsetRect(&r, (bounds.right - bounds.left)*2, 0);
7446 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &r, buff, size-1);
7447 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#lx.\n", hr);
7448 ok(buff[0] == 0xcf, "got %1x\n", buff[0]);
7449
7450 /* vista version allows texture type mismatch, mark it broken for now */
7451 memset(buff, 0xcf, sizeof(buff));
7452 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &bounds, buff, sizeof(buff));
7453 ok(hr == DWRITE_E_UNSUPPORTEDOPERATION || broken(hr == S_OK), "Unexpected hr %#lx.\n", hr);
7454 ok(buff[0] == 0xcf || broken(buff[0] == 0), "got %1x\n", buff[0]);
7455
7456 IDWriteGlyphRunAnalysis_Release(analysis);
7457 IDWriteFontFace_Release(fontface);
7458 ref = IDWriteFactory_Release(factory);
7459 ok(ref == 0, "factory not released, %lu\n", ref);
7460}
unsigned char ch[4][2]
Definition: console.c:118
@ DWRITE_RENDERING_MODE_ALIASED
Definition: dwrite.idl:162
@ DWRITE_TEXTURE_ALIASED_1x1
Definition: dwrite.idl:347
@ DWRITE_TEXTURE_CLEARTYPE_3x1
Definition: dwrite.idl:348
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:3437
#define DWRITE_E_UNSUPPORTEDOPERATION
Definition: winerror.h:7343

Referenced by START_TEST().

◆ test_CreateBitmapRenderTarget()

static void test_CreateBitmapRenderTarget ( void  )
static

Definition at line 1208 of file font.c.

1209{
1213 IDWriteGdiInterop *interop;
1214 IDWriteFontFace *fontface;
1216 DWRITE_GLYPH_RUN run;
1217 HBITMAP hbm, hbm2;
1218 UINT16 glyphs[2];
1220 DIBSECTION ds;
1221 XFORM xform;
1222 COLORREF c;
1223 HRESULT hr;
1224 FLOAT pdip;
1225 SIZE size;
1226 ULONG ref;
1227 UINT32 ch;
1228 RECT box;
1229 HDC hdc;
1230 int ret;
1231
1233
1234 hr = IDWriteFactory_GetGdiInterop(factory, &interop);
1235 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1236
1237 target = NULL;
1238 hr = IDWriteGdiInterop_CreateBitmapRenderTarget(interop, NULL, 0, 0, &target);
1239 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1240
1241 if (0) /* crashes on native */
1242 hr = IDWriteBitmapRenderTarget_GetSize(target, NULL);
1243
1244 size.cx = size.cy = -1;
1245 hr = IDWriteBitmapRenderTarget_GetSize(target, &size);
1246 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1247 ok(size.cx == 0, "got %ld\n", size.cx);
1248 ok(size.cy == 0, "got %ld\n", size.cy);
1249
1250 target2 = NULL;
1251 hr = IDWriteGdiInterop_CreateBitmapRenderTarget(interop, NULL, 0, 0, &target2);
1252 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1253 ok(target != target2, "got %p, %p\n", target2, target);
1254 IDWriteBitmapRenderTarget_Release(target2);
1255
1256 hdc = IDWriteBitmapRenderTarget_GetMemoryDC(target);
1257 ok(hdc != NULL, "got %p\n", hdc);
1258
1259 /* test mode */
1261 ok(ret == GM_ADVANCED, "got %d\n", ret);
1262
1264 ok(hbm != NULL, "got %p\n", hbm);
1265
1266 /* check DIB properties */
1267 ret = GetObjectW(hbm, sizeof(ds), &ds);
1268 ok(ret == sizeof(BITMAP), "got %d\n", ret);
1269 ok(ds.dsBm.bmWidth == 1, "got %d\n", ds.dsBm.bmWidth);
1270 ok(ds.dsBm.bmHeight == 1, "got %d\n", ds.dsBm.bmHeight);
1271 ok(ds.dsBm.bmPlanes == 1, "got %d\n", ds.dsBm.bmPlanes);
1272 ok(ds.dsBm.bmBitsPixel == 1, "got %d\n", ds.dsBm.bmBitsPixel);
1273 ok(!ds.dsBm.bmBits, "got %p\n", ds.dsBm.bmBits);
1274
1275 IDWriteBitmapRenderTarget_Release(target);
1276
1278 ok(!hbm, "got %p\n", hbm);
1279
1280 target = NULL;
1281 hr = IDWriteGdiInterop_CreateBitmapRenderTarget(interop, NULL, 10, 5, &target);
1282 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1283
1284 hdc = IDWriteBitmapRenderTarget_GetMemoryDC(target);
1285 ok(hdc != NULL, "got %p\n", hdc);
1286
1287 /* test context settings */
1288 c = GetTextColor(hdc);
1289 ok(c == RGB(0, 0, 0), "got 0x%08lx\n", c);
1290 ret = GetBkMode(hdc);
1291 ok(ret == OPAQUE, "got %d\n", ret);
1292 c = GetBkColor(hdc);
1293 ok(c == RGB(255, 255, 255), "got 0x%08lx\n", c);
1294
1296 ok(hbm != NULL, "got %p\n", hbm);
1297
1298 /* check DIB properties */
1299 ret = GetObjectW(hbm, sizeof(ds), &ds);
1300 ok(ret == sizeof(ds), "got %d\n", ret);
1301 ok(ds.dsBm.bmWidth == 10, "got %d\n", ds.dsBm.bmWidth);
1302 ok(ds.dsBm.bmHeight == 5, "got %d\n", ds.dsBm.bmHeight);
1303 ok(ds.dsBm.bmPlanes == 1, "got %d\n", ds.dsBm.bmPlanes);
1304 ok(ds.dsBm.bmBitsPixel == 32, "got %d\n", ds.dsBm.bmBitsPixel);
1305 ok(ds.dsBm.bmBits != NULL, "got %p\n", ds.dsBm.bmBits);
1306
1307 size.cx = size.cy = -1;
1308 hr = IDWriteBitmapRenderTarget_GetSize(target, &size);
1309 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1310 ok(size.cx == 10, "got %ld\n", size.cx);
1311 ok(size.cy == 5, "got %ld\n", size.cy);
1312
1313 /* resize to same size */
1314 hr = IDWriteBitmapRenderTarget_Resize(target, 10, 5);
1315 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1316
1318 ok(hbm2 == hbm, "got %p, %p\n", hbm2, hbm);
1319
1320 /* shrink */
1321 hr = IDWriteBitmapRenderTarget_Resize(target, 5, 5);
1322 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1323
1324 size.cx = size.cy = -1;
1325 hr = IDWriteBitmapRenderTarget_GetSize(target, &size);
1326 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1327 ok(size.cx == 5, "got %ld\n", size.cx);
1328 ok(size.cy == 5, "got %ld\n", size.cy);
1329
1331 ok(hbm2 != hbm, "got %p, %p\n", hbm2, hbm);
1332
1333 hr = IDWriteBitmapRenderTarget_Resize(target, 20, 5);
1334 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1335
1336 size.cx = size.cy = -1;
1337 hr = IDWriteBitmapRenderTarget_GetSize(target, &size);
1338 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1339 ok(size.cx == 20, "got %ld\n", size.cx);
1340 ok(size.cy == 5, "got %ld\n", size.cy);
1341
1343 ok(hbm2 != hbm, "got %p, %p\n", hbm2, hbm);
1344
1345 hr = IDWriteBitmapRenderTarget_Resize(target, 1, 5);
1346 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1347
1348 size.cx = size.cy = -1;
1349 hr = IDWriteBitmapRenderTarget_GetSize(target, &size);
1350 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1351 ok(size.cx == 1, "got %ld\n", size.cx);
1352 ok(size.cy == 5, "got %ld\n", size.cy);
1353
1355 ok(hbm2 != hbm, "got %p, %p\n", hbm2, hbm);
1356
1357 ret = GetObjectW(hbm2, sizeof(ds), &ds);
1358 ok(ret == sizeof(ds), "got %d\n", ret);
1359 ok(ds.dsBm.bmWidth == 1, "got %d\n", ds.dsBm.bmWidth);
1360 ok(ds.dsBm.bmHeight == 5, "got %d\n", ds.dsBm.bmHeight);
1361 ok(ds.dsBm.bmPlanes == 1, "got %d\n", ds.dsBm.bmPlanes);
1362 ok(ds.dsBm.bmBitsPixel == 32, "got %d\n", ds.dsBm.bmBitsPixel);
1363 ok(ds.dsBm.bmBits != NULL, "got %p\n", ds.dsBm.bmBits);
1364
1365 /* empty rectangle */
1366 hr = IDWriteBitmapRenderTarget_Resize(target, 0, 5);
1367 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1368
1369 size.cx = size.cy = -1;
1370 hr = IDWriteBitmapRenderTarget_GetSize(target, &size);
1371 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1372 ok(size.cx == 0, "got %ld\n", size.cx);
1373 ok(size.cy == 5, "got %ld\n", size.cy);
1374
1376 ok(hbm2 != hbm, "got %p, %p\n", hbm2, hbm);
1377
1378 ret = GetObjectW(hbm2, sizeof(ds), &ds);
1379 ok(ret == sizeof(BITMAP), "got %d\n", ret);
1380 ok(ds.dsBm.bmWidth == 1, "got %d\n", ds.dsBm.bmWidth);
1381 ok(ds.dsBm.bmHeight == 1, "got %d\n", ds.dsBm.bmHeight);
1382 ok(ds.dsBm.bmPlanes == 1, "got %d\n", ds.dsBm.bmPlanes);
1383 ok(ds.dsBm.bmBitsPixel == 1, "got %d\n", ds.dsBm.bmBitsPixel);
1384 ok(!ds.dsBm.bmBits, "got %p\n", ds.dsBm.bmBits);
1385
1386 /* transform tests, current hdc transform is not immediately affected */
1387 if (0) /* crashes on native */
1388 hr = IDWriteBitmapRenderTarget_GetCurrentTransform(target, NULL);
1389
1390 memset(&m, 0xcc, sizeof(m));
1391 hr = IDWriteBitmapRenderTarget_GetCurrentTransform(target, &m);
1392 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1393 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);
1394 ok(m.dx == 0.0 && m.dy == 0.0, "got %.1f,%.1f\n", m.dx, m.dy);
1395 ret = GetWorldTransform(hdc, &xform);
1396 ok(ret, "got %d\n", ret);
1397 ok(xform.eM11 == 1.0 && xform.eM22 == 1.0 && xform.eM12 == 0.0 && xform.eM21 == 0.0, "got wrong transform\n");
1398 ok(xform.eDx == 0.0 && xform.eDy == 0.0, "got %.1f,%.1f\n", xform.eDx, xform.eDy);
1399
1400 memset(&m, 0, sizeof(m));
1401 hr = IDWriteBitmapRenderTarget_SetCurrentTransform(target, &m);
1402 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1403
1404 memset(&m, 0xcc, sizeof(m));
1405 hr = IDWriteBitmapRenderTarget_GetCurrentTransform(target, &m);
1406 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1407 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);
1408 ok(m.dx == 0.0 && m.dy == 0.0, "got %.1f,%.1f\n", m.dx, m.dy);
1409 ret = GetWorldTransform(hdc, &xform);
1410 ok(ret, "got %d\n", ret);
1411 ok(xform.eM11 == 1.0 && xform.eM22 == 1.0 && xform.eM12 == 0.0 && xform.eM21 == 0.0, "got wrong transform\n");
1412 ok(xform.eDx == 0.0 && xform.eDy == 0.0, "got %.1f,%.1f\n", xform.eDx, xform.eDy);
1413
1414 memset(&m, 0, sizeof(m));
1415 m.m11 = 2.0; m.m22 = 1.0;
1416 hr = IDWriteBitmapRenderTarget_SetCurrentTransform(target, &m);
1417 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1418 ret = GetWorldTransform(hdc, &xform);
1419 ok(ret, "got %d\n", ret);
1420 ok(xform.eM11 == 1.0 && xform.eM22 == 1.0 && xform.eM12 == 0.0 && xform.eM21 == 0.0, "got wrong transform\n");
1421 ok(xform.eDx == 0.0 && xform.eDy == 0.0, "got %.1f,%.1f\n", xform.eDx, xform.eDy);
1422
1423 hr = IDWriteBitmapRenderTarget_SetCurrentTransform(target, NULL);
1424 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1425
1426 memset(&m, 0xcc, sizeof(m));
1427 hr = IDWriteBitmapRenderTarget_GetCurrentTransform(target, &m);
1428 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1429 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);
1430 ok(m.dx == 0.0 && m.dy == 0.0, "got %.1f,%.1f\n", m.dx, m.dy);
1431
1432 /* pixels per dip */
1433 pdip = IDWriteBitmapRenderTarget_GetPixelsPerDip(target);
1434 ok(pdip == 1.0, "got %.2f\n", pdip);
1435
1436 hr = IDWriteBitmapRenderTarget_SetPixelsPerDip(target, 2.0);
1437 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1438
1439 hr = IDWriteBitmapRenderTarget_SetPixelsPerDip(target, -1.0);
1440 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
1441
1442 hr = IDWriteBitmapRenderTarget_SetPixelsPerDip(target, 0.0);
1443 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
1444
1445 pdip = IDWriteBitmapRenderTarget_GetPixelsPerDip(target);
1446 ok(pdip == 2.0, "got %.2f\n", pdip);
1447
1448 hr = IDWriteBitmapRenderTarget_QueryInterface(target, &IID_IDWriteBitmapRenderTarget1, (void**)&target1);
1449 if (hr == S_OK) {
1451
1452 mode = IDWriteBitmapRenderTarget1_GetTextAntialiasMode(target1);
1453 ok(mode == DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE, "got %d\n", mode);
1454
1455 hr = IDWriteBitmapRenderTarget1_SetTextAntialiasMode(target1, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE+1);
1456 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
1457
1458 mode = IDWriteBitmapRenderTarget1_GetTextAntialiasMode(target1);
1459 ok(mode == DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE, "got %d\n", mode);
1460
1461 hr = IDWriteBitmapRenderTarget1_SetTextAntialiasMode(target1, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE);
1462 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1463
1464 mode = IDWriteBitmapRenderTarget1_GetTextAntialiasMode(target1);
1465 ok(mode == DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE, "got %d\n", mode);
1466
1467 IDWriteBitmapRenderTarget1_Release(target1);
1468 }
1469 else
1470 win_skip("IDWriteBitmapRenderTarget1 is not supported.\n");
1471
1472 /* DrawGlyphRun() argument validation. */
1473 hr = IDWriteBitmapRenderTarget_Resize(target, 16, 16);
1474 ok(hr == S_OK, "Failed to resize target, hr %#lx.\n", hr);
1475
1476 fontface = create_fontface(factory);
1477
1478 ch = 'A';
1479 glyphs[0] = 0;
1480 hr = IDWriteFontFace_GetGlyphIndices(fontface, &ch, 1, glyphs);
1481 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1482 ok(glyphs[0] > 0, "got %u\n", glyphs[0]);
1483 glyphs[1] = glyphs[0];
1484
1485 memset(&run, 0, sizeof(run));
1486 run.fontFace = fontface;
1487 run.fontEmSize = 12.0f;
1488 run.glyphCount = 2;
1489 run.glyphIndices = glyphs;
1490
1491 hr = IDWriteFactory_CreateCustomRenderingParams(factory, 1.0f, 0.0f, 0.0f, DWRITE_PIXEL_GEOMETRY_FLAT,
1493 ok(hr == S_OK, "Failed to create rendering params, hr %#lx.\n", hr);
1494
1495 hr = IDWriteBitmapRenderTarget_DrawGlyphRun(target, 0.0f, 0.0f, DWRITE_MEASURING_MODE_NATURAL,
1496 &run, NULL, RGB(255, 0, 0), NULL);
1497 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
1498
1499 hr = IDWriteBitmapRenderTarget_DrawGlyphRun(target, 0.0f, 0.0f, DWRITE_MEASURING_MODE_GDI_NATURAL + 1,
1500 &run, NULL, RGB(255, 0, 0), NULL);
1501 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
1502
1503 hr = IDWriteBitmapRenderTarget_DrawGlyphRun(target, 0.0f, 0.0f, DWRITE_MEASURING_MODE_GDI_NATURAL + 1,
1504 &run, params, RGB(255, 0, 0), NULL);
1505 ok(hr == E_INVALIDARG || broken(hr == S_OK) /* Vista */, "Unexpected hr %#lx.\n", hr);
1506
1507 hr = IDWriteBitmapRenderTarget_DrawGlyphRun(target, 0.0f, 0.0f, DWRITE_MEASURING_MODE_GDI_NATURAL,
1508 &run, params, RGB(255, 0, 0), NULL);
1509 ok(hr == S_OK, "Failed to draw a run, hr %#lx.\n", hr);
1510
1511 /* Glyph bitmap outside of the target bitmap. */
1512 SetRectEmpty(&box);
1513 hr = IDWriteBitmapRenderTarget_DrawGlyphRun(target, -500.0f, -500.0f, DWRITE_MEASURING_MODE_GDI_NATURAL,
1514 &run, params, RGB(255, 0, 0), &box);
1515 ok(hr == S_OK, "Failed to draw a run, hr %#lx.\n", hr);
1516 ok(!IsRectEmpty(&box), "Got unexpected rectangle %s.\n", wine_dbgstr_rect(&box));
1517
1518 IDWriteRenderingParams_Release(params);
1519
1520 /* Zero sized target returns earlier. */
1521 hr = IDWriteBitmapRenderTarget_Resize(target, 0, 16);
1522 ok(hr == S_OK, "Failed to resize target, hr %#lx.\n", hr);
1523
1524 hr = IDWriteBitmapRenderTarget_DrawGlyphRun(target, 0.0f, 0.0f, DWRITE_MEASURING_MODE_NATURAL,
1525 &run, NULL, RGB(255, 0, 0), NULL);
1526 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1527
1528 hr = IDWriteBitmapRenderTarget_DrawGlyphRun(target, 0.0f, 0.0f, DWRITE_MEASURING_MODE_GDI_NATURAL + 1,
1529 &run, params, RGB(255, 0, 0), NULL);
1530 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1531
1532 IDWriteFontFace_Release(fontface);
1533
1534 ref = IDWriteBitmapRenderTarget_Release(target);
1535 ok(ref == 0, "render target not released, %lu\n", ref);
1536 ref = IDWriteGdiInterop_Release(interop);
1537 ok(ref == 0, "interop not released, %lu\n", ref);
1538 ref = IDWriteFactory_Release(factory);
1539 ok(ref == 0, "factory not released, %lu\n", ref);
1540}
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define RGB(r, g, b)
Definition: precomp.h:67
@ DWRITE_PIXEL_GEOMETRY_FLAT
Definition: dwrite.idl:154
const GLubyte * c
Definition: glext.h:8905
GLenum const GLfloat * params
Definition: glext.h:5645
GLuint64EXT GLuint GLuint GLenum GLenum GLuint GLenum GLuint GLenum target2
Definition: glext.h:10609
GLuint64EXT GLuint GLuint GLenum GLenum GLuint GLuint GLenum target1
Definition: glext.h:10608
#define ds
Definition: i386-dis.c:443
#define c
Definition: ke_i.h:80
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
#define OBJ_BITMAP
Definition: objidl.idl:1020
_In_ HBITMAP hbm
Definition: ntgdi.h:2804
FLOAT eDy
Definition: wingdi.h:2172
FLOAT eM11
Definition: wingdi.h:2167
FLOAT eM21
Definition: wingdi.h:2169
FLOAT eM22
Definition: wingdi.h:2170
FLOAT eM12
Definition: wingdi.h:2168
FLOAT eDx
Definition: wingdi.h:2171
Definition: palette.c:466
Definition: tools.h:99
DWORD COLORREF
Definition: windef.h:100
int WINAPI GetBkMode(_In_ HDC)
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define GM_ADVANCED
Definition: wingdi.h:865
int WINAPI GetGraphicsMode(_In_ HDC)
COLORREF WINAPI GetTextColor(_In_ HDC)
Definition: text.c:860
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:428
COLORREF WINAPI GetBkColor(_In_ HDC)
Definition: dc.c:978
BOOL WINAPI GetWorldTransform(_In_ HDC, _Out_ LPXFORM)
Definition: coord.c:278
#define OPAQUE
Definition: wingdi.h:949

Referenced by START_TEST().

◆ test_CreateCustomFontFileReference()

static void test_CreateCustomFontFileReference ( void  )
static

Definition at line 3244 of file font.c.

3245{
3249 IDWriteFactory *factory, *factory2;
3251 IDWriteFontFile *file, *file2;
3252 BOOL support;
3254 DWRITE_FONT_FACE_TYPE face_type;
3255 UINT32 count;
3256 IDWriteFontFace *face, *face2;
3257 HRESULT hr;
3258 HRSRC fontrsrc;
3259 UINT32 codePoints[1] = {0xa8};
3260 UINT16 indices[2];
3261 const void *key;
3262 UINT32 key_size;
3263 WCHAR *path;
3264 ULONG ref;
3265
3267
3269 factory2 = create_factory();
3270
3271if (0) { /* crashes on win10 */
3272 hr = IDWriteFactory_RegisterFontFileLoader(factory, NULL);
3273 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
3274}
3275 /* local loader is accepted too */
3276 hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
3277 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3278
3279 hr = IDWriteFontFile_GetLoader(file, &loader);
3280 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3281
3282 hr = IDWriteFontFile_GetReferenceKey(file, &key, &key_size);
3283 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3284
3285 hr = IDWriteFactory_CreateCustomFontFileReference(factory, key, key_size, loader, &file2);
3286 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3287
3288 IDWriteFontFile_Release(file2);
3289 IDWriteFontFile_Release(file);
3290 IDWriteFontFileLoader_Release(loader);
3291
3292 hr = IDWriteFactory_RegisterFontFileLoader(factory, &floader);
3293 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3294 hr = IDWriteFactory_RegisterFontFileLoader(factory, &floader2);
3295 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3296 hr = IDWriteFactory_RegisterFontFileLoader(factory, &floader);
3297 ok(hr == DWRITE_E_ALREADYREGISTERED, "Unexpected hr %#lx.\n", hr);
3298 hr = IDWriteFactory_RegisterFontFileLoader(factory, &rloader);
3299 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3300
3301 file = NULL;
3302 hr = IDWriteFactory_CreateCustomFontFileReference(factory, "test", 4, &floader, &file);
3303 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3304 IDWriteFontFile_Release(file);
3305
3306 file = (void*)0xdeadbeef;
3307 hr = IDWriteFactory_CreateCustomFontFileReference(factory, "test", 4, &floader3, &file);
3308 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
3309 ok(file == NULL, "got %p\n", file);
3310
3311 file = (void*)0xdeadbeef;
3312 hr = IDWriteFactory_CreateCustomFontFileReference(factory, "test", 4, NULL, &file);
3313 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
3314 ok(file == NULL, "got %p\n", file);
3315
3316 file = NULL;
3317 hr = IDWriteFactory_CreateCustomFontFileReference(factory, "test", 4, &floader, &file);
3318 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3319
3322 support = TRUE;
3323 count = 1;
3324 hr = IDWriteFontFile_Analyze(file, &support, &file_type, &face_type, &count);
3325 ok(hr == 0x8faecafe, "Unexpected hr %#lx.\n", hr);
3326 ok(support == FALSE, "got %i\n", support);
3328 ok(face_type == DWRITE_FONT_FACE_TYPE_UNKNOWN, "got %i\n", face_type);
3329 ok(count == 0, "got %i\n", count);
3330
3331 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_CFF, 1, &file, 0, 0, &face);
3332 ok(hr == 0x8faecafe, "Unexpected hr %#lx.\n", hr);
3333 IDWriteFontFile_Release(file);
3334
3336 ok(fontrsrc != NULL, "Failed to find font resource\n");
3337
3338 hr = IDWriteFactory_CreateCustomFontFileReference(factory, &fontrsrc, sizeof(HRSRC), &rloader, &file);
3339 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3340
3343 support = FALSE;
3344 count = 0;
3345 hr = IDWriteFontFile_Analyze(file, &support, &file_type, &face_type, &count);
3346 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3347 ok(support == TRUE, "got %i\n", support);
3349 ok(face_type == DWRITE_FONT_FACE_TYPE_TRUETYPE, "got %i\n", face_type);
3350 ok(count == 1, "got %i\n", count);
3351
3352 /* invalid index */
3353 face = (void*)0xdeadbeef;
3354 hr = IDWriteFactory_CreateFontFace(factory, face_type, 1, &file, 1, DWRITE_FONT_SIMULATIONS_NONE, &face);
3355 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
3356 ok(face == NULL, "got %p\n", face);
3357
3358 hr = IDWriteFactory_CreateFontFace(factory, face_type, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &face);
3359 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3360
3361 hr = IDWriteFactory_CreateFontFace(factory, face_type, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &face2);
3362 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3363 /* fontface instances are reused starting with win7 */
3364 ok(face == face2 || broken(face != face2), "got %p, %p\n", face, face2);
3365 IDWriteFontFace_Release(face2);
3366
3367 /* file was created with different factory */
3368 face2 = NULL;
3369 hr = IDWriteFactory_CreateFontFace(factory2, face_type, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &face2);
3370 todo_wine
3371 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3372if (face2) {
3373 IDWriteFontFace_Release(face2);
3374}
3375 file2 = NULL;
3376 hr = IDWriteFactory_CreateCustomFontFileReference(factory, &fontrsrc, sizeof(HRSRC), &rloader, &file2);
3377 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3378 ok(file != file2, "got %p, %p\n", file, file2);
3379
3380 hr = IDWriteFactory_CreateFontFace(factory, face_type, 1, &file2, 0, DWRITE_FONT_SIMULATIONS_NONE, &face2);
3381 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3382 /* fontface instances are reused starting with win7 */
3383 ok(face == face2 || broken(face != face2), "got %p, %p\n", face, face2);
3384 IDWriteFontFace_Release(face2);
3385 IDWriteFontFile_Release(file2);
3386
3387 hr = IDWriteFontFace_GetGlyphIndices(face, NULL, 0, NULL);
3388 ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "Unexpected hr %#lx.\n", hr);
3389
3390 hr = IDWriteFontFace_GetGlyphIndices(face, codePoints, 0, NULL);
3391 ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "Unexpected hr %#lx.\n", hr);
3392
3393 hr = IDWriteFontFace_GetGlyphIndices(face, codePoints, 0, indices);
3394 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3395
3396 hr = IDWriteFontFace_GetGlyphIndices(face, NULL, 0, indices);
3397 ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "Unexpected hr %#lx.\n", hr);
3398
3399 indices[0] = indices[1] = 11;
3400 hr = IDWriteFontFace_GetGlyphIndices(face, NULL, 1, indices);
3401 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
3402 ok(indices[0] == 0, "got index %i\n", indices[0]);
3403 ok(indices[1] == 11, "got index %i\n", indices[1]);
3404
3405 if (0) /* crashes on native */
3406 hr = IDWriteFontFace_GetGlyphIndices(face, NULL, 1, NULL);
3407
3408 hr = IDWriteFontFace_GetGlyphIndices(face, codePoints, 1, indices);
3409 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3410 ok(indices[0] == 7, "Unexpected glyph index, %u.\n", indices[0]);
3411 IDWriteFontFace_Release(face);
3412 IDWriteFontFile_Release(file);
3413
3414 hr = IDWriteFactory_UnregisterFontFileLoader(factory, &floader);
3415 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3416 hr = IDWriteFactory_UnregisterFontFileLoader(factory, &floader);
3417 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
3418 hr = IDWriteFactory_UnregisterFontFileLoader(factory, &floader2);
3419 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3420 hr = IDWriteFactory_UnregisterFontFileLoader(factory, &rloader);
3421 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3422
3423 ref = IDWriteFactory_Release(factory2);
3424 ok(ref == 0, "factory not released, %lu\n", ref);
3425 ref = IDWriteFactory_Release(factory);
3426 ok(ref == 0, "factory not released, %lu\n", ref);
3428}
WORD face[3]
Definition: mesh.c:4854
DWRITE_FONT_FILE_TYPE
Definition: dwrite.idl:47
@ DWRITE_FONT_FILE_TYPE_TRUETYPE
Definition: dwrite.idl:50
@ DWRITE_FONT_FILE_TYPE_UNKNOWN
Definition: dwrite.idl:48
DWRITE_FONT_FACE_TYPE
Definition: dwrite.idl:60
@ DWRITE_FONT_FACE_TYPE_CFF
Definition: dwrite.idl:61
@ DWRITE_FONT_FACE_TYPE_UNKNOWN
Definition: dwrite.idl:67
@ DWRITE_FONT_FACE_TYPE_TRUETYPE
Definition: dwrite.idl:62
@ DWRITE_FONT_SIMULATIONS_NONE
Definition: dwrite.idl:146
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define todo_wine
Definition: minitest.h:80
static const struct IDWriteFontFileLoaderVtbl dwritefontfileloadervtbl
Definition: font.c:3237
#define DELETE_FONTFILE(filename)
Definition: font.c:560
static WCHAR * create_testfontfile(const WCHAR *filename)
Definition: font.c:535
static IDWriteFontFileLoader rloader
Definition: font.c:899
static void *static const WCHAR test_fontfile[]
Definition: font.c:123
FD_TYPE file_type(FDSC **curr, char *fixed)
Definition: file.c:221
Definition: copy.c:22
#define DWRITE_E_ALREADYREGISTERED
Definition: winerror.h:7340

Referenced by START_TEST().

◆ test_CreateCustomRenderingParams()

static void test_CreateCustomRenderingParams ( void  )
static

Definition at line 9468 of file font.c.

9469{
9470 static const struct custom_params_test
9471 {
9472 FLOAT gamma;
9473 FLOAT contrast;
9474 FLOAT cleartype_level;
9475 DWRITE_PIXEL_GEOMETRY geometry;
9476 DWRITE_RENDERING_MODE rendering_mode;
9477 HRESULT hr;
9478 } params_tests[] =
9479 {
9491 };
9493 unsigned int i;
9494 HRESULT hr;
9495 ULONG ref;
9496
9498
9499 for (i = 0; i < ARRAY_SIZE(params_tests); i++) {
9501
9502 winetest_push_context("%u", i);
9503
9504 params = (void *)0xdeadbeef;
9505 hr = IDWriteFactory_CreateCustomRenderingParams(factory, params_tests[i].gamma, params_tests[i].contrast,
9506 params_tests[i].cleartype_level, params_tests[i].geometry, params_tests[i].rendering_mode, &params);
9507 ok(hr == params_tests[i].hr, "unexpected hr %#lx, expected %#lx.\n", hr, params_tests[i].hr);
9508
9509 if (hr == S_OK) {
9510 ok(params_tests[i].gamma == IDWriteRenderingParams_GetGamma(params), "unexpected gamma %f, expected %f.\n",
9511 IDWriteRenderingParams_GetGamma(params), params_tests[i].gamma);
9512 ok(params_tests[i].contrast == IDWriteRenderingParams_GetEnhancedContrast(params),
9513 "unexpected contrast %f, expected %f.\n",
9514 IDWriteRenderingParams_GetEnhancedContrast(params), params_tests[i].contrast);
9515 ok(params_tests[i].cleartype_level == IDWriteRenderingParams_GetClearTypeLevel(params),
9516 "unexpected ClearType level %f, expected %f.\n",
9517 IDWriteRenderingParams_GetClearTypeLevel(params), params_tests[i].cleartype_level);
9518 ok(params_tests[i].geometry == IDWriteRenderingParams_GetPixelGeometry(params),
9519 "unexpected pixel geometry %u, expected %u.\n", IDWriteRenderingParams_GetPixelGeometry(params),
9520 params_tests[i].geometry);
9521 ok(params_tests[i].rendering_mode == IDWriteRenderingParams_GetRenderingMode(params),
9522 "unexpected rendering mode %u, expected %u.\n", IDWriteRenderingParams_GetRenderingMode(params),
9523 params_tests[i].rendering_mode);
9524 IDWriteRenderingParams_Release(params);
9525 }
9526 else
9527 ok(params == NULL, "%u: expected NULL interface pointer on failure.\n", i);
9528
9530 }
9531
9532 ref = IDWriteFactory_Release(factory);
9533 ok(ref == 0, "factory not released, %lu\n", ref);
9534}
DWRITE_PIXEL_GEOMETRY
Definition: dwrite.idl:153
@ DWRITE_PIXEL_GEOMETRY_BGR
Definition: dwrite.idl:156
DWRITE_RENDERING_MODE
Definition: dwrite.idl:160

Referenced by START_TEST().

◆ test_CreateFontCollectionFromFontSet()

static void test_CreateFontCollectionFromFontSet ( void  )
static

Definition at line 10363 of file font.c.

10364{
10365 unsigned int index, count, refcount;
10367 IDWriteFontSetBuilder1 *builder;
10371 IDWriteFontSet *fontset;
10373 WCHAR *path;
10374 BOOL exists;
10375 HRESULT hr;
10376
10377 if (!(factory = create_factory_iid(&IID_IDWriteFactory5)))
10378 {
10379 win_skip("_CreateFontCollectionFromFontSet() is not available.\n");
10380 return;
10381 }
10382
10383 hr = IDWriteFactory5_CreateFontSetBuilder(factory, &builder);
10384 ok(hr == S_OK, "Failed to create font set builder, hr %#lx.\n", hr);
10385
10387
10388 hr = IDWriteFactory5_CreateFontFileReference(factory, path, NULL, &file);
10389 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
10390
10391 hr = IDWriteFontSetBuilder1_AddFontFile(builder, file);
10392 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
10393
10394 /* Add same file, with explicit properties. */
10395 hr = IDWriteFactory5_CreateFontFaceReference_(factory, file, 0, DWRITE_FONT_SIMULATIONS_NONE, &ref);
10396 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
10398 props[0].propertyValue = L"Another Font";
10399 props[0].localeName = L"en-US";
10400 hr = IDWriteFontSetBuilder1_AddFontFaceReference_(builder, ref, props, 1);
10401 todo_wine
10402 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
10403 IDWriteFontFaceReference_Release(ref);
10404
10405 hr = IDWriteFontSetBuilder1_CreateFontSet(builder, &fontset);
10406 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
10407
10408 hr = IDWriteFactory5_CreateFontCollectionFromFontSet(factory, fontset, &collection);
10409 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
10410
10411 count = IDWriteFontCollection1_GetFontFamilyCount(collection);
10412 todo_wine
10413 ok(count == 2, "Unexpected family count %u.\n", count);
10414
10415 /* Explicit fontset properties are prioritized and not replaced by actual properties from a file. */
10416 exists = FALSE;
10417 hr = IDWriteFontCollection1_FindFamilyName(collection, L"Another Font", &index, &exists);
10418 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
10419 todo_wine
10420 ok(!!exists, "Unexpected return value %d.\n", exists);
10421
10422 IDWriteFontCollection1_Release(collection);
10423 IDWriteFontSet_Release(fontset);
10424
10425 IDWriteFontSetBuilder1_Release(builder);
10426
10427 IDWriteFontFile_Release(file);
10428 refcount = IDWriteFactory5_Release(factory);
10429 ok(!refcount, "Unexpected factory refcount %u.\n", refcount);
10431}
@ DWRITE_FONT_PROPERTY_ID_WEIGHT_STRETCH_STYLE_FAMILY_NAME
Definition: dwrite_3.idl:91
static const WCHAR props[]
Definition: wbemdisp.c:288

Referenced by START_TEST().

◆ test_CreateFontFace()

static void test_CreateFontFace ( void  )
static

Definition at line 1849 of file font.c.

1850{
1851 IDWriteFontFace *fontface, *fontface2;
1854 DWRITE_FONT_FACE_TYPE face_type;
1855 IDWriteFontFace5 *fontface5;
1856 IDWriteGdiInterop *interop;
1857 IDWriteFont *font, *font2;
1858 IDWriteFontFamily *family;
1861 BOOL supported, ret;
1862 LOGFONTW logfont;
1863 UINT32 count;
1864 WCHAR *path;
1865 HRESULT hr;
1866 ULONG ref;
1867
1869
1870 hr = IDWriteFactory_GetGdiInterop(factory, &interop);
1871 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1872
1873 memset(&logfont, 0, sizeof(logfont));
1874 logfont.lfHeight = 12;
1875 logfont.lfWidth = 12;
1876 logfont.lfWeight = FW_NORMAL;
1877 logfont.lfItalic = 1;
1878 lstrcpyW(logfont.lfFaceName, L"Tahoma");
1879
1880 font = NULL;
1881 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
1882 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1883
1884 font2 = NULL;
1885 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font2);
1886 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1887 ok(font != font2, "got %p, %p\n", font, font2);
1888
1889 hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFontFace, (void**)&fontface);
1890 ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr);
1891
1892 if (0) /* crashes on native */
1893 hr = IDWriteFont_CreateFontFace(font, NULL);
1894
1895 fontface = NULL;
1896 hr = IDWriteFont_CreateFontFace(font, &fontface);
1897 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1898
1899 fontface2 = NULL;
1900 hr = IDWriteFont_CreateFontFace(font, &fontface2);
1901 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1902 ok(fontface == fontface2, "got %p, was %p\n", fontface2, fontface);
1903 IDWriteFontFace_Release(fontface2);
1904
1905 fontface2 = NULL;
1906 hr = IDWriteFont_CreateFontFace(font2, &fontface2);
1907 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1908 ok(fontface == fontface2, "got %p, was %p\n", fontface2, fontface);
1909 IDWriteFontFace_Release(fontface2);
1910
1911 IDWriteFont_Release(font2);
1912 IDWriteFont_Release(font);
1913
1914 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFont, (void**)&font);
1915 ok(hr == E_NOINTERFACE || broken(hr == E_NOTIMPL), "Unexpected hr %#lx.\n", hr);
1916
1917 IDWriteFontFace_Release(fontface);
1918 IDWriteGdiInterop_Release(interop);
1919
1920 /* Create from system collection */
1921 hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
1922 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1923
1924 hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
1925 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1926
1927 font = NULL;
1928 hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
1930 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1931
1932 font2 = NULL;
1933 hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
1935 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1936 ok(font != font2, "got %p, %p\n", font, font2);
1937
1938 fontface = NULL;
1939 hr = IDWriteFont_CreateFontFace(font, &fontface);
1940 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1941
1942 fontface2 = NULL;
1943 hr = IDWriteFont_CreateFontFace(font2, &fontface2);
1944 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1945 ok(fontface == fontface2, "got %p, was %p\n", fontface2, fontface);
1946
1947 /* Trivial equality test */
1948 if (SUCCEEDED(IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace5, (void **)&fontface5)))
1949 {
1950 ret = IDWriteFontFace5_Equals(fontface5, fontface2);
1951 ok(ret, "Unexpected result %d.\n", ret);
1952 IDWriteFontFace5_Release(fontface5);
1953 }
1954
1955 IDWriteFontFace_Release(fontface);
1956 IDWriteFontFace_Release(fontface2);
1957 IDWriteFont_Release(font2);
1958 IDWriteFont_Release(font);
1959 IDWriteFontFamily_Release(family);
1960 IDWriteFontCollection_Release(collection);
1961 ref = IDWriteFactory_Release(factory);
1962 ok(ref == 0, "factory not released, %lu.\n", ref);
1963
1964 /* IDWriteFactory::CreateFontFace() */
1967
1968 hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
1969 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
1970
1971 supported = FALSE;
1973 face_type = DWRITE_FONT_FACE_TYPE_CFF;
1974 count = 0;
1975 hr = IDWriteFontFile_Analyze(file, &supported, &file_type, &face_type, &count);
1976 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1977 ok(supported == TRUE, "got %i\n", supported);
1979 ok(face_type == DWRITE_FONT_FACE_TYPE_TRUETYPE, "got %i\n", face_type);
1980 ok(count == 1, "got %i\n", count);
1981
1982 /* invalid simulation flags */
1983 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_CFF, 1, &file, 0, ~0u, &fontface);
1984 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
1985
1986 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_CFF, 1, &file, 0, 0xf, &fontface);
1987 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
1988
1989 /* try mismatching face type, the one that's not supported */
1990 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_CFF, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
1991 ok(hr == DWRITE_E_FILEFORMAT, "Unexpected hr %#lx.\n", hr);
1992
1993 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_OPENTYPE_COLLECTION, 1, &file, 0,
1994 DWRITE_FONT_SIMULATIONS_NONE, &fontface);
1995 ok(hr == DWRITE_E_FILEFORMAT || broken(hr == E_FAIL) /* < win10 */, "Unexpected hr %#lx.\n", hr);
1996
1997 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_RAW_CFF, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
1998 todo_wine
1999 ok(hr == DWRITE_E_UNSUPPORTEDOPERATION || broken(hr == E_INVALIDARG) /* older versions */, "Unexpected hr %#lx.\n", hr);
2000
2001 fontface = (void*)0xdeadbeef;
2002 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TYPE1, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
2003 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
2004 ok(fontface == NULL, "got %p\n", fontface);
2005
2006 fontface = (void*)0xdeadbeef;
2007 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_VECTOR, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
2008 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
2009 ok(fontface == NULL, "got %p\n", fontface);
2010
2011 fontface = (void*)0xdeadbeef;
2012 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_BITMAP, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
2013 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
2014 ok(fontface == NULL, "got %p\n", fontface);
2015
2016 fontface = NULL;
2017 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_UNKNOWN, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
2018 todo_wine
2019 ok(hr == S_OK || broken(hr == E_INVALIDARG) /* < win10 */, "Unexpected hr %#lx.\n", hr);
2020 if (hr == S_OK) {
2021 ok(fontface != NULL, "got %p\n", fontface);
2022 face_type = IDWriteFontFace_GetType(fontface);
2023 ok(face_type == DWRITE_FONT_FACE_TYPE_TRUETYPE, "got %d\n", face_type);
2024 IDWriteFontFace_Release(fontface);
2025 }
2026
2027 IDWriteFontFile_Release(file);
2028 ref = IDWriteFactory_Release(factory);
2029 ok(ref == 0, "factory not released, %lu.\n", ref);
2031}
@ DWRITE_FONT_FACE_TYPE_VECTOR
Definition: dwrite.idl:65
@ DWRITE_FONT_FACE_TYPE_TYPE1
Definition: dwrite.idl:64
@ DWRITE_FONT_FACE_TYPE_BITMAP
Definition: dwrite.idl:66
@ DWRITE_FONT_FACE_TYPE_OPENTYPE_COLLECTION
Definition: dwrite.idl:63
@ DWRITE_FONT_FACE_TYPE_RAW_CFF
Definition: dwrite.idl:68
#define DWRITE_E_FILEFORMAT
Definition: winerror.h:7334

Referenced by START_TEST().

◆ test_CreateFontFaceFromHdc()

static void test_CreateFontFaceFromHdc ( void  )
static

Definition at line 4303 of file font.c.

4304{
4305 IDWriteFontFileStream *stream, *stream2;
4306 void *font_data, *fragment_context;
4308 const void *refkey, *fragment;
4310 DWORD data_size, num_fonts;
4311 IDWriteGdiInterop *interop;
4312 IDWriteFontFace *fontface;
4314 UINT64 size, writetime;
4316 HFONT hfont, oldhfont;
4318 LOGFONTW logfont;
4320 IUnknown *unk;
4321 LOGFONTA lf;
4322 WCHAR *path;
4323 HRESULT hr;
4324 ULONG ref;
4325 BOOL ret;
4326 HDC hdc;
4327
4329
4330 pGetFontRealizationInfo = (void *)GetProcAddress(GetModuleHandleA("gdi32"), "GetFontRealizationInfo");
4331
4332 interop = NULL;
4333 hr = IDWriteFactory_GetGdiInterop(factory, &interop);
4334 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4335
4336 /* Invalid HDC. */
4337 fontface = (void*)0xdeadbeef;
4338 hr = IDWriteGdiInterop_CreateFontFaceFromHdc(interop, NULL, &fontface);
4339 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
4340 ok(fontface == NULL, "got %p\n", fontface);
4341
4342 fontface = (void *)0xdeadbeef;
4343 hr = IDWriteGdiInterop_CreateFontFaceFromHdc(interop, (HDC)0xdeadbeef, &fontface);
4344 ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr);
4345 ok(fontface == NULL, "got %p\n", fontface);
4346
4347 memset(&logfont, 0, sizeof(logfont));
4348 logfont.lfHeight = 12;
4349 logfont.lfWidth = 12;
4350 logfont.lfWeight = FW_NORMAL;
4351 logfont.lfItalic = 1;
4352 lstrcpyW(logfont.lfFaceName, L"Tahoma");
4353
4354 hfont = CreateFontIndirectW(&logfont);
4356 oldhfont = SelectObject(hdc, hfont);
4357
4358 fontface = NULL;
4359 hr = IDWriteGdiInterop_CreateFontFaceFromHdc(interop, hdc, &fontface);
4360 ok(hr == S_OK, "Failed to create font face, hr %#lx.\n", hr);
4361
4362 count = 1;
4363 hr = IDWriteFontFace_GetFiles(fontface, &count, &file);
4364 ok(hr == S_OK, "Failed to get font files, hr %#lx.\n", hr);
4365
4366 hr = IDWriteFontFile_GetLoader(file, &loader);
4367 ok(hr == S_OK, "Failed to get file loader, hr %#lx.\n", hr);
4368
4369 hr = IDWriteFontFileLoader_QueryInterface(loader, &IID_IDWriteLocalFontFileLoader, (void **)&unk);
4370 ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* Vista */, "Expected local loader, hr %#lx.\n", hr);
4371 if (unk)
4372 IUnknown_Release(unk);
4373
4374 IDWriteFontFileLoader_Release(loader);
4375 IDWriteFontFile_Release(file);
4376
4377 IDWriteFontFace_Release(fontface);
4378 DeleteObject(SelectObject(hdc, oldhfont));
4379
4380 /* Select bitmap font MS Sans Serif, format that's not supported by DirectWrite. */
4381 memset(&lf, 0, sizeof(lf));
4382 lf.lfHeight = -12;
4383 strcpy(lf.lfFaceName, "MS Sans Serif");
4384
4386 oldhfont = SelectObject(hdc, hfont);
4387
4388 fontface = (void *)0xdeadbeef;
4389 hr = IDWriteGdiInterop_CreateFontFaceFromHdc(interop, hdc, &fontface);
4390 ok(hr == DWRITE_E_FILEFORMAT || broken(hr == E_FAIL) /* Vista */, "Unexpected hr %#lx.\n", hr);
4391 ok(fontface == NULL, "got %p\n", fontface);
4392
4393 DeleteObject(SelectObject(hdc, oldhfont));
4394
4395 /* Memory resource font */
4397
4398 data_size = 0;
4399 font_data = map_font_file(path, &data_size);
4400
4401 num_fonts = 0;
4402 resource = AddFontMemResourceEx(font_data, data_size, NULL, &num_fonts);
4403 ok(resource != NULL, "Failed to add memory resource font, %ld.\n", GetLastError());
4404 ok(num_fonts == 1, "Unexpected number of fonts.\n");
4405
4406 memset(&lf, 0, sizeof(lf));
4407 lf.lfHeight = -12;
4408 strcpy(lf.lfFaceName, "wine_test");
4409
4411 ok(hfont != NULL, "Failed to create a font.\n");
4412 oldhfont = SelectObject(hdc, hfont);
4413
4414 hr = IDWriteGdiInterop_CreateFontFaceFromHdc(interop, hdc, &fontface);
4415 ok(hr == S_OK, "Failed to create fontface, hr %#lx.\n", hr);
4416
4417 count = 1;
4418 hr = IDWriteFontFace_GetFiles(fontface, &count, &file);
4419 ok(hr == S_OK, "Failed to get font files, hr %#lx.\n", hr);
4420
4421 hr = IDWriteFontFile_GetLoader(file, &loader);
4422 ok(hr == S_OK, "Failed to get file loader, hr %#lx.\n", hr);
4423
4424 hr = IDWriteFactory_RegisterFontFileLoader(factory, loader);
4425 ok(hr == DWRITE_E_ALREADYREGISTERED, "Unexpected hr %#lx.\n", hr);
4426
4427 hr = IDWriteFontFileLoader_QueryInterface(loader, &IID_IDWriteInMemoryFontFileLoader, (void **)&unk);
4428 ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr);
4429
4430 hr = IDWriteFontFileLoader_QueryInterface(loader, &IID_IDWriteLocalFontFileLoader, (void **)&unk);
4431 ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr);
4432
4433 count = 0;
4434 hr = IDWriteFontFile_GetReferenceKey(file, &refkey, &count);
4435 ok(hr == S_OK, "Failed to get ref key, hr %#lx.\n", hr);
4436 ok(count > 0, "Unexpected key length %u.\n", count);
4437
4438 if (pGetFontRealizationInfo)
4439 {
4440 info.size = sizeof(info);
4441 ret = pGetFontRealizationInfo(hdc, &info);
4442 ok(ret, "Failed to get realization info.\n");
4443 ok(count == sizeof(info.instance_id), "Unexpected key size.\n");
4444 ok(*(DWORD *)refkey == info.instance_id, "Unexpected stream key.\n");
4445 }
4446 else
4447 win_skip("GetFontRealizationInfo() is not available.\n");
4448
4449 hr = IDWriteFontFileLoader_CreateStreamFromKey(loader, refkey, count, &stream);
4450 ok(hr == S_OK, "Failed to create file stream, hr %#lx.\n", hr);
4451
4452 hr = IDWriteFontFileLoader_CreateStreamFromKey(loader, refkey, count, &stream2);
4453 ok(hr == S_OK, "Failed to create file stream, hr %#lx.\n", hr);
4454 ok(stream2 != stream, "Unexpected stream instance.\n");
4455 IDWriteFontFileStream_Release(stream2);
4456
4457 dummy = 1;
4458 hr = IDWriteFontFileLoader_CreateStreamFromKey(loader, &dummy, count, &stream2);
4459 ok(hr == S_OK, "Failed to create file stream, hr %#lx.\n", hr);
4460
4461 writetime = 1;
4462 hr = IDWriteFontFileStream_GetLastWriteTime(stream2, &writetime);
4463 ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
4464 ok(writetime == 1, "Unexpected write time.\n");
4465
4466 IDWriteFontFileStream_Release(stream2);
4467
4468 hr = IDWriteFontFileStream_GetFileSize(stream, &size);
4469 ok(hr == S_OK, "Failed to get stream size, hr %#lx.\n", hr);
4470 ok(size == data_size, "Unexpected stream size.\n");
4471
4472 hr = IDWriteFontFileStream_GetLastWriteTime(stream, &writetime);
4473 ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
4474
4475 fragment_context = NULL;
4476 hr = IDWriteFontFileStream_ReadFileFragment(stream, &fragment, 0, size, &fragment_context);
4477 ok(hr == S_OK, "Failed to read fragment, hr %#lx.\n", hr);
4478 ok(fragment_context != NULL, "Unexpected context %p.\n", fragment_context);
4479 ok(fragment == fragment_context, "Unexpected data pointer %p, context %p.\n", fragment, fragment_context);
4480 IDWriteFontFileStream_ReleaseFileFragment(stream, fragment_context);
4481
4482 hr = IDWriteFontFileStream_ReadFileFragment(stream, &fragment, 0, size + 1, &fragment_context);
4483 ok(FAILED(hr), "Unexpected hr %#lx.\n", hr);
4484
4485 hr = IDWriteFontFileStream_ReadFileFragment(stream, &fragment, size - 1, size / 2, &fragment_context);
4486 ok(FAILED(hr), "Unexpected hr %#lx.\n", hr);
4487
4488 IDWriteFontFileStream_Release(stream);
4489
4490 IDWriteFontFileLoader_Release(loader);
4491 IDWriteFontFile_Release(file);
4492
4493 IDWriteFontFace_Release(fontface);
4494
4496 ok(ret, "Failed to remove memory resource font, %ld.\n", GetLastError());
4497
4499
4501
4502 DeleteObject(SelectObject(hdc, oldhfont));
4503 DeleteDC(hdc);
4504 IDWriteGdiInterop_Release(interop);
4505 ref = IDWriteFactory_Release(factory);
4506 ok(ref == 0, "factory not released, %lu\n", ref);
4507}
COMPILER_DEPENDENT_UINT64 UINT64
Definition: actypes.h:131
#define UnmapViewOfFile
Definition: compat.h:746
#define GetProcAddress(x, y)
Definition: compat.h:753
#define resource
Definition: kernel32.h:9
static void * map_font_file(const WCHAR *filename, DWORD *file_size)
Definition: font.c:4268
strcpy
Definition: string.h:131
LONG lfHeight
Definition: dimm.idl:42
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
BOOL WINAPI RemoveFontMemResourceEx(HANDLE fh)
Definition: font.c:2649
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI DeleteDC(_In_ HDC)
HANDLE WINAPI AddFontMemResourceEx(_In_reads_bytes_(cjSize) PVOID pvFileView, _In_ DWORD cjSize, _Reserved_ PVOID pvResrved, _In_ DWORD *pNumFonts)

Referenced by START_TEST().

◆ test_CreateFontFaceReference()

static void test_CreateFontFaceReference ( void  )
static

Definition at line 7994 of file font.c.

7995{
7996 IDWriteFontFaceReference *ref, *ref1, *ref3;
7997 IDWriteFontFace3 *fontface, *fontface1;
7998 DWRITE_FONT_AXIS_VALUE axis_values[16];
8000 UINT32 axis_count, index, count, i;
8002 IDWriteFontFile *file, *file1;
8003 IDWriteFactory3 *factory;
8004 IDWriteFont3 *font3;
8005 ULONG refcount;
8006 WCHAR *path;
8007 HRESULT hr;
8008 BOOL ret;
8009
8010 factory = create_factory_iid(&IID_IDWriteFactory3);
8011 if (!factory) {
8012 win_skip("CreateFontFaceReference() is not supported.\n");
8013 return;
8014 }
8015
8017
8018 hr = IDWriteFactory3_CreateFontFaceReference(factory, NULL, NULL, 0, DWRITE_FONT_SIMULATIONS_NONE, &ref);
8019 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
8020
8021 /* out of range simulation flags */
8022 hr = IDWriteFactory3_CreateFontFaceReference(factory, path, NULL, 0, ~0u, &ref);
8023 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
8024
8025 /* test file is not a collection, but reference could still be created with non-zero face index */
8026 hr = IDWriteFactory3_CreateFontFaceReference(factory, path, NULL, 1, DWRITE_FONT_SIMULATIONS_NONE, &ref);
8027 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8028
8029 index = IDWriteFontFaceReference_GetFontFaceIndex(ref);
8030 ok(index == 1, "got %u\n", index);
8031
8032 hr = IDWriteFontFaceReference_GetFontFile(ref, &file);
8033 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8034 IDWriteFontFile_Release(file);
8035
8036 hr = IDWriteFontFaceReference_CreateFontFace(ref, &fontface);
8037 todo_wine
8038 ok(hr == DWRITE_E_FILEFORMAT, "Unexpected hr %#lx.\n", hr);
8039
8040 IDWriteFontFaceReference_Release(ref);
8041
8042 /* path however has to be valid */
8043 hr = IDWriteFactory3_CreateFontFaceReference(factory, L"dummy", NULL, 0, DWRITE_FONT_SIMULATIONS_NONE, &ref);
8044 todo_wine
8045 ok(hr == DWRITE_E_FILENOTFOUND, "Unexpected hr %#lx.\n", hr);
8046 if (hr == S_OK)
8047 IDWriteFontFaceReference_Release(ref);
8048
8049 EXPECT_REF(factory, 1);
8050 hr = IDWriteFactory3_CreateFontFaceReference(factory, path, NULL, 0, DWRITE_FONT_SIMULATIONS_NONE, &ref);
8051 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8052 EXPECT_REF(factory, 2);
8053
8054 /* new file is returned */
8055 hr = IDWriteFontFaceReference_GetFontFile(ref, &file);
8056 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8057
8058 hr = IDWriteFontFaceReference_GetFontFile(ref, &file1);
8059 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8060 ok(file != file1, "got %p, previous file %p\n", file1, file);
8061
8062 IDWriteFontFile_Release(file);
8063 IDWriteFontFile_Release(file1);
8064
8065 /* references are not reused */
8066 hr = IDWriteFactory3_CreateFontFaceReference(factory, path, NULL, 0, DWRITE_FONT_SIMULATIONS_NONE, &ref1);
8067 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8068 ok(ref1 != ref, "got %p, previous ref %p\n", ref1, ref);
8069
8070 /* created fontfaces are cached */
8071 hr = IDWriteFontFaceReference_CreateFontFace(ref, &fontface);
8072 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8073
8074 hr = IDWriteFontFaceReference_CreateFontFace(ref1, &fontface1);
8075 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8076 ok(fontface == fontface1, "got %p, expected %p\n", fontface1, fontface);
8077 IDWriteFontFace3_Release(fontface);
8078 IDWriteFontFace3_Release(fontface1);
8079
8080 /* reference equality */
8081 ret = IDWriteFontFaceReference_Equals(ref, ref1);
8082 ok(ret, "got %d\n", ret);
8083 IDWriteFontFaceReference_Release(ref1);
8084
8085 hr = IDWriteFactory3_CreateFontFaceReference(factory, path, NULL, 1, DWRITE_FONT_SIMULATIONS_NONE, &ref1);
8086 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8087 ret = IDWriteFontFaceReference_Equals(ref, ref1);
8088 ok(!ret, "got %d\n", ret);
8089 IDWriteFontFaceReference_Release(ref1);
8090
8091 hr = IDWriteFactory3_CreateFontFaceReference(factory, path, NULL, 0, DWRITE_FONT_SIMULATIONS_BOLD, &ref1);
8092 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8093 ret = IDWriteFontFaceReference_Equals(ref, ref1);
8094 ok(!ret, "got %d\n", ret);
8095 IDWriteFontFaceReference_Release(ref1);
8096
8097 IDWriteFontFaceReference_Release(ref);
8098
8099 /* create reference from a file */
8100 hr = IDWriteFactory3_CreateFontFileReference(factory, path, NULL, &file);
8101 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8102
8103 hr = IDWriteFactory3_CreateFontFaceReference_(factory, file, 0, DWRITE_FONT_SIMULATIONS_NONE, &ref);
8104 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8105
8106 hr = IDWriteFontFaceReference_GetFontFile(ref, &file1);
8107 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8108 ok(file != file1, "got %p, previous file %p\n", file1, file);
8109
8110 if (SUCCEEDED(IDWriteFontFaceReference_QueryInterface(ref, &IID_IDWriteFontFaceReference1, (void **)&ref2)))
8111 {
8112 axis_count = IDWriteFontFaceReference1_GetFontAxisValueCount(ref2);
8113 ok(!axis_count, "Unexpected axis value count.\n");
8114 IDWriteFontFaceReference1_Release(ref2);
8115 }
8116
8117 IDWriteFontFaceReference_Release(ref);
8118 IDWriteFontFile_Release(file);
8119 IDWriteFontFile_Release(file1);
8120
8121 /* References returned from IDWriteFont3/IDWriteFontFace3. */
8122 hr = IDWriteFactory3_GetSystemFontCollection(factory, FALSE, &collection, FALSE);
8123 ok(hr == S_OK, "Failed to get system collection, hr %#lx.\n", hr);
8124
8125 count = IDWriteFontCollection1_GetFontFamilyCount(collection);
8126 for (i = 0; i < count; i++)
8127 {
8128 IDWriteFontFamily1 *family;
8129 UINT32 font_count, j;
8130
8131 hr = IDWriteFontCollection1_GetFontFamily(collection, i, &family);
8132 ok(hr == S_OK, "Failed to get family, hr %#lx.\n", hr);
8133
8134 font_count = IDWriteFontFamily1_GetFontCount(family);
8135
8136 for (j = 0; j < font_count; j++)
8137 {
8138 hr = IDWriteFontFamily1_GetFont(family, j, &font3);
8139 ok(hr == S_OK, "Failed to get font, hr %#lx.\n", hr);
8140
8141 hr = IDWriteFont3_GetFontFaceReference(font3, &ref);
8142 ok(hr == S_OK, "Failed to get reference object, hr %#lx.\n", hr);
8143
8144 hr = IDWriteFont3_GetFontFaceReference(font3, &ref1);
8145 ok(hr == S_OK, "Failed to get reference object, hr %#lx.\n", hr);
8146 ok(ref != ref1, "Unexpected reference object %p, %p.\n", ref1, ref);
8147
8148 hr = IDWriteFont3_CreateFontFace(font3, &fontface);
8149 ok(hr == S_OK, "Failed to create a fontface, hr %#lx.\n", hr);
8150
8151 /* Fonts present regular properties as axis values, for non-variable fonts too.
8152 Normally it would include weight/width/slant/italic, but could also contain optical size axis. */
8153 if (SUCCEEDED(hr = IDWriteFontFaceReference_QueryInterface(ref, &IID_IDWriteFontFaceReference1,
8154 (void **)&ref2)))
8155 {
8156 axis_count = IDWriteFontFaceReference1_GetFontAxisValueCount(ref2);
8157 todo_wine
8158 ok(axis_count >= 4, "Unexpected axis value count.\n");
8159
8160 hr = IDWriteFontFaceReference1_GetFontAxisValues(ref2, axis_values, ARRAY_SIZE(axis_values));
8161 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8162
8163 todo_wine
8164 ok(has_main_axis_values(axis_values, axis_count), "Unexpected axis returned.\n");
8165
8166 IDWriteFontFaceReference1_Release(ref2);
8167 }
8168
8169 IDWriteFontFaceReference_Release(ref);
8170 IDWriteFontFaceReference_Release(ref1);
8171
8172 hr = IDWriteFontFace3_GetFontFaceReference(fontface, &ref);
8173 ok(hr == S_OK, "Failed to get a reference, hr %#lx.\n", hr);
8174 EXPECT_REF(fontface, 2);
8175
8176 hr = IDWriteFontFace3_GetFontFaceReference(fontface, &ref1);
8177 ok(hr == S_OK, "Failed to get a reference, hr %#lx.\n", hr);
8178 ok(ref == ref1, "Unexpected reference %p, %p.\n", ref1, ref);
8179 EXPECT_REF(fontface, 3);
8180
8181 hr = IDWriteFontFace3_QueryInterface(fontface, &IID_IDWriteFontFaceReference, (void **)&ref3);
8182 ok(hr == S_OK || broken(FAILED(hr)), "Failed to get interface, hr %#lx.\n", hr);
8183 if (SUCCEEDED(hr))
8184 {
8185 ok(ref == ref3, "Unexpected reference %p.\n", ref3);
8186 IDWriteFontFaceReference_Release(ref3);
8187 }
8188
8189 hr = IDWriteFontFaceReference_CreateFontFace(ref, &fontface1);
8190 ok(hr == S_OK, "Failed to create fontface, hr %#lx.\n", hr);
8191 ok(fontface1 == fontface, "Unexpected fontface %p, %p.\n", fontface1, fontface);
8192 IDWriteFontFace3_Release(fontface1);
8193
8194 IDWriteFontFaceReference_Release(ref);
8195 IDWriteFontFaceReference_Release(ref1);
8196
8197 IDWriteFontFace3_Release(fontface);
8198 IDWriteFont3_Release(font3);
8199 }
8200
8201 IDWriteFontFamily1_Release(family);
8202 }
8203 IDWriteFontCollection1_Release(collection);
8204
8205 refcount = IDWriteFactory3_Release(factory);
8206 ok(refcount == 0, "factory not released, %lu\n", refcount);
8208}
static BOOL has_main_axis_values(const DWRITE_FONT_AXIS_VALUE *values, unsigned int count)
Definition: font.c:7974
#define EXPECT_REF(obj, ref)
Definition: font.c:103
#define DWRITE_E_FILENOTFOUND
Definition: winerror.h:7337

Referenced by START_TEST().

◆ test_CreateFontFileReference()

static void test_CreateFontFileReference ( void  )
static

Definition at line 3430 of file font.c.

3431{
3432 HRESULT hr;
3433 IDWriteFontFile *ffile = NULL;
3434 BOOL support;
3437 UINT32 count;
3438 IDWriteFontFace *fface = NULL;
3440 WCHAR *path;
3441 ULONG ref;
3442
3445
3446 ffile = (void*)0xdeadbeef;
3447 hr = IDWriteFactory_CreateFontFileReference(factory, NULL, NULL, &ffile);
3448 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n",hr);
3449 ok(ffile == NULL, "got %p\n", ffile);
3450
3451 hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &ffile);
3452 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
3453
3454 support = FALSE;
3457 count = 0;
3458 hr = IDWriteFontFile_Analyze(ffile, &support, &type, &face, &count);
3459 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3460 ok(support == TRUE, "got %i\n", support);
3461 ok(type == DWRITE_FONT_FILE_TYPE_TRUETYPE, "got %i\n", type);
3462 ok(face == DWRITE_FONT_FACE_TYPE_TRUETYPE, "got %i\n", face);
3463 ok(count == 1, "got %i\n", count);
3464
3465 hr = IDWriteFactory_CreateFontFace(factory, face, 1, &ffile, 0, DWRITE_FONT_SIMULATIONS_NONE, &fface);
3466 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3467
3468 IDWriteFontFace_Release(fface);
3469 IDWriteFontFile_Release(ffile);
3470 ref = IDWriteFactory_Release(factory);
3471 ok(ref == 0, "factory not released, %lu\n", ref);
3472
3474}

Referenced by START_TEST().

◆ test_CreateFontFromLOGFONT()

static void test_CreateFontFromLOGFONT ( void  )
static

Definition at line 1021 of file font.c.

1022{
1023 IDWriteGdiInterop1 *interop1;
1024 IDWriteGdiInterop *interop;
1028 LOGFONTW logfont;
1029 LONG weights[][2] = {
1043 };
1046 HRESULT hr;
1047 BOOL ret;
1048 HDC hdc;
1049 HFONT hfont;
1050 BOOL exists;
1051 ULONG ref;
1052 int i;
1053 UINT r;
1054
1056
1057 hr = IDWriteFactory_GetGdiInterop(factory, &interop);
1058 ok(hr == S_OK, "got %#lx\n", hr);
1059
1060 if (0)
1061 /* null out parameter crashes this call */
1062 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, NULL, NULL);
1063
1064 font = (void*)0xdeadbeef;
1065 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, NULL, &font);
1066 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
1067 ok(font == NULL, "got %p\n", font);
1068
1069 memset(&logfont, 0, sizeof(logfont));
1070 logfont.lfHeight = 12;
1071 logfont.lfWidth = 12;
1072 logfont.lfWeight = FW_NORMAL;
1073 logfont.lfItalic = 1;
1074 lstrcpyW(logfont.lfFaceName, L"Tahoma");
1075
1076 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
1077 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1078
1079 hfont = CreateFontIndirectW(&logfont);
1082
1083 otm.otmSize = sizeof(otm);
1084 r = GetOutlineTextMetricsW(hdc, otm.otmSize, &otm);
1085 ok(r, "got %d\n", r);
1086 DeleteDC(hdc);
1088
1089 exists = TRUE;
1090 hr = IDWriteFont_HasCharacter(font, 0xd800, &exists);
1091 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1092 ok(exists == FALSE, "got %d\n", exists);
1093
1094 exists = FALSE;
1095 hr = IDWriteFont_HasCharacter(font, 0x20, &exists);
1096 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1097 ok(exists == TRUE, "got %d\n", exists);
1098
1099 /* now check properties */
1100 weight = IDWriteFont_GetWeight(font);
1101 ok(weight == DWRITE_FONT_WEIGHT_NORMAL, "got %d\n", weight);
1102
1103 style = IDWriteFont_GetStyle(font);
1104 ok(style == DWRITE_FONT_STYLE_OBLIQUE, "got %d\n", style);
1105 ok(otm.otmfsSelection & 1, "got 0x%08x\n", otm.otmfsSelection);
1106
1107 ret = IDWriteFont_IsSymbolFont(font);
1108 ok(!ret, "got %d\n", ret);
1109
1110 IDWriteFont_Release(font);
1111
1112 /* weight values */
1113 for (i = 0; i < ARRAY_SIZE(weights); i++)
1114 {
1115 memset(&logfont, 0, sizeof(logfont));
1116 logfont.lfHeight = 12;
1117 logfont.lfWidth = 12;
1118 logfont.lfWeight = weights[i][0];
1119 lstrcpyW(logfont.lfFaceName, L"Tahoma");
1120
1121 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
1122 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1123
1124 weight = IDWriteFont_GetWeight(font);
1125 ok(weight == weights[i][1],
1126 "%d: got %d, expected %ld\n", i, weight, weights[i][1]);
1127
1128 IDWriteFont_Release(font);
1129 }
1130
1131 /* weight not from enum */
1132 memset(&logfont, 0, sizeof(logfont));
1133 logfont.lfHeight = 12;
1134 logfont.lfWidth = 12;
1135 logfont.lfWeight = 550;
1136 lstrcpyW(logfont.lfFaceName, L"Tahoma");
1137
1138 font = NULL;
1139 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
1140 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1141
1142 weight = IDWriteFont_GetWeight(font);
1144 "got %d\n", weight);
1145
1146 IDWriteFont_Release(font);
1147
1148 /* empty or nonexistent face name */
1149 memset(&logfont, 0, sizeof(logfont));
1150 logfont.lfHeight = 12;
1151 logfont.lfWidth = 12;
1152 logfont.lfWeight = FW_NORMAL;
1153 lstrcpyW(logfont.lfFaceName, L"Blah!");
1154
1155 font = (void*)0xdeadbeef;
1156 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
1157 ok(hr == DWRITE_E_NOFONT, "Unexpected hr %#lx.\n", hr);
1158 ok(font == NULL, "got %p\n", font);
1159
1160 /* Try with name 'Tahoma ' */
1161 memset(&logfont, 0, sizeof(logfont));
1162 logfont.lfHeight = 12;
1163 logfont.lfWidth = 12;
1164 logfont.lfWeight = FW_NORMAL;
1165 lstrcpyW(logfont.lfFaceName, L"Tahoma ");
1166
1167 font = (void*)0xdeadbeef;
1168 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
1169 ok(hr == DWRITE_E_NOFONT, "Unexpected hr %#lx.\n", hr);
1170 ok(font == NULL, "got %p\n", font);
1171
1172 /* empty string as a facename */
1173 memset(&logfont, 0, sizeof(logfont));
1174 logfont.lfHeight = 12;
1175 logfont.lfWidth = 12;
1176 logfont.lfWeight = FW_NORMAL;
1177
1178 font = (void*)0xdeadbeef;
1179 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
1180 ok(hr == DWRITE_E_NOFONT, "Unexpected hr %#lx.\n", hr);
1181 ok(font == NULL, "got %p\n", font);
1182
1183 /* IDWriteGdiInterop1::CreateFontFromLOGFONT() */
1184 hr = IDWriteGdiInterop_QueryInterface(interop, &IID_IDWriteGdiInterop1, (void**)&interop1);
1185 if (hr == S_OK) {
1186 memset(&logfont, 0, sizeof(logfont));
1187 logfont.lfHeight = 12;
1188 logfont.lfWidth = 12;
1189 logfont.lfWeight = FW_NORMAL;
1190 logfont.lfItalic = 1;
1191 lstrcpyW(logfont.lfFaceName, L"Tahoma");
1192
1193 hr = IDWriteGdiInterop1_CreateFontFromLOGFONT(interop1, &logfont, NULL, &font);
1194 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1195
1196 IDWriteFont_Release(font);
1197 IDWriteGdiInterop1_Release(interop1);
1198 }
1199 else
1200 win_skip("IDWriteGdiInterop1 is not supported, skipping CreateFontFromLOGFONT() tests.\n");
1201
1202 ref = IDWriteGdiInterop_Release(interop);
1203 ok(ref == 0, "interop is not released, %lu\n", ref);
1204 ref = IDWriteFactory_Release(factory);
1205 ok(ref == 0, "factory is not released, %lu\n", ref);
1206}
DWRITE_FONT_WEIGHT
Definition: dwrite.idl:73
const GLbyte * weights
Definition: glext.h:6523
unsigned int UINT
Definition: sysinfo.c:13
#define DWRITE_E_NOFONT
Definition: winerror.h:7336
UINT WINAPI GetOutlineTextMetricsW(_In_ HDC hdc, _In_ UINT cjCopy, _Out_writes_bytes_opt_(cjCopy) LPOUTLINETEXTMETRICW potm)

Referenced by START_TEST().

◆ test_CreateGlyphRunAnalysis()

static void test_CreateGlyphRunAnalysis ( void  )
static

Definition at line 5666 of file font.c.

5667{
5668 static const DWRITE_RENDERING_MODE rendermodes[] = {
5674 };
5675
5676 IDWriteGlyphRunAnalysis *analysis, *analysis2;
5678 IDWriteFactory3 *factory3;
5679 IDWriteFactory2 *factory2;
5681 DWRITE_GLYPH_RUN run;
5683 UINT16 glyph, glyphs[10];
5684 FLOAT advances[2];
5685 HRESULT hr;
5686 UINT32 ch;
5687 RECT rect, rect2;
5692 ULONG size;
5693 BYTE *bits;
5694 ULONG ref;
5695 int i;
5696
5699
5700 ch = 'A';
5701 glyph = 0;
5702 hr = IDWriteFontFace_GetGlyphIndices(face, &ch, 1, &glyph);
5703 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5704 ok(glyph > 0, "got %u\n", glyph);
5705
5706 hr = IDWriteFontFace_GetDesignGlyphMetrics(face, &glyph, 1, &metrics, FALSE);
5707 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5708 advances[0] = metrics.advanceWidth;
5709
5710 offsets[0].advanceOffset = 0.0;
5711 offsets[0].ascenderOffset = 0.0;
5712
5713 run.fontFace = face;
5714 run.fontEmSize = 24.0;
5715 run.glyphCount = 1;
5716 run.glyphIndices = &glyph;
5717 run.glyphAdvances = advances;
5718 run.glyphOffsets = offsets;
5719 run.isSideways = FALSE;
5720 run.bidiLevel = 0;
5721
5722 /* zero ppdip */
5723 analysis = (void*)0xdeadbeef;
5724 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 0.0, NULL,
5726 0.0, 0.0, &analysis);
5727 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
5728 ok(analysis == NULL, "got %p\n", analysis);
5729
5730 /* negative ppdip */
5731 analysis = (void*)0xdeadbeef;
5732 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, -1.0, NULL,
5734 0.0, 0.0, &analysis);
5735 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
5736 ok(analysis == NULL, "got %p\n", analysis);
5737
5738 /* default mode is not allowed */
5739 analysis = (void*)0xdeadbeef;
5740 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
5742 0.0, 0.0, &analysis);
5743 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
5744 ok(analysis == NULL, "got %p\n", analysis);
5745
5746 /* outline too */
5747 analysis = (void*)0xdeadbeef;
5748 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
5750 0.0, 0.0, &analysis);
5751 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
5752 ok(analysis == NULL, "got %p\n", analysis);
5753
5754 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
5756 0.0, 0.0, &analysis);
5757 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5758
5759 /* invalid texture type */
5760 memset(&rect, 0xcc, sizeof(rect));
5761 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1+1, &rect);
5762 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
5763 ok(rect.left == 0 && rect.right == 0 &&
5764 rect.top == 0 && rect.bottom == 0, "unexpected rect\n");
5765
5766 /* check how origin affects bounds */
5768 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
5769 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5770 ok(!IsRectEmpty(&rect), "got empty rect\n");
5771 IDWriteGlyphRunAnalysis_Release(analysis);
5772
5773 /* doubled ppdip */
5774 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 2.0, NULL,
5776 0.0, 0.0, &analysis);
5777 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5779 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect2);
5780 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5781 ok(rect.right - rect.left < rect2.right - rect2.left, "expected wider rect\n");
5782 ok(rect.bottom - rect.top < rect2.bottom - rect2.top, "expected taller rect\n");
5783 IDWriteGlyphRunAnalysis_Release(analysis);
5784
5785 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
5787 10.0, -5.0, &analysis);
5788 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5789
5791 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect2);
5792 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5793 ok(!IsRectEmpty(&rect2), "got empty rect\n");
5794 IDWriteGlyphRunAnalysis_Release(analysis);
5795
5796 ok(!EqualRect(&rect, &rect2), "got equal bounds\n");
5797 OffsetRect(&rect, 10, -5);
5798 ok(EqualRect(&rect, &rect2), "got different bounds\n");
5799
5800 for (i = 0; i < ARRAY_SIZE(rendermodes); i++) {
5801 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
5802 rendermodes[i], DWRITE_MEASURING_MODE_NATURAL,
5803 0.0, 0.0, &analysis);
5804 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5805
5806 if (rendermodes[i] == DWRITE_RENDERING_MODE_ALIASED) {
5808 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
5809 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5810 ok(!IsRectEmpty(&rect), "got empty rect\n");
5811
5812 SetRect(&rect, 0, 0, 1, 1);
5813 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect);
5814 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5815 ok(IsRectEmpty(&rect), "unexpected empty rect\n");
5816 }
5817 else {
5818 SetRect(&rect, 0, 0, 1, 1);
5819 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
5820 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5821 ok(IsRectEmpty(&rect), "got empty rect\n");
5822
5824 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect);
5825 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5826 ok(!IsRectEmpty(&rect), "got empty rect\n");
5827 }
5828
5829 IDWriteGlyphRunAnalysis_Release(analysis);
5830 }
5831
5832 IDWriteFontFace_GetMetrics(run.fontFace, &fm);
5833
5834 /* check bbox for a single glyph run */
5835 for (run.fontEmSize = 1.0; run.fontEmSize <= 100.0; run.fontEmSize += 1.0) {
5837 LONG bboxX, bboxY;
5838
5839 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
5841 0.0, 0.0, &analysis);
5842 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5843
5845 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
5846 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5847
5848 hr = IDWriteFontFace_GetGdiCompatibleGlyphMetrics(run.fontFace, run.fontEmSize, 1.0, NULL,
5850 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5851
5852 /* metrics are in design units */
5853 bboxX = (int)floorf((gm.advanceWidth - gm.leftSideBearing - gm.rightSideBearing) * run.fontEmSize / fm.designUnitsPerEm + 0.5f);
5854 bboxY = (int)floorf((gm.advanceHeight - gm.topSideBearing - gm.bottomSideBearing) * run.fontEmSize / fm.designUnitsPerEm + 0.5f);
5855
5856 rect.right -= rect.left;
5857 rect.bottom -= rect.top;
5858 ok(abs(bboxX - rect.right) <= 2, "%.0f: bbox width %ld, from metrics %ld\n", run.fontEmSize, rect.right, bboxX);
5859 ok(abs(bboxY - rect.bottom) <= 2, "%.0f: bbox height %ld, from metrics %ld\n", run.fontEmSize, rect.bottom, bboxY);
5860
5861 IDWriteGlyphRunAnalysis_Release(analysis);
5862 }
5863
5864 /* without offsets */
5865 run.fontFace = face;
5866 run.fontEmSize = 24.0;
5867 run.glyphCount = 1;
5868 run.glyphIndices = &glyph;
5869 run.glyphAdvances = advances;
5870 run.glyphOffsets = NULL;
5871 run.isSideways = FALSE;
5872 run.bidiLevel = 0;
5873
5874 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
5876 0.0, 0.0, &analysis);
5877 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5878
5880 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
5881 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5882 ok(!IsRectEmpty(&rect), "got empty bounds\n");
5883
5884 IDWriteGlyphRunAnalysis_Release(analysis);
5885
5886 /* without explicit advances */
5887 run.fontFace = face;
5888 run.fontEmSize = 24.0;
5889 run.glyphCount = 1;
5890 run.glyphIndices = &glyph;
5891 run.glyphAdvances = NULL;
5892 run.glyphOffsets = NULL;
5893 run.isSideways = FALSE;
5894 run.bidiLevel = 0;
5895
5896 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
5898 0.0, 0.0, &analysis);
5899 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5900
5902 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
5903 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5904 ok(!IsRectEmpty(&rect), "got empty bounds\n");
5905
5906 IDWriteGlyphRunAnalysis_Release(analysis);
5907
5908 /* test that advances are scaled according to ppdip too */
5909 glyphs[0] = glyphs[1] = glyph;
5910 advances[0] = advances[1] = 100.0f;
5911 run.fontFace = face;
5912 run.fontEmSize = 24.0;
5913 run.glyphCount = 2;
5914 run.glyphIndices = glyphs;
5915 run.glyphAdvances = advances;
5916 run.glyphOffsets = NULL;
5917 run.isSideways = FALSE;
5918 run.bidiLevel = 0;
5919
5920 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
5922 0.0, 0.0, &analysis);
5923 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5924
5926 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect2);
5927 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5928 ok(!IsRectEmpty(&rect2), "got empty bounds\n");
5929 ok(!EqualRect(&rect, &rect2), "got wrong rect2\n");
5930 ok((rect2.right - rect.left) > advances[0], "got rect width %ld for advance %f\n", rect.right - rect.left, advances[0]);
5931 IDWriteGlyphRunAnalysis_Release(analysis);
5932
5933 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 2.0, NULL,
5935 0.0, 0.0, &analysis);
5936 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5937
5939 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
5940 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5941 ok((rect.right - rect.left) > 2 * advances[0], "got rect width %ld for advance %f\n", rect.right - rect.left, advances[0]);
5942 IDWriteGlyphRunAnalysis_Release(analysis);
5943
5944 /* with scaling transform */
5945 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
5947 0.0, 0.0, &analysis);
5948 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5949
5951 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
5952 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5953 ok(!IsRectEmpty(&rect), "got rect width %ld\n", rect.right - rect.left);
5954 IDWriteGlyphRunAnalysis_Release(analysis);
5955
5956 memset(&m, 0, sizeof(m));
5957 m.m11 = 2.0;
5958 m.m22 = 1.0;
5959 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, &m,
5961 0.0, 0.0, &analysis);
5962 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5963
5965 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect2);
5966 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5967 ok((rect2.right - rect2.left) > (rect.right - rect.left), "got rect width %ld\n", rect2.right - rect2.left);
5968
5969 /* instances are not reused for same runs */
5970 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, &m,
5972 0.0, 0.0, &analysis2);
5973 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5974 ok(analysis2 != analysis, "got %p, previous instance %p\n", analysis2, analysis);
5975 IDWriteGlyphRunAnalysis_Release(analysis2);
5976
5977 IDWriteGlyphRunAnalysis_Release(analysis);
5978
5979 if (IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory2, (void **)&factory2) == S_OK) {
5980 FLOAT gamma, contrast, cleartype_level;
5981
5982 /* Invalid antialias mode. */
5983 hr = IDWriteFactory2_CreateGlyphRunAnalysis(factory2, &run, NULL, DWRITE_RENDERING_MODE_ALIASED,
5984 DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DEFAULT, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE + 1,
5985 0.0f, 0.0f, &analysis);
5986 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
5987
5988 /* Invalid grid fit mode. */
5989 hr = IDWriteFactory2_CreateGlyphRunAnalysis(factory2, &run, NULL, DWRITE_RENDERING_MODE_ALIASED,
5990 DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_ENABLED + 1, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
5991 0.0f, 0.0f, &analysis);
5992 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
5993
5994 /* Invalid rendering mode. */
5995 hr = IDWriteFactory2_CreateGlyphRunAnalysis(factory2, &run, NULL, DWRITE_RENDERING_MODE_OUTLINE,
5996 DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_ENABLED, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
5997 0.0f, 0.0f, &analysis);
5998 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
5999
6000 /* Invalid measuring mode. */
6001 hr = IDWriteFactory2_CreateGlyphRunAnalysis(factory2, &run, NULL, DWRITE_RENDERING_MODE_ALIASED,
6002 DWRITE_MEASURING_MODE_GDI_NATURAL + 1, DWRITE_GRID_FIT_MODE_ENABLED, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
6003 0.0f, 0.0f, &analysis);
6004 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
6005
6006 /* Win8 does not accept default grid fitting mode. */
6007 hr = IDWriteFactory2_CreateGlyphRunAnalysis(factory2, &run, NULL, DWRITE_RENDERING_MODE_NATURAL,
6008 DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DEFAULT, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
6009 0.0f, 0.0f, &analysis);
6010 ok(hr == S_OK || broken(hr == E_INVALIDARG) /* Win8 */, "Failed to create analysis, hr %#lx.\n", hr);
6011 if (hr == S_OK)
6012 IDWriteGlyphRunAnalysis_Release(analysis);
6013
6014 /* Natural mode, grayscale antialiased. */
6015 hr = IDWriteFactory2_CreateGlyphRunAnalysis(factory2, &run, NULL, DWRITE_RENDERING_MODE_NATURAL,
6016 DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DISABLED, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
6017 0.0f, 0.0f, &analysis);
6018 ok(hr == S_OK, "Failed to create analysis, hr %#lx.\n", hr);
6019
6020 SetRect(&rect, 0, 1, 0, 1);
6021 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect);
6022 ok(hr == S_OK, "Failed to get texture bounds, hr %#lx.\n", hr);
6023 ok(IsRectEmpty(&rect), "Expected empty bbox.\n");
6024
6026 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
6027 ok(hr == S_OK, "Failed to get texture bounds, hr %#lx.\n", hr);
6028 ok(!IsRectEmpty(&rect), "Unexpected empty bbox.\n");
6029
6030 size = (rect.right - rect.left) * (rect.bottom - rect.top);
6031 bits = malloc(size);
6032
6033 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect, bits, size);
6034 ok(hr == S_OK, "Failed to get alpha texture, hr %#lx.\n", hr);
6035
6036 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect, bits, size - 1);
6037 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#lx.\n", hr);
6038
6039 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect, bits, size);
6040 ok(hr == DWRITE_E_UNSUPPORTEDOPERATION, "Unexpected hr %#lx.\n", hr);
6041
6042 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect, bits, size - 1);
6043 todo_wine
6044 ok(hr == DWRITE_E_UNSUPPORTEDOPERATION, "Unexpected hr %#lx.\n", hr);
6045
6046 free(bits);
6047
6048 hr = IDWriteFactory_CreateCustomRenderingParams(factory, 0.1f, 0.0f, 1.0f, DWRITE_PIXEL_GEOMETRY_FLAT,
6050 ok(hr == S_OK, "Failed to create custom parameters, hr %#lx.\n", hr);
6051
6052 hr = IDWriteGlyphRunAnalysis_GetAlphaBlendParams(analysis, params, &gamma, &contrast, &cleartype_level);
6053 ok(hr == S_OK, "Failed to get alpha blend params, hr %#lx.\n", hr);
6054 todo_wine
6055 ok(cleartype_level == 0.0f, "Unexpected cleartype level %f.\n", cleartype_level);
6056
6057 IDWriteRenderingParams_Release(params);
6058 IDWriteGlyphRunAnalysis_Release(analysis);
6059
6060 IDWriteFactory2_Release(factory2);
6061 }
6062
6063 if (IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory3, (void **)&factory3) == S_OK) {
6064
6065 /* Invalid antialias mode. */
6066 hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_ALIASED,
6067 DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DEFAULT, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE + 1,
6068 0.0f, 0.0f, &analysis);
6069 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
6070
6071 /* Invalid grid fit mode. */
6072 hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_ALIASED,
6073 DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_ENABLED + 1, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
6074 0.0f, 0.0f, &analysis);
6075 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
6076
6077 /* Invalid rendering mode. */
6078 hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_OUTLINE,
6079 DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_ENABLED, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
6080 0.0f, 0.0f, &analysis);
6081 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
6082
6083 /* Invalid measuring mode. */
6084 hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_ALIASED,
6086 DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE, 0.0f, 0.0f, &analysis);
6087 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
6088
6089 hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_NATURAL,
6090 DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DEFAULT, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
6091 0.0f, 0.0f, &analysis);
6092 ok(hr == S_OK, "Failed to create analysis, hr %#lx.\n", hr);
6093 IDWriteGlyphRunAnalysis_Release(analysis);
6094
6095 /* Natural mode, grayscale antialiased. */
6096 hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_NATURAL,
6097 DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DISABLED, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE,
6098 0.0f, 0.0f, &analysis);
6099 ok(hr == S_OK, "Failed to create analysis, hr %#lx.\n", hr);
6100
6101 SetRect(&rect, 0, 1, 0, 1);
6102 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect);
6103 ok(hr == S_OK, "Failed to get texture bounds, hr %#lx.\n", hr);
6104 ok(IsRectEmpty(&rect), "Expected empty bbox.\n");
6105
6107 hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
6108 ok(hr == S_OK, "Failed to get texture bounds, hr %#lx.\n", hr);
6109 ok(!IsRectEmpty(&rect), "Unexpected empty bbox.\n");
6110
6111 size = (rect.right - rect.left) * (rect.bottom - rect.top);
6112 bits = malloc(size);
6113
6114 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect, bits, size);
6115 ok(hr == S_OK, "Failed to get alpha texture, hr %#lx.\n", hr);
6116
6117 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect, bits, size - 1);
6118 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#lx.\n", hr);
6119
6120 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect, bits, size);
6121 ok(hr == DWRITE_E_UNSUPPORTEDOPERATION, "Unexpected hr %#lx.\n", hr);
6122
6123 hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect, bits, size - 1);
6124 todo_wine
6125 ok(hr == DWRITE_E_UNSUPPORTEDOPERATION, "Unexpected hr %#lx.\n", hr);
6126
6127 free(bits);
6128
6129 IDWriteGlyphRunAnalysis_Release(analysis);
6130
6131 IDWriteFactory3_Release(factory3);
6132 }
6133
6134 IDWriteFontFace_Release(face);
6135 ref = IDWriteFactory_Release(factory);
6136 ok(ref == 0, "factory not released, %lu\n", ref);
6137}
RECT rect
Definition: combotst.c:67
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
@ DWRITE_GRID_FIT_MODE_DEFAULT
Definition: dwrite_2.idl:29
@ DWRITE_RENDERING_MODE1_ALIASED
Definition: dwrite_3.idl:79
@ DWRITE_RENDERING_MODE1_NATURAL
Definition: dwrite_3.idl:82
@ DWRITE_RENDERING_MODE1_OUTLINE
Definition: dwrite_3.idl:84
RECT rect2
Definition: edittest.c:51
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define bits
Definition: infblock.c:15
#define floorf(x)
Definition: mymath.h:65
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
UINT16 designUnitsPerEm
Definition: dwrite.idl:353

Referenced by START_TEST().

◆ test_CreateRenderingParams()

static void test_CreateRenderingParams ( void  )
static

Definition at line 5590 of file font.c.

5591{
5592 IDWriteRenderingParams2 *params2;
5593 IDWriteRenderingParams1 *params1;
5596 IDWriteFactory3 *factory3;
5598 HRESULT hr;
5599 ULONG ref;
5600
5602
5603 hr = IDWriteFactory_CreateCustomRenderingParams(factory, 1.0, 0.0, 0.0, DWRITE_PIXEL_GEOMETRY_FLAT,
5605 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5606
5607 hr = IDWriteRenderingParams_QueryInterface(params, &IID_IDWriteRenderingParams1, (void**)&params1);
5608 if (hr == S_OK) {
5609 FLOAT enhcontrast;
5610
5611 /* test what enhanced contrast setting set by default to */
5612 enhcontrast = IDWriteRenderingParams1_GetGrayscaleEnhancedContrast(params1);
5613 ok(enhcontrast == 1.0, "got %.2f\n", enhcontrast);
5614 IDWriteRenderingParams1_Release(params1);
5615
5616 hr = IDWriteRenderingParams_QueryInterface(params, &IID_IDWriteRenderingParams2, (void**)&params2);
5617 if (hr == S_OK) {
5618 DWRITE_GRID_FIT_MODE gridfit;
5619
5620 /* default gridfit mode */
5621 gridfit = IDWriteRenderingParams2_GetGridFitMode(params2);
5622 ok(gridfit == DWRITE_GRID_FIT_MODE_DEFAULT, "got %d\n", gridfit);
5623
5624 IDWriteRenderingParams2_Release(params2);
5625 }
5626 else
5627 win_skip("IDWriteRenderingParams2 not supported.\n");
5628 }
5629 else
5630 win_skip("IDWriteRenderingParams1 not supported.\n");
5631
5632 IDWriteRenderingParams_Release(params);
5633
5634 hr = IDWriteFactory_CreateRenderingParams(factory, &params);
5635 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5636
5637 mode = IDWriteRenderingParams_GetRenderingMode(params);
5638 ok(mode == DWRITE_RENDERING_MODE_DEFAULT, "got %d\n", mode);
5639 IDWriteRenderingParams_Release(params);
5640
5641 hr = IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory3, (void**)&factory3);
5642 if (hr == S_OK) {
5643 IDWriteRenderingParams3 *params3;
5644
5645 hr = IDWriteFactory3_CreateCustomRenderingParams(factory3, 1.0f, 0.0f, 0.0f, 1.0f, DWRITE_PIXEL_GEOMETRY_FLAT,
5647 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5648
5649 hr = IDWriteRenderingParams3_QueryInterface(params3, &IID_IDWriteRenderingParams, (void**)&params);
5650 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5651
5652 mode = IDWriteRenderingParams_GetRenderingMode(params);
5654
5655 IDWriteRenderingParams_Release(params);
5656 IDWriteRenderingParams3_Release(params3);
5657 IDWriteFactory3_Release(factory3);
5658 }
5659 else
5660 win_skip("IDWriteRenderingParams3 not supported.\n");
5661
5662 ref = IDWriteFactory_Release(factory);
5663 ok(ref == 0, "factory not released, %lu\n", ref);
5664}
DWRITE_GRID_FIT_MODE
Definition: dwrite_2.idl:28
@ DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED
Definition: dwrite_3.idl:85

Referenced by START_TEST().

◆ test_CreateStreamFromKey()

static void test_CreateStreamFromKey ( void  )
static

Definition at line 4896 of file font.c.

4897{
4898 IDWriteLocalFontFileLoader *localloader;
4899 IDWriteFontFileStream *stream, *stream2;
4903 UINT64 writetime;
4904 WCHAR *path;
4905 void *key;
4906 UINT32 size;
4907 HRESULT hr;
4908 ULONG ref;
4909
4911
4913
4914 hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
4915 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
4916
4917 key = NULL;
4918 size = 0;
4919 hr = IDWriteFontFile_GetReferenceKey(file, (const void**)&key, &size);
4920 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4921 ok(size != 0, "got %u\n", size);
4922
4923 hr = IDWriteFontFile_GetLoader(file, &loader);
4924 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4925 IDWriteFontFileLoader_QueryInterface(loader, &IID_IDWriteLocalFontFileLoader, (void**)&localloader);
4926 IDWriteFontFileLoader_Release(loader);
4927
4928 hr = IDWriteLocalFontFileLoader_CreateStreamFromKey(localloader, key, size, &stream);
4929 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4930 EXPECT_REF(stream, 1);
4931
4932 hr = IDWriteLocalFontFileLoader_CreateStreamFromKey(localloader, key, size, &stream2);
4933 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4934 ok(stream == stream2 || broken(stream != stream2) /* Win7 SP0 */, "got %p, %p\n", stream, stream2);
4935 if (stream == stream2)
4936 EXPECT_REF(stream, 2);
4937 IDWriteFontFileStream_Release(stream);
4938 IDWriteFontFileStream_Release(stream2);
4939
4940 hr = IDWriteLocalFontFileLoader_CreateStreamFromKey(localloader, key, size, &stream);
4941 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4942 EXPECT_REF(stream, 1);
4943
4944 writetime = 0;
4945 hr = IDWriteFontFileStream_GetLastWriteTime(stream, &writetime);
4946 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4947 ok(writetime != 0, "got %s\n", wine_dbgstr_longlong(writetime));
4948
4949 IDWriteFontFileStream_Release(stream);
4950 IDWriteFontFile_Release(file);
4951
4952 IDWriteLocalFontFileLoader_Release(localloader);
4953 ref = IDWriteFactory_Release(factory);
4954 ok(ref == 0, "factory not released, %lu\n", ref);
4956}
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49

Referenced by START_TEST().

◆ test_CustomFontCollection()

static void test_CustomFontCollection ( void  )
static

Definition at line 3027 of file font.c.

3028{
3029 IDWriteFontCollectionLoader *loader, *loader2, *loader3;
3030 IDWriteFontCollection *font_collection = NULL;
3032 struct test_fontcollectionloader resource_collection = { { &resourcecollectionloadervtbl }, &rloader };
3033 IDWriteFontFamily *family, *family2, *family3;
3034 IDWriteFontFace *idfontface, *idfontface2;
3035 IDWriteFontFile *fontfile, *fontfile2;
3037 IDWriteFont *idfont, *idfont2;
3040 BOOL exists;
3041 HRESULT hr;
3042 HRSRC font;
3043 ULONG ref;
3044
3046
3048 loader2 = create_collection_loader();
3049 loader3 = create_collection_loader();
3050
3051 hr = IDWriteFactory_RegisterFontCollectionLoader(factory, NULL);
3052 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
3053
3054 hr = IDWriteFactory_UnregisterFontCollectionLoader(factory, NULL);
3055 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
3056
3057 EXPECT_REF(loader, 1);
3058 EXPECT_REF(loader2, 1);
3059
3060 hr = IDWriteFactory_RegisterFontCollectionLoader(factory, loader);
3061 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3062 hr = IDWriteFactory_RegisterFontCollectionLoader(factory, loader2);
3063 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3064 hr = IDWriteFactory_RegisterFontCollectionLoader(factory, loader);
3065 ok(hr == DWRITE_E_ALREADYREGISTERED, "Unexpected hr %#lx.\n", hr);
3066
3067 EXPECT_REF(loader, 2);
3068 EXPECT_REF(loader2, 2);
3069
3070 hr = IDWriteFactory_RegisterFontFileLoader(factory, &rloader);
3071 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3072 hr = IDWriteFactory_RegisterFontCollectionLoader(factory, &resource_collection.IDWriteFontFileCollectionLoader_iface);
3073 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3074
3075 /* Loader wasn't registered. */
3076 font_collection = (void*)0xdeadbeef;
3077 hr = IDWriteFactory_CreateCustomFontCollection(factory, loader3, "Billy", 6, &font_collection);
3078 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
3079 ok(font_collection == NULL, "got %p\n", font_collection);
3080
3081 EXPECT_REF(factory, 1);
3082 hr = IDWriteFactory_CreateCustomFontCollection(factory, loader, "Billy", 6, &font_collection);
3083 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3084 todo_wine
3085 EXPECT_REF(factory, 1);
3086 EXPECT_REF(loader, 2);
3087 IDWriteFontCollection_Release(font_collection);
3088
3089 hr = IDWriteFactory_CreateCustomFontCollection(factory, loader2, "Billy", 6, &font_collection);
3090 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3091 IDWriteFontCollection_Release(font_collection);
3092
3093 font_collection = (void*)0xdeadbeef;
3094 hr = IDWriteFactory_CreateCustomFontCollection(factory, (IDWriteFontCollectionLoader*)0xdeadbeef, "Billy", 6, &font_collection);
3095 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
3096 ok(font_collection == NULL, "got %p\n", font_collection);
3097
3099 ok(font != NULL, "Failed to find font resource\n");
3100
3101 hr = IDWriteFactory_CreateCustomFontCollection(factory, &resource_collection.IDWriteFontFileCollectionLoader_iface,
3102 &font, sizeof(HRSRC), &font_collection);
3103 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
3104 EXPECT_REF(font_collection, 1);
3105
3106 index = 1;
3107 exists = FALSE;
3108 hr = IDWriteFontCollection_FindFamilyName(font_collection, L"wine_test", &index, &exists);
3109 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3110 ok(index == 0, "got index %i\n", index);
3111 ok(exists, "got exists %i\n", exists);
3112
3113 count = IDWriteFontCollection_GetFontFamilyCount(font_collection);
3114 ok(count == 1, "got %u\n", count);
3115
3116 family = NULL;
3117 hr = IDWriteFontCollection_GetFontFamily(font_collection, 0, &family);
3118 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3119 EXPECT_REF(family, 1);
3120
3121 family2 = NULL;
3122 hr = IDWriteFontCollection_GetFontFamily(font_collection, 0, &family2);
3123 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3124 EXPECT_REF(family2, 1);
3125 ok(family != family2, "got %p, %p\n", family, family2);
3126
3127 hr = IDWriteFontFamily_GetFont(family, 0, &idfont);
3128 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3129 EXPECT_REF(idfont, 1);
3130 EXPECT_REF(family, 2);
3131 hr = IDWriteFontFamily_GetFont(family, 0, &idfont2);
3132 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3133 EXPECT_REF(idfont2, 1);
3134 EXPECT_REF(family, 3);
3135 ok(idfont != idfont2, "got %p, %p\n", idfont, idfont2);
3136 IDWriteFont_Release(idfont2);
3137
3138 hr = IDWriteFont_GetInformationalStrings(idfont, DWRITE_INFORMATIONAL_STRING_COPYRIGHT_NOTICE, &string, &exists);
3139 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3140 ok(exists, "got %d\n", exists);
3141 EXPECT_REF(string, 1);
3142 IDWriteLocalizedStrings_Release(string);
3143
3144 family3 = NULL;
3145 hr = IDWriteFont_GetFontFamily(idfont, &family3);
3146 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3147 EXPECT_REF(family, 3);
3148 ok(family == family3, "got %p, %p\n", family, family3);
3149 IDWriteFontFamily_Release(family3);
3150
3151 idfontface = NULL;
3152 hr = IDWriteFont_CreateFontFace(idfont, &idfontface);
3153 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3154 EXPECT_REF(idfont, 1);
3155
3156 idfont2 = NULL;
3157 hr = IDWriteFontFamily_GetFont(family2, 0, &idfont2);
3158 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3159 EXPECT_REF(idfont2, 1);
3160 EXPECT_REF(idfont, 1);
3161 ok(idfont2 != idfont, "Font instances should not match\n");
3162
3163 idfontface2 = NULL;
3164 hr = IDWriteFont_CreateFontFace(idfont2, &idfontface2);
3165 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3166 ok(idfontface2 == idfontface, "fontfaces should match\n");
3167
3168 index = 1;
3169 fontfile = NULL;
3170 hr = IDWriteFontFace_GetFiles(idfontface, &index, &fontfile);
3171 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3172
3173 index = 1;
3174 fontfile2 = NULL;
3175 hr = IDWriteFontFace_GetFiles(idfontface2, &index, &fontfile2);
3176 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3177 ok(fontfile == fontfile2, "fontfiles should match\n");
3178
3179 IDWriteFont_Release(idfont);
3180 IDWriteFont_Release(idfont2);
3181 IDWriteFontFile_Release(fontfile);
3182 IDWriteFontFile_Release(fontfile2);
3183 IDWriteFontFace_Release(idfontface);
3184 IDWriteFontFace_Release(idfontface2);
3185 IDWriteFontFamily_Release(family2);
3186 IDWriteFontFamily_Release(family);
3187 IDWriteFontCollection_Release(font_collection);
3188
3189 hr = IDWriteFactory_UnregisterFontCollectionLoader(factory, loader);
3190 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3191 hr = IDWriteFactory_UnregisterFontCollectionLoader(factory, loader);
3192 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
3193 hr = IDWriteFactory_UnregisterFontCollectionLoader(factory, loader2);
3194 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3195 hr = IDWriteFactory_UnregisterFontCollectionLoader(factory, &resource_collection.IDWriteFontFileCollectionLoader_iface);
3196 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3197 hr = IDWriteFactory_UnregisterFontFileLoader(factory, &rloader);
3198 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3199
3200 IDWriteFontCollectionLoader_Release(loader);
3201 IDWriteFontCollectionLoader_Release(loader2);
3202 IDWriteFontCollectionLoader_Release(loader3);
3203
3204 ref = IDWriteFactory_Release(factory);
3205 ok(ref == 0, "factory not released, %lu\n", ref);
3206}
@ DWRITE_INFORMATIONAL_STRING_COPYRIGHT_NOTICE
Definition: dwrite.idl:118
char string[160]
Definition: util.h:11
static IDWriteFontCollectionLoader * create_collection_loader(void)
Definition: font.c:3017
static const struct IDWriteFontFileLoaderVtbl resourcefontfileloadervtbl
Definition: font.c:892
static const struct IDWriteFontCollectionLoaderVtbl resourcecollectionloadervtbl
Definition: font.c:741
IDWriteFontCollectionLoader IDWriteFontFileCollectionLoader_iface
Definition: font.c:694

Referenced by START_TEST().

◆ test_expiration_event()

static void test_expiration_event ( void  )
static

Definition at line 10185 of file font.c.

10186{
10187 IDWriteFontCollection *collection, *collection2;
10188 IDWriteFontCollection3 *collection3;
10189 IDWriteFactory *factory, *factory2;
10190 unsigned int refcount;
10191 HANDLE event, event2;
10192 HRESULT hr;
10193
10195
10196 hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
10197 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10198
10199 hr = IDWriteFontCollection_QueryInterface(collection, &IID_IDWriteFontCollection3, (void **)&collection3);
10200 if (FAILED(hr))
10201 {
10202 win_skip("Expiration events are not supported.\n");
10203 IDWriteFontCollection_Release(collection);
10204 IDWriteFactory_Release(factory);
10205 return;
10206 }
10207 IDWriteFontCollection3_Release(collection3);
10208
10210 todo_wine
10211 ok(!!event, "Unexpected event handle.\n");
10212
10213 /* Compare handles with another isolated factory. */
10214 factory2 = create_factory();
10215
10216 hr = IDWriteFactory_GetSystemFontCollection(factory2, &collection2, FALSE);
10217 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10218 event2 = get_collection_expiration_event(collection2);
10219todo_wine {
10220 ok(!!event2, "Unexpected event handle.\n");
10221 ok(event != event2, "Unexpected event handle.\n");
10222}
10223 IDWriteFontCollection_Release(collection2);
10224
10225 IDWriteFontCollection_Release(collection);
10226
10227 refcount = IDWriteFactory_Release(factory2);
10228 ok(!refcount, "Unexpected factory refcount %u.\n", refcount);
10229 refcount = IDWriteFactory_Release(factory);
10230 ok(!refcount, "Unexpected factory refcount %u.\n", refcount);
10231}
static HANDLE get_collection_expiration_event(IDWriteFontCollection *collection)
Definition: font.c:10171

Referenced by START_TEST().

◆ test_family_font_set()

static void test_family_font_set ( void  )
static

Definition at line 10233 of file font.c.

10234{
10236 IDWriteFontFamily2 *family2;
10237 IDWriteFontFamily *family;
10239 unsigned int count, refcount;
10240 IDWriteFontSet1 *fontset, *fontset2;
10243 WCHAR buffW[64];
10244 BOOL exists;
10245 HRESULT hr;
10246
10248
10249 hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
10250 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10251
10252 hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
10253 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10254
10255 if (SUCCEEDED(IDWriteFontFamily_QueryInterface(family, &IID_IDWriteFontFamily2, (void **)&family2)))
10256 {
10257 hr = IDWriteFontFamily2_GetFontSet(family2, &fontset);
10258 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10259 hr = IDWriteFontFamily2_GetFontSet(family2, &fontset2);
10260 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10261 ok(fontset != fontset2, "Unexpected fontset instance.\n");
10262
10263 count = IDWriteFontSet1_GetFontCount(fontset);
10264
10265 /* Invalid property id. */
10266 exists = TRUE;
10267 values = (void *)0xdeadbeef;
10268 hr = IDWriteFontSet1_GetPropertyValues(fontset, 0, 100, &exists, &values);
10269 ok(FAILED(hr), "Unexpected hr %#lx.\n", hr);
10270 ok(!exists && !values, "Unexpected return value.\n");
10271
10272 /* Invalid index. */
10273 exists = TRUE;
10274 values = (void *)0xdeadbeef;
10275 hr = IDWriteFontSet1_GetPropertyValues(fontset, count, DWRITE_FONT_PROPERTY_ID_POSTSCRIPT_NAME, &exists, &values);
10276 ok(FAILED(hr), "Unexpected hr %#lx.\n", hr);
10277 ok(!exists && !values, "Unexpected return value.\n");
10278
10279 exists = TRUE;
10280 values = (void *)0xdeadbeef;
10281 hr = IDWriteFontSet1_GetPropertyValues(fontset, count, 100, &exists, &values);
10282 ok(FAILED(hr), "Unexpected hr %#lx.\n", hr);
10283 ok(!exists && !values, "Unexpected return value.\n");
10284
10285 hr = IDWriteFontSet1_GetPropertyValues(fontset, 0, DWRITE_FONT_PROPERTY_ID_POSTSCRIPT_NAME, &exists, &values);
10286 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10287 ok(exists == !!values, "Unexpected return value.\n");
10288 if (values)
10289 {
10290 hr = IDWriteLocalizedStrings_GetString(values, 0, buffW, ARRAY_SIZE(buffW));
10291 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10292 IDWriteLocalizedStrings_Release(values);
10293 }
10294
10295 hr = IDWriteFontSet1_CreateFontResource(fontset, 100, &resource);
10296 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
10297
10298 hr = IDWriteFontSet1_CreateFontResource(fontset, 0, &resource);
10299 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10300 IDWriteFontResource_Release(resource);
10301
10302 IDWriteFontSet1_Release(fontset2);
10303 IDWriteFontSet1_Release(fontset);
10304
10305 IDWriteFontFamily2_Release(family2);
10306 }
10307 else
10308 win_skip("IDWriteFontFamily2 is not supported.\n");
10309
10310 IDWriteFontFamily_Release(family);
10311 IDWriteFontCollection_Release(collection);
10312
10313 refcount = IDWriteFactory_Release(factory);
10314 ok(!refcount, "Unexpected factory refcount %u.\n", refcount);
10315}
@ DWRITE_FONT_PROPERTY_ID_POSTSCRIPT_NAME
Definition: dwrite_3.idl:96

Referenced by START_TEST().

◆ test_font_properties()

static void test_font_properties ( void  )
static

Definition at line 8338 of file font.c.

8339{
8340 IDWriteFontFace3 *fontface3;
8341 IDWriteFontFace *fontface;
8345 HRESULT hr;
8346 ULONG ref;
8347
8349
8350 /* this creates simulated font */
8352
8353 style = IDWriteFont_GetStyle(font);
8354 ok(style == DWRITE_FONT_STYLE_OBLIQUE, "got %u\n", style);
8355
8356 hr = IDWriteFont_CreateFontFace(font, &fontface);
8357 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8358
8359 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace3, (void**)&fontface3);
8360 IDWriteFontFace_Release(fontface);
8361 if (hr == S_OK) {
8362 style = IDWriteFontFace3_GetStyle(fontface3);
8363 ok(style == DWRITE_FONT_STYLE_OBLIQUE, "got %u\n", style);
8364
8365 IDWriteFontFace3_Release(fontface3);
8366 }
8367
8368 IDWriteFont_Release(font);
8369 ref = IDWriteFactory_Release(factory);
8370 ok(ref == 0, "factory not released, %lu\n", ref);
8371}
static IDWriteFont * get_tahoma_instance(IDWriteFactory *factory, DWRITE_FONT_STYLE style)
Definition: font.c:528

Referenced by START_TEST().

◆ test_font_resource()

static void test_font_resource ( void  )
static

Definition at line 9869 of file font.c.

9870{
9872 IDWriteFontResource *resource, *resource2;
9873 IDWriteFontFile *fontfile, *fontfile2;
9874 DWRITE_FONT_AXIS_VALUE axis_values[2];
9875 IDWriteFontFace5 *fontface5;
9876 IDWriteFontFace *fontface;
9879 HRESULT hr;
9880 ULONG ref;
9881 BOOL ret;
9882
9883 if (!(factory = create_factory_iid(&IID_IDWriteFactory6)))
9884 {
9885 win_skip("IDWriteFactory6 is not supported.\n");
9886 return;
9887 }
9888
9889 fontface = create_fontface((IDWriteFactory *)factory);
9890
9891 count = 1;
9892 hr = IDWriteFontFace_GetFiles(fontface, &count, &fontfile);
9893 ok(hr == S_OK, "Failed to get file object, hr %#lx.\n", hr);
9894
9895 hr = IDWriteFactory6_CreateFontResource(factory, fontfile, 0, &resource);
9896 ok(hr == S_OK, "Failed to create font resource, hr %#lx.\n", hr);
9897
9898 hr = IDWriteFactory6_CreateFontResource(factory, fontfile, 0, &resource2);
9899 ok(hr == S_OK, "Failed to create font resource, hr %#lx.\n", hr);
9900 ok(resource != resource2, "Unexpected instance.\n");
9901 IDWriteFontResource_Release(resource2);
9902
9903 hr = IDWriteFontResource_GetFontFile(resource, &fontfile2);
9904 ok(hr == S_OK, "Failed to get font file, hr %#lx.\n", hr);
9905 ok(fontfile2 == fontfile, "Unexpected file instance.\n");
9906 IDWriteFontFile_Release(fontfile2);
9907
9908 index = IDWriteFontResource_GetFontFaceIndex(resource);
9909 ok(!index, "Unexpected index %u.\n", index);
9910
9911 /* Specify axis value, font has no variations. */
9912 axis_values[0].axisTag = DWRITE_FONT_AXIS_TAG_WEIGHT;
9913 axis_values[0].value = 400.0f;
9914 hr = IDWriteFontResource_CreateFontFaceReference(resource, DWRITE_FONT_SIMULATIONS_NONE, axis_values, 1, &reference);
9915 ok(hr == S_OK, "Failed to create reference object, hr %#lx.\n", hr);
9916
9917 count = IDWriteFontFaceReference1_GetFontAxisValueCount(reference);
9918 ok(count == 1, "Unexpected axis value count.\n");
9919
9920 IDWriteFontFaceReference1_Release(reference);
9921
9922 hr = IDWriteFactory6_CreateFontFaceReference(factory, fontfile, 0, DWRITE_FONT_SIMULATIONS_NONE, axis_values, 1,
9923 &reference);
9924 count = IDWriteFontFaceReference1_GetFontAxisValueCount(reference);
9925 ok(count == 1, "Unexpected axis value count.\n");
9926 IDWriteFontFaceReference1_Release(reference);
9927
9928 EXPECT_REF(resource, 1);
9929 hr = IDWriteFontResource_CreateFontFaceReference(resource, DWRITE_FONT_SIMULATIONS_NONE, NULL, 0, &reference);
9930 ok(hr == S_OK, "Failed to create reference object, hr %#lx.\n", hr);
9931 EXPECT_REF(resource, 1);
9932
9933 hr = IDWriteFontResource_CreateFontFaceReference(resource, DWRITE_FONT_SIMULATIONS_NONE, NULL, 0, &reference2);
9934 ok(hr == S_OK, "Failed to create reference object, hr %#lx.\n", hr);
9935 ok(reference != reference2, "Unexpected reference instance.\n");
9936 IDWriteFontFaceReference1_Release(reference2);
9937 IDWriteFontFaceReference1_Release(reference);
9938
9939 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace5, (void **)&fontface5);
9940 ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr);
9941
9942 hr = IDWriteFontFace5_GetFontResource(fontface5, &resource2);
9943 ok(hr == S_OK, "Failed to get font resource, hr %#lx.\n", hr);
9944 ok(resource != resource2, "Unexpected resource instance.\n");
9945 IDWriteFontResource_Release(resource);
9946
9947 hr = IDWriteFontFace5_GetFontResource(fontface5, &resource);
9948 ok(hr == S_OK, "Failed to get font resource, hr %#lx.\n", hr);
9949 ok(resource != resource2, "Unexpected resource instance.\n");
9950 EXPECT_REF(resource, 1);
9951 IDWriteFontResource_Release(resource);
9952 IDWriteFontResource_Release(resource2);
9953
9954 IDWriteFontFace5_Release(fontface5);
9955
9956 /* Reference equality regarding set axis values. */
9957 axis_values[0].axisTag = DWRITE_FONT_AXIS_TAG_WEIGHT;
9958 axis_values[0].value = 400.0f;
9959 axis_values[1].axisTag = DWRITE_FONT_AXIS_TAG_ITALIC;
9960 axis_values[1].value = 1.0f;
9961 hr = IDWriteFactory6_CreateFontFaceReference(factory, fontfile, 0, DWRITE_FONT_SIMULATIONS_NONE, axis_values, 2,
9962 &reference);
9963 count = IDWriteFontFaceReference1_GetFontAxisValueCount(reference);
9964 ok(count == 2, "Unexpected axis value count.\n");
9965
9966 hr = IDWriteFactory6_CreateFontFaceReference(factory, fontfile, 0, DWRITE_FONT_SIMULATIONS_NONE, NULL, 0,
9967 &reference2);
9968 count = IDWriteFontFaceReference1_GetFontAxisValueCount(reference2);
9969 ok(!count, "Unexpected axis value count.\n");
9970
9971 ret = IDWriteFontFaceReference1_Equals(reference, (IDWriteFontFaceReference *)reference2);
9972 ok(!ret, "Unexpected result.\n");
9973 IDWriteFontFaceReference1_Release(reference2);
9974
9975 /* Different values order. */
9976 axis_values[0].axisTag = DWRITE_FONT_AXIS_TAG_ITALIC;
9977 axis_values[0].value = 1.0f;
9978 axis_values[1].axisTag = DWRITE_FONT_AXIS_TAG_WEIGHT;
9979 axis_values[1].value = 400.0f;
9980 hr = IDWriteFactory6_CreateFontFaceReference(factory, fontfile, 0, DWRITE_FONT_SIMULATIONS_NONE, axis_values, 2,
9981 &reference2);
9982 count = IDWriteFontFaceReference1_GetFontAxisValueCount(reference2);
9983 ok(count == 2, "Unexpected axis value count.\n");
9984
9985 ret = IDWriteFontFaceReference1_Equals(reference, (IDWriteFontFaceReference *)reference2);
9986 ok(!ret, "Unexpected result.\n");
9987 IDWriteFontFaceReference1_Release(reference2);
9988
9989 /* Different axis values. */
9990 axis_values[0].axisTag = DWRITE_FONT_AXIS_TAG_ITALIC;
9991 axis_values[0].value = 1.0f;
9992 axis_values[1].axisTag = DWRITE_FONT_AXIS_TAG_WEIGHT;
9993 axis_values[1].value = 401.0f;
9994 hr = IDWriteFactory6_CreateFontFaceReference(factory, fontfile, 0, DWRITE_FONT_SIMULATIONS_NONE, axis_values, 2,
9995 &reference2);
9996 count = IDWriteFontFaceReference1_GetFontAxisValueCount(reference2);
9997 ok(count == 2, "Unexpected axis value count.\n");
9998
9999 ret = IDWriteFontFaceReference1_Equals(reference, (IDWriteFontFaceReference *)reference2);
10000 ok(!ret, "Unexpected result.\n");
10001 IDWriteFontFaceReference1_Release(reference2);
10002
10003 memset(axis_values, 0, sizeof(axis_values));
10004 hr = IDWriteFontFaceReference1_GetFontAxisValues(reference, axis_values, 1);
10005 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#lx.\n", hr);
10006 ok(!axis_values[0].axisTag, "Unexpected axis tag.\n");
10007
10008 memset(axis_values, 0, sizeof(axis_values));
10009 hr = IDWriteFontFaceReference1_GetFontAxisValues(reference, axis_values, 2);
10010 ok(hr == S_OK, "Failed to get axis values, hr %#lx.\n", hr);
10011 ok(axis_values[0].axisTag == DWRITE_FONT_AXIS_TAG_WEIGHT, "Unexpected axis tag.\n");
10012
10013 hr = IDWriteFontFaceReference1_CreateFontFace(reference, &fontface5);
10014 ok(hr == S_OK, "Failed to create a font face, hr %#lx.\n", hr);
10015 IDWriteFontFace5_Release(fontface5);
10016
10017 IDWriteFontFaceReference1_Release(reference);
10018
10019 IDWriteFontFile_Release(fontfile);
10020
10021 IDWriteFontFace_Release(fontface);
10022 ref = IDWriteFactory6_Release(factory);
10023 ok(ref == 0, "Factory wasn't released, %lu.\n", ref);
10024}
GLint reference
Definition: glext.h:11729
DWRITE_FONT_AXIS_TAG axisTag
Definition: dwrite_3.idl:144

Referenced by START_TEST().

◆ test_fontsetbuilder()

static void test_fontsetbuilder ( void  )
static

Definition at line 9628 of file font.c.

9629{
9630 IDWriteFontFaceReference *ref, *ref2, *ref3;
9633 IDWriteFontSetBuilder1 *builder1;
9634 IDWriteFontSetBuilder *builder;
9635 DWRITE_FONT_AXIS_VALUE axis_values[4];
9636 IDWriteFactory3 *factory;
9637 UINT32 count, i, refcount;
9638 IDWriteFontSet *fontset;
9640 WCHAR *path;
9641 HRESULT hr;
9642
9643 factory = create_factory_iid(&IID_IDWriteFactory3);
9644 if (!factory)
9645 {
9646 win_skip("IDWriteFontSetBuilder is not supported.\n");
9647 return;
9648 }
9649
9650 EXPECT_REF(factory, 1);
9651 hr = IDWriteFactory3_CreateFontSetBuilder(factory, &builder);
9652 ok(hr == S_OK, "Failed to create font set builder, hr %#lx.\n", hr);
9653 EXPECT_REF(factory, 2);
9654
9655 if (SUCCEEDED(hr = IDWriteFontSetBuilder_QueryInterface(builder, &IID_IDWriteFontSetBuilder1, (void **)&builder1)))
9656 {
9658
9659 hr = IDWriteFactory3_CreateFontFileReference(factory, path, NULL, &file);
9660 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
9661
9662 hr = IDWriteFontSetBuilder1_AddFontFile(builder1, file);
9663 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
9664
9665 hr = IDWriteFontSetBuilder1_CreateFontSet(builder1, &fontset);
9666 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
9667 hr = IDWriteFactory3_CreateFontCollectionFromFontSet(factory, fontset, &collection);
9668 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
9669 count = IDWriteFontCollection1_GetFontFamilyCount(collection);
9670 ok(count == 1, "Unexpected family count %u.\n", count);
9671 IDWriteFontCollection1_Release(collection);
9672 IDWriteFontSet_Release(fontset);
9673
9674 hr = IDWriteFontSetBuilder1_AddFontFile(builder1, file);
9675 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
9676
9677 hr = IDWriteFontSetBuilder1_CreateFontSet(builder1, &fontset);
9678 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
9679
9680 hr = IDWriteFactory3_CreateFontCollectionFromFontSet(factory, fontset, &collection);
9681 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
9683 count = IDWriteFontCollection1_GetFontFamilyCount(collection);
9684 ok(count == 1, "Unexpected family count %u.\n", count);
9685 IDWriteFontCollection1_Release(collection);
9686
9687 /* No attempt to eliminate duplicates. */
9688 count = IDWriteFontSet_GetFontCount(fontset);
9689 ok(count == 2, "Unexpected font count %u.\n", count);
9690
9691 hr = IDWriteFontSet_GetFontFaceReference(fontset, 0, &ref);
9692 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
9693
9694 hr = IDWriteFontFaceReference_QueryInterface(ref, &IID_IDWriteFontFaceReference1, (void **)&ref1);
9695 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
9696
9697 count = IDWriteFontFaceReference1_GetFontAxisValueCount(ref1);
9698 todo_wine
9699 ok(count == 4, "Unexpected axis count %u.\n", count);
9700
9701 if (count == 4)
9702 {
9703 hr = IDWriteFontFaceReference1_GetFontAxisValues(ref1, axis_values, ARRAY_SIZE(axis_values));
9704 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
9705
9706 ok(axis_values[0].axisTag == DWRITE_FONT_AXIS_TAG_WEIGHT, "Unexpected tag[0] %s.\n",
9707 wine_dbgstr_an((char *)&axis_values[0].axisTag, 4));
9708 ok(axis_values[0].value == 500.0f, "Unexpected value[0] %f.\n", axis_values[0].value);
9709 ok(axis_values[1].axisTag == DWRITE_FONT_AXIS_TAG_WIDTH, "Unexpected tag[1] %s.\n",
9710 wine_dbgstr_an((char *)&axis_values[1].axisTag, 4));
9711 ok(axis_values[1].value == 100.0f, "Unexpected value[1] %f.\n", axis_values[1].value);
9712 ok(axis_values[2].axisTag == DWRITE_FONT_AXIS_TAG_ITALIC, "Unexpected tag[2] %s.\n",
9713 wine_dbgstr_an((char *)&axis_values[2].axisTag, 4));
9714 ok(axis_values[2].value == 0.0f, "Unexpected value[2] %f.\n", axis_values[2].value);
9715 ok(axis_values[3].axisTag == DWRITE_FONT_AXIS_TAG_SLANT, "Unexpected tag[3] %s.\n",
9716 wine_dbgstr_an((char *)&axis_values[3].axisTag, 4));
9717 ok(axis_values[3].value == 0.0f, "Unexpected value[3] %f.\n", axis_values[3].value);
9718 }
9719
9720 IDWriteFontFaceReference1_Release(ref1);
9721
9722 IDWriteFontFaceReference_Release(ref);
9723
9724 IDWriteFontSet_Release(fontset);
9725
9726 IDWriteFontFile_Release(file);
9727 IDWriteFontSetBuilder1_Release(builder1);
9728 }
9729 else
9730 win_skip("IDWriteFontSetBuilder1 is not available.\n");
9731 IDWriteFontSetBuilder_Release(builder);
9732
9733 hr = IDWriteFactory3_GetSystemFontCollection(factory, FALSE, &collection, FALSE);
9734 ok(hr == S_OK, "Failed to get system collection, hr %#lx.\n", hr);
9735 count = IDWriteFontCollection1_GetFontFamilyCount(collection);
9736
9737 for (i = 0; i < count; i++) {
9738 IDWriteFontFamily1 *family;
9739 UINT32 j, fontcount;
9741
9742 hr = IDWriteFontCollection1_GetFontFamily(collection, i, &family);
9743 ok(hr == S_OK, "Failed to get family, hr %#lx.\n", hr);
9744
9745 fontcount = IDWriteFontFamily1_GetFontCount(family);
9746 for (j = 0; j < fontcount; ++j)
9747 {
9748 IDWriteFontSet *fontset;
9749 UINT32 setcount, id;
9750
9751 hr = IDWriteFontFamily1_GetFont(family, j, &font);
9752 ok(hr == S_OK, "Failed to get font, hr %#lx.\n", hr);
9753
9754 /* Create a set with a single font reference, test set properties. */
9755 hr = IDWriteFactory3_CreateFontSetBuilder(factory, &builder);
9756 ok(hr == S_OK, "Failed to create font set builder, hr %#lx.\n", hr);
9757
9758 hr = IDWriteFont3_GetFontFaceReference(font, &ref);
9759 ok(hr == S_OK, "Failed to get fontface reference, hr %#lx.\n", hr);
9760
9761 EXPECT_REF(ref, 1);
9762 hr = IDWriteFontSetBuilder_AddFontFaceReference(builder, ref);
9763 ok(hr == S_OK, "Failed to add fontface reference, hr %#lx.\n", hr);
9764 EXPECT_REF(ref, 1);
9765
9766 hr = IDWriteFontSetBuilder_CreateFontSet(builder, &fontset);
9767 ok(hr == S_OK, "Failed to create a font set, hr %#lx.\n", hr);
9768
9769 setcount = IDWriteFontSet_GetFontCount(fontset);
9770 ok(setcount == 1, "Unexpected font count %u.\n", setcount);
9771
9772 ref2 = (void *)0xdeadbeef;
9773 hr = IDWriteFontSet_GetFontFaceReference(fontset, setcount, &ref2);
9774 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
9775 ok(!ref2, "Unexpected pointer.\n");
9776
9777 ref2 = NULL;
9778 hr = IDWriteFontSet_GetFontFaceReference(fontset, 0, &ref2);
9779 ok(hr == S_OK, "Failed to get font face reference, hr %#lx.\n", hr);
9780 ok(ref2 != ref, "Unexpected reference.\n");
9781
9782 ref3 = NULL;
9783 hr = IDWriteFontSet_GetFontFaceReference(fontset, 0, &ref3);
9784 ok(hr == S_OK, "Failed to get font face reference, hr %#lx.\n", hr);
9785 ok(ref2 != ref3, "Unexpected reference.\n");
9786
9787 IDWriteFontFaceReference_Release(ref3);
9788 IDWriteFontFaceReference_Release(ref2);
9789
9791 {
9793 WCHAR buffW[255], buff2W[255];
9794 UINT32 c, ivalue = 0;
9795 BOOL exists = FALSE;
9796
9797 hr = IDWriteFontSet_GetPropertyValues(fontset, 0, id, &exists, &values);
9798 ok(hr == S_OK, "Failed to get property value, hr %#lx.\n", hr);
9799
9802 {
9803 todo_wine
9804 ok(exists, "Property %u expected to exist.\n", id);
9805 }
9806
9807 if (!exists)
9808 continue;
9809
9810 switch (id)
9811 {
9813 ivalue = IDWriteFont3_GetWeight(font);
9814 break;
9816 ivalue = IDWriteFont3_GetStretch(font);
9817 break;
9819 ivalue = IDWriteFont3_GetStyle(font);
9820 break;
9821 default:
9822 ;
9823 }
9824
9825 switch (id)
9826 {
9830 c = IDWriteLocalizedStrings_GetCount(values);
9831 ok(c == 1, "Unexpected string count %u.\n", c);
9832
9833 buffW[0] = 'a';
9834 hr = IDWriteLocalizedStrings_GetLocaleName(values, 0, buffW, ARRAY_SIZE(buffW));
9835 ok(hr == S_OK, "Failed to get locale name, hr %#lx.\n", hr);
9836 ok(!*buffW, "Unexpected locale %s.\n", wine_dbgstr_w(buffW));
9837
9838 buff2W[0] = 0;
9839 hr = IDWriteLocalizedStrings_GetString(values, 0, buff2W, ARRAY_SIZE(buff2W));
9840 ok(hr == S_OK, "Failed to get property string, hr %#lx.\n", hr);
9841
9842 wsprintfW(buffW, L"%u", ivalue);
9843 ok(!lstrcmpW(buffW, buff2W), "Unexpected property value %s, expected %s.\n", wine_dbgstr_w(buff2W),
9844 wine_dbgstr_w(buffW));
9845 break;
9846 default:
9847 ;
9848 }
9849
9850 IDWriteLocalizedStrings_Release(values);
9851 }
9852
9853 IDWriteFontSet_Release(fontset);
9854 IDWriteFontFaceReference_Release(ref);
9855 IDWriteFontSetBuilder_Release(builder);
9856
9857 IDWriteFont3_Release(font);
9858 }
9859
9860 IDWriteFontFamily1_Release(family);
9861 }
9862
9863 IDWriteFontCollection1_Release(collection);
9864
9865 refcount = IDWriteFactory3_Release(factory);
9866 ok(!refcount, "Factory not released, %u.\n", refcount);
9867}
const char * wine_dbgstr_an(const char *str, int n)
Definition: compat.c:313
@ DWRITE_FONT_FAMILY_MODEL_WEIGHT_STRETCH_STYLE
Definition: dwrite_3.idl:171
@ DWRITE_FONT_PROPERTY_ID_FAMILY_NAME
Definition: dwrite_3.idl:106
@ DWRITE_FONT_PROPERTY_ID_TOTAL
Definition: dwrite_3.idl:104
@ DWRITE_FONT_PROPERTY_ID_STYLE
Definition: dwrite_3.idl:102
@ DWRITE_FONT_PROPERTY_ID_STRETCH
Definition: dwrite_3.idl:101
@ DWRITE_FONT_PROPERTY_ID_WEIGHT
Definition: dwrite_3.idl:100
GLuint id
Definition: glext.h:5910
#define check_familymodel(a, b)
Definition: font.c:587
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
Definition: pdh_main.c:64

Referenced by START_TEST().

◆ test_gdicompat_metrics()

static void test_gdicompat_metrics ( IDWriteFontFace *  face)
static

Definition at line 6329 of file font.c.

6330{
6331 IDWriteFontFace1 *fontface1 = NULL;
6332 HRESULT hr;
6333 DWRITE_FONT_METRICS design_metrics, comp_metrics;
6334 DWRITE_FONT_METRICS1 design_metrics1, expected;
6335 FLOAT emsize, scale;
6336 int ascent, descent;
6337 const struct VDMX_Header *vdmx;
6338 UINT32 vdmx_len;
6339 void *vdmx_ctx;
6340 BOOL exists;
6341 const struct VDMX_group *vdmx_group = NULL;
6342 int i;
6343
6344 hr = IDWriteFontFace_QueryInterface(face, &IID_IDWriteFontFace1, (void**)&fontface1);
6345 if (hr != S_OK)
6346 win_skip("gdi compatible DWRITE_FONT_METRICS1 are not supported.\n");
6347
6348 if (fontface1) {
6349 IDWriteFontFace1_GetMetrics(fontface1, &design_metrics1);
6350 memcpy(&design_metrics, &design_metrics1, sizeof(design_metrics));
6351 }
6352 else
6353 IDWriteFontFace_GetMetrics(face, &design_metrics);
6354
6355 hr = IDWriteFontFace_TryGetFontTable(face, MS_VDMX_TAG, (const void **)&vdmx,
6356 &vdmx_len, &vdmx_ctx, &exists);
6357 if (hr != S_OK || !exists)
6358 vdmx = NULL;
6359 else
6361
6362 /* negative emsize */
6363 memset(&comp_metrics, 0xcc, sizeof(comp_metrics));
6364 memset(&expected, 0, sizeof(expected));
6365 hr = IDWriteFontFace_GetGdiCompatibleMetrics(face, -10.0, 1.0, NULL, &comp_metrics);
6366 ok(hr == E_INVALIDARG, "got %08lx\n", hr);
6367 test_metrics_cmp(0.0, &comp_metrics, &expected);
6368
6369 /* zero emsize */
6370 memset(&comp_metrics, 0xcc, sizeof(comp_metrics));
6371 memset(&expected, 0, sizeof(expected));
6372 hr = IDWriteFontFace_GetGdiCompatibleMetrics(face, 0.0, 1.0, NULL, &comp_metrics);
6373 ok(hr == E_INVALIDARG, "got %08lx\n", hr);
6374 test_metrics_cmp(0.0, &comp_metrics, &expected);
6375
6376 /* zero pixels per dip */
6377 memset(&comp_metrics, 0xcc, sizeof(comp_metrics));
6378 memset(&expected, 0, sizeof(expected));
6379 hr = IDWriteFontFace_GetGdiCompatibleMetrics(face, 5.0, 0.0, NULL, &comp_metrics);
6380 ok(hr == E_INVALIDARG, "got %08lx\n", hr);
6381 test_metrics_cmp(5.0, &comp_metrics, &expected);
6382
6383 memset(&comp_metrics, 0xcc, sizeof(comp_metrics));
6384 hr = IDWriteFontFace_GetGdiCompatibleMetrics(face, 5.0, -1.0, NULL, &comp_metrics);
6385 ok(hr == E_INVALIDARG, "got %08lx\n", hr);
6386 test_metrics_cmp(5.0, &comp_metrics, &expected);
6387
6388 for (i = 0; i < ARRAY_SIZE(compatmetrics_tests); i++) {
6390
6392 hr = IDWriteFontFace_GetGdiCompatibleMetrics(face, ptr->emsize, ptr->ppdip, &ptr->m, &comp_metrics);
6393 ok(hr == S_OK, "got %08lx\n", hr);
6394 test_metrics_cmp(ptr->emsize, &comp_metrics, &expected);
6395 }
6396
6397 for (emsize = 5; emsize <= design_metrics.designUnitsPerEm; emsize++)
6398 {
6399 DWRITE_FONT_METRICS1 comp_metrics1, expected;
6400
6401 if (fontface1) {
6402 hr = IDWriteFontFace1_GetGdiCompatibleMetrics(fontface1, emsize, 1.0, NULL, &comp_metrics1);
6403 ok(hr == S_OK, "got %08lx\n", hr);
6404 }
6405 else {
6406 hr = IDWriteFontFace_GetGdiCompatibleMetrics(face, emsize, 1.0, NULL, &comp_metrics);
6407 ok(hr == S_OK, "got %08lx\n", hr);
6408 }
6409
6410 scale = emsize / design_metrics.designUnitsPerEm;
6411 if (!get_vdmx_size(vdmx_group, emsize, &ascent, &descent))
6412 {
6413 ascent = round(design_metrics.ascent * scale);
6414 descent = round(design_metrics.descent * scale);
6415 }
6416
6417 expected.designUnitsPerEm = design_metrics.designUnitsPerEm;
6418 expected.ascent = round(ascent / scale );
6419 expected.descent = round(descent / scale );
6420 expected.lineGap = round(round(design_metrics.lineGap * scale) / scale);
6421 expected.capHeight = round(round(design_metrics.capHeight * scale) / scale);
6422 expected.xHeight = round(round(design_metrics.xHeight * scale) / scale);
6423 expected.underlinePosition = round(round(design_metrics.underlinePosition * scale) / scale);
6424 expected.underlineThickness = round(round(design_metrics.underlineThickness * scale) / scale);
6425 expected.strikethroughPosition = round(round(design_metrics.strikethroughPosition * scale) / scale);
6426 expected.strikethroughThickness = round(round(design_metrics.strikethroughThickness * scale) / scale);
6427
6428 if (fontface1) {
6429 expected.glyphBoxLeft = round(round(design_metrics1.glyphBoxLeft * scale) / scale);
6430
6431 if (0) { /* those two fail on Tahoma and Win7 */
6432 expected.glyphBoxTop = round(round(design_metrics1.glyphBoxTop * scale) / scale);
6433 expected.glyphBoxRight = round(round(design_metrics1.glyphBoxRight * scale) / scale);
6434 }
6435 expected.glyphBoxBottom = round(round(design_metrics1.glyphBoxBottom * scale) / scale);
6436 expected.subscriptPositionX = round(round(design_metrics1.subscriptPositionX * scale) / scale);
6437 expected.subscriptPositionY = round(round(design_metrics1.subscriptPositionY * scale) / scale);
6438 expected.subscriptSizeX = round(round(design_metrics1.subscriptSizeX * scale) / scale);
6439 expected.subscriptSizeY = round(round(design_metrics1.subscriptSizeY * scale) / scale);
6440 expected.superscriptPositionX = round(round(design_metrics1.superscriptPositionX * scale) / scale);
6441 if (0) /* this fails for 3 emsizes, Tahoma from [5, 2048] range */ {
6442 expected.superscriptPositionY = round(round(design_metrics1.superscriptPositionY * scale) / scale);
6443 }
6444 expected.superscriptSizeX = round(round(design_metrics1.superscriptSizeX * scale) / scale);
6445 expected.superscriptSizeY = round(round(design_metrics1.superscriptSizeY * scale) / scale);
6446 expected.hasTypographicMetrics = design_metrics1.hasTypographicMetrics;
6447
6448 test_metrics1_cmp(emsize, &comp_metrics1, &expected);
6449 }
6450 else
6451 test_metrics_cmp(emsize, &comp_metrics, &expected);
6452
6453 }
6454
6455 if (fontface1)
6456 IDWriteFontFace1_Release(fontface1);
6457 if (vdmx) IDWriteFontFace_ReleaseFontTable(face, vdmx_ctx);
6458}
#define MS_VDMX_TAG
Definition: font.c:38
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
static const struct VDMX_group * find_vdmx_group(const struct VDMX_Header *hdr)
Definition: font.c:6170
#define round(x)
Definition: font.c:6139
static void test_metrics_cmp(FLOAT emsize, const DWRITE_FONT_METRICS *metrics, const DWRITE_FONT_METRICS1 *expected)
Definition: font.c:6227
static BOOL get_vdmx_size(const struct VDMX_group *group, int emsize, int *a, int *d)
Definition: font.c:6196
static void test_metrics1_cmp(FLOAT emsize, const DWRITE_FONT_METRICS1 *metrics, const DWRITE_FONT_METRICS1 *expected)
Definition: font.c:6250
static struct compatmetrics_test compatmetrics_tests[]
Definition: font.c:6308
static void get_expected_metrics(IDWriteFontFace *fontface, struct compatmetrics_test *ptr, DWRITE_FONT_METRICS *expected)
Definition: font.c:6319
INT16 strikethroughPosition
Definition: dwrite.idl:361
UINT16 strikethroughThickness
Definition: dwrite.idl:362
INT16 underlinePosition
Definition: dwrite.idl:359
UINT16 underlineThickness
Definition: dwrite.idl:360

Referenced by test_GetGdiCompatibleMetrics().

◆ test_geometrysink2_AddBeziers()

static void WINAPI test_geometrysink2_AddBeziers ( ID2D1SimplifiedGeometrySink *  iface,
const D2D1_BEZIER_SEGMENT *  beziers,
UINT32  count 
)
static

Definition at line 994 of file font.c.

996{
997 ok(0, "unexpected call\n");
998}

◆ test_geometrysink2_AddLines()

static void WINAPI test_geometrysink2_AddLines ( ID2D1SimplifiedGeometrySink *  iface,
const D2D1_POINT_2F *  points,
UINT32  count 
)
static

Definition at line 988 of file font.c.

990{
991 ok(0, "unexpected call\n");
992}

◆ test_geometrysink2_BeginFigure()

static void WINAPI test_geometrysink2_BeginFigure ( ID2D1SimplifiedGeometrySink *  iface,
D2D1_POINT_2F  startPoint,
D2D1_FIGURE_BEGIN  figureBegin 
)
static

Definition at line 982 of file font.c.

984{
985 ok(0, "unexpected call\n");
986}

◆ test_geometrysink2_EndFigure()

static void WINAPI test_geometrysink2_EndFigure ( ID2D1SimplifiedGeometrySink *  iface,
D2D1_FIGURE_END  figureEnd 
)
static

Definition at line 1000 of file font.c.

1001{
1002 ok(0, "unexpected call\n");
1003}

◆ test_geometrysink_AddBeziers()

static void WINAPI test_geometrysink_AddBeziers ( ID2D1SimplifiedGeometrySink *  iface,
const D2D1_BEZIER_SEGMENT *  beziers,
UINT32  count 
)
static

Definition at line 953 of file font.c.

955{
956}

◆ test_geometrysink_AddLines()

static void WINAPI test_geometrysink_AddLines ( ID2D1SimplifiedGeometrySink *  iface,
const D2D1_POINT_2F *  points,
UINT32  count 
)
static

Definition at line 948 of file font.c.

950{
951}

◆ test_geometrysink_AddRef()

static ULONG WINAPI test_geometrysink_AddRef ( ID2D1SimplifiedGeometrySink *  iface)
static

Definition at line 918 of file font.c.

919{
920 return 2;
921}

◆ test_geometrysink_BeginFigure()

static void WINAPI test_geometrysink_BeginFigure ( ID2D1SimplifiedGeometrySink *  iface,
D2D1_POINT_2F  startPoint,
D2D1_FIGURE_BEGIN  figureBegin 
)
static

Definition at line 939 of file font.c.

941{
942 ok(figureBegin == D2D1_FIGURE_BEGIN_FILLED, "begin figure %d\n", figureBegin);
944 g_startpoints[g_startpoint_count] = startPoint;
946}
@ D2D1_FIGURE_BEGIN_FILLED
Definition: d2d1.idl:100
static int g_startpoint_count
Definition: font.c:902
static D2D1_POINT_2F g_startpoints[2]
Definition: font.c:901

◆ test_geometrysink_Close()

static HRESULT WINAPI test_geometrysink_Close ( ID2D1SimplifiedGeometrySink *  iface)
static

Definition at line 963 of file font.c.

964{
965 ok(0, "unexpected Close()\n");
966 return E_NOTIMPL;
967}

◆ test_geometrysink_EndFigure()

static void WINAPI test_geometrysink_EndFigure ( ID2D1SimplifiedGeometrySink *  iface,
D2D1_FIGURE_END  figureEnd 
)
static

Definition at line 958 of file font.c.

959{
960 ok(figureEnd == D2D1_FIGURE_END_CLOSED, "end figure %d\n", figureEnd);
961}
@ D2D1_FIGURE_END_CLOSED
Definition: d2d1.idl:108

◆ test_geometrysink_QueryInterface()

static HRESULT WINAPI test_geometrysink_QueryInterface ( ID2D1SimplifiedGeometrySink *  iface,
REFIID  riid,
void **  ret 
)
static

Definition at line 904 of file font.c.

905{
906 if (IsEqualIID(riid, &IID_ID2D1SimplifiedGeometrySink) ||
908 {
909 *ret = iface;
910 ID2D1SimplifiedGeometrySink_AddRef(iface);
911 return S_OK;
912 }
913
914 *ret = NULL;
915 return E_NOINTERFACE;
916}

◆ test_geometrysink_Release()

static ULONG WINAPI test_geometrysink_Release ( ID2D1SimplifiedGeometrySink *  iface)
static

Definition at line 923 of file font.c.

924{
925 return 1;
926}

◆ test_geometrysink_SetFillMode()

static void WINAPI test_geometrysink_SetFillMode ( ID2D1SimplifiedGeometrySink *  iface,
D2D1_FILL_MODE  mode 
)
static

Definition at line 928 of file font.c.

929{
930 CHECK_EXPECT(setfillmode);
931 ok(mode == D2D1_FILL_MODE_WINDING, "fill mode %d\n", mode);
932}
@ D2D1_FILL_MODE_WINDING
Definition: d2d1.idl:86
#define CHECK_EXPECT(func)
Definition: font.c:86

◆ test_geometrysink_SetSegmentFlags()

static void WINAPI test_geometrysink_SetSegmentFlags ( ID2D1SimplifiedGeometrySink *  iface,
D2D1_PATH_SEGMENT  flags 
)
static

Definition at line 934 of file font.c.

935{
936 ok(0, "unexpected SetSegmentFlags() - flags %d\n", flags);
937}

◆ test_GetAlphaBlendParams()

static void test_GetAlphaBlendParams ( void  )
static

Definition at line 7222 of file font.c.

7223{
7224 static const DWRITE_RENDERING_MODE rendermodes[] = {
7230 };
7231
7232 IDWriteGlyphRunAnalysis *analysis;
7233 FLOAT gamma, contrast, ctlevel;
7237 IDWriteFontFace *fontface;
7239 DWRITE_GLYPH_RUN run;
7240 FLOAT advance, expected_gdi_gamma;
7241 UINT value = 0;
7242 UINT16 glyph;
7243 UINT32 ch, i;
7244 HRESULT hr;
7245 ULONG ref;
7246 BOOL ret;
7247
7249 fontface = create_fontface(factory);
7250
7251 ch = 'A';
7252 glyph = 0;
7253 hr = IDWriteFontFace_GetGlyphIndices(fontface, &ch, 1, &glyph);
7254 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7255 ok(glyph > 0, "got %u\n", glyph);
7256
7257 hr = IDWriteFontFace_GetDesignGlyphMetrics(fontface, &glyph, 1, &metrics, FALSE);
7258 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7259 advance = metrics.advanceWidth;
7260
7261 offset.advanceOffset = 0.0;
7262 offset.ascenderOffset = 0.0;
7263
7264 run.fontFace = fontface;
7265 run.fontEmSize = 24.0;
7266 run.glyphCount = 1;
7267 run.glyphIndices = &glyph;
7268 run.glyphAdvances = &advance;
7269 run.glyphOffsets = &offset;
7270 run.isSideways = FALSE;
7271 run.bidiLevel = 0;
7272
7273 hr = IDWriteFactory_CreateCustomRenderingParams(factory, 0.9, 0.3, 0.1, DWRITE_PIXEL_GEOMETRY_RGB,
7275 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7276
7277 value = 0;
7278 ret = SystemParametersInfoW(SPI_GETFONTSMOOTHINGCONTRAST, 0, &value, 0);
7279 ok(ret, "got %d\n", ret);
7280 expected_gdi_gamma = (FLOAT)(value / 1000.0);
7281
7282 for (i = 0; i < ARRAY_SIZE(rendermodes); i++) {
7283 hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
7284 rendermodes[i], DWRITE_MEASURING_MODE_NATURAL,
7285 0.0, 0.0, &analysis);
7286 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7287
7288 gamma = contrast = ctlevel = -1.0;
7289 hr = IDWriteGlyphRunAnalysis_GetAlphaBlendParams(analysis, NULL, &gamma, &contrast, &ctlevel);
7290 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
7291 ok(gamma == -1.0, "got %.2f\n", gamma);
7292 ok(contrast == -1.0, "got %.2f\n", contrast);
7293 ok(ctlevel == -1.0, "got %.2f\n", ctlevel);
7294
7295 gamma = contrast = ctlevel = -1.0;
7296 hr = IDWriteGlyphRunAnalysis_GetAlphaBlendParams(analysis, params, &gamma, &contrast, &ctlevel);
7297 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7298
7299 if (rendermodes[i] == DWRITE_RENDERING_MODE_GDI_CLASSIC || rendermodes[i] == DWRITE_RENDERING_MODE_GDI_NATURAL) {
7300 ok(float_eq(gamma, expected_gdi_gamma), "got %.2f, expected %.2f\n", gamma, expected_gdi_gamma);
7301 ok(contrast == 0.0f, "got %.2f\n", contrast);
7302 ok(ctlevel == 1.0f, "got %.2f\n", ctlevel);
7303 }
7304 else {
7305 ok(gamma == 0.9f, "got %.2f\n", gamma);
7306 ok(contrast == 0.3f, "got %.2f\n", contrast);
7307 ok(ctlevel == 0.1f, "got %.2f\n", ctlevel);
7308 }
7309
7310 IDWriteGlyphRunAnalysis_Release(analysis);
7311 }
7312
7313 IDWriteRenderingParams_Release(params);
7314 IDWriteFontFace_Release(fontface);
7315 ref = IDWriteFactory_Release(factory);
7316 ok(ref == 0, "factory not released, %lu\n", ref);
7317}
@ DWRITE_PIXEL_GEOMETRY_RGB
Definition: dwrite.idl:155
#define FLOAT
Definition: i386-dis.c:525
static BOOL float_eq(FLOAT left, FLOAT right)
Definition: font.c:7209
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)

Referenced by START_TEST().

◆ test_GetCaretMetrics()

static void test_GetCaretMetrics ( void  )
static

Definition at line 5434 of file font.c.

5435{
5437 IDWriteFontFace1 *fontface1;
5439 IDWriteFontFace *fontface;
5443 WCHAR *path;
5444 HRESULT hr;
5445 ULONG ref;
5446
5449
5450 hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
5451 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5452
5453 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
5454 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5455 IDWriteFontFile_Release(file);
5456
5457 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
5458 IDWriteFontFace_Release(fontface);
5459 if (hr != S_OK) {
5460 win_skip("GetCaretMetrics() is not supported.\n");
5461 ref = IDWriteFactory_Release(factory);
5462 ok(ref == 0, "factory not released, %lu\n", ref);
5464 return;
5465 }
5466
5467 memset(&caret, 0xcc, sizeof(caret));
5468 IDWriteFontFace1_GetCaretMetrics(fontface1, &caret);
5469 ok(caret.slopeRise == 1, "got %d\n", caret.slopeRise);
5470 ok(caret.slopeRun == 0, "got %d\n", caret.slopeRun);
5471 ok(caret.offset == 0, "got %d\n", caret.offset);
5472 IDWriteFontFace1_Release(fontface1);
5473 IDWriteFactory_Release(factory);
5474
5475 /* now with Tahoma Normal */
5478 hr = IDWriteFont_CreateFontFace(font, &fontface);
5479 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5480 IDWriteFont_Release(font);
5481 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
5482 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5483 IDWriteFontFace_Release(fontface);
5484
5485 memset(&caret, 0xcc, sizeof(caret));
5486 IDWriteFontFace1_GetCaretMetrics(fontface1, &caret);
5487 ok(caret.slopeRise == 1, "got %d\n", caret.slopeRise);
5488 ok(caret.slopeRun == 0, "got %d\n", caret.slopeRun);
5489 ok(caret.offset == 0, "got %d\n", caret.offset);
5490 IDWriteFontFace1_Release(fontface1);
5491
5492 /* simulated italic */
5494 hr = IDWriteFont_CreateFontFace(font, &fontface);
5495 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5496 IDWriteFont_Release(font);
5497 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
5498 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5499 IDWriteFontFace_Release(fontface);
5500
5501 IDWriteFontFace1_GetMetrics(fontface1, &metrics);
5502
5503 memset(&caret, 0xcc, sizeof(caret));
5504 IDWriteFontFace1_GetCaretMetrics(fontface1, &caret);
5505 ok(caret.slopeRise == metrics.designUnitsPerEm, "got %d\n", caret.slopeRise);
5506 ok(caret.slopeRun > 0, "got %d\n", caret.slopeRun);
5507 ok(caret.offset == 0, "got %d\n", caret.offset);
5508 IDWriteFontFace1_Release(fontface1);
5509
5510 ref = IDWriteFactory_Release(factory);
5511 ok(ref == 0, "factory not released, %lu\n", ref);
5513}

Referenced by START_TEST().

◆ test_GetDesignGlyphAdvances()

static void test_GetDesignGlyphAdvances ( void  )
static

Definition at line 5198 of file font.c.

5199{
5200 IDWriteFontFace1 *fontface1;
5201 IDWriteFontFace *fontface;
5204 WCHAR *path;
5205 HRESULT hr;
5206 ULONG ref;
5207
5209
5211
5212 hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
5213 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5214
5215 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file,
5216 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
5217 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5218 IDWriteFontFile_Release(file);
5219
5220 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
5221 if (hr == S_OK) {
5222 UINT32 codepoint;
5223 UINT16 index;
5224 INT32 advance;
5225
5226 codepoint = 'A';
5227 index = 0;
5228 hr = IDWriteFontFace1_GetGlyphIndices(fontface1, &codepoint, 1, &index);
5229 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5230 ok(index > 0, "got %u\n", index);
5231
5232 advance = 0;
5233 hr = IDWriteFontFace1_GetDesignGlyphAdvances(fontface1, 1, &index, &advance, FALSE);
5234 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5235 ok(advance == 1000, "got %i\n", advance);
5236
5237 advance = 0;
5238 hr = IDWriteFontFace1_GetDesignGlyphAdvances(fontface1, 1, &index, &advance, TRUE);
5239 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5240 todo_wine
5241 ok(advance == 2048, "got %i\n", advance);
5242
5243 IDWriteFontFace1_Release(fontface1);
5244 }
5245 else
5246 win_skip("GetDesignGlyphAdvances() is not supported.\n");
5247
5248 IDWriteFontFace_Release(fontface);
5249 ref = IDWriteFactory_Release(factory);
5250 ok(ref == 0, "factory not released, %lu\n", ref);
5252}

Referenced by START_TEST().

◆ test_GetDesignGlyphMetrics()

static void test_GetDesignGlyphMetrics ( void  )
static

Definition at line 5039 of file font.c.

5040{
5042 IDWriteFontFace *fontface;
5045 UINT16 indices[2];
5046 UINT32 codepoint;
5047 WCHAR *path;
5048 HRESULT hr;
5049 ULONG ref;
5050
5052
5054
5055 hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
5056 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
5057
5058 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file,
5059 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
5060 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
5061 IDWriteFontFile_Release(file);
5062
5063 codepoint = 'A';
5064 indices[0] = 0;
5065 hr = IDWriteFontFace_GetGlyphIndices(fontface, &codepoint, 1, &indices[0]);
5066 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5067 ok(indices[0] > 0, "got %u\n", indices[0]);
5068
5069 hr = IDWriteFontFace_GetDesignGlyphMetrics(fontface, NULL, 0, metrics, FALSE);
5070 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n",hr);
5071
5072 hr = IDWriteFontFace_GetDesignGlyphMetrics(fontface, NULL, 1, metrics, FALSE);
5073 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n",hr);
5074
5075 hr = IDWriteFontFace_GetDesignGlyphMetrics(fontface, indices, 0, metrics, FALSE);
5076 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
5077
5078 /* missing glyphs are ignored */
5079 indices[1] = 1;
5080 memset(metrics, 0xcc, sizeof(metrics));
5081 hr = IDWriteFontFace_GetDesignGlyphMetrics(fontface, indices, 2, metrics, FALSE);
5082 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
5083 ok(metrics[0].advanceWidth == 1000, "got %d\n", metrics[0].advanceWidth);
5084 ok(metrics[1].advanceWidth == 0, "got %d\n", metrics[1].advanceWidth);
5085
5086 IDWriteFontFace_Release(fontface);
5087 ref = IDWriteFactory_Release(factory);
5088 ok(ref == 0, "factory not released, %lu\n", ref);
5090}

Referenced by START_TEST().

◆ test_GetEudcFontCollection()

static void test_GetEudcFontCollection ( void  )
static

Definition at line 5406 of file font.c.

5407{
5408 IDWriteFontCollection *coll, *coll2;
5410 HRESULT hr;
5411 ULONG ref;
5412
5413 factory = create_factory_iid(&IID_IDWriteFactory1);
5414 if (!factory) {
5415 win_skip("GetEudcFontCollection() is not supported.\n");
5416 return;
5417 }
5418
5419 EXPECT_REF(factory, 1);
5420 hr = IDWriteFactory1_GetEudcFontCollection(factory, &coll, FALSE);
5421 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5422 EXPECT_REF(factory, 2);
5423 hr = IDWriteFactory1_GetEudcFontCollection(factory, &coll2, FALSE);
5424 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5425 EXPECT_REF(factory, 2);
5426 ok(coll == coll2, "got %p, %p\n", coll, coll2);
5427 IDWriteFontCollection_Release(coll);
5428 IDWriteFontCollection_Release(coll2);
5429
5430 ref = IDWriteFactory1_Release(factory);
5431 ok(ref == 0, "factory not released, %lu\n", ref);
5432}

Referenced by START_TEST().

◆ test_GetFaceNames()

static void test_GetFaceNames ( void  )
static

Definition at line 4568 of file font.c.

4569{
4570 IDWriteLocalizedStrings *strings, *strings2, *strings3;
4571 IDWriteFontFace3 *fontface3;
4572 IDWriteGdiInterop *interop;
4573 IDWriteFontFace *fontface;
4577 LOGFONTW logfont;
4578 WCHAR buffW[255];
4579 BOOL exists;
4580 HRESULT hr;
4581 ULONG ref;
4582
4584
4585 hr = IDWriteFactory_GetGdiInterop(factory, &interop);
4586 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4587
4588 memset(&logfont, 0, sizeof(logfont));
4589 logfont.lfHeight = 12;
4590 logfont.lfWidth = 12;
4591 logfont.lfWeight = FW_NORMAL;
4592 logfont.lfItalic = 1;
4593 lstrcpyW(logfont.lfFaceName, L"Tahoma");
4594
4595 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
4596 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4597
4598 hr = IDWriteFont_GetFaceNames(font, &strings);
4599 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4600
4601 hr = IDWriteFont_GetFaceNames(font, &strings2);
4602 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4603 ok(strings != strings2, "got %p, %p\n", strings2, strings);
4604 IDWriteLocalizedStrings_Release(strings2);
4605
4606 count = IDWriteLocalizedStrings_GetCount(strings);
4607 ok(count == 1, "got %d\n", count);
4608
4609 index = 1;
4610 exists = FALSE;
4611 hr = IDWriteLocalizedStrings_FindLocaleName(strings, L"en-Us", &index, &exists);
4612 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4613 ok(index == 0 && exists, "got %d, %d\n", index, exists);
4614
4615 count = 0;
4616 hr = IDWriteLocalizedStrings_GetLocaleNameLength(strings, 1, &count);
4617 ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr);
4618 ok(count == ~0, "got %d\n", count);
4619
4620 /* for simulated faces names are also simulated */
4621 buffW[0] = 0;
4622 hr = IDWriteLocalizedStrings_GetLocaleName(strings, 0, buffW, ARRAY_SIZE(buffW));
4623 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4624 ok(!lstrcmpW(buffW, L"en-us"), "Unexpected locale name %s.\n", wine_dbgstr_w(buffW));
4625
4626 buffW[0] = 0;
4627 hr = IDWriteLocalizedStrings_GetString(strings, 0, buffW, ARRAY_SIZE(buffW));
4628 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4629 ok(!lstrcmpW(buffW, L"Oblique"), "got %s\n", wine_dbgstr_w(buffW));
4630 IDWriteLocalizedStrings_Release(strings);
4631
4632 hr = IDWriteFont_CreateFontFace(font, &fontface);
4633 ok(hr == S_OK, "Failed to create a font face, hr %#lx.\n", hr);
4634
4635 if (SUCCEEDED(IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace3, (void **)&fontface3)))
4636 {
4637 hr = IDWriteFontFace3_GetFaceNames(fontface3, &strings2);
4638 ok(hr == S_OK, "Failed to get face names, hr %#lx.\n", hr);
4639
4640 hr = IDWriteFontFace3_GetFaceNames(fontface3, &strings3);
4641 ok(hr == S_OK, "Failed to get face names, hr %#lx.\n", hr);
4642 ok(strings2 != strings3, "Unexpected instance.\n");
4643 IDWriteLocalizedStrings_Release(strings3);
4644
4645 buffW[0] = 0;
4646 hr = IDWriteLocalizedStrings_GetString(strings2, 0, buffW, ARRAY_SIZE(buffW));
4647 ok(hr == S_OK, "Failed to get a string, hr %#lx.\n", hr);
4648 ok(!lstrcmpW(buffW, L"Oblique"), "Unexpected name %s.\n", wine_dbgstr_w(buffW));
4649 IDWriteLocalizedStrings_Release(strings2);
4650
4651 IDWriteFontFace3_Release(fontface3);
4652 }
4653 else
4654 win_skip("GetFaceNames() is not supported.\n");
4655
4656 IDWriteFontFace_Release(fontface);
4657
4658 IDWriteFont_Release(font);
4659 IDWriteGdiInterop_Release(interop);
4660 ref = IDWriteFactory_Release(factory);
4661 ok(ref == 0, "factory not released, %lu\n", ref);
4662}

Referenced by START_TEST().

◆ test_GetFamilyNames()

static void test_GetFamilyNames ( void  )
static

Definition at line 1727 of file font.c.

1728{
1730 IDWriteFontFace3 *fontface3;
1731 IDWriteGdiInterop *interop;
1732 IDWriteFontFamily *family;
1733 IDWriteFontFace *fontface;
1736 LOGFONTW logfont;
1737 WCHAR buffer[100];
1738 HRESULT hr;
1739 UINT32 len;
1740 ULONG ref;
1741
1743
1744 hr = IDWriteFactory_GetGdiInterop(factory, &interop);
1745 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1746
1747 memset(&logfont, 0, sizeof(logfont));
1748 logfont.lfHeight = 12;
1749 logfont.lfWidth = 12;
1750 logfont.lfWeight = FW_NORMAL;
1751 logfont.lfItalic = 1;
1752 lstrcpyW(logfont.lfFaceName, L"Tahoma");
1753
1754 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
1755 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1756
1757 hr = IDWriteFont_GetFontFamily(font, &family);
1758 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1759
1760 if (0) /* crashes on native */
1761 hr = IDWriteFontFamily_GetFamilyNames(family, NULL);
1762
1763 hr = IDWriteFontFamily_GetFamilyNames(family, &names);
1764 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1765 EXPECT_REF(names, 1);
1766
1767 hr = IDWriteFontFamily_GetFamilyNames(family, &names2);
1768 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1769 EXPECT_REF(names2, 1);
1770 ok(names != names2, "got %p, was %p\n", names2, names);
1771
1772 IDWriteLocalizedStrings_Release(names2);
1773
1774 /* GetStringLength */
1775 if (0) /* crashes on native */
1776 hr = IDWriteLocalizedStrings_GetStringLength(names, 0, NULL);
1777
1778 len = 100;
1779 hr = IDWriteLocalizedStrings_GetStringLength(names, 10, &len);
1780 ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr);
1781 ok(len == (UINT32)-1, "got %u\n", len);
1782
1783 len = 0;
1784 hr = IDWriteLocalizedStrings_GetStringLength(names, 0, &len);
1785 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1786 ok(len > 0, "got %u\n", len);
1787
1788 /* GetString */
1789 hr = IDWriteLocalizedStrings_GetString(names, 0, NULL, 0);
1790 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#lx.\n", hr);
1791
1792 hr = IDWriteLocalizedStrings_GetString(names, 10, NULL, 0);
1793 ok(FAILED(hr), "Unexpected hr %#lx.\n", hr);
1794
1795 if (0)
1796 hr = IDWriteLocalizedStrings_GetString(names, 0, NULL, 100);
1797
1798 buffer[0] = 1;
1799 hr = IDWriteLocalizedStrings_GetString(names, 10, buffer, 100);
1800 ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr);
1801 ok(buffer[0] == 0, "got %x\n", buffer[0]);
1802
1803 buffer[0] = 1;
1804 hr = IDWriteLocalizedStrings_GetString(names, 0, buffer, len-1);
1805 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#lx.\n", hr);
1806 ok(buffer[0] == 0 || broken(buffer[0] == 'T'), "Unexpected buffer contents, %#x.\n", buffer[0]);
1807
1808 buffer[0] = 1;
1809 hr = IDWriteLocalizedStrings_GetString(names, 0, buffer, len);
1810 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#lx.\n", hr);
1811 ok(buffer[0] == 0 || broken(buffer[0] == 'T'), "Unexpected buffer contents, %#x.\n", buffer[0]);
1812
1813 buffer[0] = 0;
1814 hr = IDWriteLocalizedStrings_GetString(names, 0, buffer, len+1);
1815 ok(hr == S_OK, "Failed to get a string, hr %#lx.\n", hr);
1816 ok(!lstrcmpW(buffer, L"Tahoma"), "Unexpected family name %s.\n", wine_dbgstr_w(buffer));
1817
1818 IDWriteLocalizedStrings_Release(names);
1819
1820 /* GetFamilyNames() on font face */
1821 hr = IDWriteFont_CreateFontFace(font, &fontface);
1822 ok(hr == S_OK, "Failed to create fontface, hr %#lx.\n", hr);
1823
1824 if (SUCCEEDED(IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace3, (void **)&fontface3)))
1825 {
1826 hr = IDWriteFontFace3_GetFamilyNames(fontface3, &names);
1827 ok(hr == S_OK, "Failed to get family names, hr %#lx.\n", hr);
1828
1829 buffer[0] = 0;
1830 hr = IDWriteLocalizedStrings_GetString(names, 0, buffer, len+1);
1831 ok(hr == S_OK, "Failed to get a string, hr %#lx.\n", hr);
1832 ok(!lstrcmpW(buffer, L"Tahoma"), "Unexpected family name %s.\n", wine_dbgstr_w(buffer));
1833
1834 IDWriteLocalizedStrings_Release(names);
1835 IDWriteFontFace3_Release(fontface3);
1836 }
1837 else
1838 win_skip("IDWriteFontFace3::GetFamilyNames() is not supported.\n");
1839
1840 IDWriteFontFace_Release(fontface);
1841
1842 IDWriteFontFamily_Release(family);
1843 IDWriteFont_Release(font);
1844 IDWriteGdiInterop_Release(interop);
1845 ref = IDWriteFactory_Release(factory);
1846 ok(ref == 0, "factory not released, %lu\n", ref);
1847}
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722

Referenced by START_TEST().

◆ test_GetFirstMatchingFont()

static void test_GetFirstMatchingFont ( void  )
static

Definition at line 3977 of file font.c.

3978{
3979 DWRITE_FONT_SIMULATIONS simulations;
3981 IDWriteFontFamily *family;
3982 IDWriteFont *font, *font2;
3984 HRESULT hr;
3985 ULONG ref;
3986
3988
3989 hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
3990 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3991
3992 hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
3993 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3994
3995 hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
3997 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3998
3999 hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
4001 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4002 ok(font != font2, "got %p, %p\n", font, font2);
4003 IDWriteFont_Release(font);
4004 IDWriteFont_Release(font2);
4005
4006 /* out-of-range font props are allowed */
4007 hr = IDWriteFontFamily_GetFirstMatchingFont(family, 1000, DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &font);
4008 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4009 IDWriteFont_Release(font);
4010
4011 hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL, 10, DWRITE_FONT_STYLE_NORMAL, &font);
4012 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4013 IDWriteFont_Release(font);
4014
4015 hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
4016 10, &font);
4017 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4018 IDWriteFont_Release(font);
4019
4020 IDWriteFontFamily_Release(family);
4021
4023 simulations = IDWriteFont_GetSimulations(font);
4024 ok(simulations == DWRITE_FONT_SIMULATIONS_OBLIQUE, "%d\n", simulations);
4025 IDWriteFont_Release(font);
4026
4027 IDWriteFontCollection_Release(collection);
4028 ref = IDWriteFactory_Release(factory);
4029 ok(ref == 0, "factory not released, %lu\n", ref);
4030}

Referenced by START_TEST().

◆ test_GetFontFamily()

static void test_GetFontFamily ( void  )
static

Definition at line 1542 of file font.c.

1543{
1544 IDWriteFontCollection *collection, *collection2;
1545 IDWriteFontCollection *syscoll;
1547 IDWriteFontFamily *family, *family2;
1548 IDWriteFontFamily1 *family1;
1549 IDWriteGdiInterop *interop;
1550 IDWriteFont *font, *font2;
1552 LOGFONTW logfont;
1553 ULONG ref, count;
1554 HRESULT hr;
1555
1557
1558 hr = IDWriteFactory_GetGdiInterop(factory, &interop);
1559 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1560
1561 hr = IDWriteFactory_GetSystemFontCollection(factory, &syscoll, FALSE);
1562 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1563
1564 memset(&logfont, 0, sizeof(logfont));
1565 logfont.lfHeight = 12;
1566 logfont.lfWidth = 12;
1567 logfont.lfWeight = FW_NORMAL;
1568 logfont.lfItalic = 1;
1569 lstrcpyW(logfont.lfFaceName, L"Tahoma");
1570
1571 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
1572 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1573
1574 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font2);
1575 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1576 ok(font2 != font, "got %p, %p\n", font2, font);
1577
1578 if (0) /* crashes on native */
1579 hr = IDWriteFont_GetFontFamily(font, NULL);
1580
1581 EXPECT_REF(font, 1);
1582 hr = IDWriteFont_GetFontFamily(font, &family);
1583 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1584 EXPECT_REF(font, 1);
1585 EXPECT_REF(family, 2);
1586
1587 hr = IDWriteFont_GetFontFamily(font, &family2);
1588 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1589 ok(family2 == family, "got %p, previous %p\n", family2, family);
1590 EXPECT_REF(font, 1);
1591 EXPECT_REF(family, 3);
1592 IDWriteFontFamily_Release(family2);
1593
1594 hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFontFamily, (void**)&family2);
1595 ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr);
1596 ok(family2 == NULL, "got %p\n", family2);
1597
1598 hr = IDWriteFont_GetFontFamily(font2, &family2);
1599 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1600 ok(family2 != family, "got %p, %p\n", family2, family);
1601
1602 collection = NULL;
1603 hr = IDWriteFontFamily_GetFontCollection(family, &collection);
1604 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1605
1606 collection2 = NULL;
1607 hr = IDWriteFontFamily_GetFontCollection(family2, &collection2);
1608 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1609 ok(collection == collection2, "got %p, %p\n", collection, collection2);
1610 ok(collection == syscoll, "got %p, %p\n", collection, syscoll);
1611
1612 IDWriteFont_Release(font);
1613 IDWriteFont_Release(font2);
1614
1615 hr = IDWriteFontFamily_QueryInterface(family, &IID_IDWriteFontFamily1, (void**)&family1);
1616 if (hr == S_OK) {
1618 IDWriteFontList1 *fontlist1;
1619 IDWriteFontList2 *fontlist2;
1620 IDWriteFontList *fontlist;
1621 IDWriteFont3 *font3;
1622 IDWriteFont1 *font1;
1623
1624 font3 = (void*)0xdeadbeef;
1625 hr = IDWriteFontFamily1_GetFont(family1, ~0u, &font3);
1626 ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr);
1627 ok(font3 == NULL, "got %p\n", font3);
1628
1629 hr = IDWriteFontFamily1_GetFont(family1, 0, &font3);
1630 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1631
1632 hr = IDWriteFont3_QueryInterface(font3, &IID_IDWriteFont, (void**)&font);
1633 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1634 IDWriteFont_Release(font);
1635
1636 hr = IDWriteFont3_QueryInterface(font3, &IID_IDWriteFont1, (void**)&font1);
1637 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1638 IDWriteFont1_Release(font1);
1639
1640 hr = IDWriteFontFamily1_QueryInterface(family1, &IID_IDWriteFontList1, (void **)&fontlist1);
1641 ok(hr == S_OK || broken(hr == E_NOINTERFACE), "Failed to get interface, hr %#lx.\n", hr);
1642 if (hr == S_OK) {
1643 hr = IDWriteFontFamily1_QueryInterface(family1, &IID_IDWriteFontList, (void **)&fontlist);
1644 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1645 ok(fontlist == (IDWriteFontList *)fontlist1, "Unexpected interface pointer.\n");
1646 ok(fontlist != (IDWriteFontList *)family1, "Unexpected interface pointer.\n");
1647 ok(fontlist != (IDWriteFontList *)family, "Unexpected interface pointer.\n");
1648
1649 if (SUCCEEDED(IDWriteFontFamily1_QueryInterface(family1, &IID_IDWriteFontList2, (void **)&fontlist2)))
1650 {
1651 IDWriteFontSet1 *fontset = NULL, *fontset2 = NULL;
1652
1653 ok(fontlist == (IDWriteFontList *)fontlist2, "Unexpected interface pointer.\n");
1654
1655 hr = IDWriteFontList2_GetFontSet(fontlist2, &fontset);
1656 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1657
1658 hr = IDWriteFontList2_GetFontSet(fontlist2, &fontset2);
1659 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1660 ok(fontset != fontset2, "Unexpected instance.\n");
1661
1662 IDWriteFontSet1_Release(fontset2);
1663 IDWriteFontSet1_Release(fontset);
1664
1665 IDWriteFontList2_Release(fontlist2);
1666 }
1667 else
1668 win_skip("IDWriteFontList2 is not supported.\n");
1669
1670 IDWriteFontList1_Release(fontlist1);
1671 IDWriteFontList_Release(fontlist);
1672 }
1673
1674 hr = IDWriteFontFamily1_QueryInterface(family1, &IID_IDWriteFontList, (void**)&fontlist);
1675 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1676 IDWriteFontList_Release(fontlist);
1677
1678 IDWriteFont3_Release(font3);
1679
1680 hr = IDWriteFontFamily1_GetFontFaceReference(family1, 0, &ref);
1681 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1682
1683 hr = IDWriteFontFamily1_GetFontFaceReference(family1, 0, &ref1);
1684 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1685 ok(ref != ref1, "got %p, %p\n", ref, ref1);
1686
1687 IDWriteFontFaceReference_Release(ref);
1688 IDWriteFontFaceReference_Release(ref1);
1689
1690 IDWriteFontFamily1_Release(family1);
1691 }
1692 else
1693 win_skip("IDWriteFontFamily1 is not supported.\n");
1694
1695 /* IDWriteFontCollection2::GetFontFamily() */
1696 if (SUCCEEDED(IDWriteFontCollection_QueryInterface(syscoll, &IID_IDWriteFontCollection2, (void **)&coll2)))
1697 {
1698 IDWriteFontFamily2 *family2;
1699
1700 count = IDWriteFontCollection2_GetFontFamilyCount(coll2);
1701 ok(!!count, "Unexpected family count.\n");
1702
1703 family2 = (void *)0xdeadbeef;
1704 hr = IDWriteFontCollection2_GetFontFamily(coll2, count, &family2);
1705 ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr);
1706 ok(!family2, "Unexpected pointer.\n");
1707
1708 hr = IDWriteFontCollection2_GetFontFamily(coll2, 0, &family2);
1709 ok(hr == S_OK, "Failed to get family, hr %#lx.\n", hr);
1710 IDWriteFontFamily2_Release(family2);
1711
1712 IDWriteFontCollection2_Release(coll2);
1713 }
1714 else
1715 win_skip("IDWriteFontCollection2 is not supported.\n");
1716
1717 IDWriteFontCollection_Release(syscoll);
1718 IDWriteFontCollection_Release(collection2);
1719 IDWriteFontCollection_Release(collection);
1720 IDWriteFontFamily_Release(family2);
1721 IDWriteFontFamily_Release(family);
1722 IDWriteGdiInterop_Release(interop);
1723 ref = IDWriteFactory_Release(factory);
1724 ok(ref == 0, "factory not released, %lu\n", ref);
1725}

Referenced by START_TEST().

◆ test_GetFontFromFontFace()

static void test_GetFontFromFontFace ( void  )
static

Definition at line 3902 of file font.c.

3903{
3904 IDWriteFontFace *fontface, *fontface2;
3906 IDWriteFont *font, *font2, *font3;
3907 IDWriteFontFamily *family;
3910 WCHAR *path;
3911 HRESULT hr;
3912 ULONG ref;
3913
3915
3916 hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
3917 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3918
3919 hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
3920 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3921
3922 hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
3924 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3925
3926 hr = IDWriteFont_CreateFontFace(font, &fontface);
3927 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3928
3929 font2 = NULL;
3930 hr = IDWriteFontCollection_GetFontFromFontFace(collection, fontface, &font2);
3931 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3932 ok(font2 != font, "got %p, %p\n", font2, font);
3933
3934 font3 = NULL;
3935 hr = IDWriteFontCollection_GetFontFromFontFace(collection, fontface, &font3);
3936 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3937 ok(font3 != font && font3 != font2, "got %p, %p, %p\n", font3, font2, font);
3938
3939 hr = IDWriteFont_CreateFontFace(font2, &fontface2);
3940 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3941 ok(fontface2 == fontface, "got %p, %p\n", fontface2, fontface);
3942 IDWriteFontFace_Release(fontface2);
3943
3944 hr = IDWriteFont_CreateFontFace(font3, &fontface2);
3945 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3946 ok(fontface2 == fontface, "got %p, %p\n", fontface2, fontface);
3947 IDWriteFontFace_Release(fontface2);
3948 IDWriteFontFace_Release(fontface);
3949 IDWriteFont_Release(font3);
3950 IDWriteFactory_Release(factory);
3951
3952 /* fontface that wasn't created from this collection */
3955
3956 hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
3957 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
3958
3959 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
3960 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3961 IDWriteFontFile_Release(file);
3962
3963 hr = IDWriteFontCollection_GetFontFromFontFace(collection, fontface, &font3);
3964 ok(hr == DWRITE_E_NOFONT, "Unexpected hr %#lx.\n", hr);
3965 ok(font3 == NULL, "got %p\n", font3);
3966 IDWriteFontFace_Release(fontface);
3967
3968 IDWriteFont_Release(font);
3969 IDWriteFont_Release(font2);
3970 IDWriteFontFamily_Release(family);
3971 IDWriteFontCollection_Release(collection);
3972 ref = IDWriteFactory_Release(factory);
3973 ok(ref == 0, "factory not released, %lu\n", ref);
3975}

Referenced by START_TEST().

◆ test_GetFontSignature()

static void test_GetFontSignature ( void  )
static

Definition at line 8251 of file font.c.

8252{
8253 IDWriteFontCollection *syscollection;
8254 IDWriteGdiInterop1 *interop1;
8255 IDWriteGdiInterop *interop;
8257 FONTSIGNATURE fontsig;
8258 UINT count, i;
8259 HRESULT hr;
8260 ULONG ref;
8261
8263
8264 hr = IDWriteFactory_GetGdiInterop(factory, &interop);
8265 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8266
8267 hr = IDWriteGdiInterop_QueryInterface(interop, &IID_IDWriteGdiInterop1, (void**)&interop1);
8268 IDWriteGdiInterop_Release(interop);
8269 if (FAILED(hr)) {
8270 win_skip("GetFontSignature() is not supported.\n");
8271 IDWriteGdiInterop_Release(interop);
8272 IDWriteFactory_Release(factory);
8273 return;
8274 };
8275 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8276
8277 hr = IDWriteGdiInterop1_GetFontSignature(interop1, NULL, &fontsig);
8278 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
8279
8280 hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE);
8281 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8282 count = IDWriteFontCollection_GetFontFamilyCount(syscollection);
8283
8284 for (i = 0; i < count; i++) {
8285 FONTSIGNATURE expected_signature;
8287 IDWriteFontFamily *family;
8289 WCHAR nameW[256];
8290
8291 hr = IDWriteFontCollection_GetFontFamily(syscollection, i, &family);
8292 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8293
8294 hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
8296 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8297
8298 hr = IDWriteFontFamily_GetFamilyNames(family, &names);
8299 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8300
8302
8303 IDWriteLocalizedStrings_Release(names);
8304
8305 hr = IDWriteGdiInterop1_GetFontSignature(interop1, font, &fontsig);
8306 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8307
8308 get_expected_fontsig(font, &expected_signature);
8309
8311
8312 ok(fontsig.fsUsb[0] == expected_signature.fsUsb[0], "fsUsb[0] %#lx, expected %#lx.\n",
8313 fontsig.fsUsb[0], expected_signature.fsUsb[0]);
8314 ok(fontsig.fsUsb[1] == expected_signature.fsUsb[1], "fsUsb[1] %#lx, expected %#lx.\n",
8315 fontsig.fsUsb[1], expected_signature.fsUsb[1]);
8316 ok(fontsig.fsUsb[2] == expected_signature.fsUsb[2], "fsUsb[2] %#lx, expected %#lx.\n",
8317 fontsig.fsUsb[2], expected_signature.fsUsb[2]);
8318 ok(fontsig.fsUsb[3] == expected_signature.fsUsb[3], "fsUsb[3] %#lx, expected %#lx.\n",
8319 fontsig.fsUsb[3], expected_signature.fsUsb[3]);
8320
8321 ok(fontsig.fsCsb[0] == expected_signature.fsCsb[0], "fsCsb[0] %#lx, expected %#lx.\n",
8322 fontsig.fsCsb[0], expected_signature.fsCsb[0]);
8323 ok(fontsig.fsCsb[1] == expected_signature.fsCsb[1], "fsCsb[1] %#lx, expected %#lx.\n",
8324 fontsig.fsCsb[1], expected_signature.fsCsb[1]);
8325
8327
8328 IDWriteFont_Release(font);
8329 IDWriteFontFamily_Release(family);
8330 }
8331
8332 IDWriteGdiInterop1_Release(interop1);
8333 IDWriteFontCollection_Release(syscollection);
8334 ref = IDWriteFactory_Release(factory);
8335 ok(ref == 0, "factory not released, %lu\n", ref);
8336}
struct FONTSIGNATURE FONTSIGNATURE
Definition: dwrite_3.idl:31
static void get_expected_fontsig(IDWriteFont *font, FONTSIGNATURE *fontsig)
Definition: font.c:8210

Referenced by START_TEST().

◆ test_GetGdiCompatibleGlyphAdvances()

static void test_GetGdiCompatibleGlyphAdvances ( void  )
static

Definition at line 6645 of file font.c.

6646{
6647 IDWriteFontFace1 *fontface1;
6648 IDWriteFontFace *fontface;
6651 HRESULT hr;
6652 HDC hdc;
6653 UINT32 codepoint;
6654 UINT16 glyph;
6655 FLOAT emsize;
6657 INT32 advance;
6658 ULONG ref;
6659
6662
6663 hr = IDWriteFont_CreateFontFace(font, &fontface);
6664 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6665 IDWriteFont_Release(font);
6666
6667 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void **)&fontface1);
6668 IDWriteFontFace_Release(fontface);
6669
6670 if (hr != S_OK) {
6671 ref = IDWriteFactory_Release(factory);
6672 ok(ref == 0, "factory not released, %lu\n", ref);
6673 win_skip("GetGdiCompatibleGlyphAdvances() is not supported\n");
6674 return;
6675 }
6676
6677 codepoint = 'A';
6678 glyph = 0;
6679 hr = IDWriteFontFace1_GetGlyphIndices(fontface1, &codepoint, 1, &glyph);
6680 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6681 ok(glyph > 0, "got %u\n", glyph);
6682
6683 /* zero emsize */
6684 advance = 1;
6685 hr = IDWriteFontFace1_GetGdiCompatibleGlyphAdvances(fontface1, 0.0,
6686 1.0, NULL, FALSE, FALSE, 1, &glyph, &advance);
6687 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6688 ok(advance == 0, "got %d\n", advance);
6689
6690 /* negative emsize */
6691 advance = 1;
6692 hr = IDWriteFontFace1_GetGdiCompatibleGlyphAdvances(fontface1, -1.0,
6693 1.0, NULL, FALSE, FALSE, 1, &glyph, &advance);
6694 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
6695 ok(advance == 0, "got %d\n", advance);
6696
6697 /* zero ppdip */
6698 advance = 1;
6699 hr = IDWriteFontFace1_GetGdiCompatibleGlyphAdvances(fontface1, 1.0,
6700 0.0, NULL, FALSE, FALSE, 1, &glyph, &advance);
6701 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
6702 ok(advance == 0, "got %d\n", advance);
6703
6704 /* negative ppdip */
6705 advance = 1;
6706 hr = IDWriteFontFace1_GetGdiCompatibleGlyphAdvances(fontface1, 1.0,
6707 -1.0, NULL, FALSE, FALSE, 1, &glyph, &advance);
6708 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
6709 ok(advance == 0, "got %d\n", advance);
6710
6711 IDWriteFontFace1_GetMetrics(fontface1, &fm);
6712
6714
6715 for (emsize = 1.0; emsize <= fm.designUnitsPerEm; emsize += 1.0) {
6716 INT32 gdi_advance;
6717
6718 gdi_advance = get_gdi_font_advance(hdc, emsize);
6719 hr = IDWriteFontFace1_GetGdiCompatibleGlyphAdvances(fontface1, emsize,
6720 1.0, NULL, FALSE, FALSE, 1, &glyph, &advance);
6721 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6722
6723 /* advance is in design units */
6724 advance = (int)floorf(emsize * advance / fm.designUnitsPerEm + 0.5f);
6725 ok((advance - gdi_advance) <= 2, "%.0f: got advance %d, expected %d\n", emsize, advance, gdi_advance);
6726 }
6727
6729
6730 IDWriteFontFace1_Release(fontface1);
6731 ref = IDWriteFactory_Release(factory);
6732 ok(ref == 0, "factory not released, %lu\n", ref);
6733}
static INT32 get_gdi_font_advance(HDC hdc, FLOAT emsize)
Definition: font.c:6621

Referenced by START_TEST().

◆ test_GetGdiCompatibleMetrics()

static void test_GetGdiCompatibleMetrics ( void  )
static

Definition at line 6460 of file font.c.

6461{
6464 IDWriteFontFace *fontface;
6465 HRESULT hr;
6466 ULONG ref;
6467
6469
6471 hr = IDWriteFont_CreateFontFace(font, &fontface);
6472 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6473 IDWriteFont_Release(font);
6474 test_gdicompat_metrics(fontface);
6475 IDWriteFontFace_Release(fontface);
6476
6478 if (!font)
6479 skip("Skipping tests with Arial\n");
6480 else
6481 {
6482 hr = IDWriteFont_CreateFontFace(font, &fontface);
6483 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6484 IDWriteFont_Release(font);
6485
6486 test_gdicompat_metrics(fontface);
6487 IDWriteFontFace_Release(fontface);
6488 }
6489
6490 ref = IDWriteFactory_Release(factory);
6491 ok(ref == 0, "factory not released, %lu\n", ref);
6492}
static void test_gdicompat_metrics(IDWriteFontFace *face)
Definition: font.c:6329

Referenced by START_TEST().

◆ test_GetGdiInterop()

static void test_GetGdiInterop ( void  )
static

Definition at line 4218 of file font.c.

4219{
4220 IDWriteGdiInterop *interop, *interop2;
4221 IDWriteFactory *factory, *factory2;
4223 LOGFONTW logfont;
4224 HRESULT hr;
4225 ULONG ref;
4226
4228
4229 interop = NULL;
4230 hr = IDWriteFactory_GetGdiInterop(factory, &interop);
4231 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4232
4233 interop2 = NULL;
4234 hr = IDWriteFactory_GetGdiInterop(factory, &interop2);
4235 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4236 ok(interop == interop2, "got %p, %p\n", interop, interop2);
4237 IDWriteGdiInterop_Release(interop2);
4238
4239 hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, &IID_IDWriteFactory, (IUnknown**)&factory2);
4240 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4241
4242 /* each factory gets its own interop */
4243 interop2 = NULL;
4244 hr = IDWriteFactory_GetGdiInterop(factory2, &interop2);
4245 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4246 ok(interop != interop2, "got %p, %p\n", interop, interop2);
4247
4248 /* release factory - interop still works */
4249 IDWriteFactory_Release(factory2);
4250
4251 memset(&logfont, 0, sizeof(logfont));
4252 logfont.lfHeight = 12;
4253 logfont.lfWidth = 12;
4254 logfont.lfWeight = FW_NORMAL;
4255 logfont.lfItalic = 1;
4256 lstrcpyW(logfont.lfFaceName, L"Tahoma");
4257
4258 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop2, &logfont, &font);
4259 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4260 IDWriteFont_Release(font);
4261
4262 IDWriteGdiInterop_Release(interop2);
4263 IDWriteGdiInterop_Release(interop);
4264 ref = IDWriteFactory_Release(factory);
4265 ok(ref == 0, "factory not released, %lu\n", ref);
4266}

Referenced by START_TEST().

◆ test_GetGlyphCount()

static void test_GetGlyphCount ( void  )
static

Definition at line 5515 of file font.c.

5516{
5517 IDWriteFontFace *fontface;
5520 UINT16 count;
5521 WCHAR *path;
5522 HRESULT hr;
5523 ULONG ref;
5524
5527
5528 hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
5529 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5530
5531 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
5532 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5533 IDWriteFontFile_Release(file);
5534
5535 count = IDWriteFontFace_GetGlyphCount(fontface);
5536 ok(count == 8, "got %u\n", count);
5537
5538 IDWriteFontFace_Release(fontface);
5539 ref = IDWriteFactory_Release(factory);
5540 ok(ref == 0, "factory not released, %lu\n", ref);
5542}

Referenced by START_TEST().

◆ test_GetGlyphImageFormats()

static void test_GetGlyphImageFormats ( void  )
static

Definition at line 9388 of file font.c.

9389{
9390 IDWriteFontCollection *syscollection;
9392 UINT32 i, count;
9393 HRESULT hr;
9394 ULONG ref;
9395 IDWriteFontFace *fontface;
9396 IDWriteFontFace4 *fontface4;
9397
9399
9400 fontface = create_fontface(factory);
9401 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace4, (void **)&fontface4);
9402 IDWriteFontFace_Release(fontface);
9403 if (FAILED(hr)) {
9404 win_skip("GetGlyphImageFormats() is not supported\n");
9405 IDWriteFactory_Release(factory);
9406 return;
9407 }
9408 IDWriteFontFace4_Release(fontface4);
9409
9410 hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE);
9411 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
9412 count = IDWriteFontCollection_GetFontFamilyCount(syscollection);
9413
9414 for (i = 0; i < count; i++) {
9415 WCHAR familynameW[256], facenameW[128];
9417 IDWriteFontFamily *family;
9418 UINT32 j, fontcount;
9420
9421 hr = IDWriteFontCollection_GetFontFamily(syscollection, i, &family);
9422 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
9423
9424 hr = IDWriteFontFamily_GetFamilyNames(family, &names);
9425 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
9426
9427 get_enus_string(names, familynameW, ARRAY_SIZE(familynameW));
9428 IDWriteLocalizedStrings_Release(names);
9429
9430 fontcount = IDWriteFontFamily_GetFontCount(family);
9431 for (j = 0; j < fontcount; j++) {
9432 DWORD formats, expected_formats;
9433
9434 hr = IDWriteFontFamily_GetFont(family, j, &font);
9435 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
9436
9437 hr = IDWriteFont_CreateFontFace(font, &fontface);
9438 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
9439
9440 hr = IDWriteFont_GetFaceNames(font, &names);
9441 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
9442
9443 get_enus_string(names, facenameW, ARRAY_SIZE(facenameW));
9444
9445 IDWriteLocalizedStrings_Release(names);
9446
9447 IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace4, (void **)&fontface4);
9448
9449 /* Mask describes font as a whole. */
9450 formats = IDWriteFontFace4_GetGlyphImageFormats(fontface4);
9451 expected_formats = get_face_glyph_image_formats(fontface4);
9452 ok(formats == expected_formats, "%s - %s, expected formats %#lx, got formats %#lx.\n",
9453 wine_dbgstr_w(familynameW), wine_dbgstr_w(facenameW), expected_formats, formats);
9454
9455 IDWriteFontFace4_Release(fontface4);
9456 IDWriteFontFace_Release(fontface);
9457 IDWriteFont_Release(font);
9458 }
9459
9460 IDWriteFontFamily_Release(family);
9461 }
9462
9463 IDWriteFontCollection_Release(syscollection);
9464 ref = IDWriteFactory_Release(factory);
9465 ok(ref == 0, "factory not released, %lu\n", ref);
9466}
static const struct pixel_format_desc formats[]
Definition: util.c:31
static DWORD get_face_glyph_image_formats(IDWriteFontFace4 *fontface)
Definition: font.c:9362

Referenced by START_TEST().

◆ test_GetGlyphRunOutline()

static void test_GetGlyphRunOutline ( void  )
static

Definition at line 5254 of file font.c.

5255{
5260 UINT32 codepoint;
5261 FLOAT advances[2];
5262 UINT16 glyphs[2];
5263 WCHAR *path;
5264 HRESULT hr;
5265 ULONG ref;
5266
5269
5270 hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
5271 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
5272
5273 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &face);
5274 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5275 IDWriteFontFile_Release(file);
5276
5277 codepoint = 'A';
5278 glyphs[0] = 0;
5279 hr = IDWriteFontFace_GetGlyphIndices(face, &codepoint, 1, glyphs);
5280 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5281 ok(glyphs[0] > 0, "got %u\n", glyphs[0]);
5282 glyphs[1] = glyphs[0];
5283
5284 hr = IDWriteFontFace_GetGlyphRunOutline(face, 2048.0, glyphs, advances, offsets, 1, FALSE, FALSE, NULL);
5285 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
5286
5287 hr = IDWriteFontFace_GetGlyphRunOutline(face, 2048.0, NULL, NULL, offsets, 1, FALSE, FALSE, &test_geomsink);
5288 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
5289
5290 advances[0] = 1.0;
5291 advances[1] = 0.0;
5292
5293 offsets[0].advanceOffset = 1.0;
5294 offsets[0].ascenderOffset = 1.0;
5295 offsets[1].advanceOffset = 0.0;
5296 offsets[1].ascenderOffset = 0.0;
5297
5298 /* default advances, no offsets */
5299 memset(g_startpoints, 0, sizeof(g_startpoints));
5301 SET_EXPECT(setfillmode);
5302 hr = IDWriteFontFace_GetGlyphRunOutline(face, 1024.0, glyphs, NULL, NULL, 2, FALSE, FALSE, &test_geomsink);
5303 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5304 ok(g_startpoint_count == 2, "got %d\n", g_startpoint_count);
5305 if (g_startpoint_count == 2) {
5306 /* glyph advance of 500 is applied */
5307 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);
5308 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);
5309 }
5310 CHECK_CALLED(setfillmode);
5311
5312 /* default advances, no offsets, RTL */
5313 memset(g_startpoints, 0, sizeof(g_startpoints));
5315 SET_EXPECT(setfillmode);
5316 hr = IDWriteFontFace_GetGlyphRunOutline(face, 1024.0, glyphs, NULL, NULL, 2, FALSE, TRUE, &test_geomsink);
5317 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5318 ok(g_startpoint_count == 2, "got %d\n", g_startpoint_count);
5319 if (g_startpoint_count == 2) {
5320 /* advance is -500 now */
5321 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);
5322 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);
5323 }
5324 CHECK_CALLED(setfillmode);
5325
5326 /* default advances, additional offsets */
5327 memset(g_startpoints, 0, sizeof(g_startpoints));
5329 SET_EXPECT(setfillmode);
5330 hr = IDWriteFontFace_GetGlyphRunOutline(face, 1024.0, glyphs, NULL, offsets, 2, FALSE, FALSE, &test_geomsink);
5331 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5332 ok(g_startpoint_count == 2, "got %d\n", g_startpoint_count);
5333 if (g_startpoint_count == 2) {
5334 /* offsets applied to first contour */
5335 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);
5336 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);
5337 }
5338 CHECK_CALLED(setfillmode);
5339
5340 /* default advances, additional offsets, RTL */
5341 memset(g_startpoints, 0, sizeof(g_startpoints));
5343 SET_EXPECT(setfillmode);
5344 hr = IDWriteFontFace_GetGlyphRunOutline(face, 1024.0, glyphs, NULL, offsets, 2, FALSE, TRUE, &test_geomsink);
5345 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5346 ok(g_startpoint_count == 2, "got %d\n", g_startpoint_count);
5347 if (g_startpoint_count == 2) {
5348 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);
5349 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);
5350 }
5351 CHECK_CALLED(setfillmode);
5352
5353 /* custom advances and offsets, offset turns total advance value to zero */
5354 memset(g_startpoints, 0, sizeof(g_startpoints));
5356 SET_EXPECT(setfillmode);
5357 hr = IDWriteFontFace_GetGlyphRunOutline(face, 1024.0, glyphs, advances, offsets, 2, FALSE, FALSE, &test_geomsink);
5358 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5359 ok(g_startpoint_count == 2, "got %d\n", g_startpoint_count);
5360 if (g_startpoint_count == 2) {
5361 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);
5362 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);
5363 }
5364 CHECK_CALLED(setfillmode);
5365
5366 /* 0 glyph count */
5367 hr = IDWriteFontFace_GetGlyphRunOutline(face, 1024.0, glyphs, NULL, NULL, 0, FALSE, FALSE, &test_geomsink2);
5368 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5369
5370 /* Glyph with open figure, single contour point. */
5371 codepoint = 'B';
5372 glyphs[0] = 0;
5373 hr = IDWriteFontFace_GetGlyphIndices(face, &codepoint, 1, glyphs);
5374 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5375 ok(glyphs[0] > 0, "got %u\n", glyphs[0]);
5376
5377 SET_EXPECT(setfillmode);
5378 hr = IDWriteFontFace_GetGlyphRunOutline(face, 1024.0, glyphs, NULL, NULL, 1, FALSE, FALSE, &test_geomsink2);
5379 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5380 CHECK_CALLED(setfillmode);
5381
5382 IDWriteFactory_Release(factory);
5383 IDWriteFontFace_Release(face);
5385
5386 /* space glyph */
5389
5390 codepoint = ' ';
5391 glyphs[0] = 0;
5392 hr = IDWriteFontFace_GetGlyphIndices(face, &codepoint, 1, glyphs);
5393 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5394 ok(glyphs[0] > 0, "got %u\n", glyphs[0]);
5395
5396 SET_EXPECT(setfillmode);
5397 hr = IDWriteFontFace_GetGlyphRunOutline(face, 1024.0, glyphs, NULL, NULL, 1, FALSE, FALSE, &test_geomsink2);
5398 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5399 CHECK_CALLED(setfillmode);
5400
5401 IDWriteFontFace_Release(face);
5402 ref = IDWriteFactory_Release(factory);
5403 ok(ref == 0, "factory not released, %lu\n", ref);
5404}
#define SET_EXPECT(func)
Definition: font.c:77
static ID2D1SimplifiedGeometrySink test_geomsink2
Definition: font.c:1019
static ID2D1SimplifiedGeometrySink test_geomsink
Definition: font.c:1018
#define CHECK_CALLED(func)
Definition: font.c:92

Referenced by START_TEST().

◆ test_GetInformationalStrings()

static void test_GetInformationalStrings ( void  )
static

Definition at line 4141 of file font.c.

4142{
4143 IDWriteLocalizedStrings *strings, *strings2;
4145 IDWriteFontFace3 *fontface3;
4146 IDWriteFontFace *fontface;
4147 IDWriteFontFamily *family;
4150 BOOL exists;
4151 HRESULT hr;
4152 ULONG ref;
4153
4155
4156 hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
4157 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4158
4159 hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
4160 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4161
4162 hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
4164 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4165
4166 exists = TRUE;
4167 strings = (void *)0xdeadbeef;
4168 hr = IDWriteFont_GetInformationalStrings(font, 0xdead, &strings, &exists);
4169 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4170 ok(exists == FALSE, "got %d\n", exists);
4171 ok(strings == NULL, "got %p\n", strings);
4172
4173 exists = TRUE;
4174 strings = NULL;
4175 hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_NONE, &strings, &exists);
4176 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4177 ok(exists == FALSE, "got %d\n", exists);
4178
4179 exists = FALSE;
4180 strings = NULL;
4181 hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &strings, &exists);
4182 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4183 ok(exists == TRUE, "got %d\n", exists);
4184
4185 /* strings instance is not reused */
4186 strings2 = NULL;
4187 hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &strings2, &exists);
4188 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4189 ok(strings2 != strings, "got %p, %p\n", strings2, strings);
4190
4191 IDWriteLocalizedStrings_Release(strings);
4192 IDWriteLocalizedStrings_Release(strings2);
4193
4194 hr = IDWriteFont_CreateFontFace(font, &fontface);
4195 ok(hr == S_OK, "Failed to create fontface, hr %#lx.\n", hr);
4196
4197 if (SUCCEEDED(hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace3, (void **)&fontface3)))
4198 {
4199 hr = IDWriteFontFace3_GetInformationalStrings(fontface3, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES,
4200 &strings, &exists);
4201 ok(hr == S_OK, "Failed to get info strings, hr %#lx.\n", hr);
4202 IDWriteLocalizedStrings_Release(strings);
4203
4204 IDWriteFontFace3_Release(fontface3);
4205 }
4206 else
4207 win_skip("IDWriteFontFace3::GetInformationalStrings() is not supported.\n");
4208
4209 IDWriteFontFace_Release(fontface);
4210
4211 IDWriteFont_Release(font);
4212 IDWriteFontFamily_Release(family);
4213 IDWriteFontCollection_Release(collection);
4214 ref = IDWriteFactory_Release(factory);
4215 ok(ref == 0, "factory not released, %lu\n", ref);
4216}
@ DWRITE_INFORMATIONAL_STRING_NONE
Definition: dwrite.idl:117

Referenced by START_TEST().

◆ test_GetKerningPairAdjustments()

static void test_GetKerningPairAdjustments ( void  )
static

Definition at line 5544 of file font.c.

5545{
5546 IDWriteFontFace1 *fontface1;
5547 IDWriteFontFace *fontface;
5550 WCHAR *path;
5551 HRESULT hr;
5552 ULONG ref;
5553
5556
5557 hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
5558 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5559
5560 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
5561 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5562 IDWriteFontFile_Release(file);
5563
5564 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
5565 if (hr == S_OK) {
5566 INT32 adjustments[1];
5567
5568 hr = IDWriteFontFace1_GetKerningPairAdjustments(fontface1, 0, NULL, NULL);
5569 ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "Unexpected hr %#lx.\n", hr);
5570
5571 if (0) /* crashes on native */
5572 hr = IDWriteFontFace1_GetKerningPairAdjustments(fontface1, 1, NULL, NULL);
5573
5574 adjustments[0] = 1;
5575 hr = IDWriteFontFace1_GetKerningPairAdjustments(fontface1, 1, NULL, adjustments);
5576 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
5577 ok(adjustments[0] == 0, "got %d\n", adjustments[0]);
5578
5579 IDWriteFontFace1_Release(fontface1);
5580 }
5581 else
5582 win_skip("GetKerningPairAdjustments() is not supported.\n");
5583
5584 IDWriteFontFace_Release(fontface);
5585 ref = IDWriteFactory_Release(factory);
5586 ok(ref == 0, "factory not released, %lu\n", ref);
5588}

Referenced by START_TEST().

◆ test_GetMatchingFonts()

static void test_GetMatchingFonts ( void  )
static

Definition at line 4032 of file font.c.

4033{
4035 IDWriteFontFamily *family;
4037 IDWriteFontList *fontlist, *fontlist2;
4038 IDWriteFontList1 *fontlist1;
4039 IDWriteFontList2 *fontlist3;
4040 HRESULT hr;
4041 ULONG ref;
4042
4044
4045 hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
4046 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4047
4048 hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
4049 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4050
4051 /* out-of-range font props are allowed */
4052 hr = IDWriteFontFamily_GetMatchingFonts(family, 1000, DWRITE_FONT_STRETCH_NORMAL,
4053 DWRITE_FONT_STYLE_NORMAL, &fontlist);
4054 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4055 IDWriteFontList_Release(fontlist);
4056
4057 hr = IDWriteFontFamily_GetMatchingFonts(family, DWRITE_FONT_WEIGHT_NORMAL, 10,
4058 DWRITE_FONT_STYLE_NORMAL, &fontlist);
4059 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4060 IDWriteFontList_Release(fontlist);
4061
4062 hr = IDWriteFontFamily_GetMatchingFonts(family, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
4063 10, &fontlist);
4064 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4065 IDWriteFontList_Release(fontlist);
4066
4067 hr = IDWriteFontFamily_GetMatchingFonts(family, DWRITE_FONT_WEIGHT_NORMAL,
4069 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4070
4071 hr = IDWriteFontFamily_GetMatchingFonts(family, DWRITE_FONT_WEIGHT_NORMAL,
4073 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4074 ok(fontlist != fontlist2, "got %p, %p\n", fontlist, fontlist2);
4075 IDWriteFontList_Release(fontlist2);
4076
4077 hr = IDWriteFontList_QueryInterface(fontlist, &IID_IDWriteFontList1, (void**)&fontlist1);
4078 if (hr == S_OK) {
4081 UINT32 count;
4082
4083 count = IDWriteFontList1_GetFontCount(fontlist1);
4084 ok(count > 0, "got %u\n", count);
4085
4086 font = (void*)0xdeadbeef;
4087 hr = IDWriteFontList1_GetFont(fontlist1, ~0u, &font);
4088 ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr);
4089 ok(font == NULL, "got %p\n", font);
4090
4091 font = (void*)0xdeadbeef;
4092 hr = IDWriteFontList1_GetFont(fontlist1, count, &font);
4093 ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr);
4094 ok(font == NULL, "got %p\n", font);
4095
4096 hr = IDWriteFontList1_GetFont(fontlist1, 0, &font);
4097 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4098 IDWriteFont3_Release(font);
4099
4100 hr = IDWriteFontList1_GetFontFaceReference(fontlist1, 0, &ref);
4101 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4102
4103 hr = IDWriteFontList1_GetFontFaceReference(fontlist1, 0, &ref1);
4104 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4105 ok(ref != ref1, "got %p, %p\n", ref, ref1);
4106
4107 IDWriteFontFaceReference_Release(ref1);
4108 IDWriteFontFaceReference_Release(ref);
4109 IDWriteFontList1_Release(fontlist1);
4110 }
4111 else
4112 win_skip("IDWriteFontList1 is not supported.\n");
4113
4114 if (SUCCEEDED(IDWriteFontList_QueryInterface(fontlist, &IID_IDWriteFontList2, (void **)&fontlist3)))
4115 {
4116 IDWriteFontSet1 *fontset, *fontset2;
4117
4118 hr = IDWriteFontList2_GetFontSet(fontlist3, &fontset);
4119 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4120
4121 hr = IDWriteFontList2_GetFontSet(fontlist3, &fontset2);
4122 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4123 ok(fontset != fontset2, "Unexpected instance.\n");
4124
4125 IDWriteFontSet1_Release(fontset2);
4126 IDWriteFontSet1_Release(fontset);
4127
4128 IDWriteFontList2_Release(fontlist3);
4129 }
4130 else
4131 win_skip("IDWriteFontList2 is not supported.\n");
4132
4133 IDWriteFontList_Release(fontlist);
4134 IDWriteFontFamily_Release(family);
4135
4136 IDWriteFontCollection_Release(collection);
4137 ref = IDWriteFactory_Release(factory);
4138 ok(ref == 0, "factory not released, %lu\n", ref);
4139}

Referenced by START_TEST().

◆ test_GetMatchingFontsByLOGFONT()

static void test_GetMatchingFontsByLOGFONT ( void  )
static

Definition at line 10433 of file font.c.

10434{
10435 IDWriteFontSet *systemset, *set;
10436 IDWriteGdiInterop1 *interop;
10437 IDWriteGdiInterop *interop0;
10438 IDWriteFactory3 *factory;
10439 ULONG refcount, count;
10440 LOGFONTW logfont;
10441 HRESULT hr;
10442
10443 factory = create_factory_iid(&IID_IDWriteFactory3);
10444 if (!factory)
10445 {
10446 win_skip("Skipping GetMatchingFontsByLOGFONT() tests.\n");
10447 return;
10448 }
10449
10450 hr = IDWriteFactory3_GetSystemFontSet(factory, &systemset);
10451 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10452
10453 interop = NULL;
10454 hr = IDWriteFactory3_GetGdiInterop(factory, &interop0);
10455 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10456
10457 hr = IDWriteGdiInterop_QueryInterface(interop0, &IID_IDWriteGdiInterop1, (void **)&interop);
10458 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10459 IDWriteGdiInterop_Release(interop0);
10460
10461 memset(&logfont, 0, sizeof(logfont));
10462 logfont.lfHeight = 12;
10463 logfont.lfWidth = 12;
10464 logfont.lfWeight = FW_BOLD;
10465 logfont.lfItalic = 1;
10466 lstrcpyW(logfont.lfFaceName, L"tahoma");
10467
10468 hr = IDWriteGdiInterop1_GetMatchingFontsByLOGFONT(interop, NULL, systemset, &set);
10469 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
10470
10471 hr = IDWriteGdiInterop1_GetMatchingFontsByLOGFONT(interop, &logfont, NULL, &set);
10472 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
10473
10474 hr = IDWriteGdiInterop1_GetMatchingFontsByLOGFONT(interop, &logfont, systemset, &set);
10475 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10476
10477 count = IDWriteFontSet_GetFontCount(set);
10478 ok(count > 0, "Unexpected count %lu.\n", count);
10479
10480 IDWriteFontSet_Release(set);
10481
10482 IDWriteGdiInterop1_Release(interop);
10483 IDWriteFontSet_Release(systemset);
10484
10485 refcount = IDWriteFactory3_Release(factory);
10486 ok(!refcount, "Factory wasn't released, %lu.\n", refcount);
10487}
Definition: _set.h:50

Referenced by START_TEST().

◆ test_GetMetrics()

static void test_GetMetrics ( void  )
static

Definition at line 2215 of file font.c.

2216{
2217 DWRITE_FONT_METRICS metrics, metrics2;
2218 IDWriteFontCollection *syscollection;
2219 IDWriteGdiInterop *interop;
2220 IDWriteFontFace *fontface;
2224 IDWriteFont1 *font1;
2226 LOGFONTW logfont;
2227 UINT32 count, i;
2228 HRESULT hr;
2229 HDC hdc;
2230 HFONT hfont;
2231 ULONG ref;
2232 int ret;
2233
2235
2236 hr = IDWriteFactory_GetGdiInterop(factory, &interop);
2237 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2238
2239 memset(&logfont, 0, sizeof(logfont));
2240 logfont.lfHeight = 12;
2241 logfont.lfWidth = 12;
2242 logfont.lfWeight = FW_NORMAL;
2243 logfont.lfItalic = 1;
2244 lstrcpyW(logfont.lfFaceName, L"Tahoma");
2245
2246 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
2247 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2248
2249 hfont = CreateFontIndirectW(&logfont);
2252
2253 otm.otmSize = sizeof(otm);
2254 ret = GetOutlineTextMetricsW(hdc, otm.otmSize, &otm);
2255 ok(ret, "got %d\n", ret);
2256 DeleteDC(hdc);
2258
2259 if (0) /* crashes on native */
2260 IDWriteFont_GetMetrics(font, NULL);
2261
2262 memset(&metrics, 0, sizeof(metrics));
2263 IDWriteFont_GetMetrics(font, &metrics);
2264
2265 ok(metrics.designUnitsPerEm != 0, "designUnitsPerEm %u\n", metrics.designUnitsPerEm);
2266 ok(metrics.ascent != 0, "ascent %u\n", metrics.ascent);
2267 ok(metrics.descent != 0, "descent %u\n", metrics.descent);
2268 ok(metrics.lineGap == 0, "lineGap %d\n", metrics.lineGap);
2269 ok(metrics.capHeight, "capHeight %u\n", metrics.capHeight);
2270 ok(metrics.xHeight != 0, "xHeight %u\n", metrics.xHeight);
2271 ok(metrics.underlinePosition < 0, "underlinePosition %d\n", metrics.underlinePosition);
2272 ok(metrics.underlineThickness != 0, "underlineThickness %u\n", metrics.underlineThickness);
2273 ok(metrics.strikethroughPosition > 0, "strikethroughPosition %d\n", metrics.strikethroughPosition);
2274 ok(metrics.strikethroughThickness != 0, "strikethroughThickness %u\n", metrics.strikethroughThickness);
2275
2276 hr = IDWriteFont_CreateFontFace(font, &fontface);
2277 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2278
2279 memset(&metrics, 0, sizeof(metrics));
2280 IDWriteFontFace_GetMetrics(fontface, &metrics);
2281
2282 ok(metrics.designUnitsPerEm != 0, "designUnitsPerEm %u\n", metrics.designUnitsPerEm);
2283 ok(metrics.ascent != 0, "ascent %u\n", metrics.ascent);
2284 ok(metrics.descent != 0, "descent %u\n", metrics.descent);
2285 ok(metrics.lineGap == 0, "lineGap %d\n", metrics.lineGap);
2286 ok(metrics.capHeight, "capHeight %u\n", metrics.capHeight);
2287 ok(metrics.xHeight != 0, "xHeight %u\n", metrics.xHeight);
2288 ok(metrics.underlinePosition < 0, "underlinePosition %d\n", metrics.underlinePosition);
2289 ok(metrics.underlineThickness != 0, "underlineThickness %u\n", metrics.underlineThickness);
2290 ok(metrics.strikethroughPosition > 0, "strikethroughPosition %d\n", metrics.strikethroughPosition);
2291 ok(metrics.strikethroughThickness != 0, "strikethroughThickness %u\n", metrics.strikethroughThickness);
2292
2293 hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFont1, (void**)&font1);
2294 if (hr == S_OK) {
2295 DWRITE_FONT_METRICS1 metrics1;
2296 IDWriteFontFace1 *fontface1;
2297
2298 memset(&metrics1, 0, sizeof(metrics1));
2299 IDWriteFont1_GetMetrics(font1, &metrics1);
2300
2301 ok(metrics1.designUnitsPerEm != 0, "designUnitsPerEm %u\n", metrics1.designUnitsPerEm);
2302 ok(metrics1.ascent != 0, "ascent %u\n", metrics1.ascent);
2303 ok(metrics1.descent != 0, "descent %u\n", metrics1.descent);
2304 ok(metrics1.lineGap == 0, "lineGap %d\n", metrics1.lineGap);
2305 ok(metrics1.capHeight, "capHeight %u\n", metrics1.capHeight);
2306 ok(metrics1.xHeight != 0, "xHeight %u\n", metrics1.xHeight);
2307 ok(metrics1.underlinePosition < 0, "underlinePosition %d\n", metrics1.underlinePosition);
2308 ok(metrics1.underlineThickness != 0, "underlineThickness %u\n", metrics1.underlineThickness);
2309 ok(metrics1.strikethroughPosition > 0, "strikethroughPosition %d\n", metrics1.strikethroughPosition);
2310 ok(metrics1.strikethroughThickness != 0, "strikethroughThickness %u\n", metrics1.strikethroughThickness);
2311 ok(metrics1.glyphBoxLeft < 0, "glyphBoxLeft %d\n", metrics1.glyphBoxLeft);
2312 ok(metrics1.glyphBoxTop > 0, "glyphBoxTop %d\n", metrics1.glyphBoxTop);
2313 ok(metrics1.glyphBoxRight > 0, "glyphBoxRight %d\n", metrics1.glyphBoxRight);
2314 ok(metrics1.glyphBoxBottom < 0, "glyphBoxBottom %d\n", metrics1.glyphBoxBottom);
2315 ok(metrics1.subscriptPositionY < 0, "subscriptPositionY %d\n", metrics1.subscriptPositionY);
2316 ok(metrics1.subscriptSizeX > 0, "subscriptSizeX %d\n", metrics1.subscriptSizeX);
2317 ok(metrics1.subscriptSizeY > 0, "subscriptSizeY %d\n", metrics1.subscriptSizeY);
2318 ok(metrics1.superscriptPositionY > 0, "superscriptPositionY %d\n", metrics1.superscriptPositionY);
2319 ok(metrics1.superscriptSizeX > 0, "superscriptSizeX %d\n", metrics1.superscriptSizeX);
2320 ok(metrics1.superscriptSizeY > 0, "superscriptSizeY %d\n", metrics1.superscriptSizeY);
2321 ok(!metrics1.hasTypographicMetrics, "hasTypographicMetrics %d\n", metrics1.hasTypographicMetrics);
2322
2323 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
2324 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2325
2326 memset(&metrics1, 0, sizeof(metrics1));
2327 IDWriteFontFace1_GetMetrics(fontface1, &metrics1);
2328
2329 ok(metrics1.designUnitsPerEm != 0, "designUnitsPerEm %u\n", metrics1.designUnitsPerEm);
2330 ok(metrics1.ascent != 0, "ascent %u\n", metrics1.ascent);
2331 ok(metrics1.descent != 0, "descent %u\n", metrics1.descent);
2332 ok(metrics1.lineGap == 0, "lineGap %d\n", metrics1.lineGap);
2333 ok(metrics1.capHeight, "capHeight %u\n", metrics1.capHeight);
2334 ok(metrics1.xHeight != 0, "xHeight %u\n", metrics1.xHeight);
2335 ok(metrics1.underlinePosition < 0, "underlinePosition %d\n", metrics1.underlinePosition);
2336 ok(metrics1.underlineThickness != 0, "underlineThickness %u\n", metrics1.underlineThickness);
2337 ok(metrics1.strikethroughPosition > 0, "strikethroughPosition %d\n", metrics1.strikethroughPosition);
2338 ok(metrics1.strikethroughThickness != 0, "strikethroughThickness %u\n", metrics1.strikethroughThickness);
2339 ok(metrics1.glyphBoxLeft < 0, "glyphBoxLeft %d\n", metrics1.glyphBoxLeft);
2340 ok(metrics1.glyphBoxTop > 0, "glyphBoxTop %d\n", metrics1.glyphBoxTop);
2341 ok(metrics1.glyphBoxRight > 0, "glyphBoxRight %d\n", metrics1.glyphBoxRight);
2342 ok(metrics1.glyphBoxBottom < 0, "glyphBoxBottom %d\n", metrics1.glyphBoxBottom);
2343 ok(metrics1.subscriptPositionY < 0, "subscriptPositionY %d\n", metrics1.subscriptPositionY);
2344 ok(metrics1.subscriptSizeX > 0, "subscriptSizeX %d\n", metrics1.subscriptSizeX);
2345 ok(metrics1.subscriptSizeY > 0, "subscriptSizeY %d\n", metrics1.subscriptSizeY);
2346 ok(metrics1.superscriptPositionY > 0, "superscriptPositionY %d\n", metrics1.superscriptPositionY);
2347 ok(metrics1.superscriptSizeX > 0, "superscriptSizeX %d\n", metrics1.superscriptSizeX);
2348 ok(metrics1.superscriptSizeY > 0, "superscriptSizeY %d\n", metrics1.superscriptSizeY);
2349 ok(!metrics1.hasTypographicMetrics, "hasTypographicMetrics %d\n", metrics1.hasTypographicMetrics);
2350
2351 IDWriteFontFace1_Release(fontface1);
2352 IDWriteFont1_Release(font1);
2353 }
2354 else
2355 win_skip("DWRITE_FONT_METRICS1 is not supported.\n");
2356
2357 IDWriteFontFace_Release(fontface);
2358 IDWriteFont_Release(font);
2359 IDWriteGdiInterop_Release(interop);
2360
2361 /* bold simulation affects returned font metrics */
2363
2364 /* create regulat Tahoma with bold simulation */
2365 hr = IDWriteFont_CreateFontFace(font, &fontface);
2366 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2367
2368 count = 1;
2369 hr = IDWriteFontFace_GetFiles(fontface, &count, &file);
2370 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2371
2372 IDWriteFontFace_GetMetrics(fontface, &metrics);
2373 ok(IDWriteFontFace_GetSimulations(fontface) == 0, "wrong simulations flags\n");
2374 IDWriteFontFace_Release(fontface);
2375
2376 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file,
2377 0, DWRITE_FONT_SIMULATIONS_BOLD, &fontface);
2378 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2379 IDWriteFontFace_GetMetrics(fontface, &metrics2);
2380 ok(IDWriteFontFace_GetSimulations(fontface) == DWRITE_FONT_SIMULATIONS_BOLD, "wrong simulations flags\n");
2381
2382 ok(metrics.ascent == metrics2.ascent, "got %u, %u\n", metrics2.ascent, metrics.ascent);
2383 ok(metrics.descent == metrics2.descent, "got %u, %u\n", metrics2.descent, metrics.descent);
2384 ok(metrics.lineGap == metrics2.lineGap, "got %d, %d\n", metrics2.lineGap, metrics.lineGap);
2385 ok(metrics.capHeight == metrics2.capHeight, "got %u, %u\n", metrics2.capHeight, metrics.capHeight);
2386 ok(metrics.xHeight == metrics2.xHeight, "got %u, %u\n", metrics2.xHeight, metrics.xHeight);
2387 ok(metrics.underlinePosition == metrics2.underlinePosition, "got %d, %d\n", metrics2.underlinePosition,
2388 metrics.underlinePosition);
2389 ok(metrics.underlineThickness == metrics2.underlineThickness, "got %u, %u\n", metrics2.underlineThickness,
2390 metrics.underlineThickness);
2391 ok(metrics.strikethroughPosition == metrics2.strikethroughPosition, "got %d, %d\n", metrics2.strikethroughPosition,
2392 metrics.strikethroughPosition);
2393 ok(metrics.strikethroughThickness == metrics2.strikethroughThickness, "got %u, %u\n", metrics2.strikethroughThickness,
2394 metrics.strikethroughThickness);
2395
2396 IDWriteFontFile_Release(file);
2397 IDWriteFontFace_Release(fontface);
2398 IDWriteFont_Release(font);
2399
2400 /* test metrics for whole system collection */
2401 hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE);
2402 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2403 count = IDWriteFontCollection_GetFontFamilyCount(syscollection);
2404
2405 for (i = 0; i < count; i++) {
2406 DWRITE_FONT_METRICS1 expected_metrics;
2407 WCHAR familyW[256], faceW[256];
2409 IDWriteFontFamily *family;
2410 UINT32 fontcount, j;
2412
2413 hr = IDWriteFontCollection_GetFontFamily(syscollection, i, &family);
2414 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2415
2416 fontcount = IDWriteFontFamily_GetFontCount(family);
2417
2418 hr = IDWriteFontFamily_GetFamilyNames(family, &names);
2419 ok(hr == S_OK, "Failed to get family names, hr %#lx.\n", hr);
2420 get_enus_string(names, familyW, ARRAY_SIZE(familyW));
2421 IDWriteLocalizedStrings_Release(names);
2422
2423 for (j = 0; j < fontcount; j++) {
2424 WCHAR nameW[256];
2425
2426 hr = IDWriteFontFamily_GetFont(family, j, &font);
2427 ok(hr == S_OK, "Failed to get a font, hr %#lx.\n", hr);
2428
2429 hr = IDWriteFont_CreateFontFace(font, &fontface);
2430 ok(hr == S_OK, "Failed to create face instance, hr %#lx.\n", hr);
2431
2432 hr = IDWriteFont_GetFaceNames(font, &names);
2433 ok(hr == S_OK, "Failed to get face names, hr %#lx.\n", hr);
2434 get_enus_string(names, faceW, ARRAY_SIZE(faceW));
2435 IDWriteLocalizedStrings_Release(names);
2436
2437 IDWriteFont_Release(font);
2438
2439 get_combined_font_name(familyW, faceW, nameW);
2440
2441 if (has_face_variations(fontface))
2442 {
2443 static int once;
2444 if (!once++)
2445 skip("GetMetrics() test does not support variable fonts.\n");
2446 IDWriteFontFace_Release(fontface);
2447 continue;
2448 }
2449
2450 get_expected_font_metrics(fontface, &expected_metrics);
2451 check_font_metrics(nameW, fontface, &expected_metrics);
2452
2453 IDWriteFontFace_Release(fontface);
2454 }
2455
2456 IDWriteFontFamily_Release(family);
2457 }
2458 IDWriteFontCollection_Release(syscollection);
2459 ref = IDWriteFactory_Release(factory);
2460 ok(ref == 0, "factory not released, %lu\n", ref);
2461}
static void get_expected_font_metrics(IDWriteFontFace *fontface, DWRITE_FONT_METRICS1 *metrics)
Definition: font.c:2033
static void check_font_metrics(const WCHAR *nameW, IDWriteFontFace *fontface, const DWRITE_FONT_METRICS1 *expected)
Definition: font.c:2127
UINT16 strikethroughThickness
Definition: dwrite_1.idl:450

Referenced by START_TEST().

◆ test_GetPaletteEntries()

static void test_GetPaletteEntries ( void  )
static

Definition at line 7588 of file font.c.

7589{
7590 IDWriteFontFace2 *fontface2;
7591 IDWriteFontFace *fontface;
7595 UINT32 palettecount, entrycount, size, colorrecords;
7596 void *ctxt;
7597 const struct CPAL_Header_0 *cpal_header;
7598 HRESULT hr;
7599 BOOL exists;
7600 ULONG ref;
7601
7603
7604 /* Tahoma, no color support */
7605 fontface = create_fontface(factory);
7606 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace2, (void**)&fontface2);
7607 IDWriteFontFace_Release(fontface);
7608 if (hr != S_OK) {
7609 ref = IDWriteFactory_Release(factory);
7610 ok(ref == 0, "factory not released, %lu\n", ref);
7611 win_skip("GetPaletteEntries() is not supported.\n");
7612 return;
7613 }
7614
7615 hr = IDWriteFontFace2_GetPaletteEntries(fontface2, 0, 0, 1, &color);
7616 ok(hr == DWRITE_E_NOCOLOR, "Unexpected hr %#lx.\n", hr);
7617 IDWriteFontFace2_Release(fontface2);
7618
7619 /* Segoe UI Emoji, with color support */
7620 font = get_font(factory, L"Segoe UI Emoji", DWRITE_FONT_STYLE_NORMAL);
7621 if (!font) {
7622 ref = IDWriteFactory_Release(factory);
7623 ok(ref == 0, "factory not released, %lu\n", ref);
7624 skip("Segoe UI Emoji font not found.\n");
7625 return;
7626 }
7627
7628 hr = IDWriteFont_CreateFontFace(font, &fontface);
7629 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7630 IDWriteFont_Release(font);
7631
7632 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace2, (void**)&fontface2);
7633 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7634 IDWriteFontFace_Release(fontface);
7635
7636 palettecount = IDWriteFontFace2_GetColorPaletteCount(fontface2);
7637 ok(palettecount >= 1, "got %u\n", palettecount);
7638
7639 entrycount = IDWriteFontFace2_GetPaletteEntryCount(fontface2);
7640 ok(entrycount >= 1, "got %u\n", entrycount);
7641
7642 exists = FALSE;
7643 hr = IDWriteFontFace2_TryGetFontTable(fontface2, MS_CPAL_TAG, (const void**)&cpal_header, &size, &ctxt, &exists);
7644 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7645 ok(exists, "got %d\n", exists);
7646 colorrecords = GET_BE_WORD(cpal_header->numColorRecords);
7647 ok(colorrecords >= 1, "got %u\n", colorrecords);
7648
7649 /* invalid palette index */
7650 color.r = color.g = color.b = color.a = 123.0;
7651 hr = IDWriteFontFace2_GetPaletteEntries(fontface2, palettecount, 0, 1, &color);
7652 ok(hr == DWRITE_E_NOCOLOR, "Unexpected hr %#lx.\n", hr);
7653 ok(color.r == 123.0 && color.g == 123.0 && color.b == 123.0 && color.a == 123.0,
7654 "got wrong color %.2fx%.2fx%.2fx%.2f\n", color.r, color.g, color.b, color.a);
7655
7656 /* invalid entry index */
7657 color.r = color.g = color.b = color.a = 123.0;
7658 hr = IDWriteFontFace2_GetPaletteEntries(fontface2, 0, entrycount, 1, &color);
7659 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
7660 ok(color.r == 123.0 && color.g == 123.0 && color.b == 123.0 && color.a == 123.0,
7661 "got wrong color %.2fx%.2fx%.2fx%.2f\n", color.r, color.g, color.b, color.a);
7662
7663 color.r = color.g = color.b = color.a = 123.0;
7664 hr = IDWriteFontFace2_GetPaletteEntries(fontface2, 0, entrycount - 1, 1, &color);
7665 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7666 ok(color.r != 123.0 && color.g != 123.0 && color.b != 123.0 && color.a != 123.0,
7667 "got wrong color %.2fx%.2fx%.2fx%.2f\n", color.r, color.g, color.b, color.a);
7668
7669 /* zero return length */
7670 color.r = color.g = color.b = color.a = 123.0;
7671 hr = IDWriteFontFace2_GetPaletteEntries(fontface2, 0, 0, 0, &color);
7672 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7673 ok(color.r == 123.0 && color.g == 123.0 && color.b == 123.0 && color.a == 123.0,
7674 "got wrong color %.2fx%.2fx%.2fx%.2f\n", color.r, color.g, color.b, color.a);
7675
7676 IDWriteFontFace2_Release(fontface2);
7677 ref = IDWriteFactory_Release(factory);
7678 ok(ref == 0, "factory not released, %lu\n", ref);
7679}
GLuint color
Definition: glext.h:6243
USHORT numColorRecords
Definition: font.c:7583
#define DWRITE_E_NOCOLOR
Definition: winerror.h:7346

Referenced by START_TEST().

◆ test_GetPanose()

static void test_GetPanose ( void  )
static

Definition at line 6519 of file font.c.

6520{
6521 IDWriteFontCollection *syscollection;
6523 IDWriteFont1 *font1;
6525 UINT count, i;
6526 HRESULT hr;
6527 ULONG ref;
6528
6531
6532 hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFont1, (void **)&font1);
6533 IDWriteFont_Release(font);
6534
6535 if (FAILED(hr)) {
6536 ref = IDWriteFactory_Release(factory);
6537 ok(ref == 0, "factory not released, %lu\n", ref);
6538 win_skip("GetPanose() is not supported.\n");
6539 return;
6540 }
6541 IDWriteFont1_Release(font1);
6542
6543 hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE);
6544 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6545 count = IDWriteFontCollection_GetFontFamilyCount(syscollection);
6546
6547 for (i = 0; i < count; i++) {
6548 DWRITE_PANOSE panose, expected_panose;
6550 IDWriteFontFace3 *fontface3;
6551 IDWriteFontFace *fontface;
6552 IDWriteFontFamily *family;
6553 IDWriteFont1 *font1;
6555 WCHAR nameW[256];
6556
6557 hr = IDWriteFontCollection_GetFontFamily(syscollection, i, &family);
6558 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6559
6560 hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
6562 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6563
6564 hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFont1, (void **)&font1);
6565 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6566 IDWriteFont_Release(font);
6567
6568 hr = IDWriteFontFamily_GetFamilyNames(family, &names);
6569 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6570
6572
6573 IDWriteLocalizedStrings_Release(names);
6574
6575 IDWriteFont1_GetPanose(font1, &panose);
6576 get_expected_panose(font1, &expected_panose);
6577
6579
6580 ok(panose.values[0] == expected_panose.values[0], "values[0] %#x, expected %#x.\n",
6581 panose.values[0], expected_panose.values[0]);
6582 ok(panose.values[1] == expected_panose.values[1], "values[1] %#x, expected %#x.\n",
6583 panose.values[1], expected_panose.values[1]);
6584 ok(panose.values[2] == expected_panose.values[2], "values[2] %#x, expected %#x.\n",
6585 panose.values[2], expected_panose.values[2]);
6586 ok(panose.values[3] == expected_panose.values[3], "values[3] %#x, expected %#x.\n",
6587 panose.values[3], expected_panose.values[3]);
6588 ok(panose.values[4] == expected_panose.values[4], "values[4] %#x, expected %#x.\n",
6589 panose.values[4], expected_panose.values[4]);
6590 ok(panose.values[5] == expected_panose.values[5], "values[5] %#x, expected %#x.\n",
6591 panose.values[5], expected_panose.values[5]);
6592 ok(panose.values[6] == expected_panose.values[6], "values[6] %#x, expected %#x.\n",
6593 panose.values[6], expected_panose.values[6]);
6594 ok(panose.values[7] == expected_panose.values[7], "values[7] %#x, expected %#x.\n",
6595 panose.values[7], expected_panose.values[7]);
6596 ok(panose.values[8] == expected_panose.values[8], "values[8] %#x, expected %#x.\n",
6597 panose.values[8], expected_panose.values[8]);
6598 ok(panose.values[9] == expected_panose.values[9], "values[9] %#x, expected %#x.\n",
6599 panose.values[9], expected_panose.values[9]);
6600
6602
6603 hr = IDWriteFont1_CreateFontFace(font1, &fontface);
6604 ok(hr == S_OK, "Failed to create a font face, %#lx.\n", hr);
6605 if (IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace3, (void **)&fontface3) == S_OK) {
6606 ok(!memcmp(&panose, &expected_panose, sizeof(panose)), "%s: Unexpected panose from font face.\n",
6608 IDWriteFontFace3_Release(fontface3);
6609 }
6610 IDWriteFontFace_Release(fontface);
6611
6612 IDWriteFont1_Release(font1);
6613 IDWriteFontFamily_Release(family);
6614 }
6615
6616 IDWriteFontCollection_Release(syscollection);
6617 ref = IDWriteFactory_Release(factory);
6618 ok(ref == 0, "factory not released, %lu\n", ref);
6619}
static void get_expected_panose(IDWriteFont1 *font, DWRITE_PANOSE *panose)
Definition: font.c:6494
UINT8 values[10]
Definition: dwrite_1.idl:475

Referenced by START_TEST().

◆ test_GetRecommendedRenderingMode()

static void test_GetRecommendedRenderingMode ( void  )
static

Definition at line 6854 of file font.c.

6855{
6857 IDWriteFontFace3 *fontface3;
6858 IDWriteFontFace2 *fontface2;
6859 IDWriteFontFace1 *fontface1;
6860 IDWriteFontFace *fontface;
6863 FLOAT emsize;
6864 HRESULT hr;
6865 ULONG ref;
6866
6868 fontface = create_fontface(factory);
6869
6870 fontface1 = NULL;
6871 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
6872 if (hr != S_OK)
6873 win_skip("IDWriteFontFace1::GetRecommendedRenderingMode() is not supported.\n");
6874
6875 fontface2 = NULL;
6876 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace2, (void**)&fontface2);
6877 if (hr != S_OK)
6878 win_skip("IDWriteFontFace2::GetRecommendedRenderingMode() is not supported.\n");
6879
6880 fontface3 = NULL;
6881 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace3, (void**)&fontface3);
6882 if (hr != S_OK)
6883 win_skip("IDWriteFontFace3::GetRecommendedRenderingMode() is not supported.\n");
6884
6885 if (0) /* crashes on native */
6886 hr = IDWriteFontFace_GetRecommendedRenderingMode(fontface, 3.0, 1.0,
6888
6889 mode = 10;
6890 hr = IDWriteFontFace_GetRecommendedRenderingMode(fontface, 3.0, 1.0,
6892 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
6893 ok(mode == DWRITE_RENDERING_MODE_DEFAULT, "got %d\n", mode);
6894
6895 hr = IDWriteFactory_CreateRenderingParams(factory, &params);
6896 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6897
6898 /* detect old dwrite version, that is using higher threshold value */
6899 g_is_vista = fontface1 == NULL;
6900
6901 for (emsize = 1.0; emsize < 500.0; emsize += 1.0)
6902 {
6904 unsigned int i;
6905 FLOAT ppdip;
6906 WORD gasp;
6907
6908 winetest_push_context("Size %.2f", emsize);
6909
6910 for (i = 0; i < ARRAY_SIZE(recmode_tests); ++i)
6911 {
6912 winetest_push_context("%u", i);
6913
6914 ppdip = 1.0f;
6915 mode = 10;
6916 gasp = get_gasp_flags(fontface, emsize, ppdip);
6917 expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests[i].measuring, recmode_tests[i].threshold);
6918 hr = IDWriteFontFace_GetRecommendedRenderingMode(fontface, emsize, ppdip, recmode_tests[i].measuring, params, &mode);
6919 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6920 ok(mode == expected, "got %d, ppdip %f, flags 0x%04x, expected %d.\n", mode, ppdip, gasp, expected);
6921
6922 /* some ppdip variants */
6923 ppdip = 0.5f;
6924 mode = 10;
6925 gasp = get_gasp_flags(fontface, emsize, ppdip);
6926 expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests[i].measuring, recmode_tests[i].threshold);
6927 hr = IDWriteFontFace_GetRecommendedRenderingMode(fontface, emsize, ppdip, recmode_tests[i].measuring, params, &mode);
6928 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6929 ok(mode == expected, "got %d, ppdip %f, flags 0x%04x, expected %d.\n", mode, ppdip, gasp, expected);
6930
6931 /* Only test larger sizes to workaround Win7 differences, where unscaled natural emsize threshold is used;
6932 Win8 and Win10 handle this as expected. */
6933 if (emsize > 20.0f)
6934 {
6935 ppdip = 1.5f;
6936 mode = 10;
6937 gasp = get_gasp_flags(fontface, emsize, ppdip);
6938 expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests[i].measuring, recmode_tests[i].threshold);
6939 hr = IDWriteFontFace_GetRecommendedRenderingMode(fontface, emsize, ppdip, recmode_tests[i].measuring, params, &mode);
6940 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6941 ok(mode == expected, "got %d, ppdip %f, flags 0x%04x, expected %d.\n", mode, ppdip, gasp, expected);
6942
6943 ppdip = 2.0f;
6944 mode = 10;
6945 gasp = get_gasp_flags(fontface, emsize, ppdip);
6946 expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests[i].measuring, recmode_tests[i].threshold);
6947 hr = IDWriteFontFace_GetRecommendedRenderingMode(fontface, emsize, ppdip, recmode_tests[i].measuring, params, &mode);
6948 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6949 ok(mode == expected, "got %d, ppdip %f, flags 0x%04x, expected %d.\n", mode, ppdip, gasp, expected);
6950 }
6951
6953 }
6954
6955 /* IDWriteFontFace1 offers another variant of this method */
6956 if (fontface1)
6957 {
6958 for (i = 0; i < ARRAY_SIZE(recmode_tests1); ++i)
6959 {
6960 FLOAT dpi;
6961
6962 winetest_push_context("%u", i);
6963
6964 ppdip = 1.0f;
6965 dpi = 96.0f * ppdip;
6966 mode = 10;
6967 gasp = get_gasp_flags(fontface, emsize, ppdip);
6968 expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
6969 hr = IDWriteFontFace1_GetRecommendedRenderingMode(fontface1, emsize, dpi, dpi,
6970 NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, &mode);
6971 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6972 ok(mode == expected, "got %d, dpi %f, flags 0x%04x, expected %d.\n", mode, dpi, gasp, expected);
6973
6974 /* Only test larger sizes to workaround Win7 differences, where unscaled natural emsize threshold is used;
6975 Win8 and Win10 handle this as expected. */
6976 if (emsize > 20.0f)
6977 {
6978 ppdip = 2.0f;
6979 dpi = 96.0f * ppdip;
6980 mode = 10;
6981 gasp = get_gasp_flags(fontface, emsize, ppdip);
6982 expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
6983 hr = IDWriteFontFace1_GetRecommendedRenderingMode(fontface1, emsize, dpi, dpi,
6984 NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, &mode);
6985 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6986 ok(mode == expected, "got %d, dpi %f, flags 0x%04x, expected %d.\n", mode, dpi, gasp, expected);
6987
6988 ppdip = 0.5f;
6989 dpi = 96.0f * ppdip;
6990 mode = 10;
6991 gasp = get_gasp_flags(fontface, emsize, ppdip);
6992 expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
6993 hr = IDWriteFontFace1_GetRecommendedRenderingMode(fontface1, emsize, dpi, dpi,
6994 NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, &mode);
6995 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
6996 ok(mode == expected, "got %d, dpi %f, flags 0x%04x, expected %d.\n", mode, dpi, gasp, expected);
6997
6998 /* try different dpis for X and Y direction */
6999 ppdip = 1.0f;
7000 dpi = 96.0f * ppdip;
7001 mode = 10;
7002 gasp = get_gasp_flags(fontface, emsize, ppdip);
7003 expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
7004 hr = IDWriteFontFace1_GetRecommendedRenderingMode(fontface1, emsize, dpi * 0.5f, dpi,
7005 NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, &mode);
7006 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7007 ok(mode == expected, "got %d, dpi %f, flags 0x%04x, expected %d.\n", mode, dpi, gasp, expected);
7008
7009 ppdip = 1.0f;
7010 dpi = 96.0f * ppdip;
7011 mode = 10;
7012 gasp = get_gasp_flags(fontface, emsize, ppdip);
7013 expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
7014 hr = IDWriteFontFace1_GetRecommendedRenderingMode(fontface1, emsize, dpi, dpi * 0.5f,
7015 NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, &mode);
7016 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7017 ok(mode == expected, "got %d, dpi %f, flags 0x%04x, expected %d.\n", mode, dpi, gasp, expected);
7018
7019 ppdip = 2.0f;
7020 dpi = 96.0f * ppdip;
7021 mode = 10;
7022 gasp = get_gasp_flags(fontface, emsize, ppdip);
7023 expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
7024 hr = IDWriteFontFace1_GetRecommendedRenderingMode(fontface1, emsize, dpi * 0.5f, dpi,
7025 NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, &mode);
7026 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7027 ok(mode == expected, "got %d, dpi %f, flags 0x%04x, expected %d.\n", mode, dpi, gasp, expected);
7028
7029 ppdip = 2.0f;
7030 dpi = 96.0f * ppdip;
7031 mode = 10;
7032 gasp = get_gasp_flags(fontface, emsize, ppdip);
7033 expected = get_expected_rendering_mode(emsize * ppdip, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
7034 hr = IDWriteFontFace1_GetRecommendedRenderingMode(fontface1, emsize, dpi, dpi * 0.5f,
7035 NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, &mode);
7036 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7037 ok(mode == expected, "got %d, dpi %f, flags 0x%04x, expected %d.\n", mode, dpi, gasp, expected);
7038 }
7039
7041 }
7042 }
7043
7044 /* IDWriteFontFace2 - another one */
7045 if (fontface2) {
7046 DWRITE_GRID_FIT_MODE gridfit, expected_gridfit;
7047
7048 gasp = get_gasp_flags(fontface, emsize, 1.0f);
7049 for (i = 0; i < ARRAY_SIZE(recmode_tests1); ++i)
7050 {
7051 winetest_push_context("%u", i);
7052
7053 mode = 10;
7054 expected = get_expected_rendering_mode(emsize, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
7055 expected_gridfit = get_expected_gridfit_mode(emsize, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
7056 hr = IDWriteFontFace2_GetRecommendedRenderingMode(fontface2, emsize, 96.0f, 96.0f,
7057 NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, params, &mode, &gridfit);
7058 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7059 ok(mode == expected, "got %d, flags 0x%04x, expected %d.\n", mode, gasp, expected);
7060 ok(gridfit == expected_gridfit, "gridfit: got %d, flags 0x%04x, expected %d.\n", gridfit, gasp, expected_gridfit);
7061
7063 }
7064 }
7065
7066 /* IDWriteFontFace3 - and another one */
7067 if (fontface3) {
7068 DWRITE_GRID_FIT_MODE gridfit, expected_gridfit;
7070 unsigned int expected1;
7071
7072 gasp = get_gasp_flags(fontface, emsize, 1.0f);
7073 for (i = 0; i < ARRAY_SIZE(recmode_tests1); ++i)
7074 {
7075 winetest_push_context("%u", i);
7076
7077 mode1 = 10;
7078 expected1 = get_expected_rendering_mode(emsize, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
7079 expected_gridfit = get_expected_gridfit_mode(emsize, gasp, recmode_tests1[i].measuring, recmode_tests1[i].threshold);
7080 hr = IDWriteFontFace3_GetRecommendedRenderingMode(fontface3, emsize, 96.0f, 96.0f,
7081 NULL, FALSE, recmode_tests1[i].threshold, recmode_tests1[i].measuring, params, &mode1, &gridfit);
7082 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7083 ok(mode1 == expected1, "got %d, flags 0x%04x, expected %d.\n", mode1, gasp, expected1);
7084 ok(gridfit == expected_gridfit, "gridfit: got %d, flags 0x%04x, expected %d.\n", gridfit, gasp, expected_gridfit);
7085
7087 }
7088 }
7089
7091 }
7092
7093 IDWriteRenderingParams_Release(params);
7094
7095 /* test how parameters override returned modes */
7096 hr = IDWriteFactory_CreateCustomRenderingParams(factory, 1.0, 0.0, 0.0, DWRITE_PIXEL_GEOMETRY_FLAT,
7098 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7099
7100 mode = 10;
7101 hr = IDWriteFontFace_GetRecommendedRenderingMode(fontface, 500.0, 1.0, DWRITE_MEASURING_MODE_NATURAL, params, &mode);
7102 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7104
7105 IDWriteRenderingParams_Release(params);
7106
7107 if (fontface2) {
7108 IDWriteRenderingParams2 *params2;
7109 IDWriteFactory2 *factory2;
7110 DWRITE_GRID_FIT_MODE gridfit;
7111
7112 hr = IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory2, (void**)&factory2);
7113 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7114
7115 hr = IDWriteFactory2_CreateCustomRenderingParams(factory2, 1.0, 0.0, 0.0, 0.5, DWRITE_PIXEL_GEOMETRY_FLAT,
7117 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7118
7119 mode = 10;
7120 gridfit = 10;
7121 hr = IDWriteFontFace2_GetRecommendedRenderingMode(fontface2, 5.0, 96.0, 96.0,
7123 NULL, &mode, &gridfit);
7124 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7126 ok(gridfit == DWRITE_GRID_FIT_MODE_ENABLED, "got %d\n", gridfit);
7127
7128 mode = 10;
7129 gridfit = 10;
7130 hr = IDWriteFontFace2_GetRecommendedRenderingMode(fontface2, 5.0, 96.0, 96.0,
7132 (IDWriteRenderingParams*)params2, &mode, &gridfit);
7133 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7134 ok(mode == DWRITE_RENDERING_MODE_OUTLINE, "got %d\n", mode);
7135 ok(gridfit == DWRITE_GRID_FIT_MODE_ENABLED, "got %d\n", gridfit);
7136
7137 IDWriteRenderingParams2_Release(params2);
7138 IDWriteFactory2_Release(factory2);
7139 }
7140
7141 if (fontface3) {
7142 IDWriteRenderingParams3 *params3;
7143 IDWriteRenderingParams2 *params2;
7145 IDWriteFactory3 *factory3;
7146 DWRITE_GRID_FIT_MODE gridfit;
7148
7149 hr = IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory3, (void**)&factory3);
7150 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7151
7152 hr = IDWriteFactory3_CreateCustomRenderingParams(factory3, 1.0f, 0.0f, 0.0f, 0.5f, DWRITE_PIXEL_GEOMETRY_FLAT,
7154 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7155
7156 mode1 = IDWriteRenderingParams3_GetRenderingMode1(params3);
7157 ok(mode1 == DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED, "got %d\n", mode1);
7158
7159 mode = IDWriteRenderingParams3_GetRenderingMode(params3);
7161
7162 hr = IDWriteRenderingParams3_QueryInterface(params3, &IID_IDWriteRenderingParams, (void**)&params);
7163 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7164 ok(params == (IDWriteRenderingParams*)params3, "got %p, %p\n", params3, params);
7165 mode = IDWriteRenderingParams_GetRenderingMode(params);
7167 IDWriteRenderingParams_Release(params);
7168
7169 hr = IDWriteRenderingParams3_QueryInterface(params3, &IID_IDWriteRenderingParams2, (void**)&params2);
7170 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7171 ok(params2 == (IDWriteRenderingParams2*)params3, "got %p, %p\n", params3, params2);
7172 mode = IDWriteRenderingParams2_GetRenderingMode(params2);
7174 IDWriteRenderingParams2_Release(params2);
7175
7176 mode = 10;
7177 gridfit = 10;
7178 hr = IDWriteFontFace2_GetRecommendedRenderingMode(fontface2, 5.0f, 96.0f, 96.0f,
7180 NULL, &mode, &gridfit);
7181 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7183 ok(gridfit == DWRITE_GRID_FIT_MODE_ENABLED, "got %d\n", gridfit);
7184
7185 mode = 10;
7186 gridfit = 10;
7187 hr = IDWriteFontFace2_GetRecommendedRenderingMode(fontface2, 5.0f, 96.0f, 96.0f,
7189 (IDWriteRenderingParams*)params3, &mode, &gridfit);
7190 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7192 ok(gridfit == DWRITE_GRID_FIT_MODE_ENABLED, "got %d\n", gridfit);
7193
7194 IDWriteRenderingParams3_Release(params3);
7195 IDWriteFactory3_Release(factory3);
7196 }
7197
7198 if (fontface3)
7199 IDWriteFontFace3_Release(fontface3);
7200 if (fontface2)
7201 IDWriteFontFace2_Release(fontface2);
7202 if (fontface1)
7203 IDWriteFontFace1_Release(fontface1);
7204 IDWriteFontFace_Release(fontface);
7205 ref = IDWriteFactory_Release(factory);
7206 ok(ref == 0, "factory not released, %lu\n", ref);
7207}
DWRITE_RENDERING_MODE1
Definition: dwrite_3.idl:77
static WORD get_gasp_flags(IDWriteFontFace *fontface, FLOAT emsize, FLOAT ppdip)
Definition: font.c:6735
static const struct recommendedmode_test recmode_tests[]
Definition: font.c:6839
static DWRITE_RENDERING_MODE get_expected_rendering_mode(FLOAT emsize, WORD gasp, DWRITE_MEASURING_MODE mode, DWRITE_OUTLINE_THRESHOLD threshold)
Definition: font.c:6780
static DWRITE_GRID_FIT_MODE get_expected_gridfit_mode(FLOAT emsize, WORD gasp, DWRITE_MEASURING_MODE mode, DWRITE_OUTLINE_THRESHOLD threshold)
Definition: font.c:6816
static const struct recommendedmode_test recmode_tests1[]
Definition: font.c:6845
#define dpi
Definition: sysparams.c:23

Referenced by START_TEST().

◆ test_GetSimulations()

static void test_GetSimulations ( void  )
static

Definition at line 4509 of file font.c.

4510{
4511 DWRITE_FONT_SIMULATIONS simulations;
4512 IDWriteGdiInterop *interop;
4513 IDWriteFontFace *fontface;
4516 LOGFONTW logfont;
4517 HRESULT hr;
4518 ULONG ref;
4519
4521
4522 hr = IDWriteFactory_GetGdiInterop(factory, &interop);
4523 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4524
4525 memset(&logfont, 0, sizeof(logfont));
4526 logfont.lfHeight = 12;
4527 logfont.lfWidth = 12;
4528 logfont.lfWeight = FW_NORMAL;
4529 logfont.lfItalic = 1;
4530 lstrcpyW(logfont.lfFaceName, L"Tahoma");
4531
4532 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
4533 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4534
4535 simulations = IDWriteFont_GetSimulations(font);
4536 ok(simulations == DWRITE_FONT_SIMULATIONS_OBLIQUE, "got %d\n", simulations);
4537 hr = IDWriteFont_CreateFontFace(font, &fontface);
4538 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4539 simulations = IDWriteFontFace_GetSimulations(fontface);
4540 ok(simulations == DWRITE_FONT_SIMULATIONS_OBLIQUE, "got %d\n", simulations);
4541 IDWriteFontFace_Release(fontface);
4542 IDWriteFont_Release(font);
4543
4544 memset(&logfont, 0, sizeof(logfont));
4545 logfont.lfHeight = 12;
4546 logfont.lfWidth = 12;
4547 logfont.lfWeight = FW_NORMAL;
4548 logfont.lfItalic = 0;
4549 lstrcpyW(logfont.lfFaceName, L"Tahoma");
4550
4551 hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
4552 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4553
4554 simulations = IDWriteFont_GetSimulations(font);
4555 ok(simulations == DWRITE_FONT_SIMULATIONS_NONE, "got %d\n", simulations);
4556 hr = IDWriteFont_CreateFontFace(font, &fontface);
4557 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4558 simulations = IDWriteFontFace_GetSimulations(fontface);
4559 ok(simulations == DWRITE_FONT_SIMULATIONS_NONE, "got %d\n", simulations);
4560 IDWriteFontFace_Release(fontface);
4561 IDWriteFont_Release(font);
4562
4563 IDWriteGdiInterop_Release(interop);
4564 ref = IDWriteFactory_Release(factory);
4565 ok(ref == 0, "factory not released, %lu\n", ref);
4566}

Referenced by START_TEST().

◆ test_GetUnicodeRanges()

static void test_GetUnicodeRanges ( void  )
static

Definition at line 3741 of file font.c.

3742{
3743 IDWriteFontCollection *syscollection;
3744 DWRITE_UNICODE_RANGE *ranges, r;
3745 IDWriteFontFile *ffile = NULL;
3746 IDWriteFontFace1 *fontface1;
3747 IDWriteFontFace *fontface;
3749 UINT32 count, i;
3750 HRESULT hr;
3751 HRSRC font;
3752 ULONG ref;
3753
3755
3756 hr = IDWriteFactory_RegisterFontFileLoader(factory, &rloader);
3757 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3758
3760 ok(font != NULL, "Failed to find font resource\n");
3761
3762 hr = IDWriteFactory_CreateCustomFontFileReference(factory, &font, sizeof(HRSRC), &rloader, &ffile);
3763 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3764
3765 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &ffile, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface);
3766 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3767 IDWriteFontFile_Release(ffile);
3768
3769 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
3770 IDWriteFontFace_Release(fontface);
3771 if (hr != S_OK) {
3772 win_skip("GetUnicodeRanges() is not supported.\n");
3773 IDWriteFactory_Release(factory);
3774 return;
3775 }
3776
3777 count = 0;
3778 hr = IDWriteFontFace1_GetUnicodeRanges(fontface1, 0, NULL, &count);
3779 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#lx.\n", hr);
3780 ok(count > 0, "got %u\n", count);
3781
3782 count = 1;
3783 hr = IDWriteFontFace1_GetUnicodeRanges(fontface1, 1, NULL, &count);
3784 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
3785 ok(count == 0, "got %u\n", count);
3786
3787 count = 0;
3788 hr = IDWriteFontFace1_GetUnicodeRanges(fontface1, 1, &r, &count);
3789 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#lx.\n", hr);
3790 ok(count > 1, "got %u\n", count);
3791
3792 ranges = malloc(count*sizeof(DWRITE_UNICODE_RANGE));
3793 hr = IDWriteFontFace1_GetUnicodeRanges(fontface1, count, ranges, &count);
3794 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3795
3796 ranges[0].first = ranges[0].last = 0;
3797 hr = IDWriteFontFace1_GetUnicodeRanges(fontface1, 1, ranges, &count);
3798 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#lx.\n", hr);
3799 ok(ranges[0].first != 0 && ranges[0].last != 0, "got 0x%x-0x%0x\n", ranges[0].first, ranges[0].last);
3800
3801 free(ranges);
3802
3803 hr = IDWriteFactory_UnregisterFontFileLoader(factory, &rloader);
3804 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3805
3806 IDWriteFontFace1_Release(fontface1);
3807
3808if (strcmp(winetest_platform, "wine")) {
3809
3810 hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE);
3811 ok(hr == S_OK, "Failed to get system collection, hr %#lx.\n", hr);
3812
3813 count = IDWriteFontCollection_GetFontFamilyCount(syscollection);
3814
3815 for (i = 0; i < count; i++) {
3816 WCHAR familynameW[256], facenameW[128];
3818 IDWriteFontFamily *family;
3819 UINT32 j, k, fontcount;
3821
3822 hr = IDWriteFontCollection_GetFontFamily(syscollection, i, &family);
3823 ok(hr == S_OK, "Failed to get font family, hr %#lx.\n", hr);
3824
3825 hr = IDWriteFontFamily_GetFamilyNames(family, &names);
3826 ok(hr == S_OK, "Failed to get family names, hr %#lx.\n", hr);
3827
3828 get_enus_string(names, familynameW, ARRAY_SIZE(familynameW));
3829 IDWriteLocalizedStrings_Release(names);
3830
3831 fontcount = IDWriteFontFamily_GetFontCount(family);
3832 for (j = 0; j < fontcount; j++) {
3833 DWRITE_UNICODE_RANGE *expected_ranges = NULL;
3834 UINT32 range_count, expected_count;
3835
3836 hr = IDWriteFontFamily_GetFont(family, j, &font);
3837 ok(hr == S_OK, "Failed to get font, hr %#lx.\n", hr);
3838
3839 hr = IDWriteFont_CreateFontFace(font, &fontface);
3840 ok(hr == S_OK, "Failed to create fontface, hr %#lx.\n", hr);
3841
3842 hr = IDWriteFont_GetFaceNames(font, &names);
3843 ok(hr == S_OK, "Failed to get face names, hr %#lx.\n", hr);
3844 IDWriteFont_Release(font);
3845
3846 get_enus_string(names, facenameW, ARRAY_SIZE(facenameW));
3847
3848 IDWriteLocalizedStrings_Release(names);
3849
3850 if (IDWriteFontFace_IsSymbolFont(fontface))
3851 {
3852 static int once;
3853 if (!once++)
3854 skip("GetUnicodeRanges() test does not support symbol fonts.\n");
3855 IDWriteFontFace_Release(fontface);
3856 continue;
3857 }
3858
3859 IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void **)&fontface1);
3860
3861 hr = IDWriteFontFace1_GetUnicodeRanges(fontface1, 0, NULL, &range_count);
3862 ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#lx.\n", hr);
3863
3864 ranges = malloc(range_count * sizeof(*ranges));
3865
3866 hr = IDWriteFontFace1_GetUnicodeRanges(fontface1, range_count, ranges, &range_count);
3867 ok(hr == S_OK, "Failed to get ranges, hr %#lx.\n", hr);
3868
3869 expected_count = fontface_get_expected_unicode_ranges(fontface1, &expected_ranges);
3870 ok(expected_count == range_count, "%s - %s: unexpected range count %u, expected %u.\n",
3871 wine_dbgstr_w(familynameW), wine_dbgstr_w(facenameW), range_count, expected_count);
3872
3873 if (expected_count == range_count) {
3874 if (memcmp(expected_ranges, ranges, expected_count * sizeof(*ranges))) {
3875 for (k = 0; k < expected_count; ++k) {
3876 BOOL failed = memcmp(&expected_ranges[k], &ranges[k], sizeof(*ranges));
3877 ok(!failed, "%u: %s - %s mismatching range [%#x, %#x] vs [%#x, %#x].\n", k,
3878 wine_dbgstr_w(familynameW), wine_dbgstr_w(facenameW), ranges[k].first, ranges[k].last,
3879 expected_ranges[k].first, expected_ranges[k].last);
3880 if (failed)
3881 break;
3882 }
3883 }
3884 }
3885
3886 free(expected_ranges);
3887 free(ranges);
3888
3889 IDWriteFontFace1_Release(fontface1);
3890 IDWriteFontFace_Release(fontface);
3891 }
3892
3893 IDWriteFontFamily_Release(family);
3894 }
3895
3896 IDWriteFontCollection_Release(syscollection);
3897}
3898 ref = IDWriteFactory_Release(factory);
3899 ok(ref == 0, "factory not released, %lu\n", ref);
3900}
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
static int expected_count(int *sink)
const char * winetest_platform
static UINT32 fontface_get_expected_unicode_ranges(IDWriteFontFace1 *fontface, DWRITE_UNICODE_RANGE **out)
Definition: font.c:3703
int k
Definition: mpi.c:3369

Referenced by START_TEST().

◆ test_GetVerticalGlyphVariants()

static void test_GetVerticalGlyphVariants ( void  )
static

Definition at line 10129 of file font.c.

10130{
10131 UINT16 glyphs[1], glyph_variants[1];
10132 IDWriteFontFace1 *fontface1;
10133 IDWriteFontFace *fontface;
10135 unsigned int ch;
10136 ULONG refcount;
10137 HRESULT hr;
10138 BOOL ret;
10139
10141
10142 fontface = create_fontface(factory);
10143 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void **)&fontface1);
10144 IDWriteFontFace_Release(fontface);
10145 if (FAILED(hr))
10146 {
10147 win_skip("GetVerticalGlyphVariants() is not supported.\n");
10148 IDWriteFactory_Release(factory);
10149 return;
10150 }
10151
10152 ch = 'A';
10153 *glyphs = 0;
10154 hr = IDWriteFontFace1_GetGlyphIndices(fontface1, &ch, 1, glyphs);
10155 ok(hr == S_OK, "Failed to get glyph, hr %#lx.\n", hr);
10156 ok(!!*glyphs, "Unexpected glyph %u.\n", glyphs[0]);
10157
10158 memset(glyph_variants, 0, sizeof(glyph_variants));
10159 hr = IDWriteFontFace1_GetVerticalGlyphVariants(fontface1, 1, glyphs, glyph_variants);
10160 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10161 ok(glyphs[0] == glyph_variants[0], "Unexpected glyph.\n");
10162
10163 ret = IDWriteFontFace1_HasVerticalGlyphVariants(fontface1);
10164 ok(!ret, "Unexpected flag.\n");
10165
10166 IDWriteFontFace1_Release(fontface1);
10167 refcount = IDWriteFactory_Release(factory);
10168 ok(!refcount, "Factory not released, refcount %lu.\n", refcount);
10169}

Referenced by START_TEST().

◆ test_HasCharacter()

static void test_HasCharacter ( void  )
static

Definition at line 7939 of file font.c.

7940{
7941 IDWriteFactory3 *factory3;
7943 IDWriteFont3 *font3;
7945 HRESULT hr;
7946 ULONG ref;
7947 BOOL ret;
7948
7950
7952 ok(font != NULL, "failed to create font\n");
7953
7954 /* Win8 is broken, QI claims to support IDWriteFont3, but in fact it does not */
7955 hr = IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory3, (void**)&factory3);
7956 if (hr == S_OK) {
7957 hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFont3, (void**)&font3);
7958 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7959
7960 ret = IDWriteFont3_HasCharacter(font3, 'A');
7961 ok(ret, "got %d\n", ret);
7962
7963 IDWriteFont3_Release(font3);
7964 IDWriteFactory3_Release(factory3);
7965 }
7966 else
7967 win_skip("IDWriteFont3 is not supported.\n");
7968
7969 IDWriteFont_Release(font);
7970 ref = IDWriteFactory_Release(factory);
7971 ok(ref == 0, "factory not released, %lu\n", ref);
7972}

Referenced by START_TEST().

◆ test_HasKerningPairs()

static void test_HasKerningPairs ( void  )
static

Definition at line 8522 of file font.c.

8523{
8524 IDWriteFontCollection *syscollection;
8525 IDWriteFontFace1 *fontface1;
8526 IDWriteFontFace *fontface;
8528 UINT32 count, i;
8529 HRESULT hr;
8530 ULONG ref;
8531
8533 fontface = create_fontface(factory);
8534
8535 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
8536 IDWriteFontFace_Release(fontface);
8537 if (hr != S_OK) {
8538 win_skip("HasKerningPairs() is not supported.\n");
8539 IDWriteFactory_Release(factory);
8540 return;
8541 }
8542 IDWriteFontFace1_Release(fontface1);
8543
8544 hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE);
8545 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8546 count = IDWriteFontCollection_GetFontFamilyCount(syscollection);
8547
8548 for (i = 0; i < count; i++) {
8550 BOOL exists, has_kerningpairs;
8551 IDWriteFontFamily *family;
8553 WCHAR nameW[256];
8554 const void *data;
8555 void *context;
8556 UINT32 size;
8557
8558 hr = IDWriteFontCollection_GetFontFamily(syscollection, i, &family);
8559 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8560
8561 hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
8563 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8564
8565 hr = IDWriteFont_CreateFontFace(font, &fontface);
8566 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8567
8568 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void **)&fontface1);
8569 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8570
8571 hr = IDWriteFontFamily_GetFamilyNames(family, &names);
8572 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8573
8575
8576 exists = FALSE;
8577 hr = IDWriteFontFace1_TryGetFontTable(fontface1, MS_KERN_TAG, &data, &size, &context, &exists);
8578 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8579 IDWriteFontFace1_ReleaseFontTable(fontface1, context);
8580
8581 has_kerningpairs = IDWriteFontFace1_HasKerningPairs(fontface1);
8582 if (!exists)
8583 ok(!has_kerningpairs, "%s: expected %d, got %d\n", wine_dbgstr_w(nameW), exists, has_kerningpairs);
8584
8585 IDWriteLocalizedStrings_Release(names);
8586 IDWriteFont_Release(font);
8587
8588 IDWriteFontFace1_Release(fontface1);
8589 IDWriteFontFace_Release(fontface);
8590 IDWriteFontFamily_Release(family);
8591 }
8592
8593 IDWriteFontCollection_Release(syscollection);
8594 ref = IDWriteFactory_Release(factory);
8595 ok(ref == 0, "factory not released, %lu\n", ref);
8596}
#define MS_KERN_TAG
Definition: font.c:44

Referenced by START_TEST().

◆ test_HasVerticalGlyphVariants()

static void test_HasVerticalGlyphVariants ( void  )
static

Definition at line 8452 of file font.c.

8453{
8454 IDWriteFontCollection *syscollection;
8455 IDWriteFontFace1 *fontface1;
8456 IDWriteFontFace *fontface;
8458 UINT32 count, i;
8459 HRESULT hr;
8460 ULONG ref;
8461
8463 fontface = create_fontface(factory);
8464
8465 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
8466 IDWriteFontFace_Release(fontface);
8467 if (hr != S_OK) {
8468 win_skip("HasVerticalGlyphVariants() is not supported.\n");
8469 IDWriteFactory_Release(factory);
8470 return;
8471 }
8472 IDWriteFontFace1_Release(fontface1);
8473
8474 hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE);
8475 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8476 count = IDWriteFontCollection_GetFontFamilyCount(syscollection);
8477
8478 for (i = 0; i < count; i++) {
8480 BOOL expected_vert, has_vert;
8481 IDWriteFontFamily *family;
8483 WCHAR nameW[256];
8484
8485 hr = IDWriteFontCollection_GetFontFamily(syscollection, i, &family);
8486 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8487
8488 hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
8490 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8491
8492 hr = IDWriteFont_CreateFontFace(font, &fontface);
8493 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8494
8495 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1);
8496 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8497
8498 hr = IDWriteFontFamily_GetFamilyNames(family, &names);
8499 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
8500
8502
8503 expected_vert = has_vertical_glyph_variants(fontface1);
8504 has_vert = IDWriteFontFace1_HasVerticalGlyphVariants(fontface1);
8505
8506 ok(expected_vert == has_vert, "%s: expected vertical feature %d, got %d\n",
8507 wine_dbgstr_w(nameW), expected_vert, has_vert);
8508
8509 IDWriteLocalizedStrings_Release(names);
8510 IDWriteFont_Release(font);
8511
8512 IDWriteFontFace1_Release(fontface1);
8513 IDWriteFontFace_Release(fontface);
8514 IDWriteFontFamily_Release(family);
8515 }
8516
8517 IDWriteFontCollection_Release(syscollection);
8518 ref = IDWriteFactory_Release(factory);
8519 ok(ref == 0, "factory not released, %lu\n", ref);
8520}
static BOOL has_vertical_glyph_variants(IDWriteFontFace1 *fontface)
Definition: font.c:8373

Referenced by START_TEST().

◆ test_inmemory_file_loader()

static void test_inmemory_file_loader ( void  )
static

Definition at line 8979 of file font.c.

8980{
8981 IDWriteFontFileStream *stream, *stream2, *stream3;
8985 struct testowner_object ownerobject;
8986 const void *key, *data, *frag_start;
8987 UINT64 file_size, size, writetime;
8988 IDWriteFontFile *file, *file2;
8989 IDWriteFontFace *fontface;
8990 void *context, *context2;
8992 UINT32 count, key_size;
8993 DWORD ref_key;
8994 HRESULT hr;
8995 ULONG ref;
8996
8997 factory = create_factory_iid(&IID_IDWriteFactory5);
8998 if (!factory) {
8999 win_skip("CreateInMemoryFontFileLoader() is not supported\n");
9000 return;
9001 }
9002
9003 EXPECT_REF(factory, 1);
9004 hr = IDWriteFactory5_CreateInMemoryFontFileLoader(factory, &loader);
9005 ok(hr == S_OK, "got %#lx\n", hr);
9006 EXPECT_REF(factory, 1);
9007
9008 testowner_init(&ownerobject);
9009 fontface = create_fontface((IDWriteFactory *)factory);
9010
9011 hr = IDWriteFactory5_CreateInMemoryFontFileLoader(factory, &loader2);
9012 ok(hr == S_OK, "got %#lx\n", hr);
9013 ok(loader != loader2, "unexpected pointer\n");
9014 IDWriteInMemoryFontFileLoader_Release(loader2);
9015
9016 inmemory = loader;
9017
9018 count = IDWriteInMemoryFontFileLoader_GetFileCount(inmemory);
9019 ok(!count, "Unexpected file count %u.\n", count);
9020
9021 /* Use whole font blob to construct in-memory file. */
9022 count = 1;
9023 hr = IDWriteFontFace_GetFiles(fontface, &count, &file);
9024 ok(hr == S_OK, "got %#lx\n", hr);
9025
9026 hr = IDWriteFontFile_GetLoader(file, &fileloader);
9027 ok(hr == S_OK, "got %#lx\n", hr);
9028
9029 hr = IDWriteFontFile_GetReferenceKey(file, &key, &key_size);
9030 ok(hr == S_OK, "got %#lx\n", hr);
9031
9032 hr = IDWriteFontFileLoader_CreateStreamFromKey(fileloader, key, key_size, &stream);
9033 ok(hr == S_OK, "got %#lx\n", hr);
9034 IDWriteFontFileLoader_Release(fileloader);
9035 IDWriteFontFile_Release(file);
9036
9037 hr = IDWriteFontFileStream_GetFileSize(stream, &file_size);
9038 ok(hr == S_OK, "got %#lx\n", hr);
9039
9040 hr = IDWriteFontFileStream_ReadFileFragment(stream, &data, 0, file_size, &context);
9041 ok(hr == S_OK, "got %#lx\n", hr);
9042
9043 /* Not registered yet. */
9044 hr = IDWriteInMemoryFontFileLoader_CreateInMemoryFontFileReference(inmemory, (IDWriteFactory *)factory, data,
9045 file_size, NULL, &file);
9046 ok(hr == E_INVALIDARG, "got %#lx\n", hr);
9047
9048 count = IDWriteInMemoryFontFileLoader_GetFileCount(inmemory);
9049 ok(count == 1, "Unexpected file count %u.\n", count);
9050
9051 hr = IDWriteFactory5_RegisterFontFileLoader(factory, (IDWriteFontFileLoader *)inmemory);
9052 ok(hr == S_OK, "got %#lx\n", hr);
9053 EXPECT_REF(inmemory, 2);
9054
9055 EXPECT_REF(&ownerobject.IUnknown_iface, 1);
9056 hr = IDWriteInMemoryFontFileLoader_CreateInMemoryFontFileReference(inmemory, (IDWriteFactory *)factory, data,
9057 file_size, &ownerobject.IUnknown_iface, &file);
9058 ok(hr == S_OK, "got %#lx\n", hr);
9059 EXPECT_REF(&ownerobject.IUnknown_iface, 2);
9060 EXPECT_REF(inmemory, 3);
9061
9062 count = IDWriteInMemoryFontFileLoader_GetFileCount(inmemory);
9063 ok(count == 2, "Unexpected file count %u.\n", count);
9064
9065 hr = IDWriteInMemoryFontFileLoader_CreateInMemoryFontFileReference(inmemory, (IDWriteFactory *)factory, data,
9066 file_size, &ownerobject.IUnknown_iface, &file2);
9067 ok(hr == S_OK, "got %#lx\n", hr);
9068 ok(file2 != file, "got unexpected file\n");
9069 EXPECT_REF(&ownerobject.IUnknown_iface, 3);
9070 EXPECT_REF(inmemory, 4);
9071
9072 count = IDWriteInMemoryFontFileLoader_GetFileCount(inmemory);
9073 ok(count == 3, "Unexpected file count %u.\n", count);
9074
9075 /* Check in-memory reference key format. */
9076 hr = IDWriteFontFile_GetReferenceKey(file, &key, &key_size);
9077 ok(hr == S_OK, "got %#lx\n", hr);
9078
9079 ok(key && *(DWORD*)key == 1, "got wrong ref key\n");
9080 ok(key_size == 4, "ref key size %u\n", key_size);
9081
9082 hr = IDWriteFontFile_GetReferenceKey(file2, &key, &key_size);
9083 ok(hr == S_OK, "got %#lx\n", hr);
9084
9085 ok(key && *(DWORD*)key == 2, "got wrong ref key\n");
9086 ok(key_size == 4, "ref key size %u\n", key_size);
9087
9088 EXPECT_REF(inmemory, 4);
9089 hr = IDWriteInMemoryFontFileLoader_CreateStreamFromKey(inmemory, key, key_size, &stream2);
9090 ok(hr == S_OK, "Failed to create a stream, hr %#lx.\n", hr);
9091 EXPECT_REF(stream2, 1);
9092 EXPECT_REF(inmemory, 4);
9093
9094 hr = IDWriteInMemoryFontFileLoader_CreateStreamFromKey(inmemory, key, key_size, &stream3);
9095 ok(hr == S_OK, "Failed to create a stream, hr %#lx.\n", hr);
9096
9097 ok(stream2 != stream3, "Unexpected stream.\n");
9098
9099 IDWriteFontFileStream_Release(stream2);
9100 IDWriteFontFileStream_Release(stream3);
9101
9102 /* Release file at index 1, create new one to see if index is reused. */
9103 EXPECT_REF(&ownerobject.IUnknown_iface, 3);
9104 ref = IDWriteFontFile_Release(file);
9105 ok(ref == 0, "File object not released, %lu.\n", ref);
9106 EXPECT_REF(&ownerobject.IUnknown_iface, 3);
9107
9108 count = IDWriteInMemoryFontFileLoader_GetFileCount(inmemory);
9109 ok(count == 3, "Unexpected file count %u.\n", count);
9110
9111 EXPECT_REF(&ownerobject.IUnknown_iface, 3);
9112 ref = IDWriteFontFile_Release(file2);
9113 ok(ref == 0, "File object not released, %lu.\n", ref);
9114 EXPECT_REF(&ownerobject.IUnknown_iface, 3);
9115
9116 count = IDWriteInMemoryFontFileLoader_GetFileCount(inmemory);
9117 ok(count == 3, "Unexpected file count %u.\n", count);
9118
9119 hr = IDWriteFactory5_UnregisterFontFileLoader(factory, (IDWriteFontFileLoader *)inmemory);
9120 ok(hr == S_OK, "got %#lx\n", hr);
9121 EXPECT_REF(&ownerobject.IUnknown_iface, 3);
9122
9123 EXPECT_REF(&ownerobject.IUnknown_iface, 3);
9124 ref = IDWriteInMemoryFontFileLoader_Release(inmemory);
9125 ok(ref == 0, "loader not released, %lu.\n", ref);
9126 EXPECT_REF(&ownerobject.IUnknown_iface, 1);
9127
9128 /* Test reference key for first added file. */
9129 hr = IDWriteFactory5_CreateInMemoryFontFileLoader(factory, &loader);
9130 ok(hr == S_OK, "Failed to create loader, hr %#lx.\n", hr);
9131
9132 inmemory = loader;
9133
9134 hr = IDWriteFactory5_RegisterFontFileLoader(factory, (IDWriteFontFileLoader *)inmemory);
9135 ok(hr == S_OK, "Failed to register loader, hr %#lx.\n", hr);
9136
9137 ref_key = 0;
9138 hr = IDWriteInMemoryFontFileLoader_CreateStreamFromKey(inmemory, &ref_key, sizeof(ref_key), &stream2);
9139 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
9140
9141 /* With owner object. */
9142 hr = IDWriteInMemoryFontFileLoader_CreateInMemoryFontFileReference(inmemory, (IDWriteFactory *)factory, data,
9143 file_size, &ownerobject.IUnknown_iface, &file);
9144 ok(hr == S_OK, "Failed to create in-memory file reference, hr %#lx.\n", hr);
9145
9146 ref_key = 0;
9147 hr = IDWriteInMemoryFontFileLoader_CreateStreamFromKey(inmemory, &ref_key, sizeof(ref_key), &stream2);
9148 ok(hr == S_OK, "Failed to create a stream, hr %#lx.\n", hr);
9149
9150 context2 = (void *)0xdeadbeef;
9151 hr = IDWriteFontFileStream_ReadFileFragment(stream2, &frag_start, 0, file_size, &context2);
9152 ok(hr == S_OK, "Failed to read a fragment, hr %#lx.\n", hr);
9153 ok(context2 == NULL, "Unexpected context %p.\n", context2);
9154 ok(frag_start == data, "Unexpected fragment pointer %p.\n", frag_start);
9155
9156 hr = IDWriteFontFileStream_GetFileSize(stream2, &size);
9157 ok(hr == S_OK, "Failed to get file size, hr %#lx.\n", hr);
9158 ok(size == file_size, "Unexpected file size.\n");
9159
9160 IDWriteFontFileStream_ReleaseFileFragment(stream2, context2);
9161
9162 writetime = 1;
9163 hr = IDWriteFontFileStream_GetLastWriteTime(stream2, &writetime);
9164 ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
9165 ok(writetime == 0, "Unexpected writetime.\n");
9166
9167 IDWriteFontFileStream_Release(stream2);
9168
9169 /* Without owner object. */
9170 hr = IDWriteInMemoryFontFileLoader_CreateInMemoryFontFileReference(inmemory, (IDWriteFactory *)factory, data,
9171 file_size, NULL, &file2);
9172 ok(hr == S_OK, "Failed to create in-memory file reference, hr %#lx.\n", hr);
9173
9174 ref_key = 1;
9175 hr = IDWriteInMemoryFontFileLoader_CreateStreamFromKey(inmemory, &ref_key, sizeof(ref_key), &stream2);
9176 ok(hr == S_OK, "Failed to create a stream, hr %#lx.\n", hr);
9177
9178 context2 = (void *)0xdeadbeef;
9179 hr = IDWriteFontFileStream_ReadFileFragment(stream2, &frag_start, 0, file_size, &context2);
9180 ok(hr == S_OK, "Failed to read a fragment, hr %#lx.\n", hr);
9181 ok(context2 == NULL, "Unexpected context %p.\n", context2);
9182 ok(frag_start != data, "Unexpected fragment pointer %p.\n", frag_start);
9183
9184 hr = IDWriteFontFileStream_GetFileSize(stream2, &size);
9185 ok(hr == S_OK, "Failed to get file size, hr %#lx.\n", hr);
9186 ok(size == file_size, "Unexpected file size.\n");
9187
9188 IDWriteFontFileStream_ReleaseFileFragment(stream2, context2);
9189
9190 writetime = 1;
9191 hr = IDWriteFontFileStream_GetLastWriteTime(stream2, &writetime);
9192 ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
9193 ok(writetime == 0, "Unexpected writetime.\n");
9194
9195 IDWriteFontFileStream_Release(stream2);
9196 IDWriteFontFile_Release(file2);
9197
9198 /* Key size validation. */
9199 ref_key = 0;
9200 hr = IDWriteInMemoryFontFileLoader_CreateStreamFromKey(inmemory, NULL, sizeof(ref_key) - 1, &stream2);
9201 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
9202
9203 ref_key = 0;
9204 hr = IDWriteInMemoryFontFileLoader_CreateStreamFromKey(inmemory, &ref_key, sizeof(ref_key) - 1, &stream2);
9205 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
9206
9207 ref_key = 0;
9208 hr = IDWriteInMemoryFontFileLoader_CreateStreamFromKey(inmemory, &ref_key, sizeof(ref_key) + 1, &stream2);
9209 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
9210
9211 count = IDWriteInMemoryFontFileLoader_GetFileCount(inmemory);
9212 ok(count == 2, "Unexpected file count %u.\n", count);
9213
9214 hr = IDWriteFontFile_GetReferenceKey(file, &key, &key_size);
9215 ok(hr == S_OK, "Failed to get reference key, hr %#lx.\n", hr);
9216
9217 ok(key && *(DWORD*)key == 0, "Unexpected reference key.\n");
9218 ok(key_size == 4, "Unexpected key size %u.\n", key_size);
9219
9220 IDWriteFontFile_Release(file);
9221
9222 count = IDWriteInMemoryFontFileLoader_GetFileCount(inmemory);
9223 ok(count == 2, "Unexpected file count %u.\n", count);
9224
9225 hr = IDWriteFactory5_UnregisterFontFileLoader(factory, (IDWriteFontFileLoader *)inmemory);
9226 ok(hr == S_OK, "Failed to unregister loader, hr %#lx.\n", hr);
9227
9228 IDWriteFontFileStream_ReleaseFileFragment(stream, context);
9229 IDWriteFontFileStream_Release(stream);
9230 IDWriteFontFace_Release(fontface);
9231
9232 ref = IDWriteInMemoryFontFileLoader_Release(inmemory);
9233 ok(ref == 0, "loader not released, %lu.\n", ref);
9234
9235 ref = IDWriteFactory5_Release(factory);
9236 ok(ref == 0, "factory not released, %lu\n", ref);
9237}
static void testowner_init(struct testowner_object *object)
Definition: font.c:8973

Referenced by START_TEST().

◆ test_IsColorFont()

static void test_IsColorFont ( void  )
static

Definition at line 10050 of file font.c.

10051{
10054 UINT32 count, i;
10055 ULONG refcount;
10056 HRESULT hr;
10057
10058 factory = create_factory_iid(&IID_IDWriteFactory2);
10059
10060 if (!factory)
10061 {
10062 win_skip("IsColorFont() is not supported.\n");
10063 return;
10064 }
10065
10066 hr = IDWriteFactory2_GetSystemFontCollection(factory, &collection, FALSE);
10067 ok(hr == S_OK, "Failed to get font collection, hr %#lx.\n", hr);
10068
10069 count = IDWriteFontCollection_GetFontFamilyCount(collection);
10070 for (i = 0; i < count; ++i)
10071 {
10073 IDWriteFontFamily *family;
10074 UINT32 font_count, j;
10075 WCHAR nameW[256];
10076
10077 hr = IDWriteFontCollection_GetFontFamily(collection, i, &family);
10078 ok(hr == S_OK, "Failed to get family, hr %#lx.\n", hr);
10079
10080 hr = IDWriteFontFamily_GetFamilyNames(family, &names);
10081 ok(hr == S_OK, "Failed to get names, hr %#lx.\n", hr);
10083 IDWriteLocalizedStrings_Release(names);
10084
10085 font_count = IDWriteFontFamily_GetFontCount(family);
10086
10087 for (j = 0; j < font_count; ++j)
10088 {
10089 BOOL is_color_font, is_color_face, is_color_expected;
10090 IDWriteFontFace2 *fontface2;
10091 IDWriteFontFace *fontface;
10092 IDWriteFont2 *font2;
10094
10095 hr = IDWriteFontFamily_GetFont(family, j, &font);
10096 ok(hr == S_OK, "Failed to get font, hr %#lx.\n", hr);
10097
10098 hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFont2, (void **)&font2);
10099 ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr);
10100 IDWriteFont_Release(font);
10101
10102 hr = IDWriteFont2_CreateFontFace(font2, &fontface);
10103 ok(hr == S_OK, "Failed to create fontface, hr %#lx.\n", hr);
10104
10105 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace2, (void **)&fontface2);
10106 ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr);
10107 IDWriteFontFace_Release(fontface);
10108
10109 is_color_font = IDWriteFont2_IsColorFont(font2);
10110 is_color_face = IDWriteFontFace2_IsColorFont(fontface2);
10111 ok(is_color_font == is_color_face, "Unexpected color flag.\n");
10112
10113 is_color_expected = get_expected_is_color(fontface2);
10114 ok(is_color_expected == is_color_face, "Unexpected is_color flag %d for %s, font %d.\n",
10115 is_color_face, wine_dbgstr_w(nameW), j);
10116
10117 IDWriteFontFace2_Release(fontface2);
10118 IDWriteFont2_Release(font2);
10119 }
10120
10121 IDWriteFontFamily_Release(family);
10122 }
10123
10124 IDWriteFontCollection_Release(collection);
10125 refcount = IDWriteFactory2_Release(factory);
10126 ok(refcount == 0, "Factory not released, refcount %lu.\n", refcount);
10127}
static BOOL get_expected_is_color(IDWriteFontFace2 *fontface)
Definition: font.c:10026

Referenced by START_TEST().

◆ test_IsMonospacedFont()

static void test_IsMonospacedFont ( void  )
static

Definition at line 5116 of file font.c.

5117{
5120 UINT32 count, i;
5121 HRESULT hr;
5122 ULONG ref;
5123
5124 factory = create_factory_iid(&IID_IDWriteFactory1);
5125
5126 if (!factory)
5127 {
5128 win_skip("IsMonospacedFont() is not supported.\n");
5129 return;
5130 }
5131
5132 hr = IDWriteFactory1_GetSystemFontCollection(factory, &collection, FALSE);
5133 ok(hr == S_OK, "Failed to get font collection, hr %#lx.\n", hr);
5134
5135 count = IDWriteFontCollection_GetFontFamilyCount(collection);
5136 for (i = 0; i < count; ++i)
5137 {
5139 IDWriteFontFamily *family;
5140 UINT32 font_count, j;
5141 WCHAR nameW[256];
5142
5143 hr = IDWriteFontCollection_GetFontFamily(collection, i, &family);
5144 ok(hr == S_OK, "Failed to get family, hr %#lx.\n", hr);
5145
5146 hr = IDWriteFontFamily_GetFamilyNames(family, &names);
5147 ok(hr == S_OK, "Failed to get names, hr %#lx.\n", hr);
5149 IDWriteLocalizedStrings_Release(names);
5150
5151 font_count = IDWriteFontFamily_GetFontCount(family);
5152
5153 for (j = 0; j < font_count; ++j)
5154 {
5155 BOOL is_monospaced_font, is_monospaced_face, is_monospaced_expected;
5156 IDWriteFontFace1 *fontface1;
5157 IDWriteFontFace *fontface;
5158 DWRITE_PANOSE panose;
5159 IDWriteFont1 *font1;
5161
5162 hr = IDWriteFontFamily_GetFont(family, j, &font);
5163 ok(hr == S_OK, "Failed to get font, hr %#lx.\n", hr);
5164
5165 hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFont1, (void **)&font1);
5166 ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr);
5167 IDWriteFont_Release(font);
5168
5169 hr = IDWriteFont1_CreateFontFace(font1, &fontface);
5170 ok(hr == S_OK, "Failed to create fontface, hr %#lx.\n", hr);
5171
5172 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void **)&fontface1);
5173 ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr);
5174 IDWriteFontFace_Release(fontface);
5175
5176 is_monospaced_font = IDWriteFont1_IsMonospacedFont(font1);
5177 is_monospaced_face = IDWriteFontFace1_IsMonospacedFont(fontface1);
5178 ok(is_monospaced_font == is_monospaced_face, "Unexpected monospaced flag.\n");
5179
5180 IDWriteFont1_GetPanose(font1, &panose);
5181
5182 is_monospaced_expected = get_expected_is_monospaced(fontface1, &panose);
5183 ok(is_monospaced_expected == is_monospaced_face, "Unexpected is_monospaced flag %d for %s, font %d.\n",
5184 is_monospaced_face, wine_dbgstr_w(nameW), j);
5185
5186 IDWriteFontFace1_Release(fontface1);
5187 IDWriteFont1_Release(font1);
5188 }
5189
5190 IDWriteFontFamily_Release(family);
5191 }
5192
5193 IDWriteFontCollection_Release(collection);
5194 ref = IDWriteFactory1_Release(factory);
5195 ok(ref == 0, "factory not released, %lu\n", ref);
5196}
static BOOL get_expected_is_monospaced(IDWriteFontFace1 *fontface, const DWRITE_PANOSE *panose)
Definition: font.c:5092

Referenced by START_TEST().

◆ test_IsSymbolFont()

static void test_IsSymbolFont ( void  )
static

Definition at line 7514 of file font.c.

7515{
7517 IDWriteFontFace *fontface;
7520 UINT32 count, i;
7521 HRESULT hr;
7522 ULONG ref;
7523
7525
7526 hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
7527 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7528
7529 count = IDWriteFontCollection_GetFontFamilyCount(collection);
7530 for (i = 0; i < count; ++i)
7531 {
7533 IDWriteFontFamily *family;
7534 UINT32 font_count, j;
7535 WCHAR nameW[256];
7536
7537 hr = IDWriteFontCollection_GetFontFamily(collection, i, &family);
7538 ok(hr == S_OK, "Failed to get family, hr %#lx.\n", hr);
7539
7540 hr = IDWriteFontFamily_GetFamilyNames(family, &names);
7541 ok(hr == S_OK, "Failed to get names, hr %#lx.\n", hr);
7543 IDWriteLocalizedStrings_Release(names);
7544
7545 font_count = IDWriteFontFamily_GetFontCount(family);
7546
7547 for (j = 0; j < font_count; ++j)
7548 {
7549 BOOL is_symbol_font, is_symbol_face, is_symbol_expected;
7550
7551 hr = IDWriteFontFamily_GetFont(family, j, &font);
7552 ok(hr == S_OK, "Failed to get font, hr %#lx.\n", hr);
7553
7554 hr = IDWriteFont_CreateFontFace(font, &fontface);
7555 ok(hr == S_OK, "Failed to create fontface, hr %#lx.\n", hr);
7556
7557 is_symbol_font = IDWriteFont_IsSymbolFont(font);
7558 is_symbol_face = IDWriteFontFace_IsSymbolFont(fontface);
7559 ok(is_symbol_font == is_symbol_face, "Unexpected symbol flag.\n");
7560
7561 is_symbol_expected = get_expected_is_symbol(fontface);
7562 ok(is_symbol_expected == is_symbol_face, "Unexpected is_symbol flag %d for %s, font %d.\n",
7563 is_symbol_face, wine_dbgstr_w(nameW), j);
7564
7565 IDWriteFontFace_Release(fontface);
7566 IDWriteFont_Release(font);
7567 }
7568
7569 IDWriteFontFamily_Release(family);
7570 }
7571
7572 IDWriteFontCollection_Release(collection);
7573
7574 ref = IDWriteFactory_Release(factory);
7575 ok(ref == 0, "factory not released, %lu\n", ref);
7576}
static BOOL get_expected_is_symbol(IDWriteFontFace *fontface)
Definition: font.c:7462

Referenced by START_TEST().

◆ test_localfontfileloader()

static void test_localfontfileloader ( void  )
static

Definition at line 9536 of file font.c.

9537{
9538 IDWriteFontFileLoader *loader, *loader2;
9539 IDWriteFactory *factory, *factory2;
9540 IDWriteFontFile *file, *file2;
9541 WCHAR *path;
9542 HRESULT hr;
9543 ULONG ref;
9544
9546 factory2 = create_factory();
9547
9549
9550 hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
9551 ok(hr == S_OK, "Failed to create file reference, hr %#lx.\n", hr);
9552
9553 hr = IDWriteFactory_CreateFontFileReference(factory2, path, NULL, &file2);
9554 ok(hr == S_OK, "Failed to create file reference, hr %#lx.\n", hr);
9555 ok(file != file2, "Unexpected file instance.\n");
9556
9557 hr = IDWriteFontFile_GetLoader(file, &loader);
9558 ok(hr == S_OK, "Failed to get loader, hr %#lx.\n", hr);
9559
9560 hr = IDWriteFontFile_GetLoader(file2, &loader2);
9561 ok(hr == S_OK, "Failed to get loader, hr %#lx.\n", hr);
9562 ok(loader == loader2, "Unexpected loader instance\n");
9563
9564 IDWriteFontFile_Release(file);
9565 IDWriteFontFile_Release(file2);
9566 IDWriteFontFileLoader_Release(loader);
9567 IDWriteFontFileLoader_Release(loader2);
9568 ref = IDWriteFactory_Release(factory);
9569 ok(ref == 0, "factory not released, %lu\n", ref);
9570 ref = IDWriteFactory_Release(factory2);
9571 ok(ref == 0, "factory not released, %lu\n", ref);
9573}

Referenced by START_TEST().

◆ test_metrics1_cmp()

static void test_metrics1_cmp ( FLOAT  emsize,
const DWRITE_FONT_METRICS1 *  metrics,
const DWRITE_FONT_METRICS1 *  expected 
)
static

Definition at line 6250 of file font.c.

6251{
6252 winetest_push_context("Size %.2f", emsize);
6253
6254 ok(metrics->designUnitsPerEm == expected->designUnitsPerEm, "got %u expect %u.\n",
6255 metrics->designUnitsPerEm, expected->designUnitsPerEm);
6256 ok(metrics->ascent == expected->ascent, "a: got %u expect %u.\n", metrics->ascent, expected->ascent);
6257 ok(metrics->descent == expected->descent, "d: got %u expect %u.\n", metrics->descent, expected->descent);
6258 ok(metrics->lineGap == expected->lineGap, "lg: got %d expect %d.\n", metrics->lineGap, expected->lineGap);
6259 ok(metrics->capHeight == expected->capHeight, "capH: got %u expect %u.\n", metrics->capHeight, expected->capHeight);
6260 ok(metrics->xHeight == expected->xHeight, "xH: got %u expect %u.\n", metrics->xHeight, expected->xHeight);
6261 ok(metrics->underlinePosition == expected->underlinePosition, "ulP: got %d expect %d.\n",
6262 metrics->underlinePosition, expected->underlinePosition);
6263 ok(metrics->underlineThickness == expected->underlineThickness, "ulTh: got %u expect %u.\n",
6264 metrics->underlineThickness, expected->underlineThickness);
6265 ok(metrics->strikethroughPosition == expected->strikethroughPosition, "stP: got %d expect %d.\n",
6266 metrics->strikethroughPosition, expected->strikethroughPosition);
6267 ok(metrics->strikethroughThickness == expected->strikethroughThickness, "stTh: got %u expect %u.\n",
6268 metrics->strikethroughThickness, expected->strikethroughThickness);
6269 ok(metrics->glyphBoxLeft == expected->glyphBoxLeft, "box left: got %d expect %d.\n",
6270 metrics->glyphBoxLeft, expected->glyphBoxLeft);
6271if (0) { /* this is not consistent */
6272 ok(metrics->glyphBoxTop == expected->glyphBoxTop, "box top: got %d expect %d.\n",
6273 metrics->glyphBoxTop, expected->glyphBoxTop);
6274 ok(metrics->glyphBoxRight == expected->glyphBoxRight, "box right: got %d expect %d.\n",
6275 metrics->glyphBoxRight, expected->glyphBoxRight);
6276}
6277 ok(metrics->glyphBoxBottom == expected->glyphBoxBottom, "box bottom: got %d expect %d.\n",
6278 metrics->glyphBoxBottom, expected->glyphBoxBottom);
6279 ok(metrics->subscriptPositionX == expected->subscriptPositionX, "subX: got %d expect %d.\n",
6280 metrics->subscriptPositionX, expected->subscriptPositionX);
6281 ok(metrics->subscriptPositionY == expected->subscriptPositionY, "subY: got %d expect %d.\n",
6282 metrics->subscriptPositionY, expected->subscriptPositionY);
6283 ok(metrics->subscriptSizeX == expected->subscriptSizeX, "subsizeX: got %d expect %d.\n",
6284 metrics->subscriptSizeX, expected->subscriptSizeX);
6285 ok(metrics->subscriptPositionY == expected->subscriptPositionY, "subsizeY: got %d expect %d.\n",
6286 metrics->subscriptSizeY, expected->subscriptSizeY);
6287 ok(metrics->superscriptPositionX == expected->superscriptPositionX, "supX: got %d expect %d.\n",
6288 metrics->superscriptPositionX, expected->superscriptPositionX);
6289 if (0)
6290 ok(metrics->superscriptPositionY == expected->superscriptPositionY, "supY: got %d expect %d.\n",
6291 metrics->superscriptPositionY, expected->superscriptPositionY);
6292 ok(metrics->superscriptSizeX == expected->superscriptSizeX, "supsizeX: got %d expect %d.\n",
6293 metrics->superscriptSizeX, expected->superscriptSizeX);
6294 ok(metrics->superscriptSizeY == expected->superscriptSizeY, "supsizeY: got %d expect %d.\n",
6295 metrics->superscriptSizeY, expected->superscriptSizeY);
6296 ok(metrics->hasTypographicMetrics == expected->hasTypographicMetrics, "hastypo: got %d expect %d.\n",
6297 metrics->hasTypographicMetrics, expected->hasTypographicMetrics);
6298
6300}

Referenced by test_gdicompat_metrics().

◆ test_metrics_cmp()

static void test_metrics_cmp ( FLOAT  emsize,
const DWRITE_FONT_METRICS *  metrics,
const DWRITE_FONT_METRICS1 *  expected 
)
static

Definition at line 6227 of file font.c.

6228{
6229 winetest_push_context("Size %.2f", emsize);
6230
6231 ok(metrics->designUnitsPerEm == expected->designUnitsPerEm, "got %u expect %u.\n",
6232 metrics->designUnitsPerEm, expected->designUnitsPerEm);
6233 ok(metrics->ascent == expected->ascent, "a: got %u expect %u.\n", metrics->ascent, expected->ascent);
6234 ok(metrics->descent == expected->descent, "d: got %u expect %u.\n", metrics->descent, expected->descent);
6235 ok(metrics->lineGap == expected->lineGap, "lg: got %d expect %d.\n", metrics->lineGap, expected->lineGap);
6236 ok(metrics->capHeight == expected->capHeight, "capH: got %u expect %u.\n", metrics->capHeight, expected->capHeight);
6237 ok(metrics->xHeight == expected->xHeight, "xH: got %u expect %u.\n", metrics->xHeight, expected->xHeight);
6238 ok(metrics->underlinePosition == expected->underlinePosition, "ulP: got %d expect %d.\n",
6239 metrics->underlinePosition, expected->underlinePosition);
6240 ok(metrics->underlineThickness == expected->underlineThickness, "ulTh: got %u expect %u.\n",
6241 metrics->underlineThickness, expected->underlineThickness);
6242 ok(metrics->strikethroughPosition == expected->strikethroughPosition, "stP: got %d expect %d.\n",
6243 metrics->strikethroughPosition, expected->strikethroughPosition);
6244 ok(metrics->strikethroughThickness == expected->strikethroughThickness, "stTh: got %u expect %u.\n",
6245 metrics->strikethroughThickness, expected->strikethroughThickness);
6246
6248}

Referenced by test_gdicompat_metrics().

◆ test_object_lifetime()

static void test_object_lifetime ( void  )
static

Definition at line 8775 of file font.c.

8776{
8777 IDWriteFontCollection *collection, *collection2;
8778 IDWriteFontList *fontlist, *fontlist2;
8779 IDWriteGdiInterop *interop, *interop2;
8780 IDWriteFontFamily *family, *family2;
8781 IDWriteFontFace *fontface;
8782 IDWriteFont *font, *font2;
8784 HRESULT hr;
8785 ULONG ref;
8786
8788 EXPECT_REF(factory, 1);
8789
8790 /* system collection takes factory reference */
8791 hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
8792 ok(hr == S_OK, "got %#lx\n", hr);
8793
8795 EXPECT_REF(factory, 2);
8796
8797 hr = IDWriteFactory_GetSystemFontCollection(factory, &collection2, FALSE);
8798 ok(hr == S_OK, "got %#lx\n", hr);
8799 ok(collection2 == collection, "expected same collection\n");
8800
8802 EXPECT_REF(factory, 2);
8803
8804 IDWriteFontCollection_Release(collection2);
8805
8806 IDWriteFontCollection_AddRef(collection);
8808 EXPECT_REF(factory, 2);
8809 IDWriteFontCollection_Release(collection);
8810
8812
8813 /* family takes collection reference */
8814 hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
8815 ok(hr == S_OK, "got %#lx\n", hr);
8816
8817 EXPECT_REF(family, 1);
8819 EXPECT_REF(factory, 2);
8820
8821 hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family2);
8822 ok(hr == S_OK, "got %#lx\n", hr);
8823
8824 EXPECT_REF(family2, 1);
8826 EXPECT_REF(factory, 2);
8827
8828 IDWriteFontFamily_Release(family2);
8829
8830 EXPECT_REF(family, 1);
8832 EXPECT_REF(factory, 2);
8833
8834 /* font takes family reference */
8835 hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
8837 ok(hr == S_OK, "got %#lx\n", hr);
8838
8839 EXPECT_REF(family, 2);
8841 EXPECT_REF(factory, 2);
8842
8843 hr = IDWriteFont_GetFontFamily(font, &family2);
8844 ok(hr == S_OK, "got %#lx\n", hr);
8845 ok(family2 == family, "unexpected family pointer\n");
8846 IDWriteFontFamily_Release(family2);
8847
8848 EXPECT_REF(font, 1);
8849 EXPECT_REF(factory, 2);
8850
8851 /* Fontface takes factory reference and nothing else. */
8852 hr = IDWriteFont_CreateFontFace(font, &fontface);
8853 ok(hr == S_OK, "got %#lx\n", hr);
8854
8855 EXPECT_REF(font, 1);
8856 EXPECT_REF_BROKEN(fontface, 1, 2);
8857 EXPECT_REF(family, 2);
8860
8861 /* get font from fontface */
8862 hr = IDWriteFontCollection_GetFontFromFontFace(collection, fontface, &font2);
8863 ok(hr == S_OK, "got %#lx\n", hr);
8864
8865 EXPECT_REF(font, 1);
8866 EXPECT_REF(font2, 1);
8867 EXPECT_REF_BROKEN(fontface, 1, 2);
8868 EXPECT_REF(family, 2);
8871
8872 IDWriteFont_Release(font2);
8873 IDWriteFontFace_Release(fontface);
8874
8875 EXPECT_REF(font, 1);
8876 EXPECT_REF(family, 2);
8878 EXPECT_REF(factory, 2);
8879
8880 IDWriteFont_Release(font);
8881
8882 EXPECT_REF(family, 1);
8884 EXPECT_REF(factory, 2);
8885
8886 /* Matching fonts list takes family reference. */
8887 hr = IDWriteFontFamily_GetMatchingFonts(family, DWRITE_FONT_WEIGHT_NORMAL,
8889 ok(hr == S_OK, "got %#lx\n", hr);
8890
8891 EXPECT_REF(family, 2);
8893 EXPECT_REF(factory, 2);
8894
8895 hr = IDWriteFontFamily_GetMatchingFonts(family, DWRITE_FONT_WEIGHT_NORMAL,
8897 ok(hr == S_OK, "got %#lx\n", hr);
8898 ok(fontlist2 != fontlist, "unexpected font list\n");
8899 IDWriteFontList_Release(fontlist2);
8900
8901 IDWriteFontList_Release(fontlist);
8902
8903 IDWriteFontFamily_Release(family);
8905
8906 EXPECT_REF(factory, 2);
8907 ref = IDWriteFontCollection_Release(collection);
8908 ok(ref == 0, "collection not released, %lu\n", ref);
8909 EXPECT_REF(factory, 1);
8910
8911 /* GDI interop object takes factory reference */
8912 hr = IDWriteFactory_GetGdiInterop(factory, &interop);
8913 ok(hr == S_OK, "got %#lx\n", hr);
8914 EXPECT_REF(interop, 1);
8915 EXPECT_REF(factory, 2);
8916
8917 hr = IDWriteFactory_GetGdiInterop(factory, &interop2);
8918 ok(hr == S_OK, "got %#lx\n", hr);
8919 ok(interop == interop2, "got unexpected interop pointer\n");
8920
8921 EXPECT_REF(interop, 2);
8922 EXPECT_REF(factory, 2);
8923
8924 IDWriteGdiInterop_Release(interop2);
8925 ref = IDWriteGdiInterop_Release(interop);
8926 ok(ref == 0, "interop not released, %lu\n", ref);
8927
8928 ref = IDWriteFactory_Release(factory);
8929 ok(ref == 0, "factory not released, %lu\n", ref);
8930}
#define EXPECT_REF_BROKEN(obj, ref, brokenref)
Definition: font.c:112

Referenced by START_TEST().

◆ test_ReadFileFragment()

static void test_ReadFileFragment ( void  )
static

Definition at line 4958 of file font.c.

4959{
4960 IDWriteLocalFontFileLoader *localloader;
4965 const void *fragment, *fragment2;
4966 void *key, *context, *context2;
4967 UINT64 filesize;
4968 UINT32 size;
4969 WCHAR *path;
4970 HRESULT hr;
4971 ULONG ref;
4972
4974
4976
4977 hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
4978 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
4979
4980 key = NULL;
4981 size = 0;
4982 hr = IDWriteFontFile_GetReferenceKey(file, (const void**)&key, &size);
4983 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4984 ok(size != 0, "got %u\n", size);
4985
4986 hr = IDWriteFontFile_GetLoader(file, &loader);
4987 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4988 IDWriteFontFileLoader_QueryInterface(loader, &IID_IDWriteLocalFontFileLoader, (void**)&localloader);
4989 IDWriteFontFileLoader_Release(loader);
4990
4991 hr = IDWriteLocalFontFileLoader_CreateStreamFromKey(localloader, key, size, &stream);
4992 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4993
4994 hr = IDWriteFontFileStream_GetFileSize(stream, &filesize);
4995 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4996
4997 /* reading past the end of the stream */
4998 fragment = (void*)0xdeadbeef;
4999 context = (void*)0xdeadbeef;
5000 hr = IDWriteFontFileStream_ReadFileFragment(stream, &fragment, 0, filesize+1, &context);
5001 ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr);
5002 ok(context == NULL, "got %p\n", context);
5003 ok(fragment == NULL, "got %p\n", fragment);
5004
5005 fragment = (void*)0xdeadbeef;
5006 context = (void*)0xdeadbeef;
5007 hr = IDWriteFontFileStream_ReadFileFragment(stream, &fragment, 0, filesize, &context);
5008 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5009 ok(context == NULL, "got %p\n", context);
5010 ok(fragment != NULL, "got %p\n", fragment);
5011
5012 fragment2 = (void*)0xdeadbeef;
5013 context2 = (void*)0xdeadbeef;
5014 hr = IDWriteFontFileStream_ReadFileFragment(stream, &fragment2, 0, filesize, &context2);
5015 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5016 ok(context2 == NULL, "got %p\n", context2);
5017 ok(fragment == fragment2, "got %p, %p\n", fragment, fragment2);
5018
5019 IDWriteFontFileStream_ReleaseFileFragment(stream, context);
5020 IDWriteFontFileStream_ReleaseFileFragment(stream, context2);
5021
5022 /* fragment is released, try again */
5023 fragment = (void*)0xdeadbeef;
5024 context = (void*)0xdeadbeef;
5025 hr = IDWriteFontFileStream_ReadFileFragment(stream, &fragment, 0, filesize, &context);
5026 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
5027 ok(context == NULL, "got %p\n", context);
5028 ok(fragment == fragment2, "got %p, %p\n", fragment, fragment2);
5029 IDWriteFontFileStream_ReleaseFileFragment(stream, context);
5030
5031 IDWriteFontFile_Release(file);
5032 IDWriteFontFileStream_Release(stream);
5033 IDWriteLocalFontFileLoader_Release(localloader);
5034 ref = IDWriteFactory_Release(factory);
5035 ok(ref == 0, "factory not released, %lu\n", ref);
5037}

Referenced by START_TEST().

◆ test_shared_isolated()

static void test_shared_isolated ( void  )
static

Definition at line 3476 of file font.c.

3477{
3478 IDWriteFactory *isolated, *isolated2;
3479 IDWriteFactory *shared, *shared2;
3480 HRESULT hr;
3481 ULONG ref;
3482
3483 /* invalid type */
3484 shared = NULL;
3485 hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED+1, &IID_IDWriteFactory, (IUnknown**)&shared);
3486 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3487 ok(shared != NULL, "got %p\n", shared);
3488 IDWriteFactory_Release(shared);
3489
3490 hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, &IID_IDWriteFactory, (IUnknown**)&shared);
3491 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3492
3493 hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, &IID_IDWriteFactory, (IUnknown**)&shared2);
3494 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3495 ok(shared == shared2, "got %p, and %p\n", shared, shared2);
3496 IDWriteFactory_Release(shared2);
3497
3498 IDWriteFactory_Release(shared);
3499
3500 /* we got 2 references, released 2 - still same pointer is returned */
3501 hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, &IID_IDWriteFactory, (IUnknown**)&shared2);
3502 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3503 ok(shared == shared2, "got %p, and %p\n", shared, shared2);
3504 IDWriteFactory_Release(shared2);
3505
3506 hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, &IID_IDWriteFactory, (IUnknown**)&isolated);
3507 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3508
3509 hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, &IID_IDWriteFactory, (IUnknown**)&isolated2);
3510 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3511 ok(isolated != isolated2, "got %p, and %p\n", isolated, isolated2);
3512 IDWriteFactory_Release(isolated2);
3513
3515 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3516 IDWriteFactory_Release(isolated2);
3517
3518 hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED+1, &IID_IDWriteFactory, (IUnknown**)&isolated2);
3519 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
3520 ok(shared != isolated2, "got %p, and %p\n", shared, isolated2);
3521
3522 ref = IDWriteFactory_Release(isolated);
3523 ok(ref == 0, "factory not released, %lu\n", ref);
3524 ref = IDWriteFactory_Release(isolated2);
3525 ok(ref == 0, "factory not released, %lu\n", ref);
3526}
@ DWRITE_FACTORY_TYPE_SHARED
Definition: dwrite.idl:42

Referenced by START_TEST().

◆ test_system_font_set()

static void test_system_font_set ( void  )
static

Definition at line 10317 of file font.c.

10318{
10319 IDWriteFontSet *fontset, *filtered_set;
10321 IDWriteFontFace3 *fontface;
10322 IDWriteFactory3 *factory;
10324 unsigned int count;
10325 HRESULT hr;
10326
10327 if (!(factory = create_factory_iid(&IID_IDWriteFactory3)))
10328 {
10329 win_skip("System font set is not supported.\n");
10330 return;
10331 }
10332
10333 hr = IDWriteFactory3_GetSystemFontSet(factory, &fontset);
10334 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10335
10336 count = IDWriteFontSet_GetFontCount(fontset);
10337 ok(!!count, "Unexpected font count %u.\n", count);
10338
10340 p.propertyValue = L"Tahoma";
10341 p.localeName = L"";
10342 hr = IDWriteFontSet_GetMatchingFonts(fontset, &p, 1, &filtered_set);
10343 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10344 count = IDWriteFontSet_GetFontCount(filtered_set);
10345 ok(!!count, "Unexpected font count %u.\n", count);
10346
10347 hr = IDWriteFontSet_GetFontFaceReference(filtered_set, 0, &ref);
10348 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10349
10350 hr = IDWriteFontFaceReference_CreateFontFace(ref, &fontface);
10351 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
10352
10353 IDWriteFontFace3_Release(fontface);
10354 IDWriteFontFaceReference_Release(ref);
10355
10356 IDWriteFontSet_Release(filtered_set);
10357
10358 IDWriteFontSet_Release(fontset);
10359
10360 IDWriteFactory3_Release(factory);
10361}
@ DWRITE_FONT_PROPERTY_ID_FULL_NAME
Definition: dwrite_3.idl:94
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by START_TEST().

◆ test_system_fontcollection()

static void test_system_fontcollection ( void  )
static

Definition at line 2463 of file font.c.

2464{
2466 IDWriteLocalFontFileLoader *localloader;
2467 IDWriteFontCollection1 *collection1;
2468 IDWriteFontCollection2 *collection2;
2469 IDWriteFontCollection3 *collection3;
2470 IDWriteFactory *factory, *factory2;
2472 IDWriteFontFamily *family;
2473 IDWriteFontFace *fontface;
2474 IDWriteFactory6 *factory6;
2477 HRESULT hr;
2478 ULONG ref;
2479 UINT32 i;
2480 BOOL ret;
2481
2483
2484 hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
2485 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2486
2487 hr = IDWriteFactory_GetSystemFontCollection(factory, &coll2, FALSE);
2488 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2489 ok(coll2 == collection, "got %p, was %p\n", coll2, collection);
2490 IDWriteFontCollection_Release(coll2);
2491
2492 factory2 = create_factory();
2493 hr = IDWriteFactory_GetSystemFontCollection(factory2, &coll2, FALSE);
2494 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2495 ok(coll2 != collection, "got %p, was %p\n", coll2, collection);
2496 IDWriteFontCollection_Release(coll2);
2497 IDWriteFactory_Release(factory2);
2498
2499 i = IDWriteFontCollection_GetFontFamilyCount(collection);
2500 ok(i, "got %u\n", i);
2501
2502 /* invalid index */
2503 family = (void*)0xdeadbeef;
2504 hr = IDWriteFontCollection_GetFontFamily(collection, i, &family);
2505 ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr);
2506 ok(family == NULL, "got %p\n", family);
2507
2508 ret = FALSE;
2509 i = (UINT32)-1;
2510 hr = IDWriteFontCollection_FindFamilyName(collection, L"Tahoma", &i, &ret);
2511 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2512 ok(ret, "got %d\n", ret);
2513 ok(i != (UINT32)-1, "got %u\n", i);
2514
2515 ret = FALSE;
2516 i = (UINT32)-1;
2517 hr = IDWriteFontCollection_FindFamilyName(collection, L"TAHOMA", &i, &ret);
2518 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2519 ok(ret, "got %d\n", ret);
2520 ok(i != (UINT32)-1, "got %u\n", i);
2521
2522 ret = FALSE;
2523 i = (UINT32)-1;
2524 hr = IDWriteFontCollection_FindFamilyName(collection, L"tAhOmA", &i, &ret);
2525 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2526 ok(ret, "got %d\n", ret);
2527 ok(i != (UINT32)-1, "got %u\n", i);
2528
2529 /* get back local file loader */
2530 hr = IDWriteFontCollection_GetFontFamily(collection, i, &family);
2531 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2532
2533 hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
2535 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2536 IDWriteFontFamily_Release(family);
2537
2538 hr = IDWriteFont_CreateFontFace(font, &fontface);
2539 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2540 IDWriteFont_Release(font);
2541
2542 i = 1;
2543 file = NULL;
2544 hr = IDWriteFontFace_GetFiles(fontface, &i, &file);
2545 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2546 ok(file != NULL, "got %p\n", file);
2547 IDWriteFontFace_Release(fontface);
2548
2549 hr = IDWriteFontFile_GetLoader(file, &loader);
2550 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2551 IDWriteFontFile_Release(file);
2552
2553 hr = IDWriteFontFileLoader_QueryInterface(loader, &IID_IDWriteLocalFontFileLoader, (void**)&localloader);
2554 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2555 IDWriteLocalFontFileLoader_Release(localloader);
2556
2557 /* local loader is not registered by default */
2558 hr = IDWriteFactory_RegisterFontFileLoader(factory, loader);
2559 ok(hr == S_OK || broken(hr == DWRITE_E_ALREADYREGISTERED), "Unexpected hr %#lx.\n", hr);
2560 hr = IDWriteFactory_UnregisterFontFileLoader(factory, loader);
2561 ok(hr == S_OK || broken(hr == E_INVALIDARG), "Unexpected hr %#lx.\n", hr);
2562
2563 /* try with a different factory */
2564 factory2 = create_factory();
2565 hr = IDWriteFactory_RegisterFontFileLoader(factory2, loader);
2566 ok(hr == S_OK || broken(hr == DWRITE_E_ALREADYREGISTERED), "Unexpected hr %#lx.\n", hr);
2567 hr = IDWriteFactory_RegisterFontFileLoader(factory2, loader);
2568 ok(hr == DWRITE_E_ALREADYREGISTERED, "Unexpected hr %#lx.\n", hr);
2569 hr = IDWriteFactory_UnregisterFontFileLoader(factory2, loader);
2570 ok(hr == S_OK || broken(hr == E_INVALIDARG), "Unexpected hr %#lx.\n", hr);
2571 hr = IDWriteFactory_UnregisterFontFileLoader(factory2, loader);
2572 ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
2573 IDWriteFactory_Release(factory2);
2574
2575 IDWriteFontFileLoader_Release(loader);
2576
2577 ret = TRUE;
2578 i = 0;
2579 hr = IDWriteFontCollection_FindFamilyName(collection, L"Blah!", &i, &ret);
2580 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2581 ok(!ret, "got %d\n", ret);
2582 ok(i == (UINT32)-1, "got %u\n", i);
2583
2584 hr = IDWriteFontCollection_QueryInterface(collection, &IID_IDWriteFontCollection1, (void**)&collection1);
2585 if (hr == S_OK) {
2586 IDWriteFontSet *fontset, *fontset2;
2587 IDWriteFontFamily1 *family1;
2588 IDWriteFactory3 *factory3;
2589
2590 hr = IDWriteFontCollection1_QueryInterface(collection1, &IID_IDWriteFontCollection, (void**)&coll2);
2591 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2592 ok(coll2 == collection, "got %p, %p\n", collection, coll2);
2593 IDWriteFontCollection_Release(coll2);
2594
2595 family1 = (void*)0xdeadbeef;
2596 hr = IDWriteFontCollection1_GetFontFamily(collection1, ~0u, &family1);
2597 ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr);
2598 ok(family1 == NULL, "got %p\n", family1);
2599
2600 hr = IDWriteFontCollection1_GetFontFamily(collection1, 0, &family1);
2601 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
2602 IDWriteFontFamily1_Release(family1);
2603
2604 /* system fontset */
2605 EXPECT_REF(collection1, 2);
2606 EXPECT_REF(factory, 2);
2607 hr = IDWriteFontCollection1_GetFontSet(collection1, &fontset);
2608 todo_wine
2609 ok(hr == S_OK, "Failed to get fontset, hr %#lx.\n", hr);
2610 if (hr == S_OK) {
2611 EXPECT_REF(collection1, 2);
2612 EXPECT_REF(factory, 2);
2613 EXPECT_REF(fontset, 1);
2614
2615 hr = IDWriteFontCollection1_GetFontSet(collection1, &fontset2);
2616 ok(hr == S_OK, "Failed to get fontset, hr %#lx.\n", hr);
2617 ok(fontset != fontset2, "Expected new fontset instance.\n");
2618 EXPECT_REF(fontset2, 1);
2619 IDWriteFontSet_Release(fontset2);
2620
2621 hr = IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory3, (void **)&factory3);
2622 ok(hr == S_OK, "Failed to get IDWriteFactory3 interface, hr %#lx.\n", hr);
2623
2624 EXPECT_REF(factory, 3);
2625 hr = IDWriteFactory3_GetSystemFontSet(factory3, &fontset2);
2626 ok(hr == S_OK, "Failed to get system font set, hr %#lx.\n", hr);
2627 ok(fontset != fontset2, "Expected new fontset instance.\n");
2628 EXPECT_REF(fontset2, 1);
2629 EXPECT_REF(factory, 4);
2630
2631 IDWriteFontSet_Release(fontset2);
2632 IDWriteFontSet_Release(fontset);
2633
2634 IDWriteFactory3_Release(factory3);
2635 }
2636 IDWriteFontCollection1_Release(collection1);
2637 }
2638 else
2639 win_skip("IDWriteFontCollection1 is not supported.\n");
2640
2641 hr = IDWriteFontCollection_QueryInterface(collection, &IID_IDWriteFontCollection3, (void **)&collection3);
2642 if (SUCCEEDED(hr))
2643 {
2644 HANDLE event;
2645
2646 event = IDWriteFontCollection3_GetExpirationEvent(collection3);
2647 todo_wine
2648 ok(!!event, "Expected event handle.\n");
2649
2651
2652 IDWriteFontCollection3_Release(collection3);
2653 }
2654 else
2655 win_skip("IDWriteFontCollection3 is not supported.\n");
2656
2657 /* With specified family model. */
2658 hr = IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory6, (void **)&factory6);
2659 if (SUCCEEDED(hr))
2660 {
2662
2663 hr = IDWriteFactory6_GetSystemFontCollection(factory6, FALSE, DWRITE_FONT_FAMILY_MODEL_TYPOGRAPHIC,
2664 &collection2);
2665 ok(hr == S_OK, "Failed to get collection, hr %#lx.\n", hr);
2666
2667 hr = IDWriteFactory6_GetSystemFontCollection(factory6, FALSE, DWRITE_FONT_FAMILY_MODEL_TYPOGRAPHIC, &c2);
2668 ok(hr == S_OK, "Failed to get collection, hr %#lx.\n", hr);
2669 ok(c2 == collection2 && collection != (IDWriteFontCollection *)c2, "Unexpected collection instance.\n");
2670 IDWriteFontCollection2_Release(c2);
2671 IDWriteFontCollection2_Release(collection2);
2672
2673 hr = IDWriteFactory6_GetSystemFontCollection(factory6, FALSE, DWRITE_FONT_FAMILY_MODEL_WEIGHT_STRETCH_STYLE,
2674 &collection2);
2675 ok(hr == S_OK, "Failed to get collection, hr %#lx.\n", hr);
2676 IDWriteFontCollection2_Release(collection2);
2677 IDWriteFactory6_Release(factory6);
2678 }
2679 else
2680 win_skip("IDWriteFactory6 is not supported.\n");
2681
2682 ref = IDWriteFontCollection_Release(collection);
2683 ok(!ref, "Collection wasn't released, %lu.\n", ref);
2684 ref = IDWriteFactory_Release(factory);
2685 ok(!ref, "Factory wasn't released, %lu.\n", ref);
2686}
@ DWRITE_FONT_FAMILY_MODEL_TYPOGRAPHIC
Definition: dwrite_3.idl:170

Referenced by START_TEST().

◆ test_TranslateColorGlyphRun()

static void test_TranslateColorGlyphRun ( void  )
static

Definition at line 7681 of file font.c.

7682{
7685 const DWRITE_COLOR_GLYPH_RUN1 *colorrun1;
7686 const DWRITE_COLOR_GLYPH_RUN *colorrun;
7687 IDWriteFontFace2 *fontface2;
7688 IDWriteFontFace *fontface;
7689 IDWriteFactory4 *factory4;
7691 DWRITE_GLYPH_RUN run;
7692 UINT32 codepoints[2];
7694 UINT16 glyphs[2];
7695 BOOL hasrun;
7696 HRESULT hr;
7697 ULONG ref;
7698
7699 factory = create_factory_iid(&IID_IDWriteFactory2);
7700 if (!factory) {
7701 win_skip("TranslateColorGlyphRun() is not supported.\n");
7702 return;
7703 }
7704
7705 /* Tahoma, no color support */
7706 fontface = create_fontface((IDWriteFactory *)factory);
7707
7708 codepoints[0] = 'A';
7709 hr = IDWriteFontFace_GetGlyphIndices(fontface, codepoints, 1, glyphs);
7710 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7711
7712 run.fontFace = fontface;
7713 run.fontEmSize = 20.0f;
7714 run.glyphCount = 1;
7715 run.glyphIndices = glyphs;
7716 run.glyphAdvances = NULL;
7717 run.glyphOffsets = NULL;
7718 run.isSideways = FALSE;
7719 run.bidiLevel = 0;
7720
7721 layers = (void*)0xdeadbeef;
7722 hr = IDWriteFactory2_TranslateColorGlyphRun(factory, 0.0f, 0.0f, &run, NULL,
7723 DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers);
7724 ok(hr == DWRITE_E_NOCOLOR, "Unexpected hr %#lx.\n", hr);
7725 ok(layers == NULL, "got %p\n", layers);
7726 IDWriteFontFace_Release(fontface);
7727
7728 /* Segoe UI Emoji, with color support */
7730 if (!font) {
7731 IDWriteFactory2_Release(factory);
7732 skip("Segoe UI Emoji font not found.\n");
7733 return;
7734 }
7735
7736 hr = IDWriteFont_CreateFontFace(font, &fontface);
7737 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7738 IDWriteFont_Release(font);
7739
7740 codepoints[0] = 0x26c4;
7741 hr = IDWriteFontFace_GetGlyphIndices(fontface, codepoints, 1, glyphs);
7742 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7743
7744 run.fontFace = fontface;
7745
7746 layers = NULL;
7747 hr = IDWriteFactory2_TranslateColorGlyphRun(factory, 0.0f, 0.0f, &run, NULL,
7748 DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers);
7749 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7750 ok(layers != NULL, "got %p\n", layers);
7751
7752 hr = IDWriteColorGlyphRunEnumerator_QueryInterface(layers, &IID_IDWriteColorGlyphRunEnumerator1, (void **)&layers1);
7753 if (FAILED(hr))
7754 {
7755 layers1 = NULL;
7756 win_skip("IDWriteColorGlyphRunEnumerator1 is not supported.\n");
7757 }
7758
7759 for (;;)
7760 {
7761 hasrun = FALSE;
7762 hr = IDWriteColorGlyphRunEnumerator_MoveNext(layers, &hasrun);
7763 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7764
7765 if (!hasrun)
7766 break;
7767
7768 hr = IDWriteColorGlyphRunEnumerator_GetCurrentRun(layers, &colorrun);
7769 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7770 ok(colorrun->glyphRun.fontFace == fontface, "Unexpected fontface %p.\n", colorrun->glyphRun.fontFace);
7771 ok(colorrun->glyphRun.fontEmSize == 20.0f, "got wrong font size %f\n", colorrun->glyphRun.fontEmSize);
7772 ok(colorrun->glyphRun.glyphCount == 1, "Unexpected glyph count %u.\n", colorrun->glyphRun.glyphCount);
7773 ok(colorrun->glyphRun.glyphIndices != NULL, "got null glyph indices %p\n", colorrun->glyphRun.glyphIndices);
7774 ok(colorrun->glyphRun.glyphAdvances != NULL, "got null glyph advances %p\n", colorrun->glyphRun.glyphAdvances);
7775 ok(!colorrun->glyphRunDescription, "Unexpected description pointer.\n");
7776
7777 if (layers1)
7778 {
7779 hr = IDWriteColorGlyphRunEnumerator1_GetCurrentRun(layers1, &colorrun1);
7780 ok(hr == S_OK, "Failed to get color runt, hr %#lx.\n", hr);
7781 ok((const DWRITE_COLOR_GLYPH_RUN *)colorrun1 == colorrun, "Unexpected pointer.\n");
7784 "Unexpected glyph image format %#x.\n", colorrun1->glyphImageFormat);
7785 ok(colorrun1->measuringMode == DWRITE_MEASURING_MODE_NATURAL, "Unexpected measuring mode %d.\n",
7786 colorrun1->measuringMode);
7787 }
7788 }
7789
7790 /* iterated all way through */
7791 hr = IDWriteColorGlyphRunEnumerator_GetCurrentRun(layers, &colorrun);
7792 ok(hr == E_NOT_VALID_STATE, "Unexpected hr %#lx.\n", hr);
7793
7794 if (layers1)
7795 {
7796 hr = IDWriteColorGlyphRunEnumerator1_GetCurrentRun(layers1, &colorrun1);
7797 ok(hr == E_NOT_VALID_STATE, "Unexpected hr %#lx.\n", hr);
7798 }
7799
7800 IDWriteColorGlyphRunEnumerator_Release(layers);
7801 if (layers1)
7802 IDWriteColorGlyphRunEnumerator1_Release(layers1);
7803
7804 hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace2, (void**)&fontface2);
7805 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7806
7807 /* invalid palette index */
7808 layers = (void*)0xdeadbeef;
7809 hr = IDWriteFactory2_TranslateColorGlyphRun(factory, 0.0f, 0.0f, &run, NULL,
7810 DWRITE_MEASURING_MODE_NATURAL, NULL, IDWriteFontFace2_GetColorPaletteCount(fontface2),
7811 &layers);
7812 ok(hr == DWRITE_E_NOCOLOR, "Unexpected hr %#lx.\n", hr);
7813 ok(layers == NULL, "got %p\n", layers);
7814
7815 layers = NULL;
7816 hr = IDWriteFactory2_TranslateColorGlyphRun(factory, 0.0f, 0.0f, &run, NULL,
7817 DWRITE_MEASURING_MODE_NATURAL, NULL, IDWriteFontFace2_GetColorPaletteCount(fontface2) - 1,
7818 &layers);
7819 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7820 IDWriteColorGlyphRunEnumerator_Release(layers);
7821
7822 /* color font, glyph without color info */
7823 codepoints[0] = 'A';
7824 hr = IDWriteFontFace_GetGlyphIndices(fontface, codepoints, 1, glyphs);
7825 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7826 ok(!!*glyphs, "Unexpected glyph.\n");
7827
7828 layers = (void*)0xdeadbeef;
7829 hr = IDWriteFactory2_TranslateColorGlyphRun(factory, 0.0f, 0.0f, &run, NULL,
7830 DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers);
7831 ok(hr == DWRITE_E_NOCOLOR, "Unexpected hr %#lx.\n", hr);
7832 ok(layers == NULL, "got %p\n", layers);
7833
7834 /* one glyph with, one without */
7835 codepoints[0] = 'A';
7836 codepoints[1] = 0x26c4;
7837
7838 hr = IDWriteFontFace_GetGlyphIndices(fontface, codepoints, 2, glyphs);
7839 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7840
7841 run.glyphCount = 2;
7842
7843 layers = NULL;
7844 hr = IDWriteFactory2_TranslateColorGlyphRun(factory, 0.0f, 0.0f, &run, NULL,
7845 DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers);
7846 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7847 ok(layers != NULL, "got %p\n", layers);
7848
7849 hr = IDWriteColorGlyphRunEnumerator_QueryInterface(layers, &IID_IDWriteColorGlyphRunEnumerator1, (void **)&layers1);
7850 if (SUCCEEDED(hr))
7851 {
7852 for (;;)
7853 {
7854 hasrun = FALSE;
7855 hr = IDWriteColorGlyphRunEnumerator1_MoveNext(layers1, &hasrun);
7856 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7857
7858 if (!hasrun)
7859 break;
7860
7861 hr = IDWriteColorGlyphRunEnumerator1_GetCurrentRun(layers1, &colorrun1);
7862 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7863 ok(!!colorrun1->glyphRun.fontFace, "Unexpected fontface %p.\n", colorrun1->glyphRun.fontFace);
7864 ok(colorrun1->glyphRun.fontEmSize == 20.0f, "got wrong font size %f\n", colorrun1->glyphRun.fontEmSize);
7865 ok(colorrun1->glyphRun.glyphCount > 0, "Unexpected glyph count %u.\n", colorrun1->glyphRun.glyphCount);
7866 ok(!!colorrun1->glyphRun.glyphIndices, "Unexpected indices %p.\n", colorrun1->glyphRun.glyphIndices);
7867 ok(!!colorrun1->glyphRun.glyphAdvances, "Unexpected advances %p.\n", colorrun1->glyphRun.glyphAdvances);
7868 ok(!colorrun1->glyphRunDescription, "Unexpected description pointer.\n");
7869 todo_wine
7871 colorrun1->glyphImageFormat == DWRITE_GLYPH_IMAGE_FORMATS_TRUETYPE, "Unexpected glyph image format %#x.\n",
7872 colorrun1->glyphImageFormat);
7873 ok(colorrun1->measuringMode == DWRITE_MEASURING_MODE_NATURAL, "Unexpected measuring mode %d.\n",
7874 colorrun1->measuringMode);
7875 }
7876
7877 IDWriteColorGlyphRunEnumerator1_Release(layers1);
7878 }
7879 IDWriteColorGlyphRunEnumerator_Release(layers);
7880
7881 if (SUCCEEDED(IDWriteFactory2_QueryInterface(factory, &IID_IDWriteFactory4, (void **)&factory4)))
7882 {
7884
7885 origin.x = origin.y = 0.0f;
7886 hr = IDWriteFactory4_TranslateColorGlyphRun(factory4, origin, &run, NULL,
7888 ok(hr == DWRITE_E_NOCOLOR, "Unexpected hr %#lx.\n", hr);
7889
7890 hr = IDWriteFactory4_TranslateColorGlyphRun(factory4, origin, &run, NULL,
7892 ok(hr == DWRITE_E_NOCOLOR, "Unexpected hr %#lx.\n", hr);
7893
7894 hr = IDWriteFactory4_TranslateColorGlyphRun(factory4, origin, &run, NULL,
7896 ok(hr == DWRITE_E_NOCOLOR, "Unexpected hr %#lx.\n", hr);
7897
7898 hr = IDWriteFactory4_TranslateColorGlyphRun(factory4, origin, &run, NULL,
7900 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7901
7902 for (;;)
7903 {
7904 hasrun = FALSE;
7905 hr = IDWriteColorGlyphRunEnumerator1_MoveNext(layers1, &hasrun);
7906 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7907
7908 if (!hasrun)
7909 break;
7910
7911 hr = IDWriteColorGlyphRunEnumerator1_GetCurrentRun(layers1, &colorrun1);
7912 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
7913 ok(!!colorrun1->glyphRun.fontFace, "Unexpected fontface %p.\n", colorrun1->glyphRun.fontFace);
7914 ok(colorrun1->glyphRun.fontEmSize == 20.0f, "got wrong font size %f\n", colorrun1->glyphRun.fontEmSize);
7915 ok(colorrun1->glyphRun.glyphCount > 0, "Unexpected glyph count %u.\n", colorrun1->glyphRun.glyphCount);
7916 ok(!!colorrun1->glyphRun.glyphIndices, "Unexpected indices %p.\n", colorrun1->glyphRun.glyphIndices);
7917 ok(!!colorrun1->glyphRun.glyphAdvances, "Unexpected advances %p.\n", colorrun1->glyphRun.glyphAdvances);
7918 ok(!colorrun1->glyphRunDescription, "Unexpected description pointer.\n");
7920 colorrun1->glyphImageFormat == DWRITE_GLYPH_IMAGE_FORMATS_NONE, "Unexpected glyph image format %#x.\n",
7921 colorrun1->glyphImageFormat);
7922 ok(colorrun1->measuringMode == DWRITE_MEASURING_MODE_NATURAL, "Unexpected measuring mode %d.\n",
7923 colorrun1->measuringMode);
7924 }
7925
7926 IDWriteColorGlyphRunEnumerator1_Release(layers1);
7927
7928 IDWriteFactory4_Release(factory4);
7929 }
7930 else
7931 win_skip("IDWriteFactory4::TranslateColorGlyphRun() is not supported.\n");
7932
7933 IDWriteFontFace2_Release(fontface2);
7934 IDWriteFontFace_Release(fontface);
7935 ref = IDWriteFactory2_Release(factory);
7936 ok(ref == 0, "factory not released, %lu\n", ref);
7937}
DWRITE_GLYPH_IMAGE_FORMATS glyphImageFormat
Definition: dwrite_3.idl:1289
DWRITE_MEASURING_MODE measuringMode
Definition: dwrite_3.idl:1290
DWRITE_GLYPH_RUN glyphRun
Definition: dwrite_3.idl:1280
DWRITE_GLYPH_RUN_DESCRIPTION * glyphRunDescription
Definition: dwrite_3.idl:1281
DWRITE_GLYPH_RUN glyphRun
Definition: dwrite_2.idl:77
DWRITE_GLYPH_RUN_DESCRIPTION * glyphRunDescription
Definition: dwrite_2.idl:78
#define E_NOT_VALID_STATE
Definition: winerror.h:3438

Referenced by START_TEST().

◆ test_TryGetFontTable()

static void test_TryGetFontTable ( void  )
static

Definition at line 4670 of file font.c.

4671{
4672 IDWriteLocalFontFileLoader *localloader;
4674 const struct local_refkey *key;
4676 const void *table, *table2;
4677 IDWriteFontFace *fontface;
4678 void *context, *context2;
4681 WCHAR buffW[MAX_PATH];
4682 BOOL exists, ret;
4683 UINT32 size, len;
4684 WCHAR *path;
4685 HRESULT hr;
4686 ULONG ref;
4687
4689
4691
4692 hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &file);
4693 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
4694
4695 key = NULL;
4696 size = 0;
4697 hr = IDWriteFontFile_GetReferenceKey(file, (const void**)&key, &size);
4698 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4699 ok(size != 0, "got %u\n", size);
4700
4702 ok(ret, "got %d\n", ret);
4703 ok(!memcmp(&info.ftLastWriteTime, &key->writetime, sizeof(key->writetime)), "got wrong write time\n");
4704
4705 hr = IDWriteFontFile_GetLoader(file, &loader);
4706 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4707 IDWriteFontFileLoader_QueryInterface(loader, &IID_IDWriteLocalFontFileLoader, (void**)&localloader);
4708 IDWriteFontFileLoader_Release(loader);
4709
4710 hr = IDWriteLocalFontFileLoader_GetFilePathLengthFromKey(localloader, key, size, &len);
4711 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4712 ok(lstrlenW(key->name) == len, "path length %d\n", len);
4713
4714 hr = IDWriteLocalFontFileLoader_GetFilePathFromKey(localloader, key, size, buffW, ARRAY_SIZE(buffW));
4715 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4716 ok(!lstrcmpW(buffW, key->name), "got %s, expected %s\n", wine_dbgstr_w(buffW), wine_dbgstr_w(key->name));
4717 IDWriteLocalFontFileLoader_Release(localloader);
4718
4719 hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file, 0, 0, &fontface);
4720 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
4721
4722 exists = FALSE;
4723 context = (void*)0xdeadbeef;
4724 table = NULL;
4725 hr = IDWriteFontFace_TryGetFontTable(fontface, MS_CMAP_TAG, &table, &size, &context, &exists);
4726 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
4727 ok(exists == TRUE, "got %d\n", exists);
4728 ok(context == NULL && table != NULL, "cmap: context %p, table %p\n", context, table);
4729
4730 exists = FALSE;
4731 context2 = (void*)0xdeadbeef;
4732 table2 = NULL;
4733 hr = IDWriteFontFace_TryGetFontTable(fontface, MS_CMAP_TAG, &table2, &size, &context2, &exists);
4734 ok(hr == S_OK, "Unexpected hr %#lx.\n",hr);
4735 ok(exists == TRUE, "got %d\n", exists);
4736 ok(context2 == context && table2 == table, "cmap: context2 %p, table2 %p\n", context2, table2);
4737
4738 IDWriteFontFace_ReleaseFontTable(fontface, context2);
4739 IDWriteFontFace_ReleaseFontTable(fontface, context);
4740
4741 /* table does not exist */
4742 exists = TRUE;
4743 context = (void*)0xdeadbeef;
4744 table = (void*)0xdeadbeef;
4745 hr = IDWriteFontFace_TryGetFontTable(fontface, 0xabababab, &table, &size, &context, &exists);
4746 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
4747 ok(exists == FALSE, "got %d\n", exists);
4748 ok(context == NULL && table == NULL, "got context %p, table pointer %p\n", context, table);
4749
4750 IDWriteFontFace_Release(fontface);
4751 IDWriteFontFile_Release(file);
4752 ref = IDWriteFactory_Release(factory);
4753 ok(ref == 0, "factory not released, %lu\n", ref);
4755}
#define lstrlenW
Definition: compat.h:750
BOOL WINAPI GetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation)
Definition: fileinfo.c:536
@ GetFileExInfoStandard
Definition: minwinbase.h:356
WCHAR * name
Definition: path.c:43

Referenced by START_TEST().

◆ testowner_AddRef()

static ULONG WINAPI testowner_AddRef ( IUnknown *  iface)
static

Definition at line 8955 of file font.c.

8956{
8957 struct testowner_object *object = impl_from_IUnknown(iface);
8958 return InterlockedIncrement(&object->ref);
8959}
static struct testowner_object * impl_from_IUnknown(IUnknown *iface)
Definition: font.c:8938

◆ testowner_init()

static void testowner_init ( struct testowner_object *  object)
static

Definition at line 8973 of file font.c.

8974{
8975 object->IUnknown_iface.lpVtbl = &testownervtbl;
8976 object->ref = 1;
8977}
static const IUnknownVtbl testownervtbl
Definition: font.c:8967

Referenced by test_inmemory_file_loader().

◆ testowner_QueryInterface()

static HRESULT WINAPI testowner_QueryInterface ( IUnknown *  iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 8943 of file font.c.

8944{
8945 if (IsEqualIID(riid, &IID_IUnknown)) {
8946 *obj = iface;
8947 IUnknown_AddRef(iface);
8948 return S_OK;
8949 }
8950
8951 *obj = NULL;
8952 return E_NOINTERFACE;
8953}

◆ testowner_Release()

static ULONG WINAPI testowner_Release ( IUnknown *  iface)
static

Definition at line 8961 of file font.c.

8962{
8963 struct testowner_object *object = impl_from_IUnknown(iface);
8964 return InterlockedDecrement(&object->ref);
8965}

Variable Documentation

◆ compatmetrics_tests

struct compatmetrics_test compatmetrics_tests[]
static
Initial value:
= {
{ { 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 },
}

Definition at line 6308 of file font.c.

Referenced by test_gdicompat_metrics().

◆ dwritefontcollectionloadervtbl

const struct IDWriteFontCollectionLoaderVtbl dwritefontcollectionloadervtbl
static
Initial value:
= {
}
static HRESULT WINAPI fontcollectionloader_CreateEnumeratorFromKey(IDWriteFontCollectionLoader *iface, IDWriteFactory *factory, const void *key, UINT32 key_size, IDWriteFontFileEnumerator **ret)
Definition: font.c:3002
static ULONG WINAPI fontcollectionloader_AddRef(IDWriteFontCollectionLoader *iface)
Definition: font.c:2985
static HRESULT WINAPI fontcollectionloader_QueryInterface(IDWriteFontCollectionLoader *iface, REFIID riid, void **obj)
Definition: font.c:2969
static ULONG WINAPI fontcollectionloader_Release(IDWriteFontCollectionLoader *iface)
Definition: font.c:2991

Definition at line 3010 of file font.c.

Referenced by create_collection_loader().

◆ dwritefontfileenumeratorvtbl

const struct IDWriteFontFileEnumeratorVtbl dwritefontfileenumeratorvtbl
static
Initial value:
=
{
}
static HRESULT WINAPI fontfileenumerator_QueryInterface(IDWriteFontFileEnumerator *iface, REFIID riid, void **obj)
Definition: font.c:2916
static ULONG WINAPI fontfileenumerator_Release(IDWriteFontFileEnumerator *iface)
Definition: font.c:2932
static HRESULT WINAPI fontfileenumerator_MoveNext(IDWriteFontFileEnumerator *iface, BOOL *current)
Definition: font.c:2943
static ULONG WINAPI fontfileenumerator_AddRef(IDWriteFontFileEnumerator *iface)
Definition: font.c:2927
static HRESULT WINAPI fontfileenumerator_GetCurrentFontFile(IDWriteFontFileEnumerator *iface, IDWriteFontFile **file)
Definition: font.c:2937

Definition at line 2949 of file font.c.

Referenced by fontcollectionloader_CreateEnumeratorFromKey().

◆ dwritefontfileloadervtbl

const struct IDWriteFontFileLoaderVtbl dwritefontfileloadervtbl
static
Initial value:
= {
}
static HRESULT WINAPI fontfileloader_QueryInterface(IDWriteFontFileLoader *iface, REFIID riid, void **obj)
Definition: font.c:3208
static ULONG WINAPI fontfileloader_AddRef(IDWriteFontFileLoader *iface)
Definition: font.c:3221
static ULONG WINAPI fontfileloader_Release(IDWriteFontFileLoader *iface)
Definition: font.c:3226
static HRESULT WINAPI fontfileloader_CreateStreamFromKey(IDWriteFontFileLoader *iface, const void *ref_key, UINT32 key_size, IDWriteFontFileStream **stream)
Definition: font.c:3231

Definition at line 3237 of file font.c.

Referenced by test_CreateCustomFontFileReference().

◆ fontdatastreamvtbl

const IDWriteFontFileStreamVtbl fontdatastreamvtbl
static
Initial value:
=
{
}
static ULONG WINAPI fontdatastream_Release(IDWriteFontFileStream *iface)
Definition: font.c:782
static HRESULT WINAPI fontdatastream_GetLastWriteTime(IDWriteFontFileStream *iface, UINT64 *last_writetime)
Definition: font.c:821
static HRESULT WINAPI fontdatastream_ReadFileFragment(IDWriteFontFileStream *iface, void const **fragment_start, UINT64 offset, UINT64 fragment_size, void **fragment_context)
Definition: font.c:793
static ULONG WINAPI fontdatastream_AddRef(IDWriteFontFileStream *iface)
Definition: font.c:775
static HRESULT WINAPI fontdatastream_QueryInterface(IDWriteFontFileStream *iface, REFIID riid, void **obj)
Definition: font.c:763
static void WINAPI fontdatastream_ReleaseFileFragment(IDWriteFontFileStream *iface, void *fragment_context)
Definition: font.c:809
static HRESULT WINAPI fontdatastream_GetFileSize(IDWriteFontFileStream *iface, UINT64 *size)
Definition: font.c:814

Definition at line 826 of file font.c.

Referenced by create_fontdatastream().

◆ g_is_vista

BOOL g_is_vista
static

Definition at line 6779 of file font.c.

Referenced by get_expected_rendering_mode(), and test_GetRecommendedRenderingMode().

◆ g_startpoint_count

int g_startpoint_count
static

Definition at line 902 of file font.c.

Referenced by test_geometrysink_BeginFigure(), and test_GetGlyphRunOutline().

◆ g_startpoints

D2D1_POINT_2F g_startpoints[2]
static

Definition at line 901 of file font.c.

Referenced by test_geometrysink_BeginFigure(), and test_GetGlyphRunOutline().

◆ recmode_tests

◆ recmode_tests1

◆ resourcecollectionloadervtbl

const struct IDWriteFontCollectionLoaderVtbl resourcecollectionloadervtbl
static
Initial value:
= {
}
static ULONG WINAPI resourcecollectionloader_Release(IDWriteFontCollectionLoader *iface)
Definition: font.c:719
static HRESULT WINAPI resourcecollectionloader_CreateEnumeratorFromKey(IDWriteFontCollectionLoader *iface, IDWriteFactory *factory, const void *collectionKey, UINT32 collectionKeySize, IDWriteFontFileEnumerator **fontFileEnumerator)
Definition: font.c:724
static HRESULT WINAPI resourcecollectionloader_QueryInterface(IDWriteFontCollectionLoader *iface, REFIID riid, void **obj)
Definition: font.c:703
static ULONG WINAPI resourcecollectionloader_AddRef(IDWriteFontCollectionLoader *iface)
Definition: font.c:714

Definition at line 741 of file font.c.

Referenced by test_CustomFontCollection().

◆ resourcefontfileloadervtbl

const struct IDWriteFontFileLoaderVtbl resourcefontfileloadervtbl
static
Initial value:
= {
}
static ULONG WINAPI resourcefontfileloader_AddRef(IDWriteFontFileLoader *iface)
Definition: font.c:864
static HRESULT WINAPI resourcefontfileloader_QueryInterface(IDWriteFontFileLoader *iface, REFIID riid, void **obj)
Definition: font.c:853
static HRESULT WINAPI resourcefontfileloader_CreateStreamFromKey(IDWriteFontFileLoader *iface, const void *ref_key, UINT32 key_size, IDWriteFontFileStream **stream)
Definition: font.c:874
static ULONG WINAPI resourcefontfileloader_Release(IDWriteFontFileLoader *iface)
Definition: font.c:869

Definition at line 892 of file font.c.

Referenced by test_CustomFontCollection().

◆ rloader

◆ singlefontfileenumeratorvtbl

const struct IDWriteFontFileEnumeratorVtbl singlefontfileenumeratorvtbl
static
Initial value:
=
{
}
static ULONG WINAPI singlefontfileenumerator_AddRef(IDWriteFontFileEnumerator *iface)
Definition: font.c:626
static HRESULT WINAPI singlefontfileenumerator_QueryInterface(IDWriteFontFileEnumerator *iface, REFIID riid, void **obj)
Definition: font.c:615
static HRESULT WINAPI singlefontfileenumerator_MoveNext(IDWriteFontFileEnumerator *iface, BOOL *current)
Definition: font.c:652
static HRESULT WINAPI singlefontfileenumerator_GetCurrentFontFile(IDWriteFontFileEnumerator *iface, IDWriteFontFile **font_file)
Definition: font.c:644
static ULONG WINAPI singlefontfileenumerator_Release(IDWriteFontFileEnumerator *iface)
Definition: font.c:632

Definition at line 666 of file font.c.

Referenced by create_enumerator().

◆ test_fontfile

◆ test_geometrysink2_vtbl

const ID2D1SimplifiedGeometrySinkVtbl test_geometrysink2_vtbl
static
Initial value:
= {
}
static ULONG WINAPI test_geometrysink_AddRef(ID2D1SimplifiedGeometrySink *iface)
Definition: font.c:918
static void WINAPI test_geometrysink2_AddBeziers(ID2D1SimplifiedGeometrySink *iface, const D2D1_BEZIER_SEGMENT *beziers, UINT32 count)
Definition: font.c:994
static ULONG WINAPI test_geometrysink_Release(ID2D1SimplifiedGeometrySink *iface)
Definition: font.c:923
static void WINAPI test_geometrysink_SetSegmentFlags(ID2D1SimplifiedGeometrySink *iface, D2D1_PATH_SEGMENT flags)
Definition: font.c:934
static void WINAPI test_geometrysink2_BeginFigure(ID2D1SimplifiedGeometrySink *iface, D2D1_POINT_2F startPoint, D2D1_FIGURE_BEGIN figureBegin)
Definition: font.c:982
static void WINAPI test_geometrysink2_AddLines(ID2D1SimplifiedGeometrySink *iface, const D2D1_POINT_2F *points, UINT32 count)
Definition: font.c:988
static HRESULT WINAPI test_geometrysink_QueryInterface(ID2D1SimplifiedGeometrySink *iface, REFIID riid, void **ret)
Definition: font.c:904
static void WINAPI test_geometrysink_SetFillMode(ID2D1SimplifiedGeometrySink *iface, D2D1_FILL_MODE mode)
Definition: font.c:928
static void WINAPI test_geometrysink2_EndFigure(ID2D1SimplifiedGeometrySink *iface, D2D1_FIGURE_END figureEnd)
Definition: font.c:1000
static HRESULT WINAPI test_geometrysink_Close(ID2D1SimplifiedGeometrySink *iface)
Definition: font.c:963

Definition at line 1005 of file font.c.

◆ test_geometrysink_vtbl

const ID2D1SimplifiedGeometrySinkVtbl test_geometrysink_vtbl
static
Initial value:
= {
}
static void WINAPI test_geometrysink_EndFigure(ID2D1SimplifiedGeometrySink *iface, D2D1_FIGURE_END figureEnd)
Definition: font.c:958
static void WINAPI test_geometrysink_BeginFigure(ID2D1SimplifiedGeometrySink *iface, D2D1_POINT_2F startPoint, D2D1_FIGURE_BEGIN figureBegin)
Definition: font.c:939
static void WINAPI test_geometrysink_AddLines(ID2D1SimplifiedGeometrySink *iface, const D2D1_POINT_2F *points, UINT32 count)
Definition: font.c:948
static void WINAPI test_geometrysink_AddBeziers(ID2D1SimplifiedGeometrySink *iface, const D2D1_BEZIER_SEGMENT *beziers, UINT32 count)
Definition: font.c:953

Definition at line 969 of file font.c.

◆ test_geomsink

Definition at line 1018 of file font.c.

Referenced by test_GetGlyphRunOutline().

◆ test_geomsink2

Definition at line 1019 of file font.c.

Referenced by test_GetGlyphRunOutline().

◆ testownervtbl

const IUnknownVtbl testownervtbl
static
Initial value:
= {
}
static HRESULT WINAPI testowner_QueryInterface(IUnknown *iface, REFIID riid, void **obj)
Definition: font.c:8943
static ULONG WINAPI testowner_AddRef(IUnknown *iface)
Definition: font.c:8955
static ULONG WINAPI testowner_Release(IUnknown *iface)
Definition: font.c:8961

Definition at line 8967 of file font.c.

Referenced by testowner_init().