2012-08-13 05:44:19 +02:00
|
|
|
/*
|
|
|
|
* Font and collections
|
|
|
|
*
|
2015-07-31 00:30:08 +02:00
|
|
|
* Copyright 2011 Huw Davies
|
2017-04-20 11:50:07 +02:00
|
|
|
* Copyright 2012, 2014-2017 Nikolay Sivov for CodeWeavers
|
2014-10-20 19:45:57 +02:00
|
|
|
* Copyright 2014 Aric Stewart for CodeWeavers
|
2012-08-13 05:44:19 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
2016-12-04 17:22:13 +01:00
|
|
|
|
|
|
|
#include <assert.h>
|
2015-07-08 11:36:48 +02:00
|
|
|
#include <math.h>
|
2012-08-13 05:44:19 +02:00
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "dwrite_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
|
2016-02-14 17:05:08 +01:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(dwrite_file);
|
2012-08-13 05:44:19 +02:00
|
|
|
|
2014-10-07 07:23:26 +02:00
|
|
|
#define MS_HEAD_TAG DWRITE_MAKE_OPENTYPE_TAG('h','e','a','d')
|
|
|
|
#define MS_OS2_TAG DWRITE_MAKE_OPENTYPE_TAG('O','S','/','2')
|
|
|
|
#define MS_CMAP_TAG DWRITE_MAKE_OPENTYPE_TAG('c','m','a','p')
|
2014-10-24 09:42:35 +02:00
|
|
|
#define MS_NAME_TAG DWRITE_MAKE_OPENTYPE_TAG('n','a','m','e')
|
2015-07-08 11:36:48 +02:00
|
|
|
#define MS_VDMX_TAG DWRITE_MAKE_OPENTYPE_TAG('V','D','M','X')
|
2015-07-27 10:10:32 +02:00
|
|
|
#define MS_GASP_TAG DWRITE_MAKE_OPENTYPE_TAG('g','a','s','p')
|
2015-08-06 18:43:23 +02:00
|
|
|
#define MS_CPAL_TAG DWRITE_MAKE_OPENTYPE_TAG('C','P','A','L')
|
2016-02-08 10:31:26 +01:00
|
|
|
#define MS_COLR_TAG DWRITE_MAKE_OPENTYPE_TAG('C','O','L','R')
|
2012-10-10 14:37:55 +02:00
|
|
|
|
2014-11-07 11:17:38 +01:00
|
|
|
static const IID IID_issystemcollection = {0x14d88047,0x331f,0x4cd3,{0xbc,0xa8,0x3e,0x67,0x99,0xaf,0x34,0x75}};
|
|
|
|
|
2015-07-27 10:10:32 +02:00
|
|
|
static const FLOAT RECOMMENDED_OUTLINE_AA_THRESHOLD = 100.0f;
|
|
|
|
static const FLOAT RECOMMENDED_OUTLINE_A_THRESHOLD = 350.0f;
|
|
|
|
static const FLOAT RECOMMENDED_NATURAL_PPEM = 20.0f;
|
|
|
|
|
2015-08-18 22:49:24 +02:00
|
|
|
static const WCHAR extraW[] = {'e','x','t','r','a',0};
|
|
|
|
static const WCHAR ultraW[] = {'u','l','t','r','a',0};
|
|
|
|
static const WCHAR semiW[] = {'s','e','m','i',0};
|
|
|
|
static const WCHAR extW[] = {'e','x','t',0};
|
2015-08-31 07:13:03 +02:00
|
|
|
static const WCHAR thinW[] = {'t','h','i','n',0};
|
|
|
|
static const WCHAR lightW[] = {'l','i','g','h','t',0};
|
|
|
|
static const WCHAR mediumW[] = {'m','e','d','i','u','m',0};
|
|
|
|
static const WCHAR blackW[] = {'b','l','a','c','k',0};
|
|
|
|
static const WCHAR condensedW[] = {'c','o','n','d','e','n','s','e','d',0};
|
|
|
|
static const WCHAR expandedW[] = {'e','x','p','a','n','d','e','d',0};
|
|
|
|
static const WCHAR italicW[] = {'i','t','a','l','i','c',0};
|
|
|
|
static const WCHAR boldW[] = {'B','o','l','d',0};
|
|
|
|
static const WCHAR obliqueW[] = {'O','b','l','i','q','u','e',0};
|
2015-09-03 06:35:35 +02:00
|
|
|
static const WCHAR regularW[] = {'R','e','g','u','l','a','r',0};
|
|
|
|
static const WCHAR demiW[] = {'d','e','m','i',0};
|
2015-08-31 07:13:03 +02:00
|
|
|
static const WCHAR spaceW[] = {' ',0};
|
2015-09-03 06:35:35 +02:00
|
|
|
static const WCHAR enusW[] = {'e','n','-','u','s',0};
|
2015-08-18 22:49:24 +02:00
|
|
|
|
2015-08-10 12:51:28 +02:00
|
|
|
struct dwrite_font_propvec {
|
|
|
|
FLOAT stretch;
|
|
|
|
FLOAT style;
|
|
|
|
FLOAT weight;
|
|
|
|
};
|
|
|
|
|
2020-01-23 10:24:12 +01:00
|
|
|
struct dwrite_font_data
|
|
|
|
{
|
2014-09-03 20:11:35 +02:00
|
|
|
LONG ref;
|
|
|
|
|
2014-09-02 17:19:25 +02:00
|
|
|
DWRITE_FONT_STYLE style;
|
|
|
|
DWRITE_FONT_STRETCH stretch;
|
|
|
|
DWRITE_FONT_WEIGHT weight;
|
2015-07-06 22:08:37 +02:00
|
|
|
DWRITE_PANOSE panose;
|
2017-08-15 13:40:26 +02:00
|
|
|
FONTSIGNATURE fontsig;
|
2020-01-23 10:24:12 +01:00
|
|
|
UINT32 flags; /* enum font_flags */
|
2015-08-10 12:51:28 +02:00
|
|
|
struct dwrite_font_propvec propvec;
|
2020-06-09 11:14:35 +02:00
|
|
|
struct dwrite_cmap cmap;
|
2020-02-04 11:15:09 +01:00
|
|
|
/* Static axis for weight/width/italic. */
|
|
|
|
DWRITE_FONT_AXIS_VALUE axis[3];
|
2015-08-10 12:51:28 +02:00
|
|
|
|
2014-11-06 09:49:06 +01:00
|
|
|
DWRITE_FONT_METRICS1 metrics;
|
2020-01-27 06:52:48 +01:00
|
|
|
IDWriteLocalizedStrings *info_strings[DWRITE_INFORMATIONAL_STRING_SUPPORTED_SCRIPT_LANGUAGE_TAG + 1];
|
2020-01-24 09:17:35 +01:00
|
|
|
IDWriteLocalizedStrings *family_names;
|
2015-08-12 20:10:46 +02:00
|
|
|
IDWriteLocalizedStrings *names;
|
2014-09-02 17:19:25 +02:00
|
|
|
|
2014-10-24 09:43:21 +02:00
|
|
|
/* data needed to create fontface instance */
|
|
|
|
DWRITE_FONT_FACE_TYPE face_type;
|
|
|
|
IDWriteFontFile *file;
|
|
|
|
UINT32 face_index;
|
2014-09-02 17:19:36 +02:00
|
|
|
|
2014-09-02 17:19:25 +02:00
|
|
|
WCHAR *facename;
|
2015-09-03 06:35:35 +02:00
|
|
|
|
2015-09-03 06:36:01 +02:00
|
|
|
USHORT simulations;
|
|
|
|
|
2016-12-04 17:22:13 +01:00
|
|
|
LOGFONTW lf;
|
|
|
|
|
2015-09-03 06:36:01 +02:00
|
|
|
/* used to mark font as tested when scanning for simulation candidate */
|
2020-04-24 10:56:57 +02:00
|
|
|
unsigned int bold_sim_tested : 1;
|
|
|
|
unsigned int oblique_sim_tested : 1;
|
2014-09-02 17:19:25 +02:00
|
|
|
};
|
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
struct dwrite_fontfamily_data
|
|
|
|
{
|
|
|
|
LONG refcount;
|
2014-10-08 16:52:07 +02:00
|
|
|
|
2014-09-09 02:10:48 +02:00
|
|
|
IDWriteLocalizedStrings *familyname;
|
|
|
|
|
|
|
|
struct dwrite_font_data **fonts;
|
2019-05-14 12:27:23 +02:00
|
|
|
size_t size;
|
|
|
|
size_t count;
|
|
|
|
|
2020-04-24 10:56:57 +02:00
|
|
|
unsigned int has_normal_face : 1;
|
|
|
|
unsigned int has_oblique_face : 1;
|
|
|
|
unsigned int has_italic_face : 1;
|
2014-09-09 02:10:48 +02:00
|
|
|
};
|
|
|
|
|
2019-05-14 12:27:24 +02:00
|
|
|
struct dwrite_fontcollection
|
|
|
|
{
|
2019-10-08 12:04:34 +02:00
|
|
|
IDWriteFontCollection3 IDWriteFontCollection3_iface;
|
2019-05-14 12:27:24 +02:00
|
|
|
LONG refcount;
|
2012-10-21 06:24:35 +02:00
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
IDWriteFactory7 *factory;
|
2014-10-08 16:52:07 +02:00
|
|
|
struct dwrite_fontfamily_data **family_data;
|
2019-05-14 12:27:24 +02:00
|
|
|
size_t size;
|
|
|
|
size_t count;
|
2012-10-21 03:43:01 +02:00
|
|
|
};
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
struct dwrite_fontfamily
|
|
|
|
{
|
|
|
|
IDWriteFontFamily2 IDWriteFontFamily2_iface;
|
2019-10-09 10:04:57 +02:00
|
|
|
IDWriteFontList2 IDWriteFontList2_iface;
|
2019-10-08 12:04:35 +02:00
|
|
|
LONG refcount;
|
2012-10-07 18:29:39 +02:00
|
|
|
|
2014-09-09 02:10:48 +02:00
|
|
|
struct dwrite_fontfamily_data *data;
|
2017-04-11 13:21:32 +02:00
|
|
|
struct dwrite_fontcollection *collection;
|
|
|
|
};
|
2014-09-03 20:11:35 +02:00
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
struct dwrite_fontlist
|
|
|
|
{
|
|
|
|
IDWriteFontList2 IDWriteFontList2_iface;
|
|
|
|
LONG refcount;
|
2017-04-11 13:21:32 +02:00
|
|
|
|
|
|
|
struct dwrite_font_data **fonts;
|
|
|
|
UINT32 font_count;
|
|
|
|
struct dwrite_fontfamily *family;
|
2012-08-25 11:11:31 +02:00
|
|
|
};
|
|
|
|
|
2012-08-13 05:44:19 +02:00
|
|
|
struct dwrite_font {
|
2016-03-07 15:10:17 +01:00
|
|
|
IDWriteFont3 IDWriteFont3_iface;
|
2012-08-13 05:44:19 +02:00
|
|
|
LONG ref;
|
2012-08-13 05:46:43 +02:00
|
|
|
|
2014-12-08 11:22:01 +01:00
|
|
|
DWRITE_FONT_STYLE style;
|
2014-09-02 17:19:25 +02:00
|
|
|
struct dwrite_font_data *data;
|
2017-04-11 13:21:32 +02:00
|
|
|
struct dwrite_fontfamily *family;
|
2012-08-13 05:44:19 +02:00
|
|
|
};
|
|
|
|
|
2015-11-02 14:38:41 +01:00
|
|
|
enum runanalysis_flags {
|
|
|
|
RUNANALYSIS_BOUNDS_READY = 1 << 0,
|
|
|
|
RUNANALYSIS_BITMAP_READY = 1 << 1,
|
|
|
|
RUNANALYSIS_USE_TRANSFORM = 1 << 2
|
2015-07-29 10:59:02 +02:00
|
|
|
};
|
|
|
|
|
2015-05-19 14:23:57 +02:00
|
|
|
struct dwrite_glyphrunanalysis {
|
|
|
|
IDWriteGlyphRunAnalysis IDWriteGlyphRunAnalysis_iface;
|
|
|
|
LONG ref;
|
2015-07-17 10:56:17 +02:00
|
|
|
|
2017-01-26 05:41:46 +01:00
|
|
|
DWRITE_RENDERING_MODE1 rendering_mode;
|
2017-03-30 14:06:59 +02:00
|
|
|
DWRITE_TEXTURE_TYPE texture_type; /* derived from rendering mode specified on creation */
|
2015-11-02 14:38:42 +01:00
|
|
|
DWRITE_GLYPH_RUN run; /* glyphAdvances and glyphOffsets are not used */
|
2015-11-02 14:38:41 +01:00
|
|
|
DWRITE_MATRIX m;
|
2015-07-29 10:57:52 +02:00
|
|
|
UINT16 *glyphs;
|
2017-04-04 12:13:17 +02:00
|
|
|
D2D_POINT_2F *origins;
|
2015-07-31 00:30:08 +02:00
|
|
|
|
2015-11-02 14:38:41 +01:00
|
|
|
UINT8 flags;
|
2015-07-31 00:30:08 +02:00
|
|
|
RECT bounds;
|
|
|
|
BYTE *bitmap;
|
2017-03-30 14:07:00 +02:00
|
|
|
UINT32 max_glyph_bitmap_size;
|
2015-05-19 14:23:57 +02:00
|
|
|
};
|
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
struct dwrite_colorglyphenum
|
|
|
|
{
|
|
|
|
IDWriteColorGlyphRunEnumerator1 IDWriteColorGlyphRunEnumerator1_iface;
|
|
|
|
LONG refcount;
|
2016-02-08 10:31:35 +01:00
|
|
|
|
|
|
|
FLOAT origin_x; /* original run origin */
|
|
|
|
FLOAT origin_y;
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
IDWriteFontFace5 *fontface; /* for convenience */
|
2019-11-29 10:54:25 +01:00
|
|
|
DWRITE_COLOR_GLYPH_RUN1 colorrun; /* returned with GetCurrentRun() */
|
2016-02-08 10:31:35 +01:00
|
|
|
DWRITE_GLYPH_RUN run; /* base run */
|
|
|
|
UINT32 palette; /* palette index to get layer color from */
|
|
|
|
FLOAT *advances; /* original or measured advances for base glyphs */
|
|
|
|
FLOAT *color_advances; /* returned color run points to this */
|
2016-02-09 15:11:19 +01:00
|
|
|
DWRITE_GLYPH_OFFSET *offsets; /* original offsets, or NULL */
|
|
|
|
DWRITE_GLYPH_OFFSET *color_offsets; /* returned color run offsets, or NULL */
|
2016-02-08 10:31:35 +01:00
|
|
|
UINT16 *glyphindices; /* returned color run points to this */
|
|
|
|
struct dwrite_colorglyph *glyphs; /* current glyph color info */
|
|
|
|
BOOL has_regular_glyphs; /* TRUE if there's any glyph without a color */
|
|
|
|
UINT16 current_layer; /* enumerator position, updated with MoveNext */
|
|
|
|
UINT16 max_layer_num; /* max number of layers for this run */
|
|
|
|
struct dwrite_fonttable colr; /* used to access layers */
|
2015-08-06 18:44:53 +02:00
|
|
|
};
|
|
|
|
|
2014-12-08 11:24:39 +01:00
|
|
|
#define GLYPH_BLOCK_SHIFT 8
|
|
|
|
#define GLYPH_BLOCK_SIZE (1UL << GLYPH_BLOCK_SHIFT)
|
|
|
|
#define GLYPH_BLOCK_MASK (GLYPH_BLOCK_SIZE - 1)
|
|
|
|
#define GLYPH_MAX 65536
|
|
|
|
|
2014-08-12 21:11:34 +02:00
|
|
|
struct dwrite_fontfile {
|
|
|
|
IDWriteFontFile IDWriteFontFile_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
IDWriteFontFileLoader *loader;
|
|
|
|
void *reference_key;
|
|
|
|
UINT32 key_size;
|
2014-08-17 03:40:48 +02:00
|
|
|
IDWriteFontFileStream *stream;
|
2014-08-12 21:11:34 +02:00
|
|
|
};
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
struct dwrite_fontfacereference
|
|
|
|
{
|
|
|
|
IDWriteFontFaceReference1 IDWriteFontFaceReference1_iface;
|
|
|
|
LONG refcount;
|
2016-04-20 09:51:01 +02:00
|
|
|
|
|
|
|
IDWriteFontFile *file;
|
|
|
|
UINT32 index;
|
|
|
|
USHORT simulations;
|
2019-12-05 09:56:01 +01:00
|
|
|
DWRITE_FONT_AXIS_VALUE *axis_values;
|
|
|
|
UINT32 axis_values_count;
|
2019-12-05 09:56:02 +01:00
|
|
|
IDWriteFactory7 *factory;
|
2016-04-20 09:51:01 +02:00
|
|
|
};
|
|
|
|
|
2019-12-09 09:09:36 +01:00
|
|
|
static const IDWriteFontFaceReference1Vtbl fontfacereferencevtbl;
|
|
|
|
|
2019-12-05 09:55:57 +01:00
|
|
|
struct dwrite_fontresource
|
|
|
|
{
|
|
|
|
IDWriteFontResource IDWriteFontResource_iface;
|
|
|
|
LONG refcount;
|
|
|
|
|
|
|
|
IDWriteFontFile *file;
|
|
|
|
UINT32 face_index;
|
|
|
|
IDWriteFactory7 *factory;
|
|
|
|
};
|
|
|
|
|
2019-01-31 09:35:26 +01:00
|
|
|
static void dwrite_grab_font_table(void *context, UINT32 table, const BYTE **data, UINT32 *size, void **data_context)
|
|
|
|
{
|
|
|
|
struct dwrite_fontface *fontface = context;
|
|
|
|
BOOL exists = FALSE;
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
if (FAILED(IDWriteFontFace5_TryGetFontTable(&fontface->IDWriteFontFace5_iface, table, (const void **)data,
|
2019-01-31 09:35:26 +01:00
|
|
|
size, data_context, &exists)) || !exists)
|
|
|
|
{
|
|
|
|
*data = NULL;
|
|
|
|
*size = 0;
|
|
|
|
*data_context = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dwrite_release_font_table(void *context, void *data_context)
|
|
|
|
{
|
|
|
|
struct dwrite_fontface *fontface = context;
|
2019-12-02 13:53:53 +01:00
|
|
|
IDWriteFontFace5_ReleaseFontTable(&fontface->IDWriteFontFace5_iface, data_context);
|
2019-01-31 09:35:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static UINT16 dwrite_get_font_upem(void *context)
|
|
|
|
{
|
|
|
|
struct dwrite_fontface *fontface = context;
|
|
|
|
return fontface->metrics.designUnitsPerEm;
|
|
|
|
}
|
|
|
|
|
2020-06-09 11:14:37 +02:00
|
|
|
static UINT16 dwritefontface_get_glyph(struct dwrite_fontface *fontface, unsigned int ch)
|
|
|
|
{
|
|
|
|
dwrite_cmap_init(&fontface->cmap, NULL, fontface->index, fontface->type);
|
|
|
|
return opentype_cmap_get_glyph(&fontface->cmap, ch);
|
|
|
|
}
|
|
|
|
|
2020-05-22 12:58:09 +02:00
|
|
|
static BOOL dwrite_has_glyph(void *context, unsigned int codepoint)
|
|
|
|
{
|
|
|
|
struct dwrite_fontface *fontface = context;
|
2020-06-09 11:14:37 +02:00
|
|
|
return !!dwritefontface_get_glyph(fontface, codepoint);
|
2020-05-22 12:58:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static UINT16 dwrite_get_glyph(void *context, unsigned int codepoint)
|
|
|
|
{
|
|
|
|
struct dwrite_fontface *fontface = context;
|
2020-06-09 11:14:37 +02:00
|
|
|
return dwritefontface_get_glyph(fontface, codepoint);
|
2020-05-22 12:58:09 +02:00
|
|
|
}
|
|
|
|
|
2019-01-31 09:35:26 +01:00
|
|
|
static const struct shaping_font_ops dwrite_font_ops =
|
|
|
|
{
|
|
|
|
dwrite_grab_font_table,
|
|
|
|
dwrite_release_font_table,
|
|
|
|
dwrite_get_font_upem,
|
2020-05-22 12:58:09 +02:00
|
|
|
dwrite_has_glyph,
|
|
|
|
dwrite_get_glyph,
|
2019-01-31 09:35:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct scriptshaping_cache *fontface_get_shaping_cache(struct dwrite_fontface *fontface)
|
|
|
|
{
|
|
|
|
if (fontface->shaping_cache)
|
|
|
|
return fontface->shaping_cache;
|
|
|
|
|
|
|
|
return fontface->shaping_cache = create_scriptshaping_cache(fontface, &dwrite_font_ops);
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static inline struct dwrite_fontface *impl_from_IDWriteFontFace5(IDWriteFontFace5 *iface)
|
2012-10-07 21:03:52 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_fontface, IDWriteFontFace5_iface);
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2020-02-03 17:08:31 +01:00
|
|
|
static struct dwrite_fontface *impl_from_IDWriteFontFaceReference(IDWriteFontFaceReference *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_fontface, IDWriteFontFaceReference_iface);
|
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static inline struct dwrite_font *impl_from_IDWriteFont3(IDWriteFont3 *iface)
|
2012-08-13 05:44:19 +02:00
|
|
|
{
|
2016-03-07 15:10:17 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_font, IDWriteFont3_iface);
|
2012-08-13 05:44:19 +02:00
|
|
|
}
|
|
|
|
|
2020-01-27 06:52:49 +01:00
|
|
|
static struct dwrite_font *unsafe_impl_from_IDWriteFont(IDWriteFont *iface);
|
|
|
|
|
2014-08-12 21:11:34 +02:00
|
|
|
static inline struct dwrite_fontfile *impl_from_IDWriteFontFile(IDWriteFontFile *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_fontfile, IDWriteFontFile_iface);
|
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
static inline struct dwrite_fontfamily *impl_from_IDWriteFontFamily2(IDWriteFontFamily2 *iface)
|
2012-08-25 11:11:31 +02:00
|
|
|
{
|
2019-10-08 12:04:35 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_fontfamily, IDWriteFontFamily2_iface);
|
2012-08-25 11:11:31 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:57 +02:00
|
|
|
static inline struct dwrite_fontfamily *impl_family_from_IDWriteFontList2(IDWriteFontList2 *iface)
|
2018-05-21 22:11:02 +02:00
|
|
|
{
|
2019-10-09 10:04:57 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_fontfamily, IDWriteFontList2_iface);
|
2018-05-21 22:11:02 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
static inline struct dwrite_fontcollection *impl_from_IDWriteFontCollection3(IDWriteFontCollection3 *iface)
|
2012-10-21 03:43:01 +02:00
|
|
|
{
|
2019-10-08 12:04:34 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_fontcollection, IDWriteFontCollection3_iface);
|
2012-10-21 03:43:01 +02:00
|
|
|
}
|
|
|
|
|
2015-05-19 14:23:57 +02:00
|
|
|
static inline struct dwrite_glyphrunanalysis *impl_from_IDWriteGlyphRunAnalysis(IDWriteGlyphRunAnalysis *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_glyphrunanalysis, IDWriteGlyphRunAnalysis_iface);
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
static inline struct dwrite_colorglyphenum *impl_from_IDWriteColorGlyphRunEnumerator1(IDWriteColorGlyphRunEnumerator1 *iface)
|
2015-08-06 18:44:53 +02:00
|
|
|
{
|
2019-11-29 10:54:25 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_colorglyphenum, IDWriteColorGlyphRunEnumerator1_iface);
|
2015-08-06 18:44:53 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
static inline struct dwrite_fontlist *impl_from_IDWriteFontList2(IDWriteFontList2 *iface)
|
2015-09-08 10:40:25 +02:00
|
|
|
{
|
2019-10-09 10:04:56 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_fontlist, IDWriteFontList2_iface);
|
2015-09-08 10:40:25 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static inline struct dwrite_fontfacereference *impl_from_IDWriteFontFaceReference1(IDWriteFontFaceReference1 *iface)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_fontfacereference, IDWriteFontFaceReference1_iface);
|
2016-04-20 09:51:01 +02:00
|
|
|
}
|
|
|
|
|
2019-12-05 09:55:57 +01:00
|
|
|
static struct dwrite_fontresource *impl_from_IDWriteFontResource(IDWriteFontResource *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_fontresource, IDWriteFontResource_iface);
|
|
|
|
}
|
|
|
|
|
2014-12-08 11:24:39 +01:00
|
|
|
static HRESULT get_cached_glyph_metrics(struct dwrite_fontface *fontface, UINT16 glyph, DWRITE_GLYPH_METRICS *metrics)
|
|
|
|
{
|
|
|
|
static const DWRITE_GLYPH_METRICS nil;
|
|
|
|
DWRITE_GLYPH_METRICS *block = fontface->glyphs[glyph >> GLYPH_BLOCK_SHIFT];
|
|
|
|
|
|
|
|
if (!block || !memcmp(&block[glyph & GLYPH_BLOCK_MASK], &nil, sizeof(DWRITE_GLYPH_METRICS))) return S_FALSE;
|
|
|
|
memcpy(metrics, &block[glyph & GLYPH_BLOCK_MASK], sizeof(*metrics));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT set_cached_glyph_metrics(struct dwrite_fontface *fontface, UINT16 glyph, DWRITE_GLYPH_METRICS *metrics)
|
|
|
|
{
|
|
|
|
DWRITE_GLYPH_METRICS **block = &fontface->glyphs[glyph >> GLYPH_BLOCK_SHIFT];
|
|
|
|
|
|
|
|
if (!*block) {
|
|
|
|
/* start new block */
|
|
|
|
*block = heap_alloc_zero(sizeof(*metrics) * GLYPH_BLOCK_SIZE);
|
|
|
|
if (!*block)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(&(*block)[glyph & GLYPH_BLOCK_MASK], metrics, sizeof(*metrics));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
const void* get_fontface_table(IDWriteFontFace5 *fontface, UINT32 tag, struct dwrite_fonttable *table)
|
2014-10-16 05:33:51 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
2015-07-08 11:36:48 +02:00
|
|
|
if (table->data || !table->exists)
|
|
|
|
return table->data;
|
2014-10-16 05:33:51 +02:00
|
|
|
|
2015-07-08 11:36:48 +02:00
|
|
|
table->exists = FALSE;
|
2019-12-02 13:53:53 +01:00
|
|
|
hr = IDWriteFontFace5_TryGetFontTable(fontface, tag, (const void **)&table->data, &table->size, &table->context,
|
2016-02-08 10:31:26 +01:00
|
|
|
&table->exists);
|
2015-07-08 11:36:48 +02:00
|
|
|
if (FAILED(hr) || !table->exists) {
|
2017-07-20 18:47:32 +02:00
|
|
|
TRACE("Font does not have %s table\n", debugstr_tag(tag));
|
2014-10-16 05:33:51 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-07-08 11:36:48 +02:00
|
|
|
return table->data;
|
|
|
|
}
|
|
|
|
|
2015-08-18 06:40:27 +02:00
|
|
|
static void init_font_prop_vec(DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STRETCH stretch, DWRITE_FONT_STYLE style,
|
|
|
|
struct dwrite_font_propvec *vec)
|
2015-08-10 12:51:28 +02:00
|
|
|
{
|
2015-08-18 06:40:27 +02:00
|
|
|
vec->stretch = ((INT32)stretch - DWRITE_FONT_STRETCH_NORMAL) * 11.0f;
|
|
|
|
vec->style = style * 7.0f;
|
|
|
|
vec->weight = ((INT32)weight - DWRITE_FONT_WEIGHT_NORMAL) / 100.0f * 5.0f;
|
2015-08-10 12:51:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static FLOAT get_font_prop_vec_distance(const struct dwrite_font_propvec *left, const struct dwrite_font_propvec *right)
|
|
|
|
{
|
|
|
|
return powf(left->stretch - right->stretch, 2) + powf(left->style - right->style, 2) + powf(left->weight - right->weight, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static FLOAT get_font_prop_vec_dotproduct(const struct dwrite_font_propvec *left, const struct dwrite_font_propvec *right)
|
|
|
|
{
|
|
|
|
return left->stretch * right->stretch + left->style * right->style + left->weight * right->weight;
|
|
|
|
}
|
|
|
|
|
2019-01-29 08:06:45 +01:00
|
|
|
static const struct dwrite_fonttable *get_fontface_vdmx(struct dwrite_fontface *fontface)
|
2015-07-08 11:36:48 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
get_fontface_table(&fontface->IDWriteFontFace5_iface, MS_VDMX_TAG, &fontface->vdmx);
|
2019-01-29 08:06:45 +01:00
|
|
|
return &fontface->vdmx;
|
2014-10-16 05:33:51 +02:00
|
|
|
}
|
|
|
|
|
2019-01-27 06:55:26 +01:00
|
|
|
static const struct dwrite_fonttable *get_fontface_gasp(struct dwrite_fontface *fontface)
|
2015-07-27 10:10:32 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
get_fontface_table(&fontface->IDWriteFontFace5_iface, MS_GASP_TAG, &fontface->gasp);
|
2019-01-27 06:55:26 +01:00
|
|
|
return &fontface->gasp;
|
2015-07-27 10:10:32 +02:00
|
|
|
}
|
|
|
|
|
2019-01-27 06:55:27 +01:00
|
|
|
static const struct dwrite_fonttable *get_fontface_cpal(struct dwrite_fontface *fontface)
|
2015-08-06 18:43:23 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
get_fontface_table(&fontface->IDWriteFontFace5_iface, MS_CPAL_TAG, &fontface->cpal);
|
2019-01-27 06:55:27 +01:00
|
|
|
return &fontface->cpal;
|
2016-02-08 10:31:26 +01:00
|
|
|
}
|
|
|
|
|
2017-05-30 09:10:59 +02:00
|
|
|
static void addref_font_data(struct dwrite_font_data *data)
|
|
|
|
{
|
|
|
|
InterlockedIncrement(&data->ref);
|
|
|
|
}
|
|
|
|
|
2014-10-24 09:43:21 +02:00
|
|
|
static void release_font_data(struct dwrite_font_data *data)
|
2014-09-03 20:11:35 +02:00
|
|
|
{
|
|
|
|
int i;
|
2014-11-18 10:26:01 +01:00
|
|
|
|
|
|
|
if (InterlockedDecrement(&data->ref) > 0)
|
2014-09-03 20:11:35 +02:00
|
|
|
return;
|
2014-10-20 19:45:57 +02:00
|
|
|
|
2020-01-24 09:17:37 +01:00
|
|
|
for (i = 0; i < ARRAY_SIZE(data->info_strings); ++i)
|
|
|
|
{
|
2014-10-20 19:45:57 +02:00
|
|
|
if (data->info_strings[i])
|
|
|
|
IDWriteLocalizedStrings_Release(data->info_strings[i]);
|
|
|
|
}
|
2016-02-23 15:47:14 +01:00
|
|
|
if (data->names)
|
|
|
|
IDWriteLocalizedStrings_Release(data->names);
|
2014-10-24 09:43:21 +02:00
|
|
|
|
2020-01-24 09:17:35 +01:00
|
|
|
if (data->family_names)
|
|
|
|
IDWriteLocalizedStrings_Release(data->family_names);
|
|
|
|
|
2020-06-09 11:14:35 +02:00
|
|
|
dwrite_cmap_release(&data->cmap);
|
2014-11-05 10:51:52 +01:00
|
|
|
IDWriteFontFile_Release(data->file);
|
2014-09-03 20:11:35 +02:00
|
|
|
heap_free(data->facename);
|
|
|
|
heap_free(data);
|
|
|
|
}
|
|
|
|
|
2014-11-18 10:26:01 +01:00
|
|
|
static void release_fontfamily_data(struct dwrite_fontfamily_data *data)
|
2014-10-08 16:52:07 +02:00
|
|
|
{
|
2019-05-14 12:27:23 +02:00
|
|
|
size_t i;
|
2014-11-18 10:26:01 +01:00
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
if (InterlockedDecrement(&data->refcount) > 0)
|
2014-10-08 16:52:07 +02:00
|
|
|
return;
|
2014-11-18 10:26:01 +01:00
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
for (i = 0; i < data->count; ++i)
|
2014-10-24 09:43:21 +02:00
|
|
|
release_font_data(data->fonts[i]);
|
2014-10-08 16:52:07 +02:00
|
|
|
heap_free(data->fonts);
|
|
|
|
IDWriteLocalizedStrings_Release(data->familyname);
|
|
|
|
heap_free(data);
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
void fontface_detach_from_cache(IDWriteFontFace5 *iface)
|
2017-07-20 18:47:33 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2017-07-20 18:47:33 +02:00
|
|
|
fontface->cached = NULL;
|
|
|
|
}
|
|
|
|
|
2020-01-27 06:52:49 +01:00
|
|
|
static BOOL is_same_fontfile(IDWriteFontFile *left, IDWriteFontFile *right)
|
|
|
|
{
|
|
|
|
UINT32 left_key_size, right_key_size;
|
|
|
|
const void *left_key, *right_key;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (left == right)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetReferenceKey(left, &left_key, &left_key_size);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetReferenceKey(right, &right_key, &right_key_size);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (left_key_size != right_key_size)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return !memcmp(left_key, right_key, left_key_size);
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface_QueryInterface(IDWriteFontFace5 *iface, REFIID riid, void **obj)
|
2012-10-07 21:03:52 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2012-10-07 21:03:52 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
|
2012-10-07 21:03:52 +02:00
|
|
|
|
2019-12-05 09:55:58 +01:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteFontFace5) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFontFace4) ||
|
2016-10-29 20:25:54 +02:00
|
|
|
IsEqualIID(riid, &IID_IDWriteFontFace3) ||
|
2016-03-03 06:16:25 +01:00
|
|
|
IsEqualIID(riid, &IID_IDWriteFontFace2) ||
|
2014-10-10 08:01:24 +02:00
|
|
|
IsEqualIID(riid, &IID_IDWriteFontFace1) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFontFace) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
2012-10-07 21:03:52 +02:00
|
|
|
{
|
|
|
|
*obj = iface;
|
2020-02-03 17:08:31 +01:00
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &IID_IDWriteFontFaceReference))
|
|
|
|
*obj = &fontface->IDWriteFontFaceReference_iface;
|
|
|
|
else
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
if (*obj)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
if (InterlockedIncrement(&fontface->refcount) == 1)
|
|
|
|
{
|
|
|
|
InterlockedDecrement(&fontface->refcount);
|
2017-08-15 13:40:24 +02:00
|
|
|
*obj = NULL;
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2012-10-07 21:03:52 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2012-10-07 21:03:52 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static ULONG WINAPI dwritefontface_AddRef(IDWriteFontFace5 *iface)
|
2012-10-07 21:03:52 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&fontface->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static ULONG WINAPI dwritefontface_Release(IDWriteFontFace5 *iface)
|
2012-10-07 21:03:52 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&fontface->refcount);
|
2012-10-07 21:03:52 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
2012-10-07 21:03:52 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
if (!refcount)
|
|
|
|
{
|
2014-10-24 09:40:06 +02:00
|
|
|
UINT32 i;
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
if (fontface->cached)
|
|
|
|
{
|
|
|
|
factory_lock(fontface->factory);
|
|
|
|
list_remove(&fontface->cached->entry);
|
|
|
|
factory_unlock(fontface->factory);
|
|
|
|
heap_free(fontface->cached);
|
2017-08-15 13:40:24 +02:00
|
|
|
}
|
2019-12-02 13:53:53 +01:00
|
|
|
release_scriptshaping_cache(fontface->shaping_cache);
|
|
|
|
if (fontface->vdmx.context)
|
|
|
|
IDWriteFontFace5_ReleaseFontTable(iface, fontface->vdmx.context);
|
|
|
|
if (fontface->gasp.context)
|
|
|
|
IDWriteFontFace5_ReleaseFontTable(iface, fontface->gasp.context);
|
|
|
|
if (fontface->cpal.context)
|
|
|
|
IDWriteFontFace5_ReleaseFontTable(iface, fontface->cpal.context);
|
|
|
|
if (fontface->colr.context)
|
|
|
|
IDWriteFontFace5_ReleaseFontTable(iface, fontface->colr.context);
|
|
|
|
for (i = 0; i < fontface->file_count; i++)
|
|
|
|
{
|
|
|
|
if (fontface->files[i])
|
|
|
|
IDWriteFontFile_Release(fontface->files[i]);
|
2014-11-05 21:30:32 +01:00
|
|
|
}
|
2019-12-02 13:53:53 +01:00
|
|
|
if (fontface->stream)
|
|
|
|
IDWriteFontFileStream_Release(fontface->stream);
|
|
|
|
heap_free(fontface->files);
|
2020-01-24 09:17:34 +01:00
|
|
|
if (fontface->names)
|
|
|
|
IDWriteLocalizedStrings_Release(fontface->names);
|
2020-01-24 09:17:35 +01:00
|
|
|
if (fontface->family_names)
|
|
|
|
IDWriteLocalizedStrings_Release(fontface->family_names);
|
2020-01-24 09:17:37 +01:00
|
|
|
for (i = 0; i < ARRAY_SIZE(fontface->info_strings); ++i)
|
|
|
|
{
|
|
|
|
if (fontface->info_strings[i])
|
|
|
|
IDWriteLocalizedStrings_Release(fontface->info_strings[i]);
|
|
|
|
}
|
2014-12-08 11:24:39 +01:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
for (i = 0; i < ARRAY_SIZE(fontface->glyphs); i++)
|
|
|
|
heap_free(fontface->glyphs[i]);
|
2014-12-08 11:24:39 +01:00
|
|
|
|
|
|
|
freetype_notify_cacheremove(iface);
|
2017-08-15 13:40:24 +02:00
|
|
|
|
2020-06-09 11:14:37 +02:00
|
|
|
dwrite_cmap_release(&fontface->cmap);
|
2019-12-05 09:55:59 +01:00
|
|
|
IDWriteFactory7_Release(fontface->factory);
|
2019-12-02 13:53:53 +01:00
|
|
|
heap_free(fontface);
|
2014-08-17 03:40:48 +02:00
|
|
|
}
|
2012-10-07 21:03:52 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
return refcount;
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static DWRITE_FONT_FACE_TYPE WINAPI dwritefontface_GetType(IDWriteFontFace5 *iface)
|
2012-10-07 21:03:52 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return fontface->type;
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface_GetFiles(IDWriteFontFace5 *iface, UINT32 *number_of_files,
|
2012-10-07 21:03:52 +02:00
|
|
|
IDWriteFontFile **fontfiles)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2014-08-17 03:40:48 +02:00
|
|
|
int i;
|
2014-10-10 08:01:24 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %p, %p.\n", iface, number_of_files, fontfiles);
|
|
|
|
|
2014-08-17 03:40:48 +02:00
|
|
|
if (fontfiles == NULL)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
*number_of_files = fontface->file_count;
|
2014-08-17 03:40:48 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2019-12-02 13:53:53 +01:00
|
|
|
|
|
|
|
if (*number_of_files < fontface->file_count)
|
2014-08-17 03:40:48 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
for (i = 0; i < fontface->file_count; i++)
|
2014-08-17 03:40:48 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
IDWriteFontFile_AddRef(fontface->files[i]);
|
|
|
|
fontfiles[i] = fontface->files[i];
|
2014-08-17 03:40:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static UINT32 WINAPI dwritefontface_GetIndex(IDWriteFontFace5 *iface)
|
2012-10-07 21:03:52 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return fontface->index;
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static DWRITE_FONT_SIMULATIONS WINAPI dwritefontface_GetSimulations(IDWriteFontFace5 *iface)
|
2012-10-07 21:03:52 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return fontface->simulations;
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static BOOL WINAPI dwritefontface_IsSymbolFont(IDWriteFontFace5 *iface)
|
2012-10-07 21:03:52 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
2020-01-23 10:24:12 +01:00
|
|
|
return !!(fontface->flags & FONT_IS_SYMBOL);
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static void WINAPI dwritefontface_GetMetrics(IDWriteFontFace5 *iface, DWRITE_FONT_METRICS *metrics)
|
2012-10-07 21:03:52 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, metrics);
|
|
|
|
|
|
|
|
memcpy(metrics, &fontface->metrics, sizeof(*metrics));
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static UINT16 WINAPI dwritefontface_GetGlyphCount(IDWriteFontFace5 *iface)
|
2012-10-07 21:03:52 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
2015-02-05 13:54:05 +01:00
|
|
|
return freetype_get_glyphcount(iface);
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface_GetDesignGlyphMetrics(IDWriteFontFace5 *iface,
|
2014-12-08 11:24:39 +01:00
|
|
|
UINT16 const *glyphs, UINT32 glyph_count, DWRITE_GLYPH_METRICS *ret, BOOL is_sideways)
|
2012-10-07 21:03:52 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2019-05-13 13:21:47 +02:00
|
|
|
unsigned int i;
|
2014-12-08 11:24:39 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-05-13 13:21:47 +02:00
|
|
|
TRACE("%p, %p, %u, %p, %d.\n", iface, glyphs, glyph_count, ret, is_sideways);
|
2014-12-08 11:24:39 +01:00
|
|
|
|
|
|
|
if (!glyphs)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (is_sideways)
|
|
|
|
FIXME("sideways metrics are not supported.\n");
|
|
|
|
|
|
|
|
for (i = 0; i < glyph_count; i++) {
|
|
|
|
DWRITE_GLYPH_METRICS metrics;
|
|
|
|
|
2019-05-13 13:21:47 +02:00
|
|
|
hr = get_cached_glyph_metrics(fontface, glyphs[i], &metrics);
|
2014-12-08 11:24:39 +01:00
|
|
|
if (hr != S_OK) {
|
2019-05-13 13:21:47 +02:00
|
|
|
freetype_get_design_glyph_metrics(fontface, glyphs[i], &metrics);
|
|
|
|
hr = set_cached_glyph_metrics(fontface, glyphs[i], &metrics);
|
2014-12-08 11:24:39 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
ret[i] = metrics;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface_GetGlyphIndices(IDWriteFontFace5 *iface, UINT32 const *codepoints,
|
2017-04-20 11:50:08 +02:00
|
|
|
UINT32 count, UINT16 *glyphs)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2020-06-09 11:14:37 +02:00
|
|
|
unsigned int i;
|
2017-04-20 11:50:08 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %p, %u, %p.\n", iface, codepoints, count, glyphs);
|
2017-04-20 11:50:08 +02:00
|
|
|
|
2020-05-22 12:58:09 +02:00
|
|
|
if (!glyphs)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (!codepoints)
|
|
|
|
{
|
|
|
|
memset(glyphs, 0, count * sizeof(*glyphs));
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2020-06-09 11:14:37 +02:00
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
glyphs[i] = dwritefontface_get_glyph(fontface, codepoints[i]);
|
|
|
|
|
|
|
|
return S_OK;
|
2017-04-20 11:50:08 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface_TryGetFontTable(IDWriteFontFace5 *iface, UINT32 table_tag,
|
2012-10-07 21:03:52 +02:00
|
|
|
const void **table_data, UINT32 *table_size, void **context, BOOL *exists)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2016-05-03 20:26:48 +02:00
|
|
|
struct file_stream_desc stream_desc;
|
2014-08-17 03:42:24 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %s, %p, %p, %p, %p.\n", iface, debugstr_tag(table_tag), table_data, table_size, context, exists);
|
2014-08-17 03:42:24 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
stream_desc.stream = fontface->stream;
|
|
|
|
stream_desc.face_type = fontface->type;
|
|
|
|
stream_desc.face_index = fontface->index;
|
2020-01-23 10:24:11 +01:00
|
|
|
return opentype_try_get_font_table(&stream_desc, table_tag, table_data, context, table_size, exists);
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static void WINAPI dwritefontface_ReleaseFontTable(IDWriteFontFace5 *iface, void *table_context)
|
2012-10-07 21:03:52 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2014-11-05 21:30:32 +01:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %p.\n", iface, table_context);
|
2014-08-17 03:42:24 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
IDWriteFontFileStream_ReleaseFileFragment(fontface->stream, table_context);
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface_GetGlyphRunOutline(IDWriteFontFace5 *iface, FLOAT emSize,
|
2014-12-15 07:39:26 +01:00
|
|
|
UINT16 const *glyphs, FLOAT const* advances, DWRITE_GLYPH_OFFSET const *offsets,
|
|
|
|
UINT32 count, BOOL is_sideways, BOOL is_rtl, IDWriteGeometrySink *sink)
|
2012-10-07 21:03:52 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %.8e, %p, %p, %p, %u, %d, %d, %p.\n", iface, emSize, glyphs, advances, offsets,
|
2014-12-15 07:39:26 +01:00
|
|
|
count, is_sideways, is_rtl, sink);
|
|
|
|
|
|
|
|
if (!glyphs || !sink)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (is_sideways)
|
|
|
|
FIXME("sideways mode is not supported.\n");
|
|
|
|
|
2016-01-18 22:47:09 +01:00
|
|
|
return freetype_get_glyphrun_outline(iface, emSize, glyphs, advances, offsets, count, is_rtl, sink);
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2015-07-27 10:10:32 +02:00
|
|
|
static DWRITE_RENDERING_MODE fontface_renderingmode_from_measuringmode(DWRITE_MEASURING_MODE measuring,
|
2019-01-27 06:55:26 +01:00
|
|
|
float ppem, unsigned int gasp)
|
2015-07-27 10:10:32 +02:00
|
|
|
{
|
|
|
|
DWRITE_RENDERING_MODE mode = DWRITE_RENDERING_MODE_DEFAULT;
|
|
|
|
|
|
|
|
switch (measuring)
|
|
|
|
{
|
|
|
|
case DWRITE_MEASURING_MODE_NATURAL:
|
|
|
|
{
|
|
|
|
if (!(gasp & GASP_SYMMETRIC_SMOOTHING) && (ppem <= RECOMMENDED_NATURAL_PPEM))
|
|
|
|
mode = DWRITE_RENDERING_MODE_NATURAL;
|
|
|
|
else
|
|
|
|
mode = DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DWRITE_MEASURING_MODE_GDI_CLASSIC:
|
|
|
|
mode = DWRITE_RENDERING_MODE_GDI_CLASSIC;
|
|
|
|
break;
|
|
|
|
case DWRITE_MEASURING_MODE_GDI_NATURAL:
|
|
|
|
mode = DWRITE_RENDERING_MODE_GDI_NATURAL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mode;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface_GetRecommendedRenderingMode(IDWriteFontFace5 *iface, FLOAT emSize,
|
2015-07-27 10:10:32 +02:00
|
|
|
FLOAT ppdip, DWRITE_MEASURING_MODE measuring, IDWriteRenderingParams *params, DWRITE_RENDERING_MODE *mode)
|
2012-10-07 21:03:52 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2019-01-27 06:55:26 +01:00
|
|
|
unsigned int flags;
|
2015-07-27 10:10:32 +02:00
|
|
|
FLOAT ppem;
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %.8e, %.8e, %d, %p, %p.\n", iface, emSize, ppdip, measuring, params, mode);
|
2015-07-27 10:10:32 +02:00
|
|
|
|
|
|
|
if (!params) {
|
|
|
|
*mode = DWRITE_RENDERING_MODE_DEFAULT;
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
*mode = IDWriteRenderingParams_GetRenderingMode(params);
|
|
|
|
if (*mode != DWRITE_RENDERING_MODE_DEFAULT)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
ppem = emSize * ppdip;
|
|
|
|
|
|
|
|
if (ppem >= RECOMMENDED_OUTLINE_AA_THRESHOLD) {
|
|
|
|
*mode = DWRITE_RENDERING_MODE_OUTLINE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
flags = opentype_get_gasp_flags(get_fontface_gasp(fontface), ppem);
|
2019-01-27 06:55:26 +01:00
|
|
|
*mode = fontface_renderingmode_from_measuringmode(measuring, ppem, flags);
|
2015-07-27 10:10:32 +02:00
|
|
|
return S_OK;
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface_GetGdiCompatibleMetrics(IDWriteFontFace5 *iface, FLOAT emSize, FLOAT pixels_per_dip,
|
2012-10-07 21:03:52 +02:00
|
|
|
DWRITE_MATRIX const *transform, DWRITE_FONT_METRICS *metrics)
|
|
|
|
{
|
2015-02-03 09:20:06 +01:00
|
|
|
DWRITE_FONT_METRICS1 metrics1;
|
2019-12-02 13:53:53 +01:00
|
|
|
HRESULT hr = IDWriteFontFace5_GetGdiCompatibleMetrics(iface, emSize, pixels_per_dip, transform, &metrics1);
|
2015-02-03 09:20:06 +01:00
|
|
|
memcpy(metrics, &metrics1, sizeof(*metrics));
|
|
|
|
return hr;
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2015-07-15 18:59:46 +02:00
|
|
|
static inline int round_metric(FLOAT metric)
|
|
|
|
{
|
|
|
|
return (int)floorf(metric + 0.5f);
|
|
|
|
}
|
|
|
|
|
2017-03-15 20:35:32 +01:00
|
|
|
static UINT32 fontface_get_horz_metric_adjustment(const struct dwrite_fontface *fontface)
|
|
|
|
{
|
|
|
|
if (!(fontface->simulations & DWRITE_FONT_SIMULATIONS_BOLD))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return (fontface->metrics.designUnitsPerEm + 49) / 50;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface_GetGdiCompatibleGlyphMetrics(IDWriteFontFace5 *iface, FLOAT emSize, FLOAT ppdip,
|
2015-07-15 18:59:46 +02:00
|
|
|
DWRITE_MATRIX const *m, BOOL use_gdi_natural, UINT16 const *glyphs, UINT32 glyph_count,
|
2012-10-07 21:03:52 +02:00
|
|
|
DWRITE_GLYPH_METRICS *metrics, BOOL is_sideways)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
UINT32 adjustment = fontface_get_horz_metric_adjustment(fontface);
|
2015-08-24 09:43:19 +02:00
|
|
|
DWRITE_MEASURING_MODE mode;
|
|
|
|
FLOAT scale, size;
|
2015-07-15 18:59:46 +02:00
|
|
|
HRESULT hr;
|
|
|
|
UINT32 i;
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %.8e, %.8e, %p, %d, %p, %u, %p, %d.\n", iface, emSize, ppdip, m, use_gdi_natural, glyphs,
|
2012-10-07 21:03:52 +02:00
|
|
|
glyph_count, metrics, is_sideways);
|
2015-07-15 18:59:46 +02:00
|
|
|
|
|
|
|
if (m && memcmp(m, &identity, sizeof(*m)))
|
|
|
|
FIXME("transform is not supported, %s\n", debugstr_matrix(m));
|
|
|
|
|
2015-08-24 09:43:19 +02:00
|
|
|
size = emSize * ppdip;
|
2019-12-02 13:53:53 +01:00
|
|
|
scale = size / fontface->metrics.designUnitsPerEm;
|
2015-08-24 09:43:19 +02:00
|
|
|
mode = use_gdi_natural ? DWRITE_MEASURING_MODE_GDI_NATURAL : DWRITE_MEASURING_MODE_GDI_CLASSIC;
|
2015-07-15 18:59:46 +02:00
|
|
|
|
|
|
|
for (i = 0; i < glyph_count; i++) {
|
|
|
|
DWRITE_GLYPH_METRICS *ret = metrics + i;
|
|
|
|
DWRITE_GLYPH_METRICS design;
|
2017-03-15 20:35:32 +01:00
|
|
|
BOOL has_contours;
|
2015-07-15 18:59:46 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
hr = IDWriteFontFace5_GetDesignGlyphMetrics(iface, glyphs + i, 1, &design, is_sideways);
|
2015-07-15 18:59:46 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2017-03-15 20:35:32 +01:00
|
|
|
ret->advanceWidth = freetype_get_glyph_advance(iface, size, glyphs[i], mode, &has_contours);
|
|
|
|
if (has_contours)
|
2019-12-02 13:53:53 +01:00
|
|
|
ret->advanceWidth = round_metric(ret->advanceWidth * fontface->metrics.designUnitsPerEm / size + adjustment);
|
2017-03-15 20:35:32 +01:00
|
|
|
else
|
2019-12-02 13:53:53 +01:00
|
|
|
ret->advanceWidth = round_metric(ret->advanceWidth * fontface->metrics.designUnitsPerEm / size);
|
2015-08-24 09:43:19 +02:00
|
|
|
|
2015-07-15 18:59:46 +02:00
|
|
|
#define SCALE_METRIC(x) ret->x = round_metric(round_metric((design.x) * scale) / scale)
|
|
|
|
SCALE_METRIC(leftSideBearing);
|
|
|
|
SCALE_METRIC(rightSideBearing);
|
|
|
|
SCALE_METRIC(topSideBearing);
|
|
|
|
SCALE_METRIC(advanceHeight);
|
|
|
|
SCALE_METRIC(bottomSideBearing);
|
|
|
|
SCALE_METRIC(verticalOriginY);
|
|
|
|
#undef SCALE_METRIC
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2012-10-07 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static void WINAPI dwritefontface1_GetMetrics(IDWriteFontFace5 *iface, DWRITE_FONT_METRICS1 *metrics)
|
2014-10-10 08:01:24 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, metrics);
|
|
|
|
|
|
|
|
*metrics = fontface->metrics;
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface1_GetGdiCompatibleMetrics(IDWriteFontFace5 *iface, FLOAT em_size,
|
|
|
|
FLOAT pixels_per_dip, const DWRITE_MATRIX *m, DWRITE_FONT_METRICS1 *metrics)
|
2014-10-10 08:01:24 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
const DWRITE_FONT_METRICS1 *design = &fontface->metrics;
|
2015-07-08 11:36:48 +02:00
|
|
|
UINT16 ascent, descent;
|
|
|
|
FLOAT scale;
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %.8e, %.8e, %p, %p.\n", iface, em_size, pixels_per_dip, m, metrics);
|
2015-07-08 11:36:48 +02:00
|
|
|
|
2016-01-11 14:15:53 +01:00
|
|
|
if (em_size <= 0.0f || pixels_per_dip <= 0.0f) {
|
2015-07-08 11:36:48 +02:00
|
|
|
memset(metrics, 0, sizeof(*metrics));
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
em_size *= pixels_per_dip;
|
2016-01-11 14:15:53 +01:00
|
|
|
if (m && m->m22 != 0.0f)
|
2015-07-08 11:36:48 +02:00
|
|
|
em_size *= fabs(m->m22);
|
|
|
|
|
|
|
|
scale = em_size / design->designUnitsPerEm;
|
2019-12-02 13:53:53 +01:00
|
|
|
if (!opentype_get_vdmx_size(get_fontface_vdmx(fontface), em_size, &ascent, &descent))
|
|
|
|
{
|
2015-07-08 11:36:48 +02:00
|
|
|
ascent = round_metric(design->ascent * scale);
|
|
|
|
descent = round_metric(design->descent * scale);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SCALE_METRIC(x) metrics->x = round_metric(round_metric((design->x) * scale) / scale)
|
|
|
|
metrics->designUnitsPerEm = design->designUnitsPerEm;
|
|
|
|
metrics->ascent = round_metric(ascent / scale);
|
|
|
|
metrics->descent = round_metric(descent / scale);
|
|
|
|
|
|
|
|
SCALE_METRIC(lineGap);
|
|
|
|
SCALE_METRIC(capHeight);
|
|
|
|
SCALE_METRIC(xHeight);
|
|
|
|
SCALE_METRIC(underlinePosition);
|
|
|
|
SCALE_METRIC(underlineThickness);
|
|
|
|
SCALE_METRIC(strikethroughPosition);
|
|
|
|
SCALE_METRIC(strikethroughThickness);
|
|
|
|
SCALE_METRIC(glyphBoxLeft);
|
|
|
|
SCALE_METRIC(glyphBoxTop);
|
|
|
|
SCALE_METRIC(glyphBoxRight);
|
|
|
|
SCALE_METRIC(glyphBoxBottom);
|
|
|
|
SCALE_METRIC(subscriptPositionX);
|
|
|
|
SCALE_METRIC(subscriptPositionY);
|
|
|
|
SCALE_METRIC(subscriptSizeX);
|
|
|
|
SCALE_METRIC(subscriptSizeY);
|
|
|
|
SCALE_METRIC(superscriptPositionX);
|
|
|
|
SCALE_METRIC(superscriptPositionY);
|
|
|
|
SCALE_METRIC(superscriptSizeX);
|
|
|
|
SCALE_METRIC(superscriptSizeY);
|
|
|
|
|
|
|
|
metrics->hasTypographicMetrics = design->hasTypographicMetrics;
|
|
|
|
#undef SCALE_METRIC
|
|
|
|
|
|
|
|
return S_OK;
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static void WINAPI dwritefontface1_GetCaretMetrics(IDWriteFontFace5 *iface, DWRITE_CARET_METRICS *metrics)
|
2014-10-10 08:01:24 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, metrics);
|
|
|
|
|
|
|
|
*metrics = fontface->caret;
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface1_GetUnicodeRanges(IDWriteFontFace5 *iface, UINT32 max_count,
|
2014-10-10 08:01:24 +02:00
|
|
|
DWRITE_UNICODE_RANGE *ranges, UINT32 *count)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2014-10-16 05:33:51 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, max_count, ranges, count);
|
2014-10-16 05:33:51 +02:00
|
|
|
|
|
|
|
*count = 0;
|
|
|
|
if (max_count && !ranges)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2020-06-10 16:21:29 +02:00
|
|
|
dwrite_cmap_init(&fontface->cmap, NULL, fontface->index, fontface->type);
|
|
|
|
return opentype_cmap_get_unicode_ranges(&fontface->cmap, max_count, ranges, count);
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static BOOL WINAPI dwritefontface1_IsMonospacedFont(IDWriteFontFace5 *iface)
|
2014-10-10 08:01:24 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
2020-01-23 10:24:13 +01:00
|
|
|
return !!(fontface->flags & FONT_IS_MONOSPACED);
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-01-25 12:56:41 +01:00
|
|
|
static int fontface_get_design_advance(struct dwrite_fontface *fontface, DWRITE_MEASURING_MODE measuring_mode,
|
|
|
|
float emsize, float ppdip, const DWRITE_MATRIX *transform, UINT16 glyph, BOOL is_sideways)
|
|
|
|
{
|
|
|
|
unsigned int adjustment = fontface_get_horz_metric_adjustment(fontface);
|
|
|
|
BOOL has_contours;
|
|
|
|
int advance;
|
|
|
|
|
|
|
|
if (is_sideways)
|
|
|
|
FIXME("Sideways mode is not supported.\n");
|
|
|
|
|
|
|
|
switch (measuring_mode)
|
|
|
|
{
|
|
|
|
case DWRITE_MEASURING_MODE_NATURAL:
|
2019-12-02 13:53:53 +01:00
|
|
|
advance = freetype_get_glyph_advance(&fontface->IDWriteFontFace5_iface, fontface->metrics.designUnitsPerEm,
|
2019-01-25 12:56:41 +01:00
|
|
|
glyph, measuring_mode, &has_contours);
|
|
|
|
if (has_contours)
|
|
|
|
advance += adjustment;
|
|
|
|
|
|
|
|
return advance;
|
|
|
|
case DWRITE_MEASURING_MODE_GDI_NATURAL:
|
|
|
|
case DWRITE_MEASURING_MODE_GDI_CLASSIC:
|
|
|
|
emsize *= ppdip;
|
|
|
|
if (emsize == 0.0f)
|
|
|
|
return 0.0f;
|
|
|
|
|
|
|
|
if (transform && memcmp(transform, &identity, sizeof(*transform)))
|
|
|
|
FIXME("Transform is not supported.\n");
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
advance = freetype_get_glyph_advance(&fontface->IDWriteFontFace5_iface, emsize, glyph, measuring_mode,
|
2019-01-25 12:56:41 +01:00
|
|
|
&has_contours);
|
|
|
|
if (has_contours)
|
|
|
|
advance = round_metric(advance * fontface->metrics.designUnitsPerEm / emsize + adjustment);
|
|
|
|
else
|
|
|
|
advance = round_metric(advance * fontface->metrics.designUnitsPerEm / emsize);
|
|
|
|
|
|
|
|
return advance;
|
|
|
|
default:
|
|
|
|
WARN("Unknown measuring mode %u.\n", measuring_mode);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface1_GetDesignGlyphAdvances(IDWriteFontFace5 *iface,
|
2014-12-09 08:00:45 +01:00
|
|
|
UINT32 glyph_count, UINT16 const *glyphs, INT32 *advances, BOOL is_sideways)
|
2014-10-10 08:01:24 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2019-01-25 12:56:41 +01:00
|
|
|
unsigned int i;
|
2014-12-09 08:00:45 +01:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %u, %p, %p, %d.\n", iface, glyph_count, glyphs, advances, is_sideways);
|
2014-12-09 08:00:45 +01:00
|
|
|
|
2015-08-24 09:43:19 +02:00
|
|
|
if (is_sideways)
|
|
|
|
FIXME("sideways mode not supported\n");
|
2014-12-09 08:00:45 +01:00
|
|
|
|
2019-01-25 12:56:41 +01:00
|
|
|
for (i = 0; i < glyph_count; ++i)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
advances[i] = fontface_get_design_advance(fontface, DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
fontface->metrics.designUnitsPerEm, 1.0f, NULL, glyphs[i], is_sideways);
|
2017-03-15 20:35:32 +01:00
|
|
|
}
|
2014-12-09 08:00:45 +01:00
|
|
|
|
|
|
|
return S_OK;
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface1_GetGdiCompatibleGlyphAdvances(IDWriteFontFace5 *iface,
|
2019-01-25 12:56:41 +01:00
|
|
|
float em_size, float ppdip, const DWRITE_MATRIX *transform, BOOL use_gdi_natural,
|
2015-07-15 13:40:32 +02:00
|
|
|
BOOL is_sideways, UINT32 glyph_count, UINT16 const *glyphs, INT32 *advances)
|
2014-10-10 08:01:24 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2019-01-25 12:56:41 +01:00
|
|
|
DWRITE_MEASURING_MODE measuring_mode;
|
2015-07-15 13:40:32 +02:00
|
|
|
UINT32 i;
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %.8e, %.8e, %p, %d, %d, %u, %p, %p.\n", iface, em_size, ppdip, transform,
|
2015-07-15 13:40:32 +02:00
|
|
|
use_gdi_natural, is_sideways, glyph_count, glyphs, advances);
|
|
|
|
|
2016-01-11 14:15:53 +01:00
|
|
|
if (em_size < 0.0f || ppdip <= 0.0f) {
|
2015-07-20 14:13:58 +02:00
|
|
|
memset(advances, 0, sizeof(*advances) * glyph_count);
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
2015-07-15 13:40:32 +02:00
|
|
|
|
2016-01-11 14:15:53 +01:00
|
|
|
if (em_size == 0.0f) {
|
2015-07-20 14:13:58 +02:00
|
|
|
memset(advances, 0, sizeof(*advances) * glyph_count);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-01-25 12:56:41 +01:00
|
|
|
measuring_mode = use_gdi_natural ? DWRITE_MEASURING_MODE_GDI_NATURAL : DWRITE_MEASURING_MODE_GDI_CLASSIC;
|
|
|
|
for (i = 0; i < glyph_count; ++i)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
advances[i] = fontface_get_design_advance(fontface, measuring_mode, em_size, ppdip, transform,
|
2019-01-25 12:56:41 +01:00
|
|
|
glyphs[i], is_sideways);
|
2015-07-15 13:40:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface1_GetKerningPairAdjustments(IDWriteFontFace5 *iface, UINT32 count,
|
2014-10-10 08:01:24 +02:00
|
|
|
const UINT16 *indices, INT32 *adjustments)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2015-03-13 21:19:18 +01:00
|
|
|
UINT32 i;
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, count, indices, adjustments);
|
2015-03-13 21:19:18 +01:00
|
|
|
|
|
|
|
if (!(indices || adjustments) || !count)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (!indices || count == 1) {
|
|
|
|
memset(adjustments, 0, count*sizeof(INT32));
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
if (!(fontface->flags & FONTFACE_HAS_KERNING_PAIRS))
|
|
|
|
{
|
2016-01-21 19:58:41 +01:00
|
|
|
memset(adjustments, 0, count*sizeof(INT32));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-03-13 21:19:18 +01:00
|
|
|
for (i = 0; i < count-1; i++)
|
|
|
|
adjustments[i] = freetype_get_kerning_pair_adjustment(iface, indices[i], indices[i+1]);
|
|
|
|
adjustments[count-1] = 0;
|
|
|
|
|
|
|
|
return S_OK;
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static BOOL WINAPI dwritefontface1_HasKerningPairs(IDWriteFontFace5 *iface)
|
2014-10-10 08:01:24 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return !!(fontface->flags & FONTFACE_HAS_KERNING_PAIRS);
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface1_GetRecommendedRenderingMode(IDWriteFontFace5 *iface,
|
2014-10-10 08:01:24 +02:00
|
|
|
FLOAT font_emsize, FLOAT dpiX, FLOAT dpiY, const DWRITE_MATRIX *transform, BOOL is_sideways,
|
|
|
|
DWRITE_OUTLINE_THRESHOLD threshold, DWRITE_MEASURING_MODE measuring_mode, DWRITE_RENDERING_MODE *rendering_mode)
|
|
|
|
{
|
2015-06-19 12:58:09 +02:00
|
|
|
DWRITE_GRID_FIT_MODE gridfitmode;
|
2019-12-02 13:53:53 +01:00
|
|
|
return IDWriteFontFace2_GetRecommendedRenderingMode((IDWriteFontFace2 *)iface, font_emsize, dpiX, dpiY, transform,
|
|
|
|
is_sideways, threshold, measuring_mode, NULL, rendering_mode, &gridfitmode);
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface1_GetVerticalGlyphVariants(IDWriteFontFace5 *iface, UINT32 glyph_count,
|
2020-06-10 16:21:30 +02:00
|
|
|
const UINT16 *nominal_glyphs, UINT16 *glyphs)
|
2014-10-10 08:01:24 +02:00
|
|
|
{
|
2020-06-10 16:21:30 +02:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, glyph_count, nominal_glyphs, glyphs);
|
2019-12-02 13:53:53 +01:00
|
|
|
|
2020-06-10 16:21:30 +02:00
|
|
|
return opentype_get_vertical_glyph_variants(fontface, glyph_count, nominal_glyphs, glyphs);
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static BOOL WINAPI dwritefontface1_HasVerticalGlyphVariants(IDWriteFontFace5 *iface)
|
2014-10-10 08:01:24 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return !!(fontface->flags & FONTFACE_HAS_VERTICAL_VARIANTS);
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static BOOL WINAPI dwritefontface2_IsColorFont(IDWriteFontFace5 *iface)
|
2014-10-10 08:01:24 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
2020-01-23 10:24:14 +01:00
|
|
|
return !!(fontface->flags & FONT_IS_COLORED);
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static UINT32 WINAPI dwritefontface2_GetColorPaletteCount(IDWriteFontFace5 *iface)
|
2014-10-10 08:01:24 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return opentype_get_cpal_palettecount(get_fontface_cpal(fontface));
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static UINT32 WINAPI dwritefontface2_GetPaletteEntryCount(IDWriteFontFace5 *iface)
|
2014-10-10 08:01:24 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return opentype_get_cpal_paletteentrycount(get_fontface_cpal(fontface));
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface2_GetPaletteEntries(IDWriteFontFace5 *iface, UINT32 palette_index,
|
2014-10-10 08:01:24 +02:00
|
|
|
UINT32 first_entry_index, UINT32 entry_count, DWRITE_COLOR_F *entries)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %u, %u, %u, %p.\n", iface, palette_index, first_entry_index, entry_count, entries);
|
|
|
|
|
|
|
|
return opentype_get_cpal_entries(get_fontface_cpal(fontface), palette_index, first_entry_index, entry_count, entries);
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface2_GetRecommendedRenderingMode(IDWriteFontFace5 *iface, FLOAT emSize,
|
2015-07-27 10:10:32 +02:00
|
|
|
FLOAT dpiX, FLOAT dpiY, DWRITE_MATRIX const *m, BOOL is_sideways, DWRITE_OUTLINE_THRESHOLD threshold,
|
2014-10-10 08:01:24 +02:00
|
|
|
DWRITE_MEASURING_MODE measuringmode, IDWriteRenderingParams *params, DWRITE_RENDERING_MODE *renderingmode,
|
|
|
|
DWRITE_GRID_FIT_MODE *gridfitmode)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2019-01-27 06:55:26 +01:00
|
|
|
unsigned int flags;
|
2015-07-27 10:10:32 +02:00
|
|
|
FLOAT emthreshold;
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %.8e, %.8e, %.8e, %p, %d, %d, %d, %p, %p, %p.\n", iface, emSize, dpiX, dpiY, m, is_sideways, threshold,
|
2014-10-10 08:01:24 +02:00
|
|
|
measuringmode, params, renderingmode, gridfitmode);
|
2015-07-27 10:10:32 +02:00
|
|
|
|
|
|
|
if (m)
|
|
|
|
FIXME("transform not supported %s\n", debugstr_matrix(m));
|
|
|
|
|
|
|
|
if (is_sideways)
|
|
|
|
FIXME("sideways mode not supported\n");
|
|
|
|
|
2015-10-27 20:42:10 +01:00
|
|
|
emSize *= max(dpiX, dpiY) / 96.0f;
|
|
|
|
|
2015-07-27 10:10:32 +02:00
|
|
|
*renderingmode = DWRITE_RENDERING_MODE_DEFAULT;
|
|
|
|
*gridfitmode = DWRITE_GRID_FIT_MODE_DEFAULT;
|
|
|
|
if (params) {
|
|
|
|
IDWriteRenderingParams2 *params2;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IDWriteRenderingParams_QueryInterface(params, &IID_IDWriteRenderingParams2, (void**)¶ms2);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
*renderingmode = IDWriteRenderingParams2_GetRenderingMode(params2);
|
|
|
|
*gridfitmode = IDWriteRenderingParams2_GetGridFitMode(params2);
|
|
|
|
IDWriteRenderingParams2_Release(params2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*renderingmode = IDWriteRenderingParams_GetRenderingMode(params);
|
|
|
|
}
|
|
|
|
|
|
|
|
emthreshold = threshold == DWRITE_OUTLINE_THRESHOLD_ANTIALIASED ? RECOMMENDED_OUTLINE_AA_THRESHOLD : RECOMMENDED_OUTLINE_A_THRESHOLD;
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
flags = opentype_get_gasp_flags(get_fontface_gasp(fontface), emSize);
|
2015-07-27 10:10:32 +02:00
|
|
|
|
|
|
|
if (*renderingmode == DWRITE_RENDERING_MODE_DEFAULT) {
|
|
|
|
if (emSize >= emthreshold)
|
|
|
|
*renderingmode = DWRITE_RENDERING_MODE_OUTLINE;
|
|
|
|
else
|
2019-01-27 06:55:26 +01:00
|
|
|
*renderingmode = fontface_renderingmode_from_measuringmode(measuringmode, emSize, flags);
|
2015-07-27 10:10:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*gridfitmode == DWRITE_GRID_FIT_MODE_DEFAULT) {
|
|
|
|
if (emSize >= emthreshold)
|
|
|
|
*gridfitmode = DWRITE_GRID_FIT_MODE_DISABLED;
|
|
|
|
else if (measuringmode == DWRITE_MEASURING_MODE_GDI_CLASSIC || measuringmode == DWRITE_MEASURING_MODE_GDI_NATURAL)
|
|
|
|
*gridfitmode = DWRITE_GRID_FIT_MODE_ENABLED;
|
|
|
|
else
|
2019-01-27 06:55:26 +01:00
|
|
|
*gridfitmode = flags & (GASP_GRIDFIT|GASP_SYMMETRIC_GRIDFIT) ?
|
|
|
|
DWRITE_GRID_FIT_MODE_ENABLED : DWRITE_GRID_FIT_MODE_DISABLED;
|
2015-07-27 10:10:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2014-10-10 08:01:24 +02:00
|
|
|
}
|
|
|
|
|
2020-02-03 17:08:31 +01:00
|
|
|
static HRESULT WINAPI dwritefontface3_GetFontFaceReference(IDWriteFontFace5 *iface,
|
|
|
|
IDWriteFontFaceReference **reference)
|
2016-03-03 06:16:25 +01:00
|
|
|
{
|
2020-02-03 17:08:31 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2019-12-02 13:53:53 +01:00
|
|
|
|
2020-02-03 17:08:31 +01:00
|
|
|
TRACE("%p, %p.\n", iface, reference);
|
|
|
|
|
|
|
|
*reference = &fontface->IDWriteFontFaceReference_iface;
|
|
|
|
IDWriteFontFaceReference_AddRef(*reference);
|
|
|
|
|
|
|
|
return S_OK;
|
2016-03-03 06:16:25 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static void WINAPI dwritefontface3_GetPanose(IDWriteFontFace5 *iface, DWRITE_PANOSE *panose)
|
2016-03-03 06:16:25 +01:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, panose);
|
|
|
|
|
|
|
|
*panose = fontface->panose;
|
2016-03-03 06:16:25 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static DWRITE_FONT_WEIGHT WINAPI dwritefontface3_GetWeight(IDWriteFontFace5 *iface)
|
2016-03-03 06:16:25 +01:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return fontface->weight;
|
2016-03-03 06:16:25 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static DWRITE_FONT_STRETCH WINAPI dwritefontface3_GetStretch(IDWriteFontFace5 *iface)
|
2016-03-03 06:16:25 +01:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return fontface->stretch;
|
2016-03-03 06:16:25 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static DWRITE_FONT_STYLE WINAPI dwritefontface3_GetStyle(IDWriteFontFace5 *iface)
|
2016-03-03 06:16:25 +01:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return fontface->style;
|
2016-03-03 06:16:25 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface3_GetFamilyNames(IDWriteFontFace5 *iface, IDWriteLocalizedStrings **names)
|
2016-03-03 06:16:25 +01:00
|
|
|
{
|
2020-01-24 09:17:35 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2019-12-02 13:53:53 +01:00
|
|
|
|
2020-01-24 09:17:35 +01:00
|
|
|
TRACE("%p, %p.\n", iface, names);
|
|
|
|
|
|
|
|
return clone_localizedstrings(fontface->family_names, names);
|
2016-03-03 06:16:25 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface3_GetFaceNames(IDWriteFontFace5 *iface, IDWriteLocalizedStrings **names)
|
2016-03-03 06:16:25 +01:00
|
|
|
{
|
2020-01-24 09:17:34 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2019-12-02 13:53:53 +01:00
|
|
|
|
2020-01-24 09:17:34 +01:00
|
|
|
TRACE("%p, %p.\n", iface, names);
|
|
|
|
|
|
|
|
return clone_localizedstrings(fontface->names, names);
|
2016-03-03 06:16:25 +01:00
|
|
|
}
|
|
|
|
|
2020-01-24 09:17:37 +01:00
|
|
|
static HRESULT get_font_info_strings(const struct file_stream_desc *stream_desc, IDWriteFontFile *file,
|
|
|
|
DWRITE_INFORMATIONAL_STRING_ID stringid, IDWriteLocalizedStrings **strings_cache,
|
|
|
|
IDWriteLocalizedStrings **ret, BOOL *exists)
|
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
*exists = FALSE;
|
|
|
|
*ret = NULL;
|
|
|
|
|
2020-01-27 06:52:48 +01:00
|
|
|
if (stringid > DWRITE_INFORMATIONAL_STRING_SUPPORTED_SCRIPT_LANGUAGE_TAG
|
|
|
|
|| stringid <= DWRITE_INFORMATIONAL_STRING_NONE)
|
2020-01-24 09:17:38 +01:00
|
|
|
{
|
2020-01-24 09:17:37 +01:00
|
|
|
return S_OK;
|
2020-01-24 09:17:38 +01:00
|
|
|
}
|
2020-01-24 09:17:37 +01:00
|
|
|
|
|
|
|
if (!strings_cache[stringid])
|
|
|
|
{
|
|
|
|
struct file_stream_desc desc = *stream_desc;
|
|
|
|
|
|
|
|
if (!desc.stream)
|
|
|
|
hr = get_filestream_from_file(file, &desc.stream);
|
|
|
|
if (SUCCEEDED(hr))
|
2020-01-24 09:17:38 +01:00
|
|
|
opentype_get_font_info_strings(&desc, stringid, &strings_cache[stringid]);
|
2020-01-24 09:17:37 +01:00
|
|
|
|
|
|
|
if (!stream_desc->stream && desc.stream)
|
|
|
|
IDWriteFontFileStream_Release(desc.stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr) && strings_cache[stringid])
|
|
|
|
{
|
|
|
|
hr = clone_localizedstrings(strings_cache[stringid], ret);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
*exists = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface3_GetInformationalStrings(IDWriteFontFace5 *iface,
|
|
|
|
DWRITE_INFORMATIONAL_STRING_ID stringid, IDWriteLocalizedStrings **strings, BOOL *exists)
|
2016-03-03 06:16:25 +01:00
|
|
|
{
|
2020-01-24 09:17:37 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
|
|
|
struct file_stream_desc stream_desc;
|
2019-12-02 13:53:53 +01:00
|
|
|
|
2020-01-24 09:17:37 +01:00
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, stringid, strings, exists);
|
|
|
|
|
|
|
|
stream_desc.stream = fontface->stream;
|
|
|
|
stream_desc.face_index = fontface->index;
|
|
|
|
stream_desc.face_type = fontface->type;
|
|
|
|
return get_font_info_strings(&stream_desc, NULL, stringid, fontface->info_strings, strings, exists);
|
2016-03-03 06:16:25 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static BOOL WINAPI dwritefontface3_HasCharacter(IDWriteFontFace5 *iface, UINT32 ch)
|
2016-03-03 06:16:25 +01:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2016-03-03 06:16:26 +01:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %#x.\n", iface, ch);
|
2016-03-03 06:16:26 +01:00
|
|
|
|
2020-06-09 11:14:37 +02:00
|
|
|
return !!dwritefontface_get_glyph(fontface, ch);
|
2016-03-03 06:16:25 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface3_GetRecommendedRenderingMode(IDWriteFontFace5 *iface, FLOAT emSize, FLOAT dpiX, FLOAT dpiY,
|
2016-06-06 19:31:30 +02:00
|
|
|
DWRITE_MATRIX const *m, BOOL is_sideways, DWRITE_OUTLINE_THRESHOLD threshold, DWRITE_MEASURING_MODE measuring_mode,
|
2016-03-03 06:16:25 +01:00
|
|
|
IDWriteRenderingParams *params, DWRITE_RENDERING_MODE1 *rendering_mode, DWRITE_GRID_FIT_MODE *gridfit_mode)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2019-01-27 06:55:26 +01:00
|
|
|
unsigned int flags;
|
2016-06-06 19:31:30 +02:00
|
|
|
FLOAT emthreshold;
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %.8e, %.8e, %.8e, %p, %d, %d, %d, %p, %p, %p.\n", iface, emSize, dpiX, dpiY, m, is_sideways, threshold,
|
2016-03-03 06:16:25 +01:00
|
|
|
measuring_mode, params, rendering_mode, gridfit_mode);
|
2016-06-06 19:31:30 +02:00
|
|
|
|
|
|
|
if (m)
|
|
|
|
FIXME("transform not supported %s\n", debugstr_matrix(m));
|
|
|
|
|
|
|
|
if (is_sideways)
|
|
|
|
FIXME("sideways mode not supported\n");
|
|
|
|
|
|
|
|
emSize *= max(dpiX, dpiY) / 96.0f;
|
|
|
|
|
2017-01-26 05:41:46 +01:00
|
|
|
*rendering_mode = DWRITE_RENDERING_MODE1_DEFAULT;
|
2016-06-06 19:31:30 +02:00
|
|
|
*gridfit_mode = DWRITE_GRID_FIT_MODE_DEFAULT;
|
|
|
|
if (params) {
|
|
|
|
IDWriteRenderingParams3 *params3;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IDWriteRenderingParams_QueryInterface(params, &IID_IDWriteRenderingParams3, (void**)¶ms3);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
*rendering_mode = IDWriteRenderingParams3_GetRenderingMode1(params3);
|
|
|
|
*gridfit_mode = IDWriteRenderingParams3_GetGridFitMode(params3);
|
|
|
|
IDWriteRenderingParams3_Release(params3);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*rendering_mode = IDWriteRenderingParams_GetRenderingMode(params);
|
|
|
|
}
|
|
|
|
|
|
|
|
emthreshold = threshold == DWRITE_OUTLINE_THRESHOLD_ANTIALIASED ? RECOMMENDED_OUTLINE_AA_THRESHOLD : RECOMMENDED_OUTLINE_A_THRESHOLD;
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
flags = opentype_get_gasp_flags(get_fontface_gasp(fontface), emSize);
|
2016-06-06 19:31:30 +02:00
|
|
|
|
|
|
|
if (*rendering_mode == DWRITE_RENDERING_MODE1_DEFAULT) {
|
|
|
|
if (emSize >= emthreshold)
|
|
|
|
*rendering_mode = DWRITE_RENDERING_MODE1_OUTLINE;
|
|
|
|
else
|
2019-01-27 06:55:26 +01:00
|
|
|
*rendering_mode = fontface_renderingmode_from_measuringmode(measuring_mode, emSize, flags);
|
2016-06-06 19:31:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*gridfit_mode == DWRITE_GRID_FIT_MODE_DEFAULT) {
|
|
|
|
if (emSize >= emthreshold)
|
|
|
|
*gridfit_mode = DWRITE_GRID_FIT_MODE_DISABLED;
|
|
|
|
else if (measuring_mode == DWRITE_MEASURING_MODE_GDI_CLASSIC || measuring_mode == DWRITE_MEASURING_MODE_GDI_NATURAL)
|
|
|
|
*gridfit_mode = DWRITE_GRID_FIT_MODE_ENABLED;
|
|
|
|
else
|
2019-01-27 06:55:26 +01:00
|
|
|
*gridfit_mode = flags & (GASP_GRIDFIT|GASP_SYMMETRIC_GRIDFIT) ?
|
|
|
|
DWRITE_GRID_FIT_MODE_ENABLED : DWRITE_GRID_FIT_MODE_DISABLED;
|
2016-06-06 19:31:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2016-03-03 06:16:25 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static BOOL WINAPI dwritefontface3_IsCharacterLocal(IDWriteFontFace5 *iface, UINT32 ch)
|
2016-03-03 06:16:25 +01:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
FIXME("%p, %#x: stub\n", iface, ch);
|
|
|
|
|
2016-03-03 06:16:25 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static BOOL WINAPI dwritefontface3_IsGlyphLocal(IDWriteFontFace5 *iface, UINT16 glyph)
|
2016-03-03 06:16:25 +01:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
FIXME("%p, %u: stub\n", iface, glyph);
|
|
|
|
|
2016-03-03 06:16:25 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface3_AreCharactersLocal(IDWriteFontFace5 *iface, WCHAR const *text,
|
2016-03-03 06:16:25 +01:00
|
|
|
UINT32 count, BOOL enqueue_if_not, BOOL *are_local)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
FIXME("%p, %s:%u, %d %p: stub\n", iface, debugstr_wn(text, count), count, enqueue_if_not, are_local);
|
|
|
|
|
2016-03-03 06:16:25 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface3_AreGlyphsLocal(IDWriteFontFace5 *iface, UINT16 const *glyphs,
|
2016-03-03 06:16:25 +01:00
|
|
|
UINT32 count, BOOL enqueue_if_not, BOOL *are_local)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
FIXME("%p, %p, %u, %d, %p: stub\n", iface, glyphs, count, enqueue_if_not, are_local);
|
|
|
|
|
2016-03-03 06:16:25 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface4_GetGlyphImageFormats_(IDWriteFontFace5 *iface, UINT16 glyph,
|
2016-10-29 20:25:54 +02:00
|
|
|
UINT32 ppem_first, UINT32 ppem_last, DWRITE_GLYPH_IMAGE_FORMATS *formats)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
FIXME("%p, %u, %u, %u, %p: stub\n", iface, glyph, ppem_first, ppem_last, formats);
|
|
|
|
|
2016-10-29 20:25:54 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static DWRITE_GLYPH_IMAGE_FORMATS WINAPI dwritefontface4_GetGlyphImageFormats(IDWriteFontFace5 *iface)
|
2016-10-29 20:25:54 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2017-04-21 13:28:24 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p.\n", iface);
|
2017-04-21 13:28:24 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
return fontface->glyph_image_formats;
|
2016-10-29 20:25:54 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface4_GetGlyphImageData(IDWriteFontFace5 *iface, UINT16 glyph,
|
2016-10-29 20:25:54 +02:00
|
|
|
UINT32 ppem, DWRITE_GLYPH_IMAGE_FORMATS format, DWRITE_GLYPH_IMAGE_DATA *data, void **context)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
FIXME("%p, %u, %u, %d, %p, %p: stub\n", iface, glyph, ppem, format, data, context);
|
|
|
|
|
2016-10-29 20:25:54 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static void WINAPI dwritefontface4_ReleaseGlyphImageData(IDWriteFontFace5 *iface, void *context)
|
2016-10-29 20:25:54 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
FIXME("%p, %p: stub\n", iface, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 WINAPI dwritefontface5_GetFontAxisValueCount(IDWriteFontFace5 *iface)
|
|
|
|
{
|
|
|
|
FIXME("%p: stub\n", iface);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontface5_GetFontAxisValues(IDWriteFontFace5 *iface, DWRITE_FONT_AXIS_VALUE *axis_values,
|
|
|
|
UINT32 value_count)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p, %u: stub\n", iface, axis_values, value_count);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-12-05 09:55:58 +01:00
|
|
|
static BOOL WINAPI dwritefontface5_HasVariations(IDWriteFontFace5 *iface)
|
2019-12-02 13:53:53 +01:00
|
|
|
{
|
2020-06-10 16:21:31 +02:00
|
|
|
static int once;
|
|
|
|
|
|
|
|
if (!once++)
|
|
|
|
FIXME("%p: stub\n", iface);
|
2019-12-02 13:53:53 +01:00
|
|
|
|
|
|
|
return FALSE;
|
2016-10-29 20:25:54 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT WINAPI dwritefontface5_GetFontResource(IDWriteFontFace5 *iface, IDWriteFontResource **resource)
|
|
|
|
{
|
2019-12-05 09:56:00 +01:00
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
2019-12-02 13:53:53 +01:00
|
|
|
|
2019-12-05 09:56:00 +01:00
|
|
|
TRACE("%p, %p.\n", iface, resource);
|
|
|
|
|
|
|
|
return IDWriteFactory7_CreateFontResource(fontface->factory, fontface->files[0], fontface->index, resource);
|
2019-12-02 13:53:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteFontFace5Vtbl dwritefontfacevtbl =
|
|
|
|
{
|
2012-10-07 21:03:52 +02:00
|
|
|
dwritefontface_QueryInterface,
|
|
|
|
dwritefontface_AddRef,
|
|
|
|
dwritefontface_Release,
|
|
|
|
dwritefontface_GetType,
|
|
|
|
dwritefontface_GetFiles,
|
|
|
|
dwritefontface_GetIndex,
|
|
|
|
dwritefontface_GetSimulations,
|
|
|
|
dwritefontface_IsSymbolFont,
|
|
|
|
dwritefontface_GetMetrics,
|
|
|
|
dwritefontface_GetGlyphCount,
|
|
|
|
dwritefontface_GetDesignGlyphMetrics,
|
|
|
|
dwritefontface_GetGlyphIndices,
|
|
|
|
dwritefontface_TryGetFontTable,
|
|
|
|
dwritefontface_ReleaseFontTable,
|
|
|
|
dwritefontface_GetGlyphRunOutline,
|
|
|
|
dwritefontface_GetRecommendedRenderingMode,
|
|
|
|
dwritefontface_GetGdiCompatibleMetrics,
|
2014-10-10 08:01:24 +02:00
|
|
|
dwritefontface_GetGdiCompatibleGlyphMetrics,
|
|
|
|
dwritefontface1_GetMetrics,
|
|
|
|
dwritefontface1_GetGdiCompatibleMetrics,
|
|
|
|
dwritefontface1_GetCaretMetrics,
|
|
|
|
dwritefontface1_GetUnicodeRanges,
|
|
|
|
dwritefontface1_IsMonospacedFont,
|
|
|
|
dwritefontface1_GetDesignGlyphAdvances,
|
|
|
|
dwritefontface1_GetGdiCompatibleGlyphAdvances,
|
|
|
|
dwritefontface1_GetKerningPairAdjustments,
|
|
|
|
dwritefontface1_HasKerningPairs,
|
|
|
|
dwritefontface1_GetRecommendedRenderingMode,
|
|
|
|
dwritefontface1_GetVerticalGlyphVariants,
|
|
|
|
dwritefontface1_HasVerticalGlyphVariants,
|
|
|
|
dwritefontface2_IsColorFont,
|
|
|
|
dwritefontface2_GetColorPaletteCount,
|
|
|
|
dwritefontface2_GetPaletteEntryCount,
|
|
|
|
dwritefontface2_GetPaletteEntries,
|
2016-03-03 06:16:25 +01:00
|
|
|
dwritefontface2_GetRecommendedRenderingMode,
|
|
|
|
dwritefontface3_GetFontFaceReference,
|
|
|
|
dwritefontface3_GetPanose,
|
|
|
|
dwritefontface3_GetWeight,
|
|
|
|
dwritefontface3_GetStretch,
|
|
|
|
dwritefontface3_GetStyle,
|
|
|
|
dwritefontface3_GetFamilyNames,
|
|
|
|
dwritefontface3_GetFaceNames,
|
|
|
|
dwritefontface3_GetInformationalStrings,
|
|
|
|
dwritefontface3_HasCharacter,
|
|
|
|
dwritefontface3_GetRecommendedRenderingMode,
|
|
|
|
dwritefontface3_IsCharacterLocal,
|
|
|
|
dwritefontface3_IsGlyphLocal,
|
|
|
|
dwritefontface3_AreCharactersLocal,
|
2016-10-29 20:25:54 +02:00
|
|
|
dwritefontface3_AreGlyphsLocal,
|
|
|
|
dwritefontface4_GetGlyphImageFormats_,
|
|
|
|
dwritefontface4_GetGlyphImageFormats,
|
|
|
|
dwritefontface4_GetGlyphImageData,
|
2019-12-02 13:53:53 +01:00
|
|
|
dwritefontface4_ReleaseGlyphImageData,
|
|
|
|
dwritefontface5_GetFontAxisValueCount,
|
|
|
|
dwritefontface5_GetFontAxisValues,
|
2019-12-05 09:55:58 +01:00
|
|
|
dwritefontface5_HasVariations,
|
2019-12-02 13:53:53 +01:00
|
|
|
dwritefontface5_GetFontResource,
|
2012-10-07 21:03:52 +02:00
|
|
|
};
|
|
|
|
|
2020-02-03 17:08:31 +01:00
|
|
|
static HRESULT WINAPI dwritefontface_reference_QueryInterface(IDWriteFontFaceReference *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFaceReference(iface);
|
|
|
|
return IDWriteFontFace5_QueryInterface(&fontface->IDWriteFontFace5_iface, riid, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritefontface_reference_AddRef(IDWriteFontFaceReference *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFaceReference(iface);
|
|
|
|
return IDWriteFontFace5_AddRef(&fontface->IDWriteFontFace5_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritefontface_reference_Release(IDWriteFontFaceReference *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFaceReference(iface);
|
|
|
|
return IDWriteFontFace5_Release(&fontface->IDWriteFontFace5_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontface_reference_CreateFontFace(IDWriteFontFaceReference *iface,
|
|
|
|
IDWriteFontFace3 **ret)
|
|
|
|
{
|
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFaceReference(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, ret);
|
|
|
|
|
|
|
|
*ret = (IDWriteFontFace3 *)&fontface->IDWriteFontFace5_iface;
|
|
|
|
IDWriteFontFace3_AddRef(*ret);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontface_reference_CreateFontFaceWithSimulations(IDWriteFontFaceReference *iface,
|
|
|
|
DWRITE_FONT_SIMULATIONS simulations, IDWriteFontFace3 **ret)
|
|
|
|
{
|
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFaceReference(iface);
|
|
|
|
DWRITE_FONT_FILE_TYPE file_type;
|
|
|
|
DWRITE_FONT_FACE_TYPE face_type;
|
|
|
|
IDWriteFontFace *face;
|
|
|
|
BOOL is_supported;
|
|
|
|
UINT32 face_num;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p, %#x, %p.\n", iface, simulations, ret);
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_Analyze(fontface->files[0], &is_supported, &file_type, &face_type, &face_num);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = IDWriteFactory7_CreateFontFace(fontface->factory, face_type, 1, fontface->files, fontface->index,
|
|
|
|
simulations, &face);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IDWriteFontFace_QueryInterface(face, &IID_IDWriteFontFace3, (void **)ret);
|
|
|
|
IDWriteFontFace_Release(face);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL WINAPI dwritefontface_reference_Equals(IDWriteFontFaceReference *iface, IDWriteFontFaceReference *ref)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p.\n", iface, ref);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 WINAPI dwritefontface_reference_GetFontFaceIndex(IDWriteFontFaceReference *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFaceReference(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return fontface->index;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_FONT_SIMULATIONS WINAPI dwritefontface_reference_GetSimulations(IDWriteFontFaceReference *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFaceReference(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return fontface->simulations;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontface_reference_GetFontFile(IDWriteFontFaceReference *iface, IDWriteFontFile **file)
|
|
|
|
{
|
|
|
|
struct dwrite_fontface *fontface = impl_from_IDWriteFontFaceReference(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, file);
|
|
|
|
|
|
|
|
*file = fontface->files[0];
|
|
|
|
IDWriteFontFile_AddRef(*file);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT64 WINAPI dwritefontface_reference_GetLocalFileSize(IDWriteFontFaceReference *iface)
|
|
|
|
{
|
|
|
|
FIXME("%p.\n", iface);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT64 WINAPI dwritefontface_reference_GetFileSize(IDWriteFontFaceReference *iface)
|
|
|
|
{
|
|
|
|
FIXME("%p.\n", iface);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontface_reference_GetFileTime(IDWriteFontFaceReference *iface, FILETIME *writetime)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p.\n", iface, writetime);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_LOCALITY WINAPI dwritefontface_reference_GetLocality(IDWriteFontFaceReference *iface)
|
|
|
|
{
|
|
|
|
FIXME("%p.\n", iface);
|
|
|
|
|
|
|
|
return DWRITE_LOCALITY_LOCAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontface_reference_EnqueueFontDownloadRequest(IDWriteFontFaceReference *iface)
|
|
|
|
{
|
|
|
|
FIXME("%p.\n", iface);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontface_reference_EnqueueCharacterDownloadRequest(IDWriteFontFaceReference *iface,
|
|
|
|
WCHAR const *chars, UINT32 count)
|
|
|
|
{
|
|
|
|
FIXME("%p, %s, %u.\n", iface, debugstr_wn(chars, count), count);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontface_reference_EnqueueGlyphDownloadRequest(IDWriteFontFaceReference *iface,
|
|
|
|
UINT16 const *glyphs, UINT32 count)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p, %u.\n", iface, glyphs, count);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontface_reference_EnqueueFileFragmentDownloadRequest(IDWriteFontFaceReference *iface,
|
|
|
|
UINT64 offset, UINT64 size)
|
|
|
|
{
|
|
|
|
FIXME("%p, 0x%s, 0x%s.\n", iface, wine_dbgstr_longlong(offset), wine_dbgstr_longlong(size));
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteFontFaceReferenceVtbl dwritefontface_reference_vtbl =
|
|
|
|
{
|
|
|
|
dwritefontface_reference_QueryInterface,
|
|
|
|
dwritefontface_reference_AddRef,
|
|
|
|
dwritefontface_reference_Release,
|
|
|
|
dwritefontface_reference_CreateFontFace,
|
|
|
|
dwritefontface_reference_CreateFontFaceWithSimulations,
|
|
|
|
dwritefontface_reference_Equals,
|
|
|
|
dwritefontface_reference_GetFontFaceIndex,
|
|
|
|
dwritefontface_reference_GetSimulations,
|
|
|
|
dwritefontface_reference_GetFontFile,
|
|
|
|
dwritefontface_reference_GetLocalFileSize,
|
|
|
|
dwritefontface_reference_GetFileSize,
|
|
|
|
dwritefontface_reference_GetFileTime,
|
|
|
|
dwritefontface_reference_GetLocality,
|
|
|
|
dwritefontface_reference_EnqueueFontDownloadRequest,
|
|
|
|
dwritefontface_reference_EnqueueCharacterDownloadRequest,
|
|
|
|
dwritefontface_reference_EnqueueGlyphDownloadRequest,
|
|
|
|
dwritefontface_reference_EnqueueFileFragmentDownloadRequest,
|
|
|
|
};
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
static HRESULT get_fontface_from_font(struct dwrite_font *font, IDWriteFontFace5 **fontface)
|
2014-10-16 07:36:13 +02:00
|
|
|
{
|
2014-11-05 10:48:45 +01:00
|
|
|
struct dwrite_font_data *data = font->data;
|
2016-07-05 11:55:53 +02:00
|
|
|
struct fontface_desc desc;
|
|
|
|
struct list *cached_list;
|
2014-11-05 10:48:45 +01:00
|
|
|
HRESULT hr;
|
2014-10-24 09:43:21 +02:00
|
|
|
|
2014-10-16 07:36:13 +02:00
|
|
|
*fontface = NULL;
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
hr = factory_get_cached_fontface(font->family->collection->factory, &data->file, data->face_index,
|
2017-08-15 13:40:24 +02:00
|
|
|
font->data->simulations, &cached_list, &IID_IDWriteFontFace4, (void **)fontface);
|
|
|
|
if (hr == S_OK)
|
2016-07-05 11:55:53 +02:00
|
|
|
return hr;
|
|
|
|
|
2017-10-18 13:53:06 +02:00
|
|
|
if (FAILED(hr = get_filestream_from_file(data->file, &desc.stream)))
|
|
|
|
return hr;
|
|
|
|
|
2019-12-06 15:12:14 +01:00
|
|
|
desc.factory = font->family->collection->factory;
|
2016-07-05 11:55:53 +02:00
|
|
|
desc.face_type = data->face_type;
|
|
|
|
desc.files = &data->file;
|
|
|
|
desc.files_number = 1;
|
|
|
|
desc.index = data->face_index;
|
|
|
|
desc.simulations = data->simulations;
|
|
|
|
desc.font_data = data;
|
2017-10-18 13:53:06 +02:00
|
|
|
hr = create_fontface(&desc, cached_list, fontface);
|
|
|
|
|
|
|
|
IDWriteFontFileStream_Release(desc.stream);
|
|
|
|
return hr;
|
2014-10-16 07:36:13 +02:00
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static HRESULT WINAPI dwritefont_QueryInterface(IDWriteFont3 *iface, REFIID riid, void **obj)
|
2012-08-13 05:44:19 +02:00
|
|
|
{
|
2016-03-07 15:10:17 +01:00
|
|
|
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
|
2012-08-13 05:44:19 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
|
|
|
|
|
2016-04-20 20:38:18 +02:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteFont3) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFont2) ||
|
2014-10-10 07:28:58 +02:00
|
|
|
IsEqualIID(riid, &IID_IDWriteFont1) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFont) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
2012-08-13 05:44:19 +02:00
|
|
|
{
|
|
|
|
*obj = iface;
|
2016-03-07 15:10:17 +01:00
|
|
|
IDWriteFont3_AddRef(iface);
|
2012-08-13 05:44:19 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2012-08-13 05:44:19 +02:00
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static ULONG WINAPI dwritefont_AddRef(IDWriteFont3 *iface)
|
2012-08-13 05:44:19 +02:00
|
|
|
{
|
2016-03-07 15:10:17 +01:00
|
|
|
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
|
2012-08-13 05:44:19 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static ULONG WINAPI dwritefont_Release(IDWriteFont3 *iface)
|
2012-08-13 05:44:19 +02:00
|
|
|
{
|
2016-03-07 15:10:17 +01:00
|
|
|
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
|
2012-08-13 05:44:19 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
|
2014-10-24 09:43:21 +02:00
|
|
|
if (!ref) {
|
2019-10-08 12:04:35 +02:00
|
|
|
IDWriteFontFamily2_Release(&This->family->IDWriteFontFamily2_iface);
|
2014-10-24 09:43:21 +02:00
|
|
|
release_font_data(This->data);
|
2012-08-13 05:44:19 +02:00
|
|
|
heap_free(This);
|
2012-08-25 11:11:31 +02:00
|
|
|
}
|
2012-08-13 05:44:19 +02:00
|
|
|
|
2012-10-21 03:47:22 +02:00
|
|
|
return ref;
|
2012-08-13 05:44:19 +02:00
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static HRESULT WINAPI dwritefont_GetFontFamily(IDWriteFont3 *iface, IDWriteFontFamily **family)
|
2012-08-13 05:44:19 +02:00
|
|
|
{
|
2016-03-07 15:10:17 +01:00
|
|
|
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
|
2012-08-25 11:11:31 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, family);
|
|
|
|
|
2016-03-08 20:46:51 +01:00
|
|
|
*family = (IDWriteFontFamily*)This->family;
|
2012-08-25 11:11:31 +02:00
|
|
|
IDWriteFontFamily_AddRef(*family);
|
|
|
|
return S_OK;
|
2012-08-13 05:44:19 +02:00
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static DWRITE_FONT_WEIGHT WINAPI dwritefont_GetWeight(IDWriteFont3 *iface)
|
2012-08-13 05:44:19 +02:00
|
|
|
{
|
2016-03-07 15:10:17 +01:00
|
|
|
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
|
2012-10-12 14:43:57 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2014-09-02 17:19:25 +02:00
|
|
|
return This->data->weight;
|
2012-08-13 05:44:19 +02:00
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static DWRITE_FONT_STRETCH WINAPI dwritefont_GetStretch(IDWriteFont3 *iface)
|
2012-08-13 05:44:19 +02:00
|
|
|
{
|
2016-03-07 15:10:17 +01:00
|
|
|
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
|
2012-10-10 14:37:55 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2014-09-02 17:19:25 +02:00
|
|
|
return This->data->stretch;
|
2012-08-13 05:44:19 +02:00
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static DWRITE_FONT_STYLE WINAPI dwritefont_GetStyle(IDWriteFont3 *iface)
|
2012-08-13 05:44:19 +02:00
|
|
|
{
|
2016-03-07 15:10:17 +01:00
|
|
|
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
|
2012-08-13 05:46:43 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2014-12-08 11:22:01 +01:00
|
|
|
return This->style;
|
2012-08-13 05:44:19 +02:00
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static BOOL WINAPI dwritefont_IsSymbolFont(IDWriteFont3 *iface)
|
2012-08-13 05:44:19 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_font *font = impl_from_IDWriteFont3(iface);
|
2014-11-22 18:15:27 +01:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p.\n", iface);
|
2014-11-22 18:15:27 +01:00
|
|
|
|
2020-01-23 10:24:12 +01:00
|
|
|
return !!(font->data->flags & FONT_IS_SYMBOL);
|
2012-08-13 05:44:19 +02:00
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static HRESULT WINAPI dwritefont_GetFaceNames(IDWriteFont3 *iface, IDWriteLocalizedStrings **names)
|
2012-08-13 05:44:19 +02:00
|
|
|
{
|
2020-01-24 09:17:34 +01:00
|
|
|
struct dwrite_font *font = impl_from_IDWriteFont3(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, names);
|
|
|
|
|
|
|
|
return clone_localizedstrings(font->data->names, names);
|
2012-08-13 05:44:19 +02:00
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static HRESULT WINAPI dwritefont_GetInformationalStrings(IDWriteFont3 *iface,
|
2012-08-13 05:44:19 +02:00
|
|
|
DWRITE_INFORMATIONAL_STRING_ID stringid, IDWriteLocalizedStrings **strings, BOOL *exists)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_font *font = impl_from_IDWriteFont3(iface);
|
|
|
|
struct dwrite_font_data *data = font->data;
|
2020-01-24 09:17:37 +01:00
|
|
|
struct file_stream_desc stream_desc;
|
2014-10-20 19:45:57 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %d, %p, %p.\n", iface, stringid, strings, exists);
|
2014-10-20 19:45:57 +02:00
|
|
|
|
2020-01-24 09:17:37 +01:00
|
|
|
/* Stream will be created if necessary. */
|
|
|
|
stream_desc.stream = NULL;
|
|
|
|
stream_desc.face_index = data->face_index;
|
|
|
|
stream_desc.face_type = data->face_type;
|
|
|
|
return get_font_info_strings(&stream_desc, data->file, stringid, data->info_strings, strings, exists);
|
2012-08-13 05:44:19 +02:00
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static DWRITE_FONT_SIMULATIONS WINAPI dwritefont_GetSimulations(IDWriteFont3 *iface)
|
2012-08-13 05:44:19 +02:00
|
|
|
{
|
2016-03-07 15:10:17 +01:00
|
|
|
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
|
2014-09-02 17:19:25 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2015-09-03 06:36:01 +02:00
|
|
|
return This->data->simulations;
|
2012-08-13 05:44:19 +02:00
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static void WINAPI dwritefont_GetMetrics(IDWriteFont3 *iface, DWRITE_FONT_METRICS *metrics)
|
2012-08-13 05:44:19 +02:00
|
|
|
{
|
2016-03-07 15:10:17 +01:00
|
|
|
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
|
2012-10-16 18:56:23 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, metrics);
|
2014-11-06 09:49:06 +01:00
|
|
|
memcpy(metrics, &This->data->metrics, sizeof(*metrics));
|
2012-08-13 05:44:19 +02:00
|
|
|
}
|
|
|
|
|
2020-06-09 11:14:35 +02:00
|
|
|
static BOOL dwritefont_has_character(struct dwrite_font *font, UINT32 ch)
|
2012-08-13 05:44:19 +02:00
|
|
|
{
|
2020-06-09 11:14:35 +02:00
|
|
|
UINT16 glyph;
|
|
|
|
dwrite_cmap_init(&font->data->cmap, font->data->file, font->data->face_index, font->data->face_type);
|
|
|
|
glyph = opentype_cmap_get_glyph(&font->data->cmap, ch);
|
|
|
|
return glyph != 0;
|
2012-08-13 05:44:19 +02:00
|
|
|
}
|
|
|
|
|
2017-08-15 13:40:25 +02:00
|
|
|
static HRESULT WINAPI dwritefont_HasCharacter(IDWriteFont3 *iface, UINT32 ch, BOOL *exists)
|
|
|
|
{
|
2020-06-09 11:14:35 +02:00
|
|
|
struct dwrite_font *font = impl_from_IDWriteFont3(iface);
|
2017-08-15 13:40:25 +02:00
|
|
|
|
2020-06-09 11:14:35 +02:00
|
|
|
TRACE("%p, %#x, %p.\n", iface, ch, exists);
|
2017-08-15 13:40:25 +02:00
|
|
|
|
2020-06-09 11:14:35 +02:00
|
|
|
*exists = dwritefont_has_character(font, ch);
|
|
|
|
|
|
|
|
return S_OK;
|
2017-08-15 13:40:25 +02:00
|
|
|
}
|
|
|
|
|
2016-07-05 11:55:55 +02:00
|
|
|
static HRESULT WINAPI dwritefont_CreateFontFace(IDWriteFont3 *iface, IDWriteFontFace **fontface)
|
2012-08-13 05:44:19 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_font *font = impl_from_IDWriteFont3(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, fontface);
|
|
|
|
|
|
|
|
return get_fontface_from_font(font, (IDWriteFontFace5 **)fontface);
|
2012-08-13 05:44:19 +02:00
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static void WINAPI dwritefont1_GetMetrics(IDWriteFont3 *iface, DWRITE_FONT_METRICS1 *metrics)
|
2014-10-10 07:28:58 +02:00
|
|
|
{
|
2016-03-07 15:10:17 +01:00
|
|
|
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
|
2014-11-06 09:49:06 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, metrics);
|
|
|
|
*metrics = This->data->metrics;
|
2014-10-10 07:28:58 +02:00
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static void WINAPI dwritefont1_GetPanose(IDWriteFont3 *iface, DWRITE_PANOSE *panose)
|
2014-10-10 07:28:58 +02:00
|
|
|
{
|
2016-03-07 15:10:17 +01:00
|
|
|
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
|
2015-07-06 22:08:37 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, panose);
|
|
|
|
*panose = This->data->panose;
|
2014-10-10 07:28:58 +02:00
|
|
|
}
|
|
|
|
|
2020-01-27 06:52:51 +01:00
|
|
|
static HRESULT WINAPI dwritefont1_GetUnicodeRanges(IDWriteFont3 *iface, UINT32 max_count, DWRITE_UNICODE_RANGE *ranges,
|
|
|
|
UINT32 *count)
|
2014-10-10 07:28:58 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_font *font = impl_from_IDWriteFont3(iface);
|
2014-10-16 05:33:51 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, max_count, ranges, count);
|
2014-10-16 05:33:51 +02:00
|
|
|
|
2020-01-27 06:52:51 +01:00
|
|
|
*count = 0;
|
|
|
|
if (max_count && !ranges)
|
|
|
|
return E_INVALIDARG;
|
2014-10-16 05:33:51 +02:00
|
|
|
|
2020-06-10 16:21:29 +02:00
|
|
|
dwrite_cmap_init(&font->data->cmap, font->data->file, font->data->face_index, font->data->face_type);
|
|
|
|
return opentype_cmap_get_unicode_ranges(&font->data->cmap, max_count, ranges, count);
|
2014-10-10 07:28:58 +02:00
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static BOOL WINAPI dwritefont1_IsMonospacedFont(IDWriteFont3 *iface)
|
2014-10-10 07:28:58 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_font *font = impl_from_IDWriteFont3(iface);
|
2014-11-22 18:15:27 +01:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p.\n", iface);
|
2014-11-22 18:15:27 +01:00
|
|
|
|
2020-01-23 10:24:13 +01:00
|
|
|
return !!(font->data->flags & FONT_IS_MONOSPACED);
|
2014-10-10 07:28:58 +02:00
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static BOOL WINAPI dwritefont2_IsColorFont(IDWriteFont3 *iface)
|
2014-10-10 07:28:58 +02:00
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_font *font = impl_from_IDWriteFont3(iface);
|
2014-11-22 18:15:27 +01:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p.\n", iface);
|
2014-11-22 18:15:27 +01:00
|
|
|
|
2020-01-23 10:24:14 +01:00
|
|
|
return !!(font->data->flags & FONT_IS_COLORED);
|
2014-10-10 07:28:58 +02:00
|
|
|
}
|
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
static HRESULT WINAPI dwritefont3_CreateFontFace(IDWriteFont3 *iface, IDWriteFontFace3 **fontface)
|
|
|
|
{
|
2019-12-02 13:53:53 +01:00
|
|
|
struct dwrite_font *font = impl_from_IDWriteFont3(iface);
|
2016-07-05 11:55:55 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
TRACE("%p, %p.\n", iface, fontface);
|
2016-07-05 11:55:55 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
return get_fontface_from_font(font, (IDWriteFontFace5 **)fontface);
|
2016-03-07 15:10:17 +01:00
|
|
|
}
|
|
|
|
|
2020-01-27 06:52:49 +01:00
|
|
|
static BOOL WINAPI dwritefont3_Equals(IDWriteFont3 *iface, IDWriteFont *other)
|
2016-03-07 15:10:17 +01:00
|
|
|
{
|
2020-01-27 06:52:49 +01:00
|
|
|
struct dwrite_font *font = impl_from_IDWriteFont3(iface), *other_font;
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, other);
|
|
|
|
|
|
|
|
if (!(other_font = unsafe_impl_from_IDWriteFont(other)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return font->data->face_index == other_font->data->face_index
|
|
|
|
&& font->data->simulations == other_font->data->simulations
|
|
|
|
&& is_same_fontfile(font->data->file, other_font->data->file);
|
2016-03-07 15:10:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefont3_GetFontFaceReference(IDWriteFont3 *iface, IDWriteFontFaceReference **reference)
|
|
|
|
{
|
2019-12-05 09:56:03 +01:00
|
|
|
struct dwrite_font *font = impl_from_IDWriteFont3(iface);
|
2016-04-20 20:38:20 +02:00
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
TRACE("%p, %p.\n", iface, reference);
|
2016-04-20 20:38:20 +02:00
|
|
|
|
2020-02-04 11:15:09 +01:00
|
|
|
return IDWriteFactory7_CreateFontFaceReference(font->family->collection->factory, font->data->file,
|
|
|
|
font->data->face_index, font->data->simulations, font->data->axis, ARRAY_SIZE(font->data->axis),
|
|
|
|
(IDWriteFontFaceReference1 **)reference);
|
2016-03-07 15:10:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL WINAPI dwritefont3_HasCharacter(IDWriteFont3 *iface, UINT32 ch)
|
|
|
|
{
|
2020-06-09 11:14:35 +02:00
|
|
|
struct dwrite_font *font = impl_from_IDWriteFont3(iface);
|
2016-04-20 20:38:19 +02:00
|
|
|
|
2020-06-09 11:14:35 +02:00
|
|
|
TRACE("%p, %#x.\n", iface, ch);
|
2016-04-20 20:38:19 +02:00
|
|
|
|
2020-06-09 11:14:35 +02:00
|
|
|
return dwritefont_has_character(font, ch);
|
2016-03-07 15:10:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_LOCALITY WINAPI dwritefont3_GetLocality(IDWriteFont3 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return DWRITE_LOCALITY_LOCAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteFont3Vtbl dwritefontvtbl = {
|
2012-08-13 05:44:19 +02:00
|
|
|
dwritefont_QueryInterface,
|
|
|
|
dwritefont_AddRef,
|
|
|
|
dwritefont_Release,
|
|
|
|
dwritefont_GetFontFamily,
|
|
|
|
dwritefont_GetWeight,
|
|
|
|
dwritefont_GetStretch,
|
|
|
|
dwritefont_GetStyle,
|
|
|
|
dwritefont_IsSymbolFont,
|
|
|
|
dwritefont_GetFaceNames,
|
|
|
|
dwritefont_GetInformationalStrings,
|
|
|
|
dwritefont_GetSimulations,
|
|
|
|
dwritefont_GetMetrics,
|
|
|
|
dwritefont_HasCharacter,
|
2014-10-10 07:28:58 +02:00
|
|
|
dwritefont_CreateFontFace,
|
|
|
|
dwritefont1_GetMetrics,
|
|
|
|
dwritefont1_GetPanose,
|
|
|
|
dwritefont1_GetUnicodeRanges,
|
|
|
|
dwritefont1_IsMonospacedFont,
|
2016-03-07 15:10:17 +01:00
|
|
|
dwritefont2_IsColorFont,
|
|
|
|
dwritefont3_CreateFontFace,
|
|
|
|
dwritefont3_Equals,
|
|
|
|
dwritefont3_GetFontFaceReference,
|
|
|
|
dwritefont3_HasCharacter,
|
|
|
|
dwritefont3_GetLocality
|
2012-08-13 05:44:19 +02:00
|
|
|
};
|
|
|
|
|
2016-12-04 17:22:13 +01:00
|
|
|
static struct dwrite_font *unsafe_impl_from_IDWriteFont(IDWriteFont *iface)
|
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
assert(iface->lpVtbl == (IDWriteFontVtbl*)&dwritefontvtbl);
|
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_font, IDWriteFont3_iface);
|
|
|
|
}
|
|
|
|
|
2019-01-31 09:35:26 +01:00
|
|
|
struct dwrite_fontface *unsafe_impl_from_IDWriteFontFace(IDWriteFontFace *iface)
|
2016-12-07 14:46:39 +01:00
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
2016-12-11 06:17:17 +01:00
|
|
|
assert(iface->lpVtbl == (IDWriteFontFaceVtbl*)&dwritefontfacevtbl);
|
2019-12-02 13:53:53 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_fontface, IDWriteFontFace5_iface);
|
2016-12-07 14:46:39 +01:00
|
|
|
}
|
|
|
|
|
2019-12-09 09:09:36 +01:00
|
|
|
static struct dwrite_fontfacereference *unsafe_impl_from_IDWriteFontFaceReference(IDWriteFontFaceReference *iface)
|
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
if (iface->lpVtbl != (IDWriteFontFaceReferenceVtbl *)&fontfacereferencevtbl)
|
|
|
|
return NULL;
|
|
|
|
return CONTAINING_RECORD((IDWriteFontFaceReference1 *)iface, struct dwrite_fontfacereference,
|
|
|
|
IDWriteFontFaceReference1_iface);
|
|
|
|
}
|
|
|
|
|
2016-12-04 17:22:13 +01:00
|
|
|
void get_logfont_from_font(IDWriteFont *iface, LOGFONTW *lf)
|
|
|
|
{
|
|
|
|
struct dwrite_font *font = unsafe_impl_from_IDWriteFont(iface);
|
|
|
|
*lf = font->data->lf;
|
|
|
|
}
|
|
|
|
|
2016-12-07 14:46:39 +01:00
|
|
|
void get_logfont_from_fontface(IDWriteFontFace *iface, LOGFONTW *lf)
|
|
|
|
{
|
|
|
|
struct dwrite_fontface *fontface = unsafe_impl_from_IDWriteFontFace(iface);
|
|
|
|
*lf = fontface->lf;
|
|
|
|
}
|
|
|
|
|
2017-08-15 13:40:26 +02:00
|
|
|
HRESULT get_fontsig_from_font(IDWriteFont *iface, FONTSIGNATURE *fontsig)
|
|
|
|
{
|
|
|
|
struct dwrite_font *font = unsafe_impl_from_IDWriteFont(iface);
|
|
|
|
*fontsig = font->data->fontsig;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT get_fontsig_from_fontface(IDWriteFontFace *iface, FONTSIGNATURE *fontsig)
|
|
|
|
{
|
|
|
|
struct dwrite_fontface *fontface = unsafe_impl_from_IDWriteFontFace(iface);
|
|
|
|
*fontsig = fontface->fontsig;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-04-11 13:21:33 +02:00
|
|
|
static HRESULT create_font(struct dwrite_fontfamily *family, UINT32 index, IDWriteFont3 **font)
|
2014-11-04 14:37:10 +01:00
|
|
|
{
|
|
|
|
struct dwrite_font *This;
|
2017-04-11 13:21:32 +02:00
|
|
|
|
2014-11-04 14:37:10 +01:00
|
|
|
*font = NULL;
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
This = heap_alloc(sizeof(*This));
|
|
|
|
if (!This)
|
|
|
|
return E_OUTOFMEMORY;
|
2014-11-04 14:37:10 +01:00
|
|
|
|
2016-03-07 15:10:17 +01:00
|
|
|
This->IDWriteFont3_iface.lpVtbl = &dwritefontvtbl;
|
2014-11-04 14:37:10 +01:00
|
|
|
This->ref = 1;
|
|
|
|
This->family = family;
|
2019-10-08 12:04:35 +02:00
|
|
|
IDWriteFontFamily2_AddRef(&family->IDWriteFontFamily2_iface);
|
2017-04-11 13:21:33 +02:00
|
|
|
This->data = family->data->fonts[index];
|
|
|
|
This->style = This->data->style;
|
2017-05-30 09:10:59 +02:00
|
|
|
addref_font_data(This->data);
|
2014-11-04 14:37:10 +01:00
|
|
|
|
2016-03-08 20:46:52 +01:00
|
|
|
*font = &This->IDWriteFont3_iface;
|
2014-11-04 14:37:10 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
/* IDWriteFontList2 */
|
|
|
|
static HRESULT WINAPI dwritefontlist_QueryInterface(IDWriteFontList2 *iface, REFIID riid, void **obj)
|
2015-09-08 10:40:25 +02:00
|
|
|
{
|
2019-10-09 10:04:56 +02:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
|
2015-09-08 10:40:25 +02:00
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteFontList2) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFontList1) ||
|
2016-03-08 20:46:55 +01:00
|
|
|
IsEqualIID(riid, &IID_IDWriteFontList) ||
|
2015-09-08 10:40:25 +02:00
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
2019-10-09 10:04:56 +02:00
|
|
|
IDWriteFontList2_AddRef(iface);
|
2015-09-08 10:40:25 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2015-09-08 10:40:25 +02:00
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
static ULONG WINAPI dwritefontlist_AddRef(IDWriteFontList2 *iface)
|
2015-09-08 10:40:25 +02:00
|
|
|
{
|
2019-10-09 10:04:56 +02:00
|
|
|
struct dwrite_fontlist *fontlist = impl_from_IDWriteFontList2(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&fontlist->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
2015-09-08 10:40:25 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
static ULONG WINAPI dwritefontlist_Release(IDWriteFontList2 *iface)
|
2015-09-08 10:40:25 +02:00
|
|
|
{
|
2019-10-09 10:04:56 +02:00
|
|
|
struct dwrite_fontlist *fontlist = impl_from_IDWriteFontList2(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&fontlist->refcount);
|
2015-09-08 10:40:25 +02:00
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
2015-09-08 10:40:25 +02:00
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
if (!refcount)
|
|
|
|
{
|
2015-09-08 10:41:28 +02:00
|
|
|
UINT32 i;
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
for (i = 0; i < fontlist->font_count; i++)
|
|
|
|
release_font_data(fontlist->fonts[i]);
|
|
|
|
IDWriteFontFamily2_Release(&fontlist->family->IDWriteFontFamily2_iface);
|
|
|
|
heap_free(fontlist->fonts);
|
|
|
|
heap_free(fontlist);
|
2015-09-08 10:40:25 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
return refcount;
|
2015-09-08 10:40:25 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
static HRESULT WINAPI dwritefontlist_GetFontCollection(IDWriteFontList2 *iface, IDWriteFontCollection **collection)
|
2015-09-08 10:40:25 +02:00
|
|
|
{
|
2019-10-09 10:04:56 +02:00
|
|
|
struct dwrite_fontlist *fontlist = impl_from_IDWriteFontList2(iface);
|
|
|
|
return IDWriteFontFamily2_GetFontCollection(&fontlist->family->IDWriteFontFamily2_iface, collection);
|
2015-09-08 10:40:25 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
static UINT32 WINAPI dwritefontlist_GetFontCount(IDWriteFontList2 *iface)
|
2015-09-08 10:40:25 +02:00
|
|
|
{
|
2019-10-09 10:04:56 +02:00
|
|
|
struct dwrite_fontlist *fontlist = impl_from_IDWriteFontList2(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return fontlist->font_count;
|
2015-09-08 10:40:25 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
static HRESULT WINAPI dwritefontlist_GetFont(IDWriteFontList2 *iface, UINT32 index, IDWriteFont **font)
|
2015-09-08 10:40:25 +02:00
|
|
|
{
|
2019-10-09 10:04:56 +02:00
|
|
|
struct dwrite_fontlist *fontlist = impl_from_IDWriteFontList2(iface);
|
2015-09-08 10:40:25 +02:00
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
TRACE("%p, %u, %p.\n", iface, index, font);
|
2015-09-08 10:40:25 +02:00
|
|
|
|
|
|
|
*font = NULL;
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
if (fontlist->font_count == 0)
|
2015-09-08 10:41:28 +02:00
|
|
|
return S_FALSE;
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
if (index >= fontlist->font_count)
|
2015-09-08 10:41:28 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
return create_font(fontlist->family, index, (IDWriteFont3 **)font);
|
2015-09-08 10:40:25 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
static DWRITE_LOCALITY WINAPI dwritefontlist1_GetFontLocality(IDWriteFontList2 *iface, UINT32 index)
|
2016-03-08 20:46:55 +01:00
|
|
|
{
|
2019-10-09 10:04:56 +02:00
|
|
|
FIXME("%p, %u.\n", iface, index);
|
2016-03-08 20:46:55 +01:00
|
|
|
|
|
|
|
return DWRITE_LOCALITY_LOCAL;
|
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
static HRESULT WINAPI dwritefontlist1_GetFont(IDWriteFontList2 *iface, UINT32 index, IDWriteFont3 **font)
|
2016-03-08 20:46:55 +01:00
|
|
|
{
|
2019-10-09 10:04:56 +02:00
|
|
|
struct dwrite_fontlist *fontlist = impl_from_IDWriteFontList2(iface);
|
2016-03-08 20:46:55 +01:00
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
TRACE("%p, %u, %p.\n", iface, index, font);
|
2016-03-08 20:46:55 +01:00
|
|
|
|
2016-05-05 23:34:01 +02:00
|
|
|
*font = NULL;
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
if (fontlist->font_count == 0)
|
2016-05-05 23:34:01 +02:00
|
|
|
return S_FALSE;
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
if (index >= fontlist->font_count)
|
2016-05-05 23:34:01 +02:00
|
|
|
return E_FAIL;
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
return create_font(fontlist->family, index, font);
|
2016-03-08 20:46:55 +01:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
static HRESULT WINAPI dwritefontlist1_GetFontFaceReference(IDWriteFontList2 *iface, UINT32 index,
|
2016-03-08 20:46:55 +01:00
|
|
|
IDWriteFontFaceReference **reference)
|
|
|
|
{
|
2016-05-05 23:34:02 +02:00
|
|
|
IDWriteFont3 *font;
|
|
|
|
HRESULT hr;
|
2016-03-08 20:46:55 +01:00
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
TRACE("%p, %u, %p.\n", iface, index, reference);
|
2016-03-08 20:46:55 +01:00
|
|
|
|
2016-05-05 23:34:02 +02:00
|
|
|
*reference = NULL;
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
hr = IDWriteFontList2_GetFont(iface, index, &font);
|
2016-05-05 23:34:02 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = IDWriteFont3_GetFontFaceReference(font, reference);
|
|
|
|
IDWriteFont3_Release(font);
|
|
|
|
|
|
|
|
return hr;
|
2016-03-08 20:46:55 +01:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
static HRESULT WINAPI dwritefontlist2_GetFontSet(IDWriteFontList2 *iface, IDWriteFontSet1 **fontset)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p.\n", iface, fontset);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteFontList2Vtbl dwritefontlistvtbl =
|
|
|
|
{
|
2015-09-08 10:40:25 +02:00
|
|
|
dwritefontlist_QueryInterface,
|
|
|
|
dwritefontlist_AddRef,
|
|
|
|
dwritefontlist_Release,
|
|
|
|
dwritefontlist_GetFontCollection,
|
|
|
|
dwritefontlist_GetFontCount,
|
2016-03-08 20:46:55 +01:00
|
|
|
dwritefontlist_GetFont,
|
|
|
|
dwritefontlist1_GetFontLocality,
|
|
|
|
dwritefontlist1_GetFont,
|
2019-10-09 10:04:56 +02:00
|
|
|
dwritefontlist1_GetFontFaceReference,
|
|
|
|
dwritefontlist2_GetFontSet,
|
2015-09-08 10:40:25 +02:00
|
|
|
};
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
static HRESULT WINAPI dwritefontfamily_QueryInterface(IDWriteFontFamily2 *iface, REFIID riid, void **obj)
|
2012-08-25 11:11:31 +02:00
|
|
|
{
|
2019-10-08 12:04:35 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_from_IDWriteFontFamily2(iface);
|
2016-03-08 20:46:51 +01:00
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
|
2012-08-25 11:11:31 +02:00
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteFontFamily2) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFontFamily1) ||
|
2016-03-08 20:46:51 +01:00
|
|
|
IsEqualIID(riid, &IID_IDWriteFontFamily) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
2012-08-25 11:11:31 +02:00
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
}
|
2019-10-09 10:04:57 +02:00
|
|
|
else if (IsEqualIID(riid, &IID_IDWriteFontList2) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFontList1) ||
|
2018-05-21 22:11:02 +02:00
|
|
|
IsEqualIID(riid, &IID_IDWriteFontList))
|
|
|
|
{
|
2019-10-09 10:04:57 +02:00
|
|
|
*obj = &family->IDWriteFontList2_iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
2018-05-21 22:11:02 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:57 +02:00
|
|
|
IUnknown_AddRef((IUnknown *)*obj);
|
|
|
|
return S_OK;
|
2012-08-25 11:11:31 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
static ULONG WINAPI dwritefontfamily_AddRef(IDWriteFontFamily2 *iface)
|
2012-08-25 11:11:31 +02:00
|
|
|
{
|
2019-10-08 12:04:35 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_from_IDWriteFontFamily2(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&family->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
2012-08-25 11:11:31 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
static ULONG WINAPI dwritefontfamily_Release(IDWriteFontFamily2 *iface)
|
2012-08-25 11:11:31 +02:00
|
|
|
{
|
2019-10-08 12:04:35 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_from_IDWriteFontFamily2(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&family->refcount);
|
2012-08-25 11:11:31 +02:00
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
TRACE("%p, %u.\n", iface, refcount);
|
2012-08-25 11:11:31 +02:00
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
if (!refcount)
|
2012-10-07 18:29:39 +02:00
|
|
|
{
|
2019-10-08 12:04:35 +02:00
|
|
|
IDWriteFontCollection3_Release(&family->collection->IDWriteFontCollection3_iface);
|
|
|
|
release_fontfamily_data(family->data);
|
|
|
|
heap_free(family);
|
2012-10-07 18:29:39 +02:00
|
|
|
}
|
2012-08-25 11:11:31 +02:00
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
return refcount;
|
2012-08-25 11:11:31 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
static HRESULT WINAPI dwritefontfamily_GetFontCollection(IDWriteFontFamily2 *iface, IDWriteFontCollection **collection)
|
2012-08-25 11:11:31 +02:00
|
|
|
{
|
2019-10-08 12:04:35 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_from_IDWriteFontFamily2(iface);
|
2016-04-19 08:39:26 +02:00
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
TRACE("%p, %p.\n", iface, collection);
|
2014-10-29 20:41:47 +01:00
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
*collection = (IDWriteFontCollection *)family->collection;
|
2016-04-19 08:39:26 +02:00
|
|
|
IDWriteFontCollection_AddRef(*collection);
|
2014-10-29 20:41:47 +01:00
|
|
|
return S_OK;
|
2012-08-25 11:11:31 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
static UINT32 WINAPI dwritefontfamily_GetFontCount(IDWriteFontFamily2 *iface)
|
2012-08-25 11:11:31 +02:00
|
|
|
{
|
2019-10-08 12:04:35 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_from_IDWriteFontFamily2(iface);
|
2019-05-14 12:27:23 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return family->data->count;
|
2012-08-25 11:11:31 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
static HRESULT WINAPI dwritefontfamily_GetFont(IDWriteFontFamily2 *iface, UINT32 index, IDWriteFont **font)
|
2012-08-25 11:11:31 +02:00
|
|
|
{
|
2019-10-08 12:04:35 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_from_IDWriteFontFamily2(iface);
|
2014-10-29 20:41:47 +01:00
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
TRACE("%p, %u, %p.\n", iface, index, font);
|
2014-10-29 20:41:47 +01:00
|
|
|
|
|
|
|
*font = NULL;
|
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
if (!family->data->count)
|
2014-10-29 20:41:47 +01:00
|
|
|
return S_FALSE;
|
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
if (index >= family->data->count)
|
2014-10-29 20:41:47 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
return create_font(family, index, (IDWriteFont3 **)font);
|
2012-08-25 11:11:31 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
static HRESULT WINAPI dwritefontfamily_GetFamilyNames(IDWriteFontFamily2 *iface, IDWriteLocalizedStrings **names)
|
2012-08-25 11:11:31 +02:00
|
|
|
{
|
2019-10-08 12:04:35 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_from_IDWriteFontFamily2(iface);
|
2020-01-24 09:17:34 +01:00
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, names);
|
|
|
|
|
|
|
|
return clone_localizedstrings(family->data->familyname, names);
|
2012-08-25 11:11:31 +02:00
|
|
|
}
|
|
|
|
|
2015-08-10 12:51:28 +02:00
|
|
|
static BOOL is_better_font_match(const struct dwrite_font_propvec *next, const struct dwrite_font_propvec *cur,
|
|
|
|
const struct dwrite_font_propvec *req)
|
2014-10-27 17:01:48 +01:00
|
|
|
{
|
2015-08-10 12:51:28 +02:00
|
|
|
FLOAT cur_to_req = get_font_prop_vec_distance(cur, req);
|
|
|
|
FLOAT next_to_req = get_font_prop_vec_distance(next, req);
|
|
|
|
FLOAT cur_req_prod, next_req_prod;
|
|
|
|
|
|
|
|
if (next_to_req < cur_to_req)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (next_to_req > cur_to_req)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
cur_req_prod = get_font_prop_vec_dotproduct(cur, req);
|
|
|
|
next_req_prod = get_font_prop_vec_dotproduct(next, req);
|
|
|
|
|
|
|
|
if (next_req_prod > cur_req_prod)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (next_req_prod < cur_req_prod)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (next->stretch > cur->stretch)
|
|
|
|
return TRUE;
|
|
|
|
if (next->stretch < cur->stretch)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (next->style > cur->style)
|
2014-10-27 17:01:48 +01:00
|
|
|
return TRUE;
|
2015-08-10 12:51:28 +02:00
|
|
|
if (next->style < cur->style)
|
|
|
|
return FALSE;
|
2014-10-27 17:01:48 +01:00
|
|
|
|
2015-08-10 12:51:28 +02:00
|
|
|
if (next->weight > cur->weight)
|
2014-10-27 17:01:48 +01:00
|
|
|
return TRUE;
|
2015-08-10 12:51:28 +02:00
|
|
|
if (next->weight < cur->weight)
|
|
|
|
return FALSE;
|
2014-10-27 17:01:48 +01:00
|
|
|
|
2015-08-10 12:51:28 +02:00
|
|
|
/* full match, no reason to prefer new variant */
|
2014-10-27 17:01:48 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
static HRESULT WINAPI dwritefontfamily_GetFirstMatchingFont(IDWriteFontFamily2 *iface, DWRITE_FONT_WEIGHT weight,
|
|
|
|
DWRITE_FONT_STRETCH stretch, DWRITE_FONT_STYLE style, IDWriteFont **font)
|
2012-08-25 11:11:31 +02:00
|
|
|
{
|
2019-10-08 12:04:35 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_from_IDWriteFontFamily2(iface);
|
2015-08-10 12:51:28 +02:00
|
|
|
struct dwrite_font_propvec req;
|
2019-05-14 12:27:23 +02:00
|
|
|
size_t i, match;
|
2012-10-23 14:18:32 +02:00
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
TRACE("%p, %d, %d, %d, %p.\n", iface, weight, stretch, style, font);
|
2012-10-23 14:18:32 +02:00
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
if (!family->data->count)
|
|
|
|
{
|
2015-08-10 12:51:28 +02:00
|
|
|
*font = NULL;
|
|
|
|
return DWRITE_E_NOFONT;
|
2014-10-29 20:41:47 +01:00
|
|
|
}
|
2014-10-27 12:53:59 +01:00
|
|
|
|
2015-08-18 06:40:27 +02:00
|
|
|
init_font_prop_vec(weight, stretch, style, &req);
|
2017-04-11 13:21:33 +02:00
|
|
|
match = 0;
|
2014-10-27 17:01:48 +01:00
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
for (i = 1; i < family->data->count; ++i)
|
|
|
|
{
|
|
|
|
if (is_better_font_match(&family->data->fonts[i]->propvec, &family->data->fonts[match]->propvec, &req))
|
2017-04-11 13:21:33 +02:00
|
|
|
match = i;
|
2014-10-29 20:41:47 +01:00
|
|
|
}
|
2015-08-10 12:51:28 +02:00
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
return create_font(family, match, (IDWriteFont3 **)font);
|
2012-08-25 11:11:31 +02:00
|
|
|
}
|
|
|
|
|
2015-09-08 10:41:28 +02:00
|
|
|
typedef BOOL (*matching_filter_func)(const struct dwrite_font_data*);
|
|
|
|
|
|
|
|
static BOOL is_font_acceptable_for_normal(const struct dwrite_font_data *font)
|
|
|
|
{
|
|
|
|
return font->style == DWRITE_FONT_STYLE_NORMAL || font->style == DWRITE_FONT_STYLE_ITALIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_font_acceptable_for_oblique_italic(const struct dwrite_font_data *font)
|
|
|
|
{
|
|
|
|
return font->style == DWRITE_FONT_STYLE_OBLIQUE || font->style == DWRITE_FONT_STYLE_ITALIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void matchingfonts_sort(struct dwrite_fontlist *fonts, const struct dwrite_font_propvec *req)
|
|
|
|
{
|
|
|
|
UINT32 b = fonts->font_count - 1, j, t;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
t = b;
|
|
|
|
|
|
|
|
for (j = 0; j < b; j++) {
|
|
|
|
if (is_better_font_match(&fonts->fonts[j+1]->propvec, &fonts->fonts[j]->propvec, req)) {
|
|
|
|
struct dwrite_font_data *s = fonts->fonts[j];
|
|
|
|
fonts->fonts[j] = fonts->fonts[j+1];
|
|
|
|
fonts->fonts[j+1] = s;
|
|
|
|
t = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (t == b)
|
|
|
|
break;
|
|
|
|
b = t;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
static HRESULT WINAPI dwritefontfamily_GetMatchingFonts(IDWriteFontFamily2 *iface, DWRITE_FONT_WEIGHT weight,
|
|
|
|
DWRITE_FONT_STRETCH stretch, DWRITE_FONT_STYLE style, IDWriteFontList **ret)
|
2012-08-25 11:11:31 +02:00
|
|
|
{
|
2019-10-08 12:04:35 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_from_IDWriteFontFamily2(iface);
|
2015-09-08 10:41:28 +02:00
|
|
|
matching_filter_func func = NULL;
|
|
|
|
struct dwrite_font_propvec req;
|
2015-09-08 10:40:25 +02:00
|
|
|
struct dwrite_fontlist *fonts;
|
2019-05-14 12:27:23 +02:00
|
|
|
size_t i;
|
2015-09-08 10:40:25 +02:00
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
TRACE("%p, %d, %d, %d, %p.\n", iface, weight, stretch, style, ret);
|
2015-09-08 10:40:25 +02:00
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
|
|
|
|
fonts = heap_alloc(sizeof(*fonts));
|
|
|
|
if (!fonts)
|
|
|
|
return E_OUTOFMEMORY;
|
2015-09-08 10:41:28 +02:00
|
|
|
|
|
|
|
/* Allocate as many as family has, not all of them will be necessary used. */
|
2019-05-14 12:27:23 +02:00
|
|
|
fonts->fonts = heap_calloc(family->data->count, sizeof(*fonts->fonts));
|
2015-09-08 10:41:28 +02:00
|
|
|
if (!fonts->fonts) {
|
|
|
|
heap_free(fonts);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
fonts->IDWriteFontList2_iface.lpVtbl = &dwritefontlistvtbl;
|
|
|
|
fonts->refcount = 1;
|
2019-05-14 12:27:23 +02:00
|
|
|
fonts->family = family;
|
2019-10-08 12:04:35 +02:00
|
|
|
IDWriteFontFamily2_AddRef(&fonts->family->IDWriteFontFamily2_iface);
|
2015-09-08 10:41:28 +02:00
|
|
|
fonts->font_count = 0;
|
|
|
|
|
|
|
|
/* Normal style accepts Normal or Italic, Oblique and Italic - both Oblique and Italic styles */
|
|
|
|
if (style == DWRITE_FONT_STYLE_NORMAL) {
|
2019-05-14 12:27:23 +02:00
|
|
|
if (family->data->has_normal_face || family->data->has_italic_face)
|
2015-09-08 10:41:28 +02:00
|
|
|
func = is_font_acceptable_for_normal;
|
|
|
|
}
|
|
|
|
else /* requested oblique or italic */ {
|
2019-05-14 12:27:23 +02:00
|
|
|
if (family->data->has_oblique_face || family->data->has_italic_face)
|
2015-09-08 10:41:28 +02:00
|
|
|
func = is_font_acceptable_for_oblique_italic;
|
|
|
|
}
|
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
for (i = 0; i < family->data->count; ++i)
|
|
|
|
{
|
|
|
|
if (!func || func(family->data->fonts[i]))
|
|
|
|
{
|
|
|
|
fonts->fonts[fonts->font_count] = family->data->fonts[i];
|
|
|
|
addref_font_data(family->data->fonts[i]);
|
2015-09-08 10:41:28 +02:00
|
|
|
fonts->font_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now potential matches are sorted using same criteria GetFirstMatchingFont uses */
|
|
|
|
init_font_prop_vec(weight, stretch, style, &req);
|
|
|
|
matchingfonts_sort(fonts, &req);
|
2015-09-08 10:40:25 +02:00
|
|
|
|
2019-10-09 10:04:56 +02:00
|
|
|
*ret = (IDWriteFontList *)&fonts->IDWriteFontList2_iface;
|
2015-09-08 10:40:25 +02:00
|
|
|
return S_OK;
|
2012-08-25 11:11:31 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
static DWRITE_LOCALITY WINAPI dwritefontfamily1_GetFontLocality(IDWriteFontFamily2 *iface, UINT32 index)
|
2016-03-08 20:46:51 +01:00
|
|
|
{
|
2019-10-08 12:04:35 +02:00
|
|
|
FIXME("%p, %u.\n", iface, index);
|
2016-03-08 20:46:51 +01:00
|
|
|
|
|
|
|
return DWRITE_LOCALITY_LOCAL;
|
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
static HRESULT WINAPI dwritefontfamily1_GetFont(IDWriteFontFamily2 *iface, UINT32 index, IDWriteFont3 **font)
|
2016-03-08 20:46:51 +01:00
|
|
|
{
|
2019-10-08 12:04:35 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_from_IDWriteFontFamily2(iface);
|
2016-03-08 20:46:51 +01:00
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
TRACE("%p, %u, %p.\n", iface, index, font);
|
2016-03-08 20:46:51 +01:00
|
|
|
|
2016-03-08 20:46:52 +01:00
|
|
|
*font = NULL;
|
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
if (!family->data->count)
|
2016-03-08 20:46:52 +01:00
|
|
|
return S_FALSE;
|
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
if (index >= family->data->count)
|
2016-03-08 20:46:52 +01:00
|
|
|
return E_FAIL;
|
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
return create_font(family, index, font);
|
2016-03-08 20:46:51 +01:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
static HRESULT WINAPI dwritefontfamily1_GetFontFaceReference(IDWriteFontFamily2 *iface, UINT32 index,
|
|
|
|
IDWriteFontFaceReference **reference)
|
2016-03-08 20:46:51 +01:00
|
|
|
{
|
2020-02-03 17:08:30 +01:00
|
|
|
struct dwrite_fontfamily *family = impl_from_IDWriteFontFamily2(iface);
|
|
|
|
const struct dwrite_font_data *font;
|
2016-03-08 20:46:51 +01:00
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
TRACE("%p, %u, %p.\n", iface, index, reference);
|
2016-03-08 20:46:51 +01:00
|
|
|
|
2016-05-05 23:34:03 +02:00
|
|
|
*reference = NULL;
|
|
|
|
|
2020-02-03 17:08:30 +01:00
|
|
|
if (index >= family->data->count)
|
|
|
|
return E_FAIL;
|
2016-05-05 23:34:03 +02:00
|
|
|
|
2020-02-03 17:08:30 +01:00
|
|
|
font = family->data->fonts[index];
|
|
|
|
return IDWriteFactory5_CreateFontFaceReference_((IDWriteFactory5 *)family->collection->factory,
|
|
|
|
font->file, font->face_index, font->simulations, reference);
|
2016-03-08 20:46:51 +01:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
static HRESULT WINAPI dwritefontfamily2_GetMatchingFonts(IDWriteFontFamily2 *iface,
|
|
|
|
DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 num_values, IDWriteFontList2 **fontlist)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p, %u, %p.\n", iface, axis_values, num_values, fontlist);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontfamily2_GetFontSet(IDWriteFontFamily2 *iface, IDWriteFontSet1 **fontset)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p.\n", iface, fontset);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteFontFamily2Vtbl fontfamilyvtbl =
|
|
|
|
{
|
2012-08-25 11:11:31 +02:00
|
|
|
dwritefontfamily_QueryInterface,
|
|
|
|
dwritefontfamily_AddRef,
|
|
|
|
dwritefontfamily_Release,
|
|
|
|
dwritefontfamily_GetFontCollection,
|
|
|
|
dwritefontfamily_GetFontCount,
|
|
|
|
dwritefontfamily_GetFont,
|
|
|
|
dwritefontfamily_GetFamilyNames,
|
|
|
|
dwritefontfamily_GetFirstMatchingFont,
|
2016-03-08 20:46:51 +01:00
|
|
|
dwritefontfamily_GetMatchingFonts,
|
|
|
|
dwritefontfamily1_GetFontLocality,
|
|
|
|
dwritefontfamily1_GetFont,
|
2019-10-08 12:04:35 +02:00
|
|
|
dwritefontfamily1_GetFontFaceReference,
|
|
|
|
dwritefontfamily2_GetMatchingFonts,
|
|
|
|
dwritefontfamily2_GetFontSet,
|
2012-08-25 11:11:31 +02:00
|
|
|
};
|
|
|
|
|
2019-10-09 10:04:57 +02:00
|
|
|
static HRESULT WINAPI dwritefontfamilylist_QueryInterface(IDWriteFontList2 *iface, REFIID riid, void **obj)
|
2018-05-21 22:11:02 +02:00
|
|
|
{
|
2019-10-09 10:04:57 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_family_from_IDWriteFontList2(iface);
|
|
|
|
return dwritefontfamily_QueryInterface(&family->IDWriteFontFamily2_iface, riid, obj);
|
2018-05-21 22:11:02 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:57 +02:00
|
|
|
static ULONG WINAPI dwritefontfamilylist_AddRef(IDWriteFontList2 *iface)
|
2018-05-21 22:11:02 +02:00
|
|
|
{
|
2019-10-09 10:04:57 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_family_from_IDWriteFontList2(iface);
|
|
|
|
return dwritefontfamily_AddRef(&family->IDWriteFontFamily2_iface);
|
2018-05-21 22:11:02 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:57 +02:00
|
|
|
static ULONG WINAPI dwritefontfamilylist_Release(IDWriteFontList2 *iface)
|
2018-05-21 22:11:02 +02:00
|
|
|
{
|
2019-10-09 10:04:57 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_family_from_IDWriteFontList2(iface);
|
|
|
|
return dwritefontfamily_Release(&family->IDWriteFontFamily2_iface);
|
2018-05-21 22:11:02 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:57 +02:00
|
|
|
static HRESULT WINAPI dwritefontfamilylist_GetFontCollection(IDWriteFontList2 *iface,
|
2018-05-21 22:11:02 +02:00
|
|
|
IDWriteFontCollection **collection)
|
|
|
|
{
|
2019-10-09 10:04:57 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_family_from_IDWriteFontList2(iface);
|
|
|
|
return dwritefontfamily_GetFontCollection(&family->IDWriteFontFamily2_iface, collection);
|
2018-05-21 22:11:02 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:57 +02:00
|
|
|
static UINT32 WINAPI dwritefontfamilylist_GetFontCount(IDWriteFontList2 *iface)
|
2018-05-21 22:11:02 +02:00
|
|
|
{
|
2019-10-09 10:04:57 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_family_from_IDWriteFontList2(iface);
|
|
|
|
return dwritefontfamily_GetFontCount(&family->IDWriteFontFamily2_iface);
|
2018-05-21 22:11:02 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:57 +02:00
|
|
|
static HRESULT WINAPI dwritefontfamilylist_GetFont(IDWriteFontList2 *iface, UINT32 index, IDWriteFont **font)
|
2018-05-21 22:11:02 +02:00
|
|
|
{
|
2019-10-09 10:04:57 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_family_from_IDWriteFontList2(iface);
|
|
|
|
return dwritefontfamily_GetFont(&family->IDWriteFontFamily2_iface, index, font);
|
2018-05-21 22:11:02 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:57 +02:00
|
|
|
static DWRITE_LOCALITY WINAPI dwritefontfamilylist1_GetFontLocality(IDWriteFontList2 *iface, UINT32 index)
|
2018-05-21 22:11:02 +02:00
|
|
|
{
|
2019-10-09 10:04:57 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_family_from_IDWriteFontList2(iface);
|
|
|
|
return dwritefontfamily1_GetFontLocality(&family->IDWriteFontFamily2_iface, index);
|
2018-05-21 22:11:02 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:57 +02:00
|
|
|
static HRESULT WINAPI dwritefontfamilylist1_GetFont(IDWriteFontList2 *iface, UINT32 index, IDWriteFont3 **font)
|
2018-05-21 22:11:02 +02:00
|
|
|
{
|
2019-10-09 10:04:57 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_family_from_IDWriteFontList2(iface);
|
|
|
|
return dwritefontfamily1_GetFont(&family->IDWriteFontFamily2_iface, index, font);
|
2018-05-21 22:11:02 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:57 +02:00
|
|
|
static HRESULT WINAPI dwritefontfamilylist1_GetFontFaceReference(IDWriteFontList2 *iface, UINT32 index,
|
2018-05-21 22:11:02 +02:00
|
|
|
IDWriteFontFaceReference **reference)
|
|
|
|
{
|
2019-10-09 10:04:57 +02:00
|
|
|
struct dwrite_fontfamily *family = impl_family_from_IDWriteFontList2(iface);
|
|
|
|
return dwritefontfamily1_GetFontFaceReference(&family->IDWriteFontFamily2_iface, index, reference);
|
2018-05-21 22:11:02 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:57 +02:00
|
|
|
static HRESULT WINAPI dwritefontfamilylist2_GetFontSet(IDWriteFontList2 *iface, IDWriteFontSet1 **fontset)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p.\n", iface, fontset);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteFontList2Vtbl fontfamilylistvtbl =
|
|
|
|
{
|
2018-05-21 22:11:02 +02:00
|
|
|
dwritefontfamilylist_QueryInterface,
|
|
|
|
dwritefontfamilylist_AddRef,
|
|
|
|
dwritefontfamilylist_Release,
|
|
|
|
dwritefontfamilylist_GetFontCollection,
|
|
|
|
dwritefontfamilylist_GetFontCount,
|
|
|
|
dwritefontfamilylist_GetFont,
|
|
|
|
dwritefontfamilylist1_GetFontLocality,
|
|
|
|
dwritefontfamilylist1_GetFont,
|
|
|
|
dwritefontfamilylist1_GetFontFaceReference,
|
2019-10-09 10:04:57 +02:00
|
|
|
dwritefontfamilylist2_GetFontSet,
|
2018-05-21 22:11:02 +02:00
|
|
|
};
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
static HRESULT create_fontfamily(struct dwrite_fontcollection *collection, UINT32 index,
|
|
|
|
struct dwrite_fontfamily **family)
|
2014-11-04 14:37:10 +01:00
|
|
|
{
|
2019-05-14 12:27:23 +02:00
|
|
|
struct dwrite_fontfamily *object;
|
2014-11-04 14:37:10 +01:00
|
|
|
|
|
|
|
*family = NULL;
|
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
object = heap_alloc(sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
return E_OUTOFMEMORY;
|
2014-11-04 14:37:10 +01:00
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
object->IDWriteFontFamily2_iface.lpVtbl = &fontfamilyvtbl;
|
2019-10-09 10:04:57 +02:00
|
|
|
object->IDWriteFontList2_iface.lpVtbl = &fontfamilylistvtbl;
|
2019-10-08 12:04:35 +02:00
|
|
|
object->refcount = 1;
|
2019-05-14 12:27:23 +02:00
|
|
|
object->collection = collection;
|
2019-10-08 12:04:34 +02:00
|
|
|
IDWriteFontCollection3_AddRef(&collection->IDWriteFontCollection3_iface);
|
2019-05-14 12:27:23 +02:00
|
|
|
object->data = collection->family_data[index];
|
|
|
|
InterlockedIncrement(&object->data->refcount);
|
2014-11-04 14:37:10 +01:00
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
*family = object;
|
2014-11-04 14:37:10 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-11-07 11:17:38 +01:00
|
|
|
BOOL is_system_collection(IDWriteFontCollection *collection)
|
|
|
|
{
|
|
|
|
void *obj;
|
2019-02-28 00:50:27 +01:00
|
|
|
return IDWriteFontCollection_QueryInterface(collection, &IID_issystemcollection, &obj) == S_OK;
|
2014-11-07 11:17:38 +01:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
static HRESULT WINAPI dwritesystemfontcollection_QueryInterface(IDWriteFontCollection3 *iface, REFIID riid, void **obj)
|
2012-10-21 03:43:01 +02:00
|
|
|
{
|
2019-10-08 12:04:34 +02:00
|
|
|
struct dwrite_fontcollection *collection = impl_from_IDWriteFontCollection3(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %s, %p.\n", collection, debugstr_guid(riid), obj);
|
2012-10-21 03:43:01 +02:00
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteFontCollection3) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFontCollection2) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFontCollection1) ||
|
2016-03-08 20:46:53 +01:00
|
|
|
IsEqualIID(riid, &IID_IDWriteFontCollection) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
2012-10-21 03:43:01 +02:00
|
|
|
{
|
|
|
|
*obj = iface;
|
2019-10-08 12:04:34 +02:00
|
|
|
IDWriteFontCollection3_AddRef(iface);
|
2012-10-21 03:43:01 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
2014-11-07 11:17:38 +01:00
|
|
|
|
2016-03-08 20:46:54 +01:00
|
|
|
if (IsEqualIID(riid, &IID_issystemcollection))
|
2014-11-07 11:17:38 +01:00
|
|
|
return S_OK;
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2012-10-21 03:43:01 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
static HRESULT WINAPI dwritefontcollection_QueryInterface(IDWriteFontCollection3 *iface, REFIID riid, void **obj)
|
2016-03-08 20:46:54 +01:00
|
|
|
{
|
2019-10-08 12:04:34 +02:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
|
2016-03-08 20:46:54 +01:00
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteFontCollection3) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFontCollection2) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFontCollection1) ||
|
2016-03-08 20:46:54 +01:00
|
|
|
IsEqualIID(riid, &IID_IDWriteFontCollection) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
2019-10-08 12:04:34 +02:00
|
|
|
IDWriteFontCollection3_AddRef(iface);
|
2016-03-08 20:46:54 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2016-03-08 20:46:54 +01:00
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
static ULONG WINAPI dwritefontcollection_AddRef(IDWriteFontCollection3 *iface)
|
2012-10-21 03:43:01 +02:00
|
|
|
{
|
2019-10-08 12:04:34 +02:00
|
|
|
struct dwrite_fontcollection *collection = impl_from_IDWriteFontCollection3(iface);
|
2019-05-14 12:27:24 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&collection->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %d.\n", collection, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
2012-10-21 03:43:01 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
static ULONG WINAPI dwritefontcollection_Release(IDWriteFontCollection3 *iface)
|
2012-10-21 03:43:01 +02:00
|
|
|
{
|
2019-10-08 12:04:34 +02:00
|
|
|
struct dwrite_fontcollection *collection = impl_from_IDWriteFontCollection3(iface);
|
2019-05-14 12:27:24 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&collection->refcount);
|
|
|
|
size_t i;
|
2014-09-02 14:17:57 +02:00
|
|
|
|
2019-05-14 12:27:24 +02:00
|
|
|
TRACE("%p, refcount %d.\n", iface, refcount);
|
2017-04-11 13:21:32 +02:00
|
|
|
|
2019-05-14 12:27:24 +02:00
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
factory_detach_fontcollection(collection->factory, iface);
|
|
|
|
for (i = 0; i < collection->count; ++i)
|
|
|
|
release_fontfamily_data(collection->family_data[i]);
|
|
|
|
heap_free(collection->family_data);
|
|
|
|
heap_free(collection);
|
2014-09-02 14:17:57 +02:00
|
|
|
}
|
|
|
|
|
2019-05-14 12:27:24 +02:00
|
|
|
return refcount;
|
2012-10-21 03:43:01 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
static UINT32 WINAPI dwritefontcollection_GetFontFamilyCount(IDWriteFontCollection3 *iface)
|
2012-10-21 03:43:01 +02:00
|
|
|
{
|
2019-10-08 12:04:34 +02:00
|
|
|
struct dwrite_fontcollection *collection = impl_from_IDWriteFontCollection3(iface);
|
2019-05-14 12:27:24 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return collection->count;
|
2012-10-21 03:43:01 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
static HRESULT WINAPI dwritefontcollection_GetFontFamily(IDWriteFontCollection3 *iface, UINT32 index,
|
2019-10-08 12:04:35 +02:00
|
|
|
IDWriteFontFamily **ret)
|
2012-10-21 03:43:01 +02:00
|
|
|
{
|
2019-10-08 12:04:34 +02:00
|
|
|
struct dwrite_fontcollection *collection = impl_from_IDWriteFontCollection3(iface);
|
2019-10-08 12:04:35 +02:00
|
|
|
struct dwrite_fontfamily *family;
|
|
|
|
HRESULT hr;
|
2012-10-22 06:06:03 +02:00
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
TRACE("%p, %u, %p.\n", iface, index, ret);
|
|
|
|
|
|
|
|
*ret = NULL;
|
2012-10-22 06:06:03 +02:00
|
|
|
|
2019-05-14 12:27:24 +02:00
|
|
|
if (index >= collection->count)
|
2014-10-29 20:41:47 +01:00
|
|
|
return E_FAIL;
|
2012-10-22 06:06:03 +02:00
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
if (SUCCEEDED(hr = create_fontfamily(collection, index, &family)))
|
|
|
|
*ret = (IDWriteFontFamily *)&family->IDWriteFontFamily2_iface;
|
|
|
|
|
|
|
|
return hr;
|
2012-10-21 03:43:01 +02:00
|
|
|
}
|
|
|
|
|
2015-02-04 13:28:48 +01:00
|
|
|
static UINT32 collection_find_family(struct dwrite_fontcollection *collection, const WCHAR *name)
|
2012-10-21 03:43:01 +02:00
|
|
|
{
|
2019-05-14 12:27:24 +02:00
|
|
|
size_t i;
|
2012-10-21 06:31:11 +02:00
|
|
|
|
2019-05-14 12:27:24 +02:00
|
|
|
for (i = 0; i < collection->count; ++i)
|
|
|
|
{
|
2015-02-04 13:28:48 +01:00
|
|
|
IDWriteLocalizedStrings *family_name = collection->family_data[i]->familyname;
|
2015-06-15 00:14:25 +02:00
|
|
|
UINT32 j, count = IDWriteLocalizedStrings_GetCount(family_name);
|
2015-02-04 13:28:48 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2015-06-15 00:14:25 +02:00
|
|
|
for (j = 0; j < count; j++) {
|
2015-02-04 13:28:48 +01:00
|
|
|
WCHAR buffer[255];
|
2019-09-11 16:04:43 +02:00
|
|
|
hr = IDWriteLocalizedStrings_GetString(family_name, j, buffer, ARRAY_SIZE(buffer));
|
2015-04-10 21:08:31 +02:00
|
|
|
if (SUCCEEDED(hr) && !strcmpiW(buffer, name))
|
2015-02-04 13:28:48 +01:00
|
|
|
return i;
|
2012-10-21 06:31:11 +02:00
|
|
|
}
|
2014-10-08 16:52:07 +02:00
|
|
|
}
|
2012-10-21 06:31:11 +02:00
|
|
|
|
2015-02-04 13:28:48 +01:00
|
|
|
return ~0u;
|
2012-10-21 03:43:01 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
static HRESULT WINAPI dwritefontcollection_FindFamilyName(IDWriteFontCollection3 *iface, const WCHAR *name,
|
|
|
|
UINT32 *index, BOOL *exists)
|
2014-10-24 09:43:21 +02:00
|
|
|
{
|
2019-10-08 12:04:34 +02:00
|
|
|
struct dwrite_fontcollection *collection = impl_from_IDWriteFontCollection3(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %s, %p, %p.\n", iface, debugstr_w(name), index, exists);
|
|
|
|
|
|
|
|
*index = collection_find_family(collection, name);
|
2015-02-04 13:28:48 +01:00
|
|
|
*exists = *index != ~0u;
|
|
|
|
return S_OK;
|
2014-10-24 09:43:21 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
static HRESULT WINAPI dwritefontcollection_GetFontFromFontFace(IDWriteFontCollection3 *iface, IDWriteFontFace *face,
|
2019-05-14 12:27:24 +02:00
|
|
|
IDWriteFont **font)
|
2012-10-21 03:43:01 +02:00
|
|
|
{
|
2019-10-08 12:04:34 +02:00
|
|
|
struct dwrite_fontcollection *collection = impl_from_IDWriteFontCollection3(iface);
|
2019-10-08 12:04:35 +02:00
|
|
|
struct dwrite_fontfamily *family;
|
2017-04-11 13:21:33 +02:00
|
|
|
BOOL found_font = FALSE;
|
2014-11-05 10:48:45 +01:00
|
|
|
IDWriteFontFile *file;
|
2019-05-14 12:27:24 +02:00
|
|
|
UINT32 face_index, count;
|
|
|
|
size_t i, j;
|
2014-10-27 09:25:43 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-05-14 12:27:24 +02:00
|
|
|
TRACE("%p, %p, %p.\n", iface, face, font);
|
2014-10-27 09:25:43 +01:00
|
|
|
|
|
|
|
*font = NULL;
|
|
|
|
|
|
|
|
if (!face)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-05-14 12:27:24 +02:00
|
|
|
count = 1;
|
|
|
|
hr = IDWriteFontFace_GetFiles(face, &count, &file);
|
2014-11-05 10:48:45 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
face_index = IDWriteFontFace_GetIndex(face);
|
|
|
|
|
2017-04-11 13:21:33 +02:00
|
|
|
found_font = FALSE;
|
2019-05-14 12:27:24 +02:00
|
|
|
for (i = 0; i < collection->count; ++i)
|
|
|
|
{
|
|
|
|
struct dwrite_fontfamily_data *family_data = collection->family_data[i];
|
2017-04-11 13:21:33 +02:00
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
for (j = 0; j < family_data->count; ++j)
|
|
|
|
{
|
2014-11-05 10:48:45 +01:00
|
|
|
struct dwrite_font_data *font_data = family_data->fonts[j];
|
|
|
|
|
|
|
|
if (face_index == font_data->face_index && is_same_fontfile(file, font_data->file)) {
|
2017-04-11 13:21:33 +02:00
|
|
|
found_font = TRUE;
|
2014-10-27 09:25:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-04-11 13:21:33 +02:00
|
|
|
|
|
|
|
if (found_font)
|
|
|
|
break;
|
2014-10-27 09:25:43 +01:00
|
|
|
}
|
2017-04-11 13:21:34 +02:00
|
|
|
IDWriteFontFile_Release(file);
|
2014-10-27 09:25:43 +01:00
|
|
|
|
|
|
|
if (!found_font)
|
2015-02-18 20:46:10 +01:00
|
|
|
return DWRITE_E_NOFONT;
|
2014-10-27 09:25:43 +01:00
|
|
|
|
2019-05-14 12:27:24 +02:00
|
|
|
hr = create_fontfamily(collection, i, &family);
|
2014-10-27 09:25:43 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
hr = create_font(family, j, (IDWriteFont3 **)font);
|
|
|
|
IDWriteFontFamily2_Release(&family->IDWriteFontFamily2_iface);
|
2014-10-27 09:25:43 +01:00
|
|
|
return hr;
|
2012-10-21 03:43:01 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
static HRESULT WINAPI dwritefontcollection1_GetFontSet(IDWriteFontCollection3 *iface, IDWriteFontSet **fontset)
|
2016-03-08 20:46:53 +01:00
|
|
|
{
|
2019-10-08 12:04:34 +02:00
|
|
|
FIXME("%p, %p.\n", iface, fontset);
|
2016-03-08 20:46:53 +01:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
static HRESULT WINAPI dwritefontcollection1_GetFontFamily(IDWriteFontCollection3 *iface, UINT32 index,
|
2019-10-08 12:04:35 +02:00
|
|
|
IDWriteFontFamily1 **ret)
|
2016-03-08 20:46:53 +01:00
|
|
|
{
|
2019-10-08 12:04:34 +02:00
|
|
|
struct dwrite_fontcollection *collection = impl_from_IDWriteFontCollection3(iface);
|
2019-10-08 12:04:35 +02:00
|
|
|
struct dwrite_fontfamily *family;
|
|
|
|
HRESULT hr;
|
2016-03-08 20:46:53 +01:00
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
TRACE("%p, %u, %p.\n", iface, index, ret);
|
|
|
|
|
|
|
|
*ret = NULL;
|
2016-03-08 20:46:53 +01:00
|
|
|
|
2019-05-14 12:27:24 +02:00
|
|
|
if (index >= collection->count)
|
2016-04-19 08:39:26 +02:00
|
|
|
return E_FAIL;
|
|
|
|
|
2019-10-08 12:04:35 +02:00
|
|
|
if (SUCCEEDED(hr = create_fontfamily(collection, index, &family)))
|
|
|
|
*ret = (IDWriteFontFamily1 *)&family->IDWriteFontFamily2_iface;
|
|
|
|
|
|
|
|
return hr;
|
2016-03-08 20:46:53 +01:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
static HRESULT WINAPI dwritefontcollection2_GetFontFamily(IDWriteFontCollection3 *iface,
|
|
|
|
UINT32 index, IDWriteFontFamily2 **family)
|
|
|
|
{
|
|
|
|
FIXME("%p, %u, %p.\n", iface, index, family);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontcollection2_GetMatchingFonts(IDWriteFontCollection3 *iface,
|
|
|
|
const WCHAR *familyname, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 num_values,
|
|
|
|
IDWriteFontList2 **fontlist)
|
|
|
|
{
|
|
|
|
FIXME("%p, %s, %p, %u, %p.\n", iface, debugstr_w(familyname), axis_values, num_values, fontlist);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_FONT_FAMILY_MODEL WINAPI dwritefontcollection2_GetFontFamilyModel(IDWriteFontCollection3 *iface)
|
|
|
|
{
|
|
|
|
FIXME("%p.\n", iface);
|
|
|
|
|
|
|
|
return DWRITE_FONT_FAMILY_MODEL_WEIGHT_STRETCH_STYLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontcollection2_GetFontSet(IDWriteFontCollection3 *iface, IDWriteFontSet1 **fontset)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p.\n", iface, fontset);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HANDLE WINAPI dwritefontcollection3_GetExpirationEvent(IDWriteFontCollection3 *iface)
|
|
|
|
{
|
|
|
|
FIXME("%p.\n", iface);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteFontCollection3Vtbl fontcollectionvtbl =
|
|
|
|
{
|
2012-10-21 03:43:01 +02:00
|
|
|
dwritefontcollection_QueryInterface,
|
2014-09-02 14:17:57 +02:00
|
|
|
dwritefontcollection_AddRef,
|
|
|
|
dwritefontcollection_Release,
|
2012-10-21 03:43:01 +02:00
|
|
|
dwritefontcollection_GetFontFamilyCount,
|
|
|
|
dwritefontcollection_GetFontFamily,
|
|
|
|
dwritefontcollection_FindFamilyName,
|
2016-03-08 20:46:53 +01:00
|
|
|
dwritefontcollection_GetFontFromFontFace,
|
|
|
|
dwritefontcollection1_GetFontSet,
|
2019-10-08 12:04:34 +02:00
|
|
|
dwritefontcollection1_GetFontFamily,
|
|
|
|
dwritefontcollection2_GetFontFamily,
|
|
|
|
dwritefontcollection2_GetMatchingFonts,
|
|
|
|
dwritefontcollection2_GetFontFamilyModel,
|
|
|
|
dwritefontcollection2_GetFontSet,
|
|
|
|
dwritefontcollection3_GetExpirationEvent,
|
2012-10-21 03:43:01 +02:00
|
|
|
};
|
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
static const IDWriteFontCollection3Vtbl systemfontcollectionvtbl =
|
|
|
|
{
|
2016-03-08 20:46:54 +01:00
|
|
|
dwritesystemfontcollection_QueryInterface,
|
|
|
|
dwritefontcollection_AddRef,
|
|
|
|
dwritefontcollection_Release,
|
|
|
|
dwritefontcollection_GetFontFamilyCount,
|
|
|
|
dwritefontcollection_GetFontFamily,
|
|
|
|
dwritefontcollection_FindFamilyName,
|
|
|
|
dwritefontcollection_GetFontFromFontFace,
|
|
|
|
dwritefontcollection1_GetFontSet,
|
2019-10-08 12:04:34 +02:00
|
|
|
dwritefontcollection1_GetFontFamily,
|
|
|
|
dwritefontcollection2_GetFontFamily,
|
|
|
|
dwritefontcollection2_GetMatchingFonts,
|
|
|
|
dwritefontcollection2_GetFontFamilyModel,
|
|
|
|
dwritefontcollection2_GetFontSet,
|
|
|
|
dwritefontcollection3_GetExpirationEvent,
|
2016-03-08 20:46:54 +01:00
|
|
|
};
|
|
|
|
|
2014-10-24 09:43:21 +02:00
|
|
|
static HRESULT fontfamily_add_font(struct dwrite_fontfamily_data *family_data, struct dwrite_font_data *font_data)
|
|
|
|
{
|
2019-05-14 12:27:23 +02:00
|
|
|
if (!dwrite_array_reserve((void **)&family_data->fonts, &family_data->size, family_data->count + 1,
|
|
|
|
sizeof(*family_data->fonts)))
|
|
|
|
{
|
|
|
|
return E_OUTOFMEMORY;
|
2014-10-24 09:43:21 +02:00
|
|
|
}
|
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
family_data->fonts[family_data->count++] = font_data;
|
2015-09-08 10:40:54 +02:00
|
|
|
if (font_data->style == DWRITE_FONT_STYLE_NORMAL)
|
2016-02-01 23:41:10 +01:00
|
|
|
family_data->has_normal_face = 1;
|
2015-09-08 10:40:54 +02:00
|
|
|
else if (font_data->style == DWRITE_FONT_STYLE_OBLIQUE)
|
2016-02-01 23:41:10 +01:00
|
|
|
family_data->has_oblique_face = 1;
|
2015-09-08 10:40:54 +02:00
|
|
|
else
|
2016-02-01 23:41:10 +01:00
|
|
|
family_data->has_italic_face = 1;
|
2014-10-24 09:43:21 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-14 12:27:24 +02:00
|
|
|
static HRESULT fontcollection_add_family(struct dwrite_fontcollection *collection,
|
|
|
|
struct dwrite_fontfamily_data *family)
|
2014-10-24 09:43:21 +02:00
|
|
|
{
|
2019-05-14 12:27:24 +02:00
|
|
|
if (!dwrite_array_reserve((void **)&collection->family_data, &collection->size, collection->count + 1,
|
|
|
|
sizeof(*collection->family_data)))
|
|
|
|
{
|
|
|
|
return E_OUTOFMEMORY;
|
2014-10-24 09:43:21 +02:00
|
|
|
}
|
|
|
|
|
2019-05-14 12:27:24 +02:00
|
|
|
collection->family_data[collection->count++] = family;
|
2014-10-24 09:43:21 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-11-07 11:17:38 +01:00
|
|
|
static HRESULT init_font_collection(struct dwrite_fontcollection *collection, BOOL is_system)
|
2014-10-24 09:43:21 +02:00
|
|
|
{
|
2019-10-08 12:04:34 +02:00
|
|
|
collection->IDWriteFontCollection3_iface.lpVtbl = is_system ? &systemfontcollectionvtbl : &fontcollectionvtbl;
|
2019-05-14 12:27:24 +02:00
|
|
|
collection->refcount = 1;
|
|
|
|
collection->count = 0;
|
|
|
|
collection->size = 0;
|
|
|
|
collection->family_data = NULL;
|
2014-10-24 09:43:21 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-12-08 11:24:39 +01:00
|
|
|
HRESULT get_filestream_from_file(IDWriteFontFile *file, IDWriteFontFileStream **stream)
|
2014-10-24 09:43:21 +02:00
|
|
|
{
|
|
|
|
IDWriteFontFileLoader *loader;
|
|
|
|
const void *key;
|
|
|
|
UINT32 key_size;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
*stream = NULL;
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetReferenceKey(file, &key, &key_size);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetLoader(file, &loader);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = IDWriteFontFileLoader_CreateStreamFromKey(loader, key, key_size, stream);
|
|
|
|
IDWriteFontFileLoader_Release(loader);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2015-08-18 06:40:27 +02:00
|
|
|
static void fontstrings_get_en_string(IDWriteLocalizedStrings *strings, WCHAR *buffer, UINT32 size)
|
|
|
|
{
|
|
|
|
BOOL exists = FALSE;
|
|
|
|
UINT32 index;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
buffer[0] = 0;
|
|
|
|
hr = IDWriteLocalizedStrings_FindLocaleName(strings, enusW, &index, &exists);
|
|
|
|
if (FAILED(hr) || !exists)
|
|
|
|
return;
|
|
|
|
|
|
|
|
IDWriteLocalizedStrings_GetString(strings, index, buffer, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int trim_spaces(WCHAR *in, WCHAR *ret)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
while (isspaceW(*in))
|
|
|
|
in++;
|
|
|
|
|
2015-08-18 22:49:50 +02:00
|
|
|
ret[0] = 0;
|
|
|
|
if (!(len = strlenW(in)))
|
|
|
|
return 0;
|
|
|
|
|
2015-08-18 06:40:27 +02:00
|
|
|
while (isspaceW(in[len-1]))
|
|
|
|
len--;
|
|
|
|
|
|
|
|
memcpy(ret, in, len*sizeof(WCHAR));
|
|
|
|
ret[len] = 0;
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct name_token {
|
|
|
|
struct list entry;
|
|
|
|
const WCHAR *ptr;
|
2015-09-01 11:09:24 +02:00
|
|
|
INT len; /* token length */
|
|
|
|
INT fulllen; /* full length including following separators */
|
2015-08-18 06:40:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline BOOL is_name_separator_char(WCHAR ch)
|
|
|
|
{
|
|
|
|
return ch == ' ' || ch == '.' || ch == '-' || ch == '_';
|
|
|
|
}
|
|
|
|
|
2015-08-18 22:48:44 +02:00
|
|
|
struct name_pattern {
|
|
|
|
const WCHAR *part1; /* NULL indicates end of list */
|
|
|
|
const WCHAR *part2; /* optional, if not NULL should point to non-empty string */
|
|
|
|
};
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
static BOOL match_pattern_list(struct list *tokens, const struct name_pattern *patterns, struct name_token *match)
|
2015-08-18 06:40:27 +02:00
|
|
|
{
|
2015-08-18 22:48:44 +02:00
|
|
|
const struct name_pattern *pattern;
|
2015-08-18 06:40:27 +02:00
|
|
|
struct name_token *token;
|
|
|
|
int i = 0;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
while ((pattern = &patterns[i++])->part1) {
|
2015-08-18 22:48:44 +02:00
|
|
|
int len_part1 = strlenW(pattern->part1);
|
|
|
|
int len_part2 = pattern->part2 ? strlenW(pattern->part2) : 0;
|
2015-08-18 06:40:27 +02:00
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(token, tokens, struct name_token, entry) {
|
2015-08-18 22:48:44 +02:00
|
|
|
if (len_part2 == 0) {
|
|
|
|
/* simple case with single part pattern */
|
|
|
|
if (token->len != len_part1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!strncmpiW(token->ptr, pattern->part1, len_part1)) {
|
2015-09-03 06:35:35 +02:00
|
|
|
if (match) *match = *token;
|
2015-08-18 22:48:44 +02:00
|
|
|
list_remove(&token->entry);
|
|
|
|
heap_free(token);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
struct name_token *next_token;
|
|
|
|
struct list *next_entry;
|
|
|
|
|
|
|
|
/* pattern parts are stored in reading order, tokens list is reversed */
|
|
|
|
if (token->len < len_part2)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* it's possible to have combined string as a token, like ExtraCondensed */
|
|
|
|
if (token->len == len_part1 + len_part2) {
|
|
|
|
if (strncmpiW(token->ptr, pattern->part1, len_part1))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (strncmpiW(&token->ptr[len_part1], pattern->part2, len_part2))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* combined string match */
|
2015-09-03 06:35:35 +02:00
|
|
|
if (match) *match = *token;
|
2015-08-18 22:48:44 +02:00
|
|
|
list_remove(&token->entry);
|
|
|
|
heap_free(token);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now it's only possible to have two tokens matched to respective pattern parts */
|
|
|
|
if (token->len != len_part2)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
next_entry = list_next(tokens, &token->entry);
|
|
|
|
if (next_entry) {
|
|
|
|
next_token = LIST_ENTRY(next_entry, struct name_token, entry);
|
|
|
|
if (next_token->len != len_part1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (strncmpiW(token->ptr, pattern->part2, len_part2))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (strncmpiW(next_token->ptr, pattern->part1, len_part1))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* both parts matched, remove tokens */
|
2015-09-03 06:35:35 +02:00
|
|
|
if (match) {
|
|
|
|
match->ptr = next_token->ptr;
|
|
|
|
match->len = (token->ptr - next_token->ptr) + token->len;
|
|
|
|
}
|
2015-08-18 22:48:44 +02:00
|
|
|
list_remove(&token->entry);
|
|
|
|
list_remove(&next_token->entry);
|
|
|
|
heap_free(next_token);
|
|
|
|
heap_free(token);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2015-08-18 06:40:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-03 06:35:35 +02:00
|
|
|
if (match) {
|
|
|
|
match->ptr = NULL;
|
|
|
|
match->len = 0;
|
|
|
|
}
|
2015-08-18 06:40:27 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
static DWRITE_FONT_STYLE font_extract_style(struct list *tokens, DWRITE_FONT_STYLE style, struct name_token *match)
|
2015-08-18 06:40:27 +02:00
|
|
|
{
|
|
|
|
static const WCHAR itaW[] = {'i','t','a',0};
|
|
|
|
static const WCHAR italW[] = {'i','t','a','l',0};
|
|
|
|
static const WCHAR cursiveW[] = {'c','u','r','s','i','v','e',0};
|
|
|
|
static const WCHAR kursivW[] = {'k','u','r','s','i','v',0};
|
|
|
|
|
|
|
|
static const WCHAR inclinedW[] = {'i','n','c','l','i','n','e','d',0};
|
|
|
|
static const WCHAR backslantedW[] = {'b','a','c','k','s','l','a','n','t','e','d',0};
|
|
|
|
static const WCHAR backslantW[] = {'b','a','c','k','s','l','a','n','t',0};
|
|
|
|
static const WCHAR slantedW[] = {'s','l','a','n','t','e','d',0};
|
|
|
|
|
2015-08-18 22:48:44 +02:00
|
|
|
static const struct name_pattern italic_patterns[] = {
|
|
|
|
{ itaW },
|
|
|
|
{ italW },
|
|
|
|
{ italicW },
|
|
|
|
{ cursiveW },
|
|
|
|
{ kursivW },
|
|
|
|
{ NULL }
|
2015-08-18 06:40:27 +02:00
|
|
|
};
|
|
|
|
|
2015-08-18 22:48:44 +02:00
|
|
|
static const struct name_pattern oblique_patterns[] = {
|
|
|
|
{ inclinedW },
|
|
|
|
{ obliqueW },
|
|
|
|
{ backslantedW },
|
|
|
|
{ backslantW },
|
|
|
|
{ slantedW },
|
|
|
|
{ NULL }
|
2015-08-18 06:40:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* italic patterns first */
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, italic_patterns, match))
|
2015-08-18 06:40:27 +02:00
|
|
|
return DWRITE_FONT_STYLE_ITALIC;
|
|
|
|
|
|
|
|
/* oblique patterns */
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, oblique_patterns, match))
|
2015-08-18 06:40:27 +02:00
|
|
|
return DWRITE_FONT_STYLE_OBLIQUE;
|
|
|
|
|
|
|
|
return style;
|
|
|
|
}
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
static DWRITE_FONT_STRETCH font_extract_stretch(struct list *tokens, DWRITE_FONT_STRETCH stretch,
|
|
|
|
struct name_token *match)
|
2015-08-18 22:48:44 +02:00
|
|
|
{
|
|
|
|
static const WCHAR compressedW[] = {'c','o','m','p','r','e','s','s','e','d',0};
|
|
|
|
static const WCHAR extendedW[] = {'e','x','t','e','n','d','e','d',0};
|
|
|
|
static const WCHAR compactW[] = {'c','o','m','p','a','c','t',0};
|
|
|
|
static const WCHAR narrowW[] = {'n','a','r','r','o','w',0};
|
|
|
|
static const WCHAR wideW[] = {'w','i','d','e',0};
|
|
|
|
static const WCHAR condW[] = {'c','o','n','d',0};
|
|
|
|
|
|
|
|
static const struct name_pattern ultracondensed_patterns[] = {
|
|
|
|
{ extraW, compressedW },
|
|
|
|
{ extW, compressedW },
|
|
|
|
{ ultraW, compressedW },
|
|
|
|
{ ultraW, condensedW },
|
|
|
|
{ ultraW, condW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern extracondensed_patterns[] = {
|
|
|
|
{ compressedW },
|
|
|
|
{ extraW, condensedW },
|
|
|
|
{ extW, condensedW },
|
|
|
|
{ extraW, condW },
|
|
|
|
{ extW, condW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern semicondensed_patterns[] = {
|
|
|
|
{ narrowW },
|
|
|
|
{ compactW },
|
|
|
|
{ semiW, condensedW },
|
|
|
|
{ semiW, condW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern semiexpanded_patterns[] = {
|
|
|
|
{ wideW },
|
|
|
|
{ semiW, expandedW },
|
|
|
|
{ semiW, extendedW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern extraexpanded_patterns[] = {
|
|
|
|
{ extraW, expandedW },
|
|
|
|
{ extW, expandedW },
|
|
|
|
{ extraW, extendedW },
|
|
|
|
{ extW, extendedW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern ultraexpanded_patterns[] = {
|
|
|
|
{ ultraW, expandedW },
|
|
|
|
{ ultraW, extendedW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern condensed_patterns[] = {
|
|
|
|
{ condensedW },
|
|
|
|
{ condW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern expanded_patterns[] = {
|
|
|
|
{ expandedW },
|
|
|
|
{ extendedW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, ultracondensed_patterns, match))
|
2015-08-18 22:48:44 +02:00
|
|
|
return DWRITE_FONT_STRETCH_ULTRA_CONDENSED;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, extracondensed_patterns, match))
|
2015-08-18 22:48:44 +02:00
|
|
|
return DWRITE_FONT_STRETCH_EXTRA_CONDENSED;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, semicondensed_patterns, match))
|
2015-08-18 22:48:44 +02:00
|
|
|
return DWRITE_FONT_STRETCH_SEMI_CONDENSED;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, semiexpanded_patterns, match))
|
2015-08-18 22:48:44 +02:00
|
|
|
return DWRITE_FONT_STRETCH_SEMI_EXPANDED;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, extraexpanded_patterns, match))
|
2015-08-18 22:48:44 +02:00
|
|
|
return DWRITE_FONT_STRETCH_EXTRA_EXPANDED;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, ultraexpanded_patterns, match))
|
2015-08-18 22:48:44 +02:00
|
|
|
return DWRITE_FONT_STRETCH_ULTRA_EXPANDED;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, condensed_patterns, match))
|
2015-08-18 22:48:44 +02:00
|
|
|
return DWRITE_FONT_STRETCH_CONDENSED;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, expanded_patterns, match))
|
2015-08-18 22:48:44 +02:00
|
|
|
return DWRITE_FONT_STRETCH_EXPANDED;
|
|
|
|
|
|
|
|
return stretch;
|
|
|
|
}
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
static DWRITE_FONT_WEIGHT font_extract_weight(struct list *tokens, DWRITE_FONT_WEIGHT weight,
|
|
|
|
struct name_token *match)
|
2015-08-18 22:49:24 +02:00
|
|
|
{
|
|
|
|
static const WCHAR heavyW[] = {'h','e','a','v','y',0};
|
|
|
|
static const WCHAR nordW[] = {'n','o','r','d',0};
|
|
|
|
|
|
|
|
static const struct name_pattern thin_patterns[] = {
|
|
|
|
{ extraW, thinW },
|
|
|
|
{ extW, thinW },
|
|
|
|
{ ultraW, thinW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern extralight_patterns[] = {
|
|
|
|
{ extraW, lightW },
|
|
|
|
{ extW, lightW },
|
|
|
|
{ ultraW, lightW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
2015-08-31 07:13:44 +02:00
|
|
|
static const struct name_pattern semilight_patterns[] = {
|
|
|
|
{ semiW, lightW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
2015-08-18 22:49:24 +02:00
|
|
|
static const struct name_pattern demibold_patterns[] = {
|
|
|
|
{ semiW, boldW },
|
|
|
|
{ demiW, boldW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern extrabold_patterns[] = {
|
|
|
|
{ extraW, boldW },
|
|
|
|
{ extW, boldW },
|
|
|
|
{ ultraW, boldW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern extrablack_patterns[] = {
|
|
|
|
{ extraW, blackW },
|
|
|
|
{ extW, blackW },
|
|
|
|
{ ultraW, blackW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern bold_patterns[] = {
|
|
|
|
{ boldW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern thin2_patterns[] = {
|
|
|
|
{ thinW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern light_patterns[] = {
|
|
|
|
{ lightW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern medium_patterns[] = {
|
|
|
|
{ mediumW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern black_patterns[] = {
|
|
|
|
{ blackW },
|
|
|
|
{ heavyW },
|
|
|
|
{ nordW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern demibold2_patterns[] = {
|
|
|
|
{ demiW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct name_pattern extrabold2_patterns[] = {
|
|
|
|
{ ultraW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
/* FIXME: allow optional 'face' suffix, separated or not. It's removed together with
|
|
|
|
matching pattern. */
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, thin_patterns, match))
|
2015-08-18 22:49:24 +02:00
|
|
|
return DWRITE_FONT_WEIGHT_THIN;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, extralight_patterns, match))
|
2015-08-18 22:49:24 +02:00
|
|
|
return DWRITE_FONT_WEIGHT_EXTRA_LIGHT;
|
|
|
|
|
2015-08-31 07:13:44 +02:00
|
|
|
if (match_pattern_list(tokens, semilight_patterns, match))
|
|
|
|
return DWRITE_FONT_WEIGHT_SEMI_LIGHT;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, demibold_patterns, match))
|
2015-08-18 22:49:24 +02:00
|
|
|
return DWRITE_FONT_WEIGHT_DEMI_BOLD;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, extrabold_patterns, match))
|
2015-08-18 22:49:24 +02:00
|
|
|
return DWRITE_FONT_WEIGHT_EXTRA_BOLD;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, extrablack_patterns, match))
|
2015-08-18 22:49:24 +02:00
|
|
|
return DWRITE_FONT_WEIGHT_EXTRA_BLACK;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, bold_patterns, match))
|
2015-08-18 22:49:24 +02:00
|
|
|
return DWRITE_FONT_WEIGHT_BOLD;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, thin2_patterns, match))
|
2015-08-18 22:49:24 +02:00
|
|
|
return DWRITE_FONT_WEIGHT_THIN;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, light_patterns, match))
|
2015-08-18 22:49:24 +02:00
|
|
|
return DWRITE_FONT_WEIGHT_LIGHT;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, medium_patterns, match))
|
2015-08-18 22:49:24 +02:00
|
|
|
return DWRITE_FONT_WEIGHT_MEDIUM;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, black_patterns, match))
|
2015-08-18 22:49:24 +02:00
|
|
|
return DWRITE_FONT_WEIGHT_BLACK;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, black_patterns, match))
|
2015-08-18 22:49:24 +02:00
|
|
|
return DWRITE_FONT_WEIGHT_BLACK;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, demibold2_patterns, match))
|
2015-08-18 22:49:24 +02:00
|
|
|
return DWRITE_FONT_WEIGHT_DEMI_BOLD;
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
if (match_pattern_list(tokens, extrabold2_patterns, match))
|
2015-08-18 22:49:24 +02:00
|
|
|
return DWRITE_FONT_WEIGHT_EXTRA_BOLD;
|
|
|
|
|
|
|
|
/* FIXME: use abbreviated names to extract weight */
|
|
|
|
|
|
|
|
return weight;
|
|
|
|
}
|
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
struct knownweight_entry {
|
|
|
|
const WCHAR *nameW;
|
|
|
|
DWRITE_FONT_WEIGHT weight;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int compare_knownweights(const void *a, const void* b)
|
|
|
|
{
|
|
|
|
DWRITE_FONT_WEIGHT target = *(DWRITE_FONT_WEIGHT*)a;
|
|
|
|
const struct knownweight_entry *entry = (struct knownweight_entry*)b;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (target > entry->weight)
|
|
|
|
ret = 1;
|
|
|
|
else if (target < entry->weight)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_known_weight_value(DWRITE_FONT_WEIGHT weight, WCHAR *nameW)
|
|
|
|
{
|
|
|
|
static const WCHAR extralightW[] = {'E','x','t','r','a',' ','L','i','g','h','t',0};
|
2015-08-31 07:13:44 +02:00
|
|
|
static const WCHAR semilightW[] = {'S','e','m','i',' ','L','i','g','h','t',0};
|
2015-08-31 07:13:03 +02:00
|
|
|
static const WCHAR extrablackW[] = {'E','x','t','r','a',' ','B','l','a','c','k',0};
|
|
|
|
static const WCHAR extraboldW[] = {'E','x','t','r','a',' ','B','o','l','d',0};
|
|
|
|
static const WCHAR demiboldW[] = {'D','e','m','i',' ','B','o','l','d',0};
|
|
|
|
const struct knownweight_entry *ptr;
|
|
|
|
|
|
|
|
static const struct knownweight_entry knownweights[] = {
|
|
|
|
{ thinW, DWRITE_FONT_WEIGHT_THIN },
|
|
|
|
{ extralightW, DWRITE_FONT_WEIGHT_EXTRA_LIGHT },
|
|
|
|
{ lightW, DWRITE_FONT_WEIGHT_LIGHT },
|
2015-08-31 07:13:44 +02:00
|
|
|
{ semilightW, DWRITE_FONT_WEIGHT_SEMI_LIGHT },
|
2015-08-31 07:13:03 +02:00
|
|
|
{ mediumW, DWRITE_FONT_WEIGHT_MEDIUM },
|
|
|
|
{ demiboldW, DWRITE_FONT_WEIGHT_DEMI_BOLD },
|
|
|
|
{ boldW, DWRITE_FONT_WEIGHT_BOLD },
|
|
|
|
{ extraboldW, DWRITE_FONT_WEIGHT_EXTRA_BOLD },
|
|
|
|
{ blackW, DWRITE_FONT_WEIGHT_BLACK },
|
|
|
|
{ extrablackW, DWRITE_FONT_WEIGHT_EXTRA_BLACK }
|
|
|
|
};
|
|
|
|
|
2018-02-21 06:15:22 +01:00
|
|
|
ptr = bsearch(&weight, knownweights, ARRAY_SIZE(knownweights), sizeof(knownweights[0]),
|
2015-08-31 07:13:03 +02:00
|
|
|
compare_knownweights);
|
|
|
|
if (!ptr) {
|
|
|
|
nameW[0] = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpyW(nameW, ptr->nameW);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void font_name_token_to_str(const struct name_token *name, WCHAR *strW)
|
|
|
|
{
|
|
|
|
memcpy(strW, name->ptr, name->len * sizeof(WCHAR));
|
|
|
|
strW[name->len] = 0;
|
|
|
|
}
|
|
|
|
|
2015-09-03 06:35:35 +02:00
|
|
|
/* Modifies facenameW string, and returns pointer to regular term that was removed */
|
|
|
|
static const WCHAR *facename_remove_regular_term(WCHAR *facenameW, INT len)
|
2015-08-18 06:40:27 +02:00
|
|
|
{
|
|
|
|
static const WCHAR bookW[] = {'B','o','o','k',0};
|
|
|
|
static const WCHAR normalW[] = {'N','o','r','m','a','l',0};
|
|
|
|
static const WCHAR regularW[] = {'R','e','g','u','l','a','r',0};
|
|
|
|
static const WCHAR romanW[] = {'R','o','m','a','n',0};
|
|
|
|
static const WCHAR uprightW[] = {'U','p','r','i','g','h','t',0};
|
|
|
|
|
|
|
|
static const WCHAR *regular_patterns[] = {
|
|
|
|
bookW,
|
|
|
|
normalW,
|
|
|
|
regularW,
|
|
|
|
romanW,
|
|
|
|
uprightW,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2015-09-03 06:35:35 +02:00
|
|
|
const WCHAR *regular_ptr = NULL, *ptr;
|
|
|
|
int i = 0;
|
2015-08-18 06:40:27 +02:00
|
|
|
|
2015-09-03 06:35:35 +02:00
|
|
|
if (len == -1)
|
|
|
|
len = strlenW(facenameW);
|
2015-08-18 06:40:27 +02:00
|
|
|
|
|
|
|
/* remove rightmost regular variant from face name */
|
2015-08-31 07:13:03 +02:00
|
|
|
while (!regular_ptr && (ptr = regular_patterns[i++])) {
|
2015-08-18 06:40:27 +02:00
|
|
|
int pattern_len = strlenW(ptr);
|
2015-08-31 07:13:03 +02:00
|
|
|
WCHAR *src;
|
2015-08-18 06:40:27 +02:00
|
|
|
|
|
|
|
if (pattern_len > len)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
src = facenameW + len - pattern_len;
|
|
|
|
while (src >= facenameW) {
|
|
|
|
if (!strncmpiW(src, ptr, pattern_len)) {
|
|
|
|
memmove(src, src + pattern_len, (len - pattern_len - (src - facenameW) + 1)*sizeof(WCHAR));
|
|
|
|
len = strlenW(facenameW);
|
2015-08-31 07:13:03 +02:00
|
|
|
regular_ptr = ptr;
|
2015-08-18 06:40:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
src--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-03 06:35:35 +02:00
|
|
|
return regular_ptr;
|
|
|
|
}
|
2015-08-18 06:40:27 +02:00
|
|
|
|
2015-09-03 06:35:35 +02:00
|
|
|
static void fontname_tokenize(struct list *tokens, const WCHAR *nameW)
|
|
|
|
{
|
|
|
|
const WCHAR *ptr;
|
|
|
|
|
|
|
|
list_init(tokens);
|
|
|
|
ptr = nameW;
|
2015-08-18 06:40:27 +02:00
|
|
|
|
|
|
|
while (*ptr) {
|
|
|
|
struct name_token *token = heap_alloc(sizeof(*token));
|
|
|
|
token->ptr = ptr;
|
|
|
|
token->len = 0;
|
2015-09-01 11:09:24 +02:00
|
|
|
token->fulllen = 0;
|
2015-08-18 06:40:27 +02:00
|
|
|
|
|
|
|
while (*ptr && !is_name_separator_char(*ptr)) {
|
|
|
|
token->len++;
|
2015-09-01 11:09:24 +02:00
|
|
|
token->fulllen++;
|
2015-08-18 06:40:27 +02:00
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* skip separators */
|
2015-09-01 11:09:24 +02:00
|
|
|
while (is_name_separator_char(*ptr)) {
|
|
|
|
token->fulllen++;
|
2015-08-18 06:40:27 +02:00
|
|
|
ptr++;
|
2015-09-01 11:09:24 +02:00
|
|
|
}
|
2015-08-18 06:40:27 +02:00
|
|
|
|
2015-09-03 06:35:35 +02:00
|
|
|
list_add_head(tokens, &token->entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fontname_tokens_to_str(struct list *tokens, WCHAR *nameW)
|
|
|
|
{
|
|
|
|
struct name_token *token, *token2;
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE_REV(token, token2, tokens, struct name_token, entry) {
|
|
|
|
int len;
|
|
|
|
|
|
|
|
list_remove(&token->entry);
|
|
|
|
|
|
|
|
/* don't include last separator */
|
|
|
|
len = list_empty(tokens) ? token->len : token->fulllen;
|
|
|
|
memcpy(nameW, token->ptr, len * sizeof(WCHAR));
|
|
|
|
nameW += len;
|
|
|
|
|
|
|
|
heap_free(token);
|
|
|
|
}
|
|
|
|
*nameW = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL font_apply_differentiation_rules(struct dwrite_font_data *font, WCHAR *familyW, WCHAR *faceW)
|
|
|
|
{
|
|
|
|
struct name_token stretch_name, weight_name, style_name;
|
|
|
|
WCHAR familynameW[255], facenameW[255], finalW[255];
|
|
|
|
WCHAR weightW[32], stretchW[32], styleW[32];
|
|
|
|
const WCHAR *regular_ptr = NULL;
|
|
|
|
DWRITE_FONT_STRETCH stretch;
|
|
|
|
DWRITE_FONT_WEIGHT weight;
|
|
|
|
struct list tokens;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
/* remove leading and trailing spaces from family and face name */
|
|
|
|
trim_spaces(familyW, familynameW);
|
|
|
|
len = trim_spaces(faceW, facenameW);
|
|
|
|
|
|
|
|
/* remove rightmost regular variant from face name */
|
|
|
|
regular_ptr = facename_remove_regular_term(facenameW, len);
|
|
|
|
|
|
|
|
/* append face name to family name, FIXME check if face name is a substring of family name */
|
|
|
|
if (*facenameW) {
|
|
|
|
strcatW(familynameW, spaceW);
|
|
|
|
strcatW(familynameW, facenameW);
|
2015-08-18 06:40:27 +02:00
|
|
|
}
|
|
|
|
|
2015-09-03 06:35:35 +02:00
|
|
|
/* tokenize with " .-_" */
|
|
|
|
fontname_tokenize(&tokens, familynameW);
|
|
|
|
|
2015-08-18 06:40:27 +02:00
|
|
|
/* extract and resolve style */
|
2015-08-31 07:13:03 +02:00
|
|
|
font->style = font_extract_style(&tokens, font->style, &style_name);
|
2015-08-18 06:40:27 +02:00
|
|
|
|
2015-08-18 22:48:44 +02:00
|
|
|
/* extract stretch */
|
2015-08-31 07:13:03 +02:00
|
|
|
stretch = font_extract_stretch(&tokens, font->stretch, &stretch_name);
|
2015-08-18 06:40:27 +02:00
|
|
|
|
2015-08-18 22:49:24 +02:00
|
|
|
/* extract weight */
|
2015-08-31 07:13:03 +02:00
|
|
|
weight = font_extract_weight(&tokens, font->weight, &weight_name);
|
2015-08-18 22:49:24 +02:00
|
|
|
|
|
|
|
/* resolve weight */
|
|
|
|
if (weight != font->weight) {
|
|
|
|
if (!(weight < DWRITE_FONT_WEIGHT_NORMAL && font->weight < DWRITE_FONT_WEIGHT_NORMAL) &&
|
|
|
|
!(weight > DWRITE_FONT_WEIGHT_MEDIUM && font->weight > DWRITE_FONT_WEIGHT_MEDIUM) &&
|
|
|
|
!((weight == DWRITE_FONT_WEIGHT_NORMAL && font->weight == DWRITE_FONT_WEIGHT_MEDIUM) ||
|
|
|
|
(weight == DWRITE_FONT_WEIGHT_MEDIUM && font->weight == DWRITE_FONT_WEIGHT_NORMAL)) &&
|
|
|
|
!(abs(weight - font->weight) <= 150 &&
|
|
|
|
font->weight != DWRITE_FONT_WEIGHT_NORMAL &&
|
|
|
|
font->weight != DWRITE_FONT_WEIGHT_MEDIUM &&
|
|
|
|
font->weight != DWRITE_FONT_WEIGHT_BOLD)) {
|
|
|
|
|
|
|
|
font->weight = weight;
|
|
|
|
}
|
|
|
|
}
|
2015-08-18 06:40:27 +02:00
|
|
|
|
2015-08-18 22:48:44 +02:00
|
|
|
/* Resolve stretch - extracted stretch can't be normal, it will override specified stretch if
|
|
|
|
it's leaning in opposite direction from normal comparing to specified stretch or if specified
|
|
|
|
stretch itself is normal (extracted stretch is never normal). */
|
|
|
|
if (stretch != font->stretch) {
|
|
|
|
if ((font->stretch == DWRITE_FONT_STRETCH_NORMAL) ||
|
|
|
|
(font->stretch < DWRITE_FONT_STRETCH_NORMAL && stretch > DWRITE_FONT_STRETCH_NORMAL) ||
|
|
|
|
(font->stretch > DWRITE_FONT_STRETCH_NORMAL && stretch < DWRITE_FONT_STRETCH_NORMAL)) {
|
|
|
|
|
|
|
|
font->stretch = stretch;
|
|
|
|
}
|
|
|
|
}
|
2015-08-18 06:40:27 +02:00
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
/* FIXME: cleanup face name from possible 2-3 digit prefixes */
|
2015-08-18 22:49:24 +02:00
|
|
|
|
2015-08-31 07:13:03 +02:00
|
|
|
/* get final combined string from what's left in token list, list is released */
|
2015-09-03 06:35:35 +02:00
|
|
|
fontname_tokens_to_str(&tokens, finalW);
|
2015-08-31 07:13:03 +02:00
|
|
|
|
|
|
|
if (!strcmpW(familyW, finalW))
|
2015-09-01 11:09:24 +02:00
|
|
|
return FALSE;
|
2015-08-31 07:13:03 +02:00
|
|
|
|
|
|
|
/* construct face name */
|
|
|
|
strcpyW(familyW, finalW);
|
|
|
|
|
|
|
|
/* resolved weight name */
|
|
|
|
if (weight_name.ptr)
|
|
|
|
font_name_token_to_str(&weight_name, weightW);
|
|
|
|
/* ignore normal weight */
|
|
|
|
else if (font->weight == DWRITE_FONT_WEIGHT_NORMAL)
|
|
|
|
weightW[0] = 0;
|
|
|
|
/* for known weight values use appropriate names */
|
|
|
|
else if (is_known_weight_value(font->weight, weightW)) {
|
|
|
|
}
|
2016-01-17 19:41:56 +01:00
|
|
|
/* use Wnnn format as a fallback in case weight is not one of known values */
|
2015-08-31 07:13:03 +02:00
|
|
|
else {
|
|
|
|
static const WCHAR fmtW[] = {'W','%','d',0};
|
|
|
|
sprintfW(weightW, fmtW, font->weight);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* resolved stretch name */
|
|
|
|
if (stretch_name.ptr)
|
|
|
|
font_name_token_to_str(&stretch_name, stretchW);
|
|
|
|
/* ignore normal stretch */
|
|
|
|
else if (font->stretch == DWRITE_FONT_STRETCH_NORMAL)
|
|
|
|
stretchW[0] = 0;
|
|
|
|
/* use predefined stretch names */
|
|
|
|
else {
|
|
|
|
static const WCHAR ultracondensedW[] = {'U','l','t','r','a',' ','C','o','n','d','e','n','s','e','d',0};
|
|
|
|
static const WCHAR extracondensedW[] = {'E','x','t','r','a',' ','C','o','n','d','e','n','s','e','d',0};
|
|
|
|
static const WCHAR semicondensedW[] = {'S','e','m','i',' ','C','o','n','d','e','n','s','e','d',0};
|
|
|
|
static const WCHAR semiexpandedW[] = {'S','e','m','i',' ','E','x','p','a','n','d','e','d',0};
|
|
|
|
static const WCHAR extraexpandedW[] = {'E','x','t','r','a',' ','E','x','p','a','n','d','e','d',0};
|
|
|
|
static const WCHAR ultraexpandedW[] = {'U','l','t','r','a',' ','E','x','p','a','n','d','e','d',0};
|
|
|
|
|
|
|
|
static const WCHAR *stretchnamesW[] = {
|
2016-08-13 21:21:14 +02:00
|
|
|
NULL, /* DWRITE_FONT_STRETCH_UNDEFINED */
|
2015-08-31 07:13:03 +02:00
|
|
|
ultracondensedW,
|
|
|
|
extracondensedW,
|
|
|
|
condensedW,
|
|
|
|
semicondensedW,
|
|
|
|
NULL, /* DWRITE_FONT_STRETCH_NORMAL */
|
|
|
|
semiexpandedW,
|
|
|
|
expandedW,
|
|
|
|
extraexpandedW,
|
|
|
|
ultraexpandedW
|
|
|
|
};
|
|
|
|
strcpyW(stretchW, stretchnamesW[font->stretch]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* resolved style name */
|
|
|
|
if (style_name.ptr)
|
|
|
|
font_name_token_to_str(&style_name, styleW);
|
|
|
|
else if (font->style == DWRITE_FONT_STYLE_NORMAL)
|
|
|
|
styleW[0] = 0;
|
|
|
|
/* use predefined names */
|
|
|
|
else {
|
|
|
|
if (font->style == DWRITE_FONT_STYLE_ITALIC)
|
|
|
|
strcpyW(styleW, italicW);
|
|
|
|
else
|
|
|
|
strcpyW(styleW, obliqueW);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* use Regular match if it was found initially */
|
|
|
|
if (!*weightW && !*stretchW && !*styleW)
|
|
|
|
strcpyW(faceW, regular_ptr ? regular_ptr : regularW);
|
|
|
|
else {
|
|
|
|
faceW[0] = 0;
|
|
|
|
if (*stretchW)
|
|
|
|
strcpyW(faceW, stretchW);
|
|
|
|
if (*weightW) {
|
|
|
|
if (*faceW)
|
|
|
|
strcatW(faceW, spaceW);
|
|
|
|
strcatW(faceW, weightW);
|
|
|
|
}
|
|
|
|
if (*styleW) {
|
|
|
|
if (*faceW)
|
|
|
|
strcatW(faceW, spaceW);
|
|
|
|
strcatW(faceW, styleW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("resolved family %s, face %s\n", debugstr_w(familyW), debugstr_w(faceW));
|
2015-09-01 11:09:24 +02:00
|
|
|
return TRUE;
|
2015-08-18 06:40:27 +02:00
|
|
|
}
|
|
|
|
|
2020-01-24 09:17:35 +01:00
|
|
|
static HRESULT init_font_data(const struct fontface_desc *desc, struct dwrite_font_data **ret)
|
2014-10-24 09:43:21 +02:00
|
|
|
{
|
2020-02-04 11:15:09 +01:00
|
|
|
static const float width_axis_values[] =
|
|
|
|
{
|
|
|
|
0.0f, /* DWRITE_FONT_STRETCH_UNDEFINED */
|
|
|
|
50.0f, /* DWRITE_FONT_STRETCH_ULTRA_CONDENSED */
|
|
|
|
62.5f, /* DWRITE_FONT_STRETCH_EXTRA_CONDENSED */
|
|
|
|
75.0f, /* DWRITE_FONT_STRETCH_CONDENSED */
|
|
|
|
87.5f, /* DWRITE_FONT_STRETCH_SEMI_CONDENSED */
|
|
|
|
100.0f, /* DWRITE_FONT_STRETCH_NORMAL */
|
|
|
|
112.5f, /* DWRITE_FONT_STRETCH_SEMI_EXPANDED */
|
|
|
|
125.0f, /* DWRITE_FONT_STRETCH_EXPANDED */
|
|
|
|
150.0f, /* DWRITE_FONT_STRETCH_EXTRA_EXPANDED */
|
|
|
|
200.0f, /* DWRITE_FONT_STRETCH_ULTRA_EXPANDED */
|
|
|
|
};
|
|
|
|
|
2016-05-03 20:26:48 +02:00
|
|
|
struct file_stream_desc stream_desc;
|
2015-07-06 22:08:37 +02:00
|
|
|
struct dwrite_font_props props;
|
2015-02-04 13:34:12 +01:00
|
|
|
struct dwrite_font_data *data;
|
2015-08-18 06:40:27 +02:00
|
|
|
WCHAR familyW[255], faceW[255];
|
2014-10-24 09:43:21 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2015-08-18 06:40:27 +02:00
|
|
|
*ret = NULL;
|
2017-10-18 13:53:06 +02:00
|
|
|
|
2015-02-04 13:34:12 +01:00
|
|
|
data = heap_alloc_zero(sizeof(*data));
|
|
|
|
if (!data)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
data->ref = 1;
|
2016-07-05 11:55:53 +02:00
|
|
|
data->file = desc->files[0];
|
|
|
|
data->face_index = desc->index;
|
|
|
|
data->face_type = desc->face_type;
|
2015-09-03 06:36:01 +02:00
|
|
|
data->simulations = DWRITE_FONT_SIMULATIONS_NONE;
|
2016-02-01 23:41:10 +01:00
|
|
|
data->bold_sim_tested = 0;
|
|
|
|
data->oblique_sim_tested = 0;
|
2016-07-05 11:55:53 +02:00
|
|
|
IDWriteFontFile_AddRef(data->file);
|
2014-10-24 09:43:21 +02:00
|
|
|
|
2017-10-18 13:53:06 +02:00
|
|
|
stream_desc.stream = desc->stream;
|
2016-07-05 11:55:53 +02:00
|
|
|
stream_desc.face_type = desc->face_type;
|
|
|
|
stream_desc.face_index = desc->index;
|
2016-05-03 20:26:48 +02:00
|
|
|
opentype_get_font_properties(&stream_desc, &props);
|
|
|
|
opentype_get_font_metrics(&stream_desc, &data->metrics, NULL);
|
2016-12-04 17:22:16 +01:00
|
|
|
opentype_get_font_facename(&stream_desc, props.lf.lfFaceName, &data->names);
|
2014-10-24 09:43:21 +02:00
|
|
|
|
2015-08-18 06:40:27 +02:00
|
|
|
/* get family name from font file */
|
2020-01-24 09:17:35 +01:00
|
|
|
hr = opentype_get_font_familyname(&stream_desc, &data->family_names);
|
2015-08-18 06:40:27 +02:00
|
|
|
if (FAILED(hr)) {
|
|
|
|
WARN("unable to get family name from font\n");
|
|
|
|
release_font_data(data);
|
|
|
|
return hr;
|
|
|
|
}
|
2014-10-24 09:43:21 +02:00
|
|
|
|
2015-07-06 22:08:37 +02:00
|
|
|
data->style = props.style;
|
|
|
|
data->stretch = props.stretch;
|
|
|
|
data->weight = props.weight;
|
|
|
|
data->panose = props.panose;
|
2017-08-15 13:40:26 +02:00
|
|
|
data->fontsig = props.fontsig;
|
2016-12-04 17:22:13 +01:00
|
|
|
data->lf = props.lf;
|
2020-01-23 10:24:12 +01:00
|
|
|
data->flags = props.flags;
|
2015-07-06 22:08:37 +02:00
|
|
|
|
2020-01-24 09:17:35 +01:00
|
|
|
fontstrings_get_en_string(data->family_names, familyW, ARRAY_SIZE(familyW));
|
2018-02-21 06:15:22 +01:00
|
|
|
fontstrings_get_en_string(data->names, faceW, ARRAY_SIZE(faceW));
|
2015-09-01 11:09:24 +02:00
|
|
|
if (font_apply_differentiation_rules(data, familyW, faceW)) {
|
2020-01-24 09:17:35 +01:00
|
|
|
set_en_localizedstring(data->family_names, familyW);
|
2015-09-01 11:09:24 +02:00
|
|
|
set_en_localizedstring(data->names, faceW);
|
|
|
|
}
|
2015-08-18 06:40:27 +02:00
|
|
|
|
|
|
|
init_font_prop_vec(data->weight, data->stretch, data->style, &data->propvec);
|
2014-10-24 09:43:21 +02:00
|
|
|
|
2020-02-04 11:15:09 +01:00
|
|
|
data->axis[0].axisTag = DWRITE_FONT_AXIS_TAG_WEIGHT;
|
|
|
|
data->axis[0].value = props.weight;
|
|
|
|
data->axis[1].axisTag = DWRITE_FONT_AXIS_TAG_WIDTH;
|
|
|
|
data->axis[1].value = width_axis_values[props.stretch];
|
|
|
|
data->axis[2].axisTag = DWRITE_FONT_AXIS_TAG_ITALIC;
|
|
|
|
data->axis[2].value = data->style == DWRITE_FONT_STYLE_ITALIC ? 1.0f : 0.0f;
|
|
|
|
|
2015-02-04 13:34:12 +01:00
|
|
|
*ret = data;
|
2014-10-24 09:43:21 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
static HRESULT init_font_data_from_font(const struct dwrite_font_data *src, DWRITE_FONT_SIMULATIONS sim,
|
|
|
|
const WCHAR *facenameW, struct dwrite_font_data **ret)
|
2015-09-03 06:35:35 +02:00
|
|
|
{
|
|
|
|
struct dwrite_font_data *data;
|
|
|
|
|
|
|
|
*ret = NULL;
|
2017-04-11 13:21:32 +02:00
|
|
|
|
2015-09-03 06:35:35 +02:00
|
|
|
data = heap_alloc_zero(sizeof(*data));
|
|
|
|
if (!data)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
*data = *src;
|
|
|
|
data->ref = 1;
|
2015-09-03 06:36:01 +02:00
|
|
|
data->simulations |= sim;
|
|
|
|
if (sim == DWRITE_FONT_SIMULATIONS_BOLD)
|
|
|
|
data->weight = DWRITE_FONT_WEIGHT_BOLD;
|
|
|
|
else if (sim == DWRITE_FONT_SIMULATIONS_OBLIQUE)
|
|
|
|
data->style = DWRITE_FONT_STYLE_OBLIQUE;
|
2015-09-03 06:35:35 +02:00
|
|
|
memset(data->info_strings, 0, sizeof(data->info_strings));
|
|
|
|
data->names = NULL;
|
|
|
|
IDWriteFontFile_AddRef(data->file);
|
2020-01-24 09:17:35 +01:00
|
|
|
IDWriteLocalizedStrings_AddRef(data->family_names);
|
2015-09-03 06:35:35 +02:00
|
|
|
|
|
|
|
create_localizedstrings(&data->names);
|
|
|
|
add_localizedstring(data->names, enusW, facenameW);
|
|
|
|
|
|
|
|
init_font_prop_vec(data->weight, data->stretch, data->style, &data->propvec);
|
|
|
|
|
|
|
|
*ret = data;
|
|
|
|
return S_OK;
|
|
|
|
};
|
|
|
|
|
2015-02-04 13:34:12 +01:00
|
|
|
static HRESULT init_fontfamily_data(IDWriteLocalizedStrings *familyname, struct dwrite_fontfamily_data **ret)
|
2014-10-24 09:43:21 +02:00
|
|
|
{
|
2015-02-04 13:34:12 +01:00
|
|
|
struct dwrite_fontfamily_data *data;
|
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
data = heap_alloc_zero(sizeof(*data));
|
2015-02-04 13:34:12 +01:00
|
|
|
if (!data)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
data->refcount = 1;
|
2014-10-24 09:43:21 +02:00
|
|
|
data->familyname = familyname;
|
|
|
|
IDWriteLocalizedStrings_AddRef(familyname);
|
|
|
|
|
2015-02-04 13:34:12 +01:00
|
|
|
*ret = data;
|
2019-05-14 12:27:23 +02:00
|
|
|
|
2014-10-24 09:43:21 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-03 06:35:35 +02:00
|
|
|
static void fontfamily_add_bold_simulated_face(struct dwrite_fontfamily_data *family)
|
|
|
|
{
|
2019-05-14 12:27:23 +02:00
|
|
|
size_t i, j, heaviest;
|
2015-09-03 06:35:35 +02:00
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
for (i = 0; i < family->count; ++i)
|
|
|
|
{
|
2015-09-03 06:35:35 +02:00
|
|
|
DWRITE_FONT_WEIGHT weight = family->fonts[i]->weight;
|
|
|
|
heaviest = i;
|
|
|
|
|
|
|
|
if (family->fonts[i]->bold_sim_tested)
|
|
|
|
continue;
|
|
|
|
|
2016-02-01 23:41:10 +01:00
|
|
|
family->fonts[i]->bold_sim_tested = 1;
|
2019-05-14 12:27:23 +02:00
|
|
|
for (j = i; j < family->count; ++j)
|
|
|
|
{
|
2015-09-03 06:35:35 +02:00
|
|
|
if (family->fonts[j]->bold_sim_tested)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((family->fonts[i]->style == family->fonts[j]->style) &&
|
|
|
|
(family->fonts[i]->stretch == family->fonts[j]->stretch)) {
|
|
|
|
if (family->fonts[j]->weight > weight) {
|
|
|
|
weight = family->fonts[j]->weight;
|
|
|
|
heaviest = j;
|
|
|
|
}
|
2016-02-01 23:41:10 +01:00
|
|
|
family->fonts[j]->bold_sim_tested = 1;
|
2015-09-03 06:35:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (weight >= DWRITE_FONT_WEIGHT_SEMI_LIGHT && weight <= 550) {
|
|
|
|
static const struct name_pattern weightsim_patterns[] = {
|
|
|
|
{ extraW, lightW },
|
|
|
|
{ extW, lightW },
|
|
|
|
{ ultraW, lightW },
|
|
|
|
{ semiW, lightW },
|
|
|
|
{ semiW, boldW },
|
|
|
|
{ demiW, boldW },
|
|
|
|
{ boldW },
|
|
|
|
{ thinW },
|
|
|
|
{ lightW },
|
|
|
|
{ mediumW },
|
|
|
|
{ demiW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
WCHAR facenameW[255], initialW[255];
|
|
|
|
struct dwrite_font_data *boldface;
|
|
|
|
struct list tokens;
|
|
|
|
|
|
|
|
/* add Bold simulation based on heaviest face data */
|
|
|
|
|
|
|
|
/* Simulated face name should only contain Bold as weight term,
|
|
|
|
so remove existing regular and weight terms. */
|
2018-02-21 06:15:22 +01:00
|
|
|
fontstrings_get_en_string(family->fonts[heaviest]->names, initialW, ARRAY_SIZE(initialW));
|
2015-09-03 06:35:35 +02:00
|
|
|
facename_remove_regular_term(initialW, -1);
|
|
|
|
|
|
|
|
/* remove current weight pattern */
|
|
|
|
fontname_tokenize(&tokens, initialW);
|
|
|
|
match_pattern_list(&tokens, weightsim_patterns, NULL);
|
|
|
|
fontname_tokens_to_str(&tokens, facenameW);
|
|
|
|
|
|
|
|
/* Bold suffix for new name */
|
|
|
|
if (*facenameW)
|
|
|
|
strcatW(facenameW, spaceW);
|
|
|
|
strcatW(facenameW, boldW);
|
|
|
|
|
2015-09-03 06:36:01 +02:00
|
|
|
if (init_font_data_from_font(family->fonts[heaviest], DWRITE_FONT_SIMULATIONS_BOLD, facenameW, &boldface) == S_OK) {
|
2016-02-01 23:41:10 +01:00
|
|
|
boldface->bold_sim_tested = 1;
|
2016-12-04 17:22:14 +01:00
|
|
|
boldface->lf.lfWeight += (FW_BOLD - FW_REGULAR) / 2 + 1;
|
2015-09-03 06:35:35 +02:00
|
|
|
fontfamily_add_font(family, boldface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-03 06:36:01 +02:00
|
|
|
static void fontfamily_add_oblique_simulated_face(struct dwrite_fontfamily_data *family)
|
|
|
|
{
|
2019-05-14 12:27:23 +02:00
|
|
|
size_t i, j;
|
2015-09-03 06:36:01 +02:00
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
for (i = 0; i < family->count; ++i)
|
|
|
|
{
|
2015-09-03 06:36:01 +02:00
|
|
|
UINT32 regular = ~0u, oblique = ~0u;
|
|
|
|
struct dwrite_font_data *obliqueface;
|
|
|
|
WCHAR facenameW[255];
|
|
|
|
|
|
|
|
if (family->fonts[i]->oblique_sim_tested)
|
|
|
|
continue;
|
|
|
|
|
2016-02-01 23:41:10 +01:00
|
|
|
family->fonts[i]->oblique_sim_tested = 1;
|
2015-09-03 06:36:01 +02:00
|
|
|
if (family->fonts[i]->style == DWRITE_FONT_STYLE_NORMAL)
|
|
|
|
regular = i;
|
|
|
|
else if (family->fonts[i]->style == DWRITE_FONT_STYLE_OBLIQUE)
|
|
|
|
oblique = i;
|
|
|
|
|
|
|
|
/* find regular style with same weight/stretch values */
|
2019-05-14 12:27:23 +02:00
|
|
|
for (j = i; j < family->count; ++j)
|
|
|
|
{
|
2015-09-03 06:36:01 +02:00
|
|
|
if (family->fonts[j]->oblique_sim_tested)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((family->fonts[i]->weight == family->fonts[j]->weight) &&
|
|
|
|
(family->fonts[i]->stretch == family->fonts[j]->stretch)) {
|
|
|
|
|
2016-02-01 23:41:10 +01:00
|
|
|
family->fonts[j]->oblique_sim_tested = 1;
|
2015-09-03 06:36:01 +02:00
|
|
|
if (regular == ~0 && family->fonts[j]->style == DWRITE_FONT_STYLE_NORMAL)
|
|
|
|
regular = j;
|
|
|
|
|
|
|
|
if (oblique == ~0 && family->fonts[j]->style == DWRITE_FONT_STYLE_OBLIQUE)
|
|
|
|
oblique = j;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (regular != ~0u && oblique != ~0u)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no regular variant for this weight/stretch pair, nothing to base simulated face on */
|
|
|
|
if (regular == ~0u)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* regular face exists, and corresponding oblique is present as well, nothing to do */
|
|
|
|
if (oblique != ~0u)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* add oblique simulation based on this regular face */
|
|
|
|
|
|
|
|
/* remove regular term if any, append 'Oblique' */
|
2018-02-21 06:15:22 +01:00
|
|
|
fontstrings_get_en_string(family->fonts[regular]->names, facenameW, ARRAY_SIZE(facenameW));
|
2015-09-03 06:36:01 +02:00
|
|
|
facename_remove_regular_term(facenameW, -1);
|
|
|
|
|
|
|
|
if (*facenameW)
|
|
|
|
strcatW(facenameW, spaceW);
|
|
|
|
strcatW(facenameW, obliqueW);
|
|
|
|
|
|
|
|
if (init_font_data_from_font(family->fonts[regular], DWRITE_FONT_SIMULATIONS_OBLIQUE, facenameW, &obliqueface) == S_OK) {
|
2016-02-01 23:41:10 +01:00
|
|
|
obliqueface->oblique_sim_tested = 1;
|
2016-12-04 17:22:13 +01:00
|
|
|
obliqueface->lf.lfItalic = 1;
|
2015-09-03 06:36:01 +02:00
|
|
|
fontfamily_add_font(family, obliqueface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-11 23:51:58 +01:00
|
|
|
static BOOL fontcollection_add_replacement(struct dwrite_fontcollection *collection, const WCHAR *target_name,
|
|
|
|
const WCHAR *replacement_name)
|
|
|
|
{
|
|
|
|
UINT32 i = collection_find_family(collection, replacement_name);
|
|
|
|
struct dwrite_fontfamily_data *target;
|
|
|
|
IDWriteLocalizedStrings *strings;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* replacement does not exist */
|
|
|
|
if (i == ~0u)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
hr = create_localizedstrings(&strings);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* add a new family with target name, reuse font data from replacement */
|
|
|
|
add_localizedstring(strings, enusW, target_name);
|
|
|
|
hr = init_fontfamily_data(strings, &target);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
struct dwrite_fontfamily_data *replacement = collection->family_data[i];
|
|
|
|
WCHAR nameW[255];
|
|
|
|
|
2019-05-14 12:27:23 +02:00
|
|
|
for (i = 0; i < replacement->count; ++i)
|
|
|
|
{
|
2016-02-11 23:51:58 +01:00
|
|
|
fontfamily_add_font(target, replacement->fonts[i]);
|
2017-05-30 09:10:59 +02:00
|
|
|
addref_font_data(replacement->fonts[i]);
|
|
|
|
}
|
2016-02-11 23:51:58 +01:00
|
|
|
|
|
|
|
fontcollection_add_family(collection, target);
|
2018-02-21 06:15:22 +01:00
|
|
|
fontstrings_get_en_string(replacement->familyname, nameW, ARRAY_SIZE(nameW));
|
2016-02-11 23:51:58 +01:00
|
|
|
TRACE("replacement %s -> %s\n", debugstr_w(target_name), debugstr_w(nameW));
|
|
|
|
}
|
|
|
|
IDWriteLocalizedStrings_Release(strings);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add family mappings from HKCU\Software\Wine\Fonts\Replacements. This only affects
|
|
|
|
system font collections. */
|
|
|
|
static void fontcollection_add_replacements(struct dwrite_fontcollection *collection)
|
|
|
|
{
|
|
|
|
DWORD max_namelen, max_datalen, i = 0, type, datalen, namelen;
|
|
|
|
WCHAR *name;
|
|
|
|
void *data;
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Fonts\\Replacements", &hkey))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (RegQueryInfoKeyW(hkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &max_namelen, &max_datalen, NULL, NULL)) {
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
max_namelen++; /* returned value doesn't include room for '\0' */
|
|
|
|
name = heap_alloc(max_namelen * sizeof(WCHAR));
|
|
|
|
data = heap_alloc(max_datalen);
|
|
|
|
|
|
|
|
datalen = max_datalen;
|
|
|
|
namelen = max_namelen;
|
|
|
|
while (RegEnumValueW(hkey, i++, name, &namelen, NULL, &type, data, &datalen) == ERROR_SUCCESS) {
|
|
|
|
if (collection_find_family(collection, name) == ~0u) {
|
|
|
|
if (type == REG_MULTI_SZ) {
|
|
|
|
WCHAR *replacement = data;
|
|
|
|
while (*replacement) {
|
|
|
|
if (fontcollection_add_replacement(collection, name, replacement))
|
|
|
|
break;
|
|
|
|
replacement += strlenW(replacement) + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (type == REG_SZ)
|
|
|
|
fontcollection_add_replacement(collection, name, data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TRACE("%s is available, won't be replaced.\n", debugstr_w(name));
|
|
|
|
|
|
|
|
datalen = max_datalen;
|
|
|
|
namelen = max_namelen;
|
|
|
|
}
|
|
|
|
|
|
|
|
heap_free(data);
|
|
|
|
heap_free(name);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
HRESULT create_font_collection(IDWriteFactory7 *factory, IDWriteFontFileEnumerator *enumerator, BOOL is_system,
|
2019-10-08 12:04:34 +02:00
|
|
|
IDWriteFontCollection3 **ret)
|
2014-10-24 09:43:21 +02:00
|
|
|
{
|
2015-09-03 22:52:22 +02:00
|
|
|
struct fontfile_enum {
|
|
|
|
struct list entry;
|
|
|
|
IDWriteFontFile *file;
|
|
|
|
};
|
|
|
|
struct fontfile_enum *fileenum, *fileenum2;
|
2014-10-24 09:43:21 +02:00
|
|
|
struct dwrite_fontcollection *collection;
|
2015-09-03 22:52:22 +02:00
|
|
|
struct list scannedfiles;
|
2014-10-24 09:43:21 +02:00
|
|
|
BOOL current = FALSE;
|
2015-02-04 13:34:12 +01:00
|
|
|
HRESULT hr = S_OK;
|
2019-05-14 12:27:24 +02:00
|
|
|
size_t i;
|
2014-10-24 09:43:21 +02:00
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
|
|
|
|
collection = heap_alloc(sizeof(struct dwrite_fontcollection));
|
|
|
|
if (!collection) return E_OUTOFMEMORY;
|
|
|
|
|
2014-11-07 11:17:38 +01:00
|
|
|
hr = init_font_collection(collection, is_system);
|
2014-10-24 09:43:21 +02:00
|
|
|
if (FAILED(hr)) {
|
|
|
|
heap_free(collection);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
*ret = &collection->IDWriteFontCollection3_iface;
|
2014-10-24 09:43:21 +02:00
|
|
|
|
|
|
|
TRACE("building font collection:\n");
|
|
|
|
|
2015-09-03 22:52:22 +02:00
|
|
|
list_init(&scannedfiles);
|
2015-02-04 13:34:12 +01:00
|
|
|
while (hr == S_OK) {
|
2014-10-24 09:43:21 +02:00
|
|
|
DWRITE_FONT_FACE_TYPE face_type;
|
|
|
|
DWRITE_FONT_FILE_TYPE file_type;
|
2015-09-03 22:52:22 +02:00
|
|
|
BOOL supported, same = FALSE;
|
2017-10-18 13:53:06 +02:00
|
|
|
IDWriteFontFileStream *stream;
|
2014-10-24 09:43:21 +02:00
|
|
|
IDWriteFontFile *file;
|
2015-09-03 06:35:35 +02:00
|
|
|
UINT32 face_count;
|
2014-10-24 09:43:21 +02:00
|
|
|
|
|
|
|
current = FALSE;
|
|
|
|
hr = IDWriteFontFileEnumerator_MoveNext(enumerator, ¤t);
|
|
|
|
if (FAILED(hr) || !current)
|
|
|
|
break;
|
|
|
|
|
|
|
|
hr = IDWriteFontFileEnumerator_GetCurrentFontFile(enumerator, &file);
|
|
|
|
if (FAILED(hr))
|
|
|
|
break;
|
|
|
|
|
2015-09-03 22:52:22 +02:00
|
|
|
/* check if we've scanned this file already */
|
|
|
|
LIST_FOR_EACH_ENTRY(fileenum, &scannedfiles, struct fontfile_enum, entry) {
|
|
|
|
if ((same = is_same_fontfile(fileenum->file, file)))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (same) {
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-10-18 13:53:06 +02:00
|
|
|
if (FAILED(get_filestream_from_file(file, &stream))) {
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unsupported formats are skipped. */
|
|
|
|
hr = opentype_analyze_font(stream, &supported, &file_type, &face_type, &face_count);
|
2014-10-24 09:43:21 +02:00
|
|
|
if (FAILED(hr) || !supported || face_count == 0) {
|
2017-10-18 13:53:06 +02:00
|
|
|
TRACE("Unsupported font (%p, 0x%08x, %d, %u)\n", file, hr, supported, face_count);
|
|
|
|
IDWriteFontFileStream_Release(stream);
|
2014-10-24 09:43:21 +02:00
|
|
|
IDWriteFontFile_Release(file);
|
2015-03-30 10:57:28 +02:00
|
|
|
hr = S_OK;
|
2014-10-24 09:43:21 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:52:22 +02:00
|
|
|
/* add to scanned list */
|
|
|
|
fileenum = heap_alloc(sizeof(*fileenum));
|
|
|
|
fileenum->file = file;
|
|
|
|
list_add_tail(&scannedfiles, &fileenum->entry);
|
|
|
|
|
2020-01-24 09:17:35 +01:00
|
|
|
for (i = 0; i < face_count; ++i)
|
|
|
|
{
|
2014-10-24 09:43:21 +02:00
|
|
|
struct dwrite_font_data *font_data;
|
2016-07-05 11:55:53 +02:00
|
|
|
struct fontface_desc desc;
|
2015-08-18 06:40:27 +02:00
|
|
|
WCHAR familyW[255];
|
2014-10-24 09:43:21 +02:00
|
|
|
UINT32 index;
|
|
|
|
|
2019-12-06 15:12:14 +01:00
|
|
|
desc.factory = factory;
|
2016-07-05 11:55:53 +02:00
|
|
|
desc.face_type = face_type;
|
|
|
|
desc.files = &file;
|
2017-10-18 13:53:06 +02:00
|
|
|
desc.stream = stream;
|
2016-07-05 11:55:53 +02:00
|
|
|
desc.files_number = 1;
|
|
|
|
desc.index = i;
|
|
|
|
desc.simulations = DWRITE_FONT_SIMULATIONS_NONE;
|
|
|
|
desc.font_data = NULL;
|
|
|
|
|
2020-01-24 09:17:35 +01:00
|
|
|
/* Allocate an initialize new font data structure. */
|
|
|
|
hr = init_font_data(&desc, &font_data);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2016-02-23 15:47:14 +01:00
|
|
|
/* move to next one */
|
|
|
|
hr = S_OK;
|
2014-10-24 09:43:21 +02:00
|
|
|
continue;
|
2016-02-23 15:47:14 +01:00
|
|
|
}
|
2014-10-24 09:43:21 +02:00
|
|
|
|
2020-01-24 09:17:35 +01:00
|
|
|
fontstrings_get_en_string(font_data->family_names, familyW, ARRAY_SIZE(familyW));
|
2014-10-24 09:43:21 +02:00
|
|
|
|
2016-07-15 10:05:37 +02:00
|
|
|
/* ignore dot named faces */
|
2020-01-24 09:17:35 +01:00
|
|
|
if (familyW[0] == '.')
|
|
|
|
{
|
2016-07-15 10:05:37 +02:00
|
|
|
WARN("Ignoring face %s\n", debugstr_w(familyW));
|
|
|
|
release_font_data(font_data);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-08-18 06:40:27 +02:00
|
|
|
index = collection_find_family(collection, familyW);
|
2015-02-04 13:28:48 +01:00
|
|
|
if (index != ~0u)
|
2015-02-04 13:34:12 +01:00
|
|
|
hr = fontfamily_add_font(collection->family_data[index], font_data);
|
2014-10-24 09:43:21 +02:00
|
|
|
else {
|
|
|
|
struct dwrite_fontfamily_data *family_data;
|
|
|
|
|
|
|
|
/* create and init new family */
|
2020-01-24 09:17:35 +01:00
|
|
|
hr = init_fontfamily_data(font_data->family_names, &family_data);
|
2015-02-04 13:34:12 +01:00
|
|
|
if (hr == S_OK) {
|
|
|
|
/* add font to family, family - to collection */
|
|
|
|
hr = fontfamily_add_font(family_data, font_data);
|
|
|
|
if (hr == S_OK)
|
|
|
|
hr = fontcollection_add_family(collection, family_data);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
release_fontfamily_data(family_data);
|
|
|
|
}
|
2014-10-24 09:43:21 +02:00
|
|
|
}
|
|
|
|
|
2015-02-04 13:34:12 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
break;
|
2014-10-24 09:43:21 +02:00
|
|
|
}
|
2018-10-31 13:34:11 +01:00
|
|
|
|
|
|
|
IDWriteFontFileStream_Release(stream);
|
2015-09-03 22:52:22 +02:00
|
|
|
}
|
2014-10-24 09:43:21 +02:00
|
|
|
|
2015-09-03 22:52:22 +02:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(fileenum, fileenum2, &scannedfiles, struct fontfile_enum, entry) {
|
|
|
|
IDWriteFontFile_Release(fileenum->file);
|
|
|
|
list_remove(&fileenum->entry);
|
|
|
|
heap_free(fileenum);
|
2015-09-03 06:35:35 +02:00
|
|
|
}
|
|
|
|
|
2019-05-14 12:27:24 +02:00
|
|
|
for (i = 0; i < collection->count; ++i)
|
|
|
|
{
|
2015-09-03 06:35:35 +02:00
|
|
|
fontfamily_add_bold_simulated_face(collection->family_data[i]);
|
2015-09-03 06:36:01 +02:00
|
|
|
fontfamily_add_oblique_simulated_face(collection->family_data[i]);
|
2015-09-03 06:35:35 +02:00
|
|
|
}
|
2014-10-24 09:43:21 +02:00
|
|
|
|
2016-02-11 23:51:58 +01:00
|
|
|
if (is_system)
|
|
|
|
fontcollection_add_replacements(collection);
|
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
collection->factory = factory;
|
2019-12-05 09:56:03 +01:00
|
|
|
IDWriteFactory7_AddRef(factory);
|
2017-04-11 13:21:32 +02:00
|
|
|
|
2015-02-04 13:34:12 +01:00
|
|
|
return hr;
|
2014-10-24 09:43:21 +02:00
|
|
|
}
|
|
|
|
|
2014-10-29 20:41:47 +01:00
|
|
|
struct system_fontfile_enumerator
|
|
|
|
{
|
|
|
|
IDWriteFontFileEnumerator IDWriteFontFileEnumerator_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
IDWriteFactory7 *factory;
|
2014-10-29 20:41:47 +01:00
|
|
|
HKEY hkey;
|
|
|
|
int index;
|
2017-04-11 13:21:32 +02:00
|
|
|
|
2017-10-16 11:11:17 +02:00
|
|
|
WCHAR *filename;
|
|
|
|
DWORD filename_size;
|
2014-10-29 20:41:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct system_fontfile_enumerator *impl_from_IDWriteFontFileEnumerator(IDWriteFontFileEnumerator* iface)
|
2012-10-21 06:24:35 +02:00
|
|
|
{
|
2014-10-29 20:41:47 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct system_fontfile_enumerator, IDWriteFontFileEnumerator_iface);
|
2012-10-21 06:24:35 +02:00
|
|
|
}
|
|
|
|
|
2014-10-29 20:41:47 +01:00
|
|
|
static HRESULT WINAPI systemfontfileenumerator_QueryInterface(IDWriteFontFileEnumerator *iface, REFIID riid, void **obj)
|
2012-10-22 05:20:42 +02:00
|
|
|
{
|
2014-10-29 20:41:47 +01:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteFontFileEnumerator) || IsEqualIID(riid, &IID_IUnknown)) {
|
|
|
|
IDWriteFontFileEnumerator_AddRef(iface);
|
|
|
|
*obj = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2012-10-21 03:43:01 +02:00
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
2014-10-29 20:41:47 +01:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2012-10-21 06:24:35 +02:00
|
|
|
|
2014-10-29 20:41:47 +01:00
|
|
|
static ULONG WINAPI systemfontfileenumerator_AddRef(IDWriteFontFileEnumerator *iface)
|
|
|
|
{
|
|
|
|
struct system_fontfile_enumerator *enumerator = impl_from_IDWriteFontFileEnumerator(iface);
|
|
|
|
return InterlockedIncrement(&enumerator->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI systemfontfileenumerator_Release(IDWriteFontFileEnumerator *iface)
|
|
|
|
{
|
|
|
|
struct system_fontfile_enumerator *enumerator = impl_from_IDWriteFontFileEnumerator(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&enumerator->ref);
|
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
if (!ref)
|
|
|
|
{
|
|
|
|
IDWriteFactory7_Release(enumerator->factory);
|
2014-10-29 20:41:47 +01:00
|
|
|
RegCloseKey(enumerator->hkey);
|
2017-10-16 11:11:17 +02:00
|
|
|
heap_free(enumerator->filename);
|
2014-10-29 20:41:47 +01:00
|
|
|
heap_free(enumerator);
|
2014-10-08 16:52:07 +02:00
|
|
|
}
|
2014-10-29 20:41:47 +01:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
static HRESULT create_local_file_reference(IDWriteFactory7 *factory, const WCHAR *filename, IDWriteFontFile **file)
|
2015-12-28 05:35:12 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* Fonts installed in 'Fonts' system dir don't get full path in registry font files cache */
|
|
|
|
if (!strchrW(filename, '\\')) {
|
|
|
|
static const WCHAR fontsW[] = {'\\','f','o','n','t','s','\\',0};
|
|
|
|
WCHAR fullpathW[MAX_PATH];
|
|
|
|
|
2018-02-21 06:15:22 +01:00
|
|
|
GetWindowsDirectoryW(fullpathW, ARRAY_SIZE(fullpathW));
|
2015-12-28 05:35:12 +01:00
|
|
|
strcatW(fullpathW, fontsW);
|
|
|
|
strcatW(fullpathW, filename);
|
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
hr = IDWriteFactory7_CreateFontFileReference(factory, fullpathW, NULL, file);
|
2015-12-28 05:35:12 +01:00
|
|
|
}
|
|
|
|
else
|
2019-12-05 09:56:03 +01:00
|
|
|
hr = IDWriteFactory7_CreateFontFileReference(factory, filename, NULL, file);
|
2015-12-28 05:35:12 +01:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2014-10-29 20:41:47 +01:00
|
|
|
static HRESULT WINAPI systemfontfileenumerator_GetCurrentFontFile(IDWriteFontFileEnumerator *iface, IDWriteFontFile **file)
|
|
|
|
{
|
|
|
|
struct system_fontfile_enumerator *enumerator = impl_from_IDWriteFontFileEnumerator(iface);
|
|
|
|
|
|
|
|
*file = NULL;
|
|
|
|
|
2017-10-16 11:11:17 +02:00
|
|
|
if (enumerator->index < 0 || !enumerator->filename || !*enumerator->filename)
|
2014-10-29 20:41:47 +01:00
|
|
|
return E_FAIL;
|
|
|
|
|
2017-10-16 11:11:17 +02:00
|
|
|
return create_local_file_reference(enumerator->factory, enumerator->filename, file);
|
2014-10-29 20:41:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI systemfontfileenumerator_MoveNext(IDWriteFontFileEnumerator *iface, BOOL *current)
|
|
|
|
{
|
|
|
|
struct system_fontfile_enumerator *enumerator = impl_from_IDWriteFontFileEnumerator(iface);
|
2017-10-16 11:11:17 +02:00
|
|
|
WCHAR name_buf[256], *name = name_buf;
|
2018-02-21 06:15:22 +01:00
|
|
|
DWORD name_count, max_name_count = ARRAY_SIZE(name_buf), type, data_size;
|
2017-10-16 11:11:17 +02:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
LONG r;
|
2014-10-29 20:41:47 +01:00
|
|
|
|
|
|
|
*current = FALSE;
|
|
|
|
enumerator->index++;
|
|
|
|
|
|
|
|
/* iterate until we find next string value */
|
2017-04-11 13:21:32 +02:00
|
|
|
for (;;) {
|
2017-10-16 11:11:17 +02:00
|
|
|
do {
|
|
|
|
name_count = max_name_count;
|
|
|
|
data_size = enumerator->filename_size - sizeof(*enumerator->filename);
|
|
|
|
|
|
|
|
r = RegEnumValueW(enumerator->hkey, enumerator->index, name, &name_count,
|
|
|
|
NULL, &type, (BYTE *)enumerator->filename, &data_size);
|
|
|
|
if (r == ERROR_MORE_DATA) {
|
|
|
|
if (name_count >= max_name_count) {
|
|
|
|
if (name != name_buf) heap_free(name);
|
|
|
|
max_name_count *= 2;
|
|
|
|
name = heap_alloc(max_name_count * sizeof(*name));
|
|
|
|
if (!name) return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
if (data_size > enumerator->filename_size - sizeof(*enumerator->filename)) {
|
|
|
|
heap_free(enumerator->filename);
|
|
|
|
enumerator->filename_size = max(data_size + sizeof(*enumerator->filename), enumerator->filename_size * 2);
|
|
|
|
enumerator->filename = heap_alloc(enumerator->filename_size);
|
|
|
|
if (!enumerator->filename) {
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (r == ERROR_MORE_DATA);
|
2016-12-01 23:31:56 +01:00
|
|
|
|
2017-10-16 11:11:17 +02:00
|
|
|
if (r != ERROR_SUCCESS) {
|
|
|
|
enumerator->filename[0] = 0;
|
2014-10-29 20:41:47 +01:00
|
|
|
break;
|
2017-10-16 11:11:17 +02:00
|
|
|
}
|
|
|
|
enumerator->filename[data_size / sizeof(*enumerator->filename)] = 0;
|
|
|
|
if (type == REG_SZ && *name != '@') {
|
2014-10-29 20:41:47 +01:00
|
|
|
*current = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
enumerator->index++;
|
2014-10-08 16:52:07 +02:00
|
|
|
}
|
2014-10-29 20:41:47 +01:00
|
|
|
TRACE("index = %d, current = %d\n", enumerator->index, *current);
|
2017-10-16 11:11:17 +02:00
|
|
|
|
|
|
|
err:
|
|
|
|
if (name != name_buf) heap_free(name);
|
|
|
|
return hr;
|
2014-10-29 20:41:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IDWriteFontFileEnumeratorVtbl systemfontfileenumeratorvtbl =
|
|
|
|
{
|
|
|
|
systemfontfileenumerator_QueryInterface,
|
|
|
|
systemfontfileenumerator_AddRef,
|
|
|
|
systemfontfileenumerator_Release,
|
|
|
|
systemfontfileenumerator_MoveNext,
|
|
|
|
systemfontfileenumerator_GetCurrentFontFile
|
|
|
|
};
|
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
static HRESULT create_system_fontfile_enumerator(IDWriteFactory7 *factory, IDWriteFontFileEnumerator **ret)
|
2014-10-29 20:41:47 +01:00
|
|
|
{
|
|
|
|
struct system_fontfile_enumerator *enumerator;
|
|
|
|
static const WCHAR fontslistW[] = {
|
|
|
|
'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'F','o','n','t','s',0
|
|
|
|
};
|
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
|
|
|
|
enumerator = heap_alloc(sizeof(*enumerator));
|
|
|
|
if (!enumerator)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
enumerator->IDWriteFontFileEnumerator_iface.lpVtbl = &systemfontfileenumeratorvtbl;
|
|
|
|
enumerator->ref = 1;
|
|
|
|
enumerator->factory = factory;
|
|
|
|
enumerator->index = -1;
|
2017-10-16 11:11:17 +02:00
|
|
|
enumerator->filename_size = MAX_PATH * sizeof(*enumerator->filename);
|
|
|
|
enumerator->filename = heap_alloc(enumerator->filename_size);
|
|
|
|
if (!enumerator->filename) {
|
|
|
|
heap_free(enumerator);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
IDWriteFactory7_AddRef(factory);
|
2012-10-22 05:20:42 +02:00
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, fontslistW, 0, GENERIC_READ, &enumerator->hkey))
|
|
|
|
{
|
2014-10-29 20:41:47 +01:00
|
|
|
ERR("failed to open fonts list key\n");
|
2019-12-05 09:56:03 +01:00
|
|
|
IDWriteFactory7_Release(factory);
|
2017-10-16 11:11:17 +02:00
|
|
|
heap_free(enumerator->filename);
|
2014-10-29 20:41:47 +01:00
|
|
|
heap_free(enumerator);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2012-10-21 06:24:35 +02:00
|
|
|
|
2014-10-29 20:41:47 +01:00
|
|
|
*ret = &enumerator->IDWriteFontFileEnumerator_iface;
|
2012-10-21 03:43:01 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
HRESULT get_system_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection1 **collection)
|
2014-10-29 20:41:47 +01:00
|
|
|
{
|
|
|
|
IDWriteFontFileEnumerator *enumerator;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
*collection = NULL;
|
|
|
|
|
|
|
|
hr = create_system_fontfile_enumerator(factory, &enumerator);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
TRACE("building system font collection for factory %p\n", factory);
|
2019-10-08 12:04:34 +02:00
|
|
|
hr = create_font_collection(factory, enumerator, TRUE, (IDWriteFontCollection3 **)collection);
|
2014-10-29 20:41:47 +01:00
|
|
|
IDWriteFontFileEnumerator_Release(enumerator);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
static HRESULT eudc_collection_add_family(IDWriteFactory7 *factory, struct dwrite_fontcollection *collection,
|
2015-12-28 05:35:12 +01:00
|
|
|
const WCHAR *keynameW, const WCHAR *pathW)
|
2014-12-17 07:54:13 +01:00
|
|
|
{
|
2015-12-28 05:35:12 +01:00
|
|
|
static const WCHAR defaultfontW[] = {'S','y','s','t','e','m','D','e','f','a','u','l','t','E','U','D','C','F','o','n','t',0};
|
|
|
|
static const WCHAR emptyW[] = {0};
|
2017-10-18 13:53:06 +02:00
|
|
|
struct dwrite_fontfamily_data *family_data;
|
2015-12-28 05:35:12 +01:00
|
|
|
IDWriteLocalizedStrings *names;
|
|
|
|
DWRITE_FONT_FACE_TYPE face_type;
|
|
|
|
DWRITE_FONT_FILE_TYPE file_type;
|
2017-10-18 13:53:06 +02:00
|
|
|
IDWriteFontFileStream *stream;
|
2015-12-28 05:35:12 +01:00
|
|
|
IDWriteFontFile *file;
|
2017-10-18 13:53:06 +02:00
|
|
|
UINT32 face_count, i;
|
|
|
|
BOOL supported;
|
2015-12-28 05:35:12 +01:00
|
|
|
HRESULT hr;
|
2014-12-17 07:54:13 +01:00
|
|
|
|
2015-12-28 05:35:12 +01:00
|
|
|
/* create font file from this path */
|
|
|
|
hr = create_local_file_reference(factory, pathW, &file);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return S_FALSE;
|
|
|
|
|
2017-10-18 13:53:06 +02:00
|
|
|
if (FAILED(get_filestream_from_file(file, &stream))) {
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unsupported formats are skipped. */
|
|
|
|
hr = opentype_analyze_font(stream, &supported, &file_type, &face_type, &face_count);
|
2015-12-28 05:35:12 +01:00
|
|
|
if (FAILED(hr) || !supported || face_count == 0) {
|
2017-10-18 13:53:06 +02:00
|
|
|
TRACE("Unsupported font (%p, 0x%08x, %d, %u)\n", file, hr, supported, face_count);
|
|
|
|
IDWriteFontFileStream_Release(stream);
|
2015-12-28 05:35:12 +01:00
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
return S_FALSE;
|
2014-12-17 07:54:13 +01:00
|
|
|
}
|
|
|
|
|
2015-12-28 05:35:12 +01:00
|
|
|
/* create and init new family */
|
2014-12-17 07:54:13 +01:00
|
|
|
|
2015-12-28 05:35:12 +01:00
|
|
|
/* Family names are added for non-specific locale, represented with empty string.
|
|
|
|
Default family appears with empty family name. */
|
|
|
|
create_localizedstrings(&names);
|
|
|
|
if (!strcmpiW(keynameW, defaultfontW))
|
|
|
|
add_localizedstring(names, emptyW, emptyW);
|
|
|
|
else
|
|
|
|
add_localizedstring(names, emptyW, keynameW);
|
2014-12-17 07:54:13 +01:00
|
|
|
|
2015-12-28 05:35:12 +01:00
|
|
|
hr = init_fontfamily_data(names, &family_data);
|
|
|
|
IDWriteLocalizedStrings_Release(names);
|
|
|
|
if (hr != S_OK) {
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
return hr;
|
|
|
|
}
|
2014-12-17 07:54:13 +01:00
|
|
|
|
2015-12-28 05:35:12 +01:00
|
|
|
/* fill with faces */
|
|
|
|
for (i = 0; i < face_count; i++) {
|
|
|
|
struct dwrite_font_data *font_data;
|
2016-07-05 11:55:53 +02:00
|
|
|
struct fontface_desc desc;
|
2014-12-17 07:54:13 +01:00
|
|
|
|
2015-12-28 05:35:12 +01:00
|
|
|
/* alloc and init new font data structure */
|
2019-12-06 15:12:14 +01:00
|
|
|
desc.factory = factory;
|
2016-07-05 11:55:53 +02:00
|
|
|
desc.face_type = face_type;
|
|
|
|
desc.index = i;
|
|
|
|
desc.files = &file;
|
2017-10-18 13:53:06 +02:00
|
|
|
desc.stream = stream;
|
2016-07-05 11:55:53 +02:00
|
|
|
desc.files_number = 1;
|
|
|
|
desc.simulations = DWRITE_FONT_SIMULATIONS_NONE;
|
|
|
|
desc.font_data = NULL;
|
|
|
|
|
2020-01-24 09:17:35 +01:00
|
|
|
hr = init_font_data(&desc, &font_data);
|
2015-12-28 05:35:12 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* add font to family */
|
|
|
|
hr = fontfamily_add_font(family_data, font_data);
|
|
|
|
if (hr != S_OK)
|
|
|
|
release_font_data(font_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add family to collection */
|
|
|
|
hr = fontcollection_add_family(collection, family_data);
|
|
|
|
if (FAILED(hr))
|
|
|
|
release_fontfamily_data(family_data);
|
2017-10-18 13:53:06 +02:00
|
|
|
IDWriteFontFileStream_Release(stream);
|
2015-12-28 05:35:12 +01:00
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
|
|
|
|
return hr;
|
2014-12-17 07:54:13 +01:00
|
|
|
}
|
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
HRESULT get_eudc_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 **ret)
|
2014-12-17 07:54:13 +01:00
|
|
|
{
|
2015-12-28 05:35:12 +01:00
|
|
|
static const WCHAR eudckeyfmtW[] = {'E','U','D','C','\\','%','u',0};
|
|
|
|
struct dwrite_fontcollection *collection;
|
|
|
|
static const WCHAR emptyW[] = {0};
|
|
|
|
WCHAR eudckeypathW[16];
|
|
|
|
HKEY eudckey;
|
|
|
|
DWORD index;
|
|
|
|
BOOL exists;
|
|
|
|
LONG retval;
|
|
|
|
HRESULT hr;
|
2019-05-14 12:27:24 +02:00
|
|
|
size_t i;
|
2014-12-17 07:54:13 +01:00
|
|
|
|
2015-12-28 05:35:12 +01:00
|
|
|
TRACE("building EUDC font collection for factory %p, ACP %u\n", factory, GetACP());
|
2014-12-17 07:54:13 +01:00
|
|
|
|
2015-12-28 05:35:12 +01:00
|
|
|
*ret = NULL;
|
|
|
|
|
|
|
|
collection = heap_alloc(sizeof(struct dwrite_fontcollection));
|
|
|
|
if (!collection) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hr = init_font_collection(collection, FALSE);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
heap_free(collection);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:34 +02:00
|
|
|
*ret = &collection->IDWriteFontCollection3_iface;
|
2017-04-27 17:20:03 +02:00
|
|
|
collection->factory = factory;
|
2019-12-05 09:56:03 +01:00
|
|
|
IDWriteFactory7_AddRef(factory);
|
2015-12-28 05:35:12 +01:00
|
|
|
|
|
|
|
/* return empty collection if EUDC fonts are not configured */
|
|
|
|
sprintfW(eudckeypathW, eudckeyfmtW, GetACP());
|
|
|
|
if (RegOpenKeyExW(HKEY_CURRENT_USER, eudckeypathW, 0, GENERIC_READ, &eudckey))
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
retval = ERROR_SUCCESS;
|
|
|
|
index = 0;
|
|
|
|
while (retval != ERROR_NO_MORE_ITEMS) {
|
|
|
|
WCHAR keynameW[64], pathW[MAX_PATH];
|
|
|
|
DWORD type, path_len, name_len;
|
|
|
|
|
2018-02-21 06:15:22 +01:00
|
|
|
path_len = ARRAY_SIZE(pathW);
|
|
|
|
name_len = ARRAY_SIZE(keynameW);
|
2015-12-28 05:35:12 +01:00
|
|
|
retval = RegEnumValueW(eudckey, index++, keynameW, &name_len, NULL, &type, (BYTE*)pathW, &path_len);
|
|
|
|
if (retval || type != REG_SZ)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
hr = eudc_collection_add_family(factory, collection, keynameW, pathW);
|
|
|
|
if (hr != S_OK)
|
|
|
|
WARN("failed to add family %s, path %s\n", debugstr_w(keynameW), debugstr_w(pathW));
|
|
|
|
}
|
|
|
|
RegCloseKey(eudckey);
|
|
|
|
|
|
|
|
/* try to add global default if not defined for specific codepage */
|
|
|
|
exists = FALSE;
|
2019-10-08 12:04:34 +02:00
|
|
|
hr = IDWriteFontCollection3_FindFamilyName(&collection->IDWriteFontCollection3_iface, emptyW,
|
2015-12-28 05:35:12 +01:00
|
|
|
&index, &exists);
|
|
|
|
if (FAILED(hr) || !exists) {
|
2018-11-30 08:14:03 +01:00
|
|
|
static const WCHAR globaldefaultW[] = {'E','U','D','C','.','T','T','E',0};
|
2015-12-28 05:35:12 +01:00
|
|
|
hr = eudc_collection_add_family(factory, collection, emptyW, globaldefaultW);
|
|
|
|
if (hr != S_OK)
|
|
|
|
WARN("failed to add global default EUDC font, 0x%08x\n", hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EUDC collection offers simulated faces too */
|
2019-05-14 12:27:24 +02:00
|
|
|
for (i = 0; i < collection->count; ++i)
|
|
|
|
{
|
2015-12-28 05:35:12 +01:00
|
|
|
fontfamily_add_bold_simulated_face(collection->family_data[i]);
|
|
|
|
fontfamily_add_oblique_simulated_face(collection->family_data[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2014-12-17 07:54:13 +01:00
|
|
|
}
|
|
|
|
|
2014-08-12 21:11:34 +02:00
|
|
|
static HRESULT WINAPI dwritefontfile_QueryInterface(IDWriteFontFile *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct dwrite_fontfile *This = impl_from_IDWriteFontFile(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteFontFile))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
IDWriteFontFile_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2014-08-12 21:11:34 +02:00
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritefontfile_AddRef(IDWriteFontFile *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_fontfile *This = impl_from_IDWriteFontFile(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritefontfile_Release(IDWriteFontFile *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_fontfile *This = impl_from_IDWriteFontFile(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
|
|
|
|
if (!ref)
|
|
|
|
{
|
|
|
|
IDWriteFontFileLoader_Release(This->loader);
|
2014-08-17 03:40:48 +02:00
|
|
|
if (This->stream) IDWriteFontFileStream_Release(This->stream);
|
2014-08-12 21:11:34 +02:00
|
|
|
heap_free(This->reference_key);
|
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontfile_GetReferenceKey(IDWriteFontFile *iface, const void **fontFileReferenceKey, UINT32 *fontFileReferenceKeySize)
|
|
|
|
{
|
|
|
|
struct dwrite_fontfile *This = impl_from_IDWriteFontFile(iface);
|
|
|
|
TRACE("(%p)->(%p, %p)\n", This, fontFileReferenceKey, fontFileReferenceKeySize);
|
|
|
|
*fontFileReferenceKey = This->reference_key;
|
|
|
|
*fontFileReferenceKeySize = This->key_size;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontfile_GetLoader(IDWriteFontFile *iface, IDWriteFontFileLoader **fontFileLoader)
|
|
|
|
{
|
|
|
|
struct dwrite_fontfile *This = impl_from_IDWriteFontFile(iface);
|
|
|
|
TRACE("(%p)->(%p)\n", This, fontFileLoader);
|
|
|
|
*fontFileLoader = This->loader;
|
|
|
|
IDWriteFontFileLoader_AddRef(This->loader);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-10-18 13:53:06 +02:00
|
|
|
static HRESULT WINAPI dwritefontfile_Analyze(IDWriteFontFile *iface, BOOL *is_supported, DWRITE_FONT_FILE_TYPE *file_type,
|
|
|
|
DWRITE_FONT_FACE_TYPE *face_type, UINT32 *face_count)
|
2014-08-12 21:11:34 +02:00
|
|
|
{
|
2014-10-08 12:14:51 +02:00
|
|
|
struct dwrite_fontfile *This = impl_from_IDWriteFontFile(iface);
|
2014-08-12 21:11:37 +02:00
|
|
|
IDWriteFontFileStream *stream;
|
2014-10-08 12:14:51 +02:00
|
|
|
HRESULT hr;
|
2014-08-12 21:11:37 +02:00
|
|
|
|
2017-10-18 13:53:06 +02:00
|
|
|
TRACE("(%p)->(%p, %p, %p, %p)\n", This, is_supported, file_type, face_type, face_count);
|
2014-08-12 21:11:37 +02:00
|
|
|
|
2017-10-18 13:53:06 +02:00
|
|
|
*is_supported = FALSE;
|
|
|
|
*file_type = DWRITE_FONT_FILE_TYPE_UNKNOWN;
|
|
|
|
if (face_type)
|
|
|
|
*face_type = DWRITE_FONT_FACE_TYPE_UNKNOWN;
|
|
|
|
*face_count = 0;
|
2014-08-12 21:11:37 +02:00
|
|
|
|
|
|
|
hr = IDWriteFontFileLoader_CreateStreamFromKey(This->loader, This->reference_key, This->key_size, &stream);
|
|
|
|
if (FAILED(hr))
|
2015-03-30 10:57:28 +02:00
|
|
|
return hr;
|
2014-10-08 12:14:51 +02:00
|
|
|
|
2017-10-18 13:53:06 +02:00
|
|
|
hr = opentype_analyze_font(stream, is_supported, file_type, face_type, face_count);
|
2014-10-08 12:14:51 +02:00
|
|
|
|
2014-08-12 21:11:37 +02:00
|
|
|
/* TODO: Further Analysis */
|
|
|
|
IDWriteFontFileStream_Release(stream);
|
|
|
|
return S_OK;
|
2014-08-12 21:11:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteFontFileVtbl dwritefontfilevtbl = {
|
|
|
|
dwritefontfile_QueryInterface,
|
|
|
|
dwritefontfile_AddRef,
|
|
|
|
dwritefontfile_Release,
|
|
|
|
dwritefontfile_GetReferenceKey,
|
|
|
|
dwritefontfile_GetLoader,
|
|
|
|
dwritefontfile_Analyze,
|
|
|
|
};
|
|
|
|
|
2017-04-20 11:50:07 +02:00
|
|
|
HRESULT create_font_file(IDWriteFontFileLoader *loader, const void *reference_key, UINT32 key_size,
|
|
|
|
IDWriteFontFile **ret)
|
2014-08-12 21:11:34 +02:00
|
|
|
{
|
2017-04-20 11:50:07 +02:00
|
|
|
struct dwrite_fontfile *file;
|
|
|
|
void *key;
|
2014-08-12 21:11:34 +02:00
|
|
|
|
2017-04-20 11:50:07 +02:00
|
|
|
*ret = NULL;
|
2014-08-12 21:11:34 +02:00
|
|
|
|
2017-04-20 11:50:07 +02:00
|
|
|
file = heap_alloc(sizeof(*file));
|
|
|
|
key = heap_alloc(key_size);
|
|
|
|
if (!file || !key) {
|
|
|
|
heap_free(file);
|
|
|
|
heap_free(key);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
file->IDWriteFontFile_iface.lpVtbl = &dwritefontfilevtbl;
|
|
|
|
file->ref = 1;
|
2014-08-12 21:11:34 +02:00
|
|
|
IDWriteFontFileLoader_AddRef(loader);
|
2017-04-20 11:50:07 +02:00
|
|
|
file->loader = loader;
|
|
|
|
file->stream = NULL;
|
|
|
|
file->reference_key = key;
|
|
|
|
memcpy(file->reference_key, reference_key, key_size);
|
|
|
|
file->key_size = key_size;
|
2014-08-12 21:11:34 +02:00
|
|
|
|
2017-04-20 11:50:07 +02:00
|
|
|
*ret = &file->IDWriteFontFile_iface;
|
2014-08-12 21:11:34 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2014-08-17 03:40:48 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
HRESULT create_fontface(const struct fontface_desc *desc, struct list *cached_list, IDWriteFontFace5 **ret)
|
2014-08-17 03:40:48 +02:00
|
|
|
{
|
2016-05-03 20:26:48 +02:00
|
|
|
struct file_stream_desc stream_desc;
|
2020-01-24 09:17:34 +01:00
|
|
|
struct dwrite_font_data *font_data;
|
2014-10-24 09:40:06 +02:00
|
|
|
struct dwrite_fontface *fontface;
|
2020-01-23 10:24:12 +01:00
|
|
|
HRESULT hr;
|
2014-10-24 09:40:06 +02:00
|
|
|
int i;
|
2014-08-17 03:40:48 +02:00
|
|
|
|
2014-11-21 09:48:23 +01:00
|
|
|
*ret = NULL;
|
|
|
|
|
2017-04-27 16:27:33 +02:00
|
|
|
fontface = heap_alloc_zero(sizeof(struct dwrite_fontface));
|
2014-10-24 09:40:06 +02:00
|
|
|
if (!fontface)
|
|
|
|
return E_OUTOFMEMORY;
|
2014-10-12 16:18:10 +02:00
|
|
|
|
2016-07-05 11:55:53 +02:00
|
|
|
fontface->files = heap_alloc_zero(sizeof(*fontface->files) * desc->files_number);
|
2017-10-18 13:53:06 +02:00
|
|
|
if (!fontface->files) {
|
2014-10-24 09:40:06 +02:00
|
|
|
heap_free(fontface);
|
2014-09-02 17:19:31 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2014-08-17 03:40:48 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
fontface->IDWriteFontFace5_iface.lpVtbl = &dwritefontfacevtbl;
|
2020-02-03 17:08:31 +01:00
|
|
|
fontface->IDWriteFontFaceReference_iface.lpVtbl = &dwritefontface_reference_vtbl;
|
2019-12-02 13:53:53 +01:00
|
|
|
fontface->refcount = 1;
|
2016-07-05 11:55:53 +02:00
|
|
|
fontface->type = desc->face_type;
|
|
|
|
fontface->file_count = desc->files_number;
|
2015-07-08 11:36:48 +02:00
|
|
|
fontface->vdmx.exists = TRUE;
|
2015-07-27 10:10:32 +02:00
|
|
|
fontface->gasp.exists = TRUE;
|
2015-08-06 18:43:23 +02:00
|
|
|
fontface->cpal.exists = TRUE;
|
2016-02-08 10:31:26 +01:00
|
|
|
fontface->colr.exists = TRUE;
|
2016-07-05 11:55:53 +02:00
|
|
|
fontface->index = desc->index;
|
|
|
|
fontface->simulations = desc->simulations;
|
2019-12-05 09:55:59 +01:00
|
|
|
fontface->factory = desc->factory;
|
|
|
|
IDWriteFactory7_AddRef(fontface->factory);
|
2014-10-24 09:40:06 +02:00
|
|
|
|
|
|
|
for (i = 0; i < fontface->file_count; i++) {
|
2016-07-05 11:55:53 +02:00
|
|
|
fontface->files[i] = desc->files[i];
|
|
|
|
IDWriteFontFile_AddRef(fontface->files[i]);
|
2014-08-17 03:40:48 +02:00
|
|
|
}
|
2017-10-18 13:53:06 +02:00
|
|
|
fontface->stream = desc->stream;
|
|
|
|
IDWriteFontFileStream_AddRef(fontface->stream);
|
2014-08-17 03:40:48 +02:00
|
|
|
|
2017-10-18 13:53:06 +02:00
|
|
|
stream_desc.stream = fontface->stream;
|
2016-07-05 11:55:53 +02:00
|
|
|
stream_desc.face_type = desc->face_type;
|
|
|
|
stream_desc.face_index = desc->index;
|
2016-05-03 20:26:48 +02:00
|
|
|
opentype_get_font_metrics(&stream_desc, &fontface->metrics, &fontface->caret);
|
2019-05-13 13:21:47 +02:00
|
|
|
opentype_get_font_typo_metrics(&stream_desc, &fontface->typo_metrics.ascent, &fontface->typo_metrics.descent);
|
2016-07-05 11:55:53 +02:00
|
|
|
if (desc->simulations & DWRITE_FONT_SIMULATIONS_OBLIQUE) {
|
2015-02-03 11:27:24 +01:00
|
|
|
/* TODO: test what happens if caret is already slanted */
|
|
|
|
if (fontface->caret.slopeRise == 1) {
|
|
|
|
fontface->caret.slopeRise = fontface->metrics.designUnitsPerEm;
|
|
|
|
fontface->caret.slopeRun = fontface->caret.slopeRise / 3;
|
|
|
|
}
|
|
|
|
}
|
2016-07-05 11:55:54 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
if (freetype_has_kerning_pairs(&fontface->IDWriteFontFace5_iface))
|
2017-03-15 20:35:34 +01:00
|
|
|
fontface->flags |= FONTFACE_HAS_KERNING_PAIRS;
|
2019-12-02 13:53:53 +01:00
|
|
|
if (opentype_has_vertical_variants(&fontface->IDWriteFontFace5_iface))
|
2016-07-05 11:55:54 +02:00
|
|
|
fontface->flags |= FONTFACE_HAS_VERTICAL_VARIANTS;
|
2019-12-02 13:53:53 +01:00
|
|
|
fontface->glyph_image_formats = opentype_get_glyph_image_formats(&fontface->IDWriteFontFace5_iface);
|
2014-08-17 03:40:48 +02:00
|
|
|
|
2016-07-05 11:55:53 +02:00
|
|
|
/* Font properties are reused from font object when 'normal' face creation path is used:
|
|
|
|
collection -> family -> matching font -> fontface.
|
|
|
|
|
|
|
|
If face is created directly from factory we have to go through properties resolution.
|
|
|
|
*/
|
2020-01-23 10:24:12 +01:00
|
|
|
if (desc->font_data)
|
|
|
|
{
|
2020-01-24 09:17:34 +01:00
|
|
|
font_data = desc->font_data;
|
|
|
|
addref_font_data(font_data);
|
2016-07-05 11:55:53 +02:00
|
|
|
}
|
2020-01-23 10:24:12 +01:00
|
|
|
else
|
|
|
|
{
|
2020-01-24 09:17:35 +01:00
|
|
|
hr = init_font_data(desc, &font_data);
|
2019-12-02 13:53:53 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IDWriteFontFace5_Release(&fontface->IDWriteFontFace5_iface);
|
2016-07-05 11:55:53 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-24 09:17:34 +01:00
|
|
|
fontface->weight = font_data->weight;
|
|
|
|
fontface->style = font_data->style;
|
|
|
|
fontface->stretch = font_data->stretch;
|
|
|
|
fontface->panose = font_data->panose;
|
|
|
|
fontface->fontsig = font_data->fontsig;
|
|
|
|
fontface->lf = font_data->lf;
|
|
|
|
fontface->flags |= font_data->flags & (FONT_IS_SYMBOL | FONT_IS_MONOSPACED | FONT_IS_COLORED);
|
|
|
|
fontface->names = font_data->names;
|
|
|
|
if (fontface->names)
|
|
|
|
IDWriteLocalizedStrings_AddRef(fontface->names);
|
2020-01-24 09:17:35 +01:00
|
|
|
fontface->family_names = font_data->family_names;
|
|
|
|
if (fontface->family_names)
|
|
|
|
IDWriteLocalizedStrings_AddRef(fontface->family_names);
|
2020-01-24 09:17:37 +01:00
|
|
|
memcpy(fontface->info_strings, font_data->info_strings, sizeof(fontface->info_strings));
|
|
|
|
for (i = 0; i < ARRAY_SIZE(fontface->info_strings); ++i)
|
|
|
|
{
|
|
|
|
if (fontface->info_strings[i])
|
|
|
|
IDWriteLocalizedStrings_AddRef(fontface->info_strings[i]);
|
|
|
|
}
|
2020-06-09 11:14:37 +02:00
|
|
|
fontface->cmap.stream = fontface->stream;
|
|
|
|
IDWriteFontFileStream_AddRef(fontface->cmap.stream);
|
2020-01-24 09:17:34 +01:00
|
|
|
release_font_data(font_data);
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
fontface->cached = factory_cache_fontface(fontface->factory, cached_list, &fontface->IDWriteFontFace5_iface);
|
|
|
|
|
|
|
|
*ret = &fontface->IDWriteFontFace5_iface;
|
2017-04-11 13:21:32 +02:00
|
|
|
|
2014-08-17 03:40:48 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2014-08-26 17:11:59 +02:00
|
|
|
|
|
|
|
/* IDWriteLocalFontFileLoader and its required IDWriteFontFileStream */
|
2014-11-18 10:43:10 +01:00
|
|
|
struct local_refkey
|
|
|
|
{
|
|
|
|
FILETIME writetime;
|
|
|
|
WCHAR name[1];
|
|
|
|
};
|
|
|
|
|
2014-11-17 10:30:25 +01:00
|
|
|
struct local_cached_stream
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
IDWriteFontFileStream *stream;
|
2014-11-18 10:43:10 +01:00
|
|
|
struct local_refkey *key;
|
2014-11-17 10:30:25 +01:00
|
|
|
UINT32 key_size;
|
|
|
|
};
|
2014-08-26 17:11:59 +02:00
|
|
|
|
|
|
|
struct dwrite_localfontfilestream
|
|
|
|
{
|
|
|
|
IDWriteFontFileStream IDWriteFontFileStream_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
2014-11-17 10:30:25 +01:00
|
|
|
struct local_cached_stream *entry;
|
2014-11-26 06:59:04 +01:00
|
|
|
const void *file_ptr;
|
|
|
|
UINT64 size;
|
2014-08-26 17:11:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct dwrite_localfontfileloader {
|
|
|
|
IDWriteLocalFontFileLoader IDWriteLocalFontFileLoader_iface;
|
|
|
|
LONG ref;
|
2014-11-17 10:30:25 +01:00
|
|
|
|
|
|
|
struct list streams;
|
2017-09-24 23:08:40 +02:00
|
|
|
CRITICAL_SECTION cs;
|
2014-08-26 17:11:59 +02:00
|
|
|
};
|
|
|
|
|
2017-09-24 23:08:40 +02:00
|
|
|
static struct dwrite_localfontfileloader local_fontfile_loader;
|
|
|
|
|
2017-10-06 11:45:20 +02:00
|
|
|
struct dwrite_inmemory_stream_data
|
|
|
|
{
|
|
|
|
LONG ref;
|
|
|
|
IUnknown *owner;
|
|
|
|
void *data;
|
|
|
|
UINT32 size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct dwrite_inmemory_filestream
|
|
|
|
{
|
|
|
|
IDWriteFontFileStream IDWriteFontFileStream_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
struct dwrite_inmemory_stream_data *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct dwrite_inmemory_fileloader
|
|
|
|
{
|
|
|
|
IDWriteInMemoryFontFileLoader IDWriteInMemoryFontFileLoader_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
struct dwrite_inmemory_stream_data **streams;
|
2019-05-14 12:27:25 +02:00
|
|
|
size_t size;
|
|
|
|
size_t count;
|
2017-10-06 11:45:20 +02:00
|
|
|
};
|
|
|
|
|
2014-08-26 17:11:59 +02:00
|
|
|
static inline struct dwrite_localfontfileloader *impl_from_IDWriteLocalFontFileLoader(IDWriteLocalFontFileLoader *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_localfontfileloader, IDWriteLocalFontFileLoader_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct dwrite_localfontfilestream *impl_from_IDWriteFontFileStream(IDWriteFontFileStream *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_localfontfilestream, IDWriteFontFileStream_iface);
|
|
|
|
}
|
|
|
|
|
2017-10-06 11:45:20 +02:00
|
|
|
static inline struct dwrite_inmemory_fileloader *impl_from_IDWriteInMemoryFontFileLoader(IDWriteInMemoryFontFileLoader *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_inmemory_fileloader, IDWriteInMemoryFontFileLoader_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct dwrite_inmemory_filestream *inmemory_impl_from_IDWriteFontFileStream(IDWriteFontFileStream *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_inmemory_filestream, IDWriteFontFileStream_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void release_inmemory_stream(struct dwrite_inmemory_stream_data *stream)
|
|
|
|
{
|
|
|
|
if (InterlockedDecrement(&stream->ref) == 0) {
|
|
|
|
if (stream->owner)
|
|
|
|
IUnknown_Release(stream->owner);
|
|
|
|
else
|
|
|
|
heap_free(stream->data);
|
|
|
|
heap_free(stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-26 17:11:59 +02:00
|
|
|
static HRESULT WINAPI localfontfilestream_QueryInterface(IDWriteFontFileStream *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct dwrite_localfontfilestream *This = impl_from_IDWriteFontFileStream(iface);
|
2017-09-24 23:08:40 +02:00
|
|
|
|
2016-02-14 17:05:08 +01:00
|
|
|
TRACE_(dwrite_file)("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
|
2017-09-24 23:08:40 +02:00
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IDWriteFontFileStream) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
2014-08-26 17:11:59 +02:00
|
|
|
{
|
|
|
|
*obj = iface;
|
2017-09-24 23:08:40 +02:00
|
|
|
if (InterlockedIncrement(&This->ref) == 1) {
|
|
|
|
InterlockedDecrement(&This->ref);
|
|
|
|
*obj = NULL;
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2014-08-26 17:11:59 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2014-08-26 17:11:59 +02:00
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI localfontfilestream_AddRef(IDWriteFontFileStream *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_localfontfilestream *This = impl_from_IDWriteFontFileStream(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2016-02-14 17:05:08 +01:00
|
|
|
TRACE_(dwrite_file)("(%p)->(%d)\n", This, ref);
|
2014-08-26 17:11:59 +02:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2014-11-17 10:30:25 +01:00
|
|
|
static inline void release_cached_stream(struct local_cached_stream *stream)
|
|
|
|
{
|
|
|
|
list_remove(&stream->entry);
|
|
|
|
heap_free(stream->key);
|
|
|
|
heap_free(stream);
|
|
|
|
}
|
|
|
|
|
2014-08-26 17:11:59 +02:00
|
|
|
static ULONG WINAPI localfontfilestream_Release(IDWriteFontFileStream *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_localfontfilestream *This = impl_from_IDWriteFontFileStream(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2016-02-14 17:05:08 +01:00
|
|
|
TRACE_(dwrite_file)("(%p)->(%d)\n", This, ref);
|
2014-08-26 17:11:59 +02:00
|
|
|
|
2014-11-17 10:30:25 +01:00
|
|
|
if (!ref) {
|
2014-11-26 06:59:04 +01:00
|
|
|
UnmapViewOfFile(This->file_ptr);
|
2017-09-24 23:08:40 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&local_fontfile_loader.cs);
|
2014-11-17 10:30:25 +01:00
|
|
|
release_cached_stream(This->entry);
|
2017-09-24 23:08:40 +02:00
|
|
|
LeaveCriticalSection(&local_fontfile_loader.cs);
|
|
|
|
|
2014-08-26 17:11:59 +02:00
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2016-11-16 17:57:00 +01:00
|
|
|
static HRESULT WINAPI localfontfilestream_ReadFileFragment(IDWriteFontFileStream *iface, void const **fragment_start,
|
|
|
|
UINT64 offset, UINT64 fragment_size, void **fragment_context)
|
2014-08-26 17:11:59 +02:00
|
|
|
{
|
|
|
|
struct dwrite_localfontfilestream *This = impl_from_IDWriteFontFileStream(iface);
|
|
|
|
|
2016-11-16 17:57:00 +01:00
|
|
|
TRACE_(dwrite_file)("(%p)->(%p, 0x%s, 0x%s, %p)\n", This, fragment_start,
|
2014-08-26 17:11:59 +02:00
|
|
|
wine_dbgstr_longlong(offset), wine_dbgstr_longlong(fragment_size), fragment_context);
|
|
|
|
|
|
|
|
*fragment_context = NULL;
|
2014-11-26 06:59:04 +01:00
|
|
|
|
|
|
|
if ((offset >= This->size - 1) || (fragment_size > This->size - offset)) {
|
|
|
|
*fragment_start = NULL;
|
2014-08-26 17:11:59 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2014-11-26 06:59:04 +01:00
|
|
|
*fragment_start = (char*)This->file_ptr + offset;
|
2014-08-26 17:11:59 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI localfontfilestream_ReleaseFileFragment(IDWriteFontFileStream *iface, void *fragment_context)
|
|
|
|
{
|
|
|
|
struct dwrite_localfontfilestream *This = impl_from_IDWriteFontFileStream(iface);
|
2016-02-14 17:05:08 +01:00
|
|
|
TRACE_(dwrite_file)("(%p)->(%p)\n", This, fragment_context);
|
2014-08-26 17:11:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI localfontfilestream_GetFileSize(IDWriteFontFileStream *iface, UINT64 *size)
|
|
|
|
{
|
|
|
|
struct dwrite_localfontfilestream *This = impl_from_IDWriteFontFileStream(iface);
|
2016-02-14 17:05:08 +01:00
|
|
|
TRACE_(dwrite_file)("(%p)->(%p)\n", This, size);
|
2014-11-26 06:59:04 +01:00
|
|
|
*size = This->size;
|
2014-08-26 17:11:59 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI localfontfilestream_GetLastWriteTime(IDWriteFontFileStream *iface, UINT64 *last_writetime)
|
|
|
|
{
|
|
|
|
struct dwrite_localfontfilestream *This = impl_from_IDWriteFontFileStream(iface);
|
2014-11-18 10:43:10 +01:00
|
|
|
ULARGE_INTEGER li;
|
|
|
|
|
2016-02-14 17:05:08 +01:00
|
|
|
TRACE_(dwrite_file)("(%p)->(%p)\n", This, last_writetime);
|
2014-11-18 10:43:10 +01:00
|
|
|
|
2014-12-05 12:55:00 +01:00
|
|
|
li.u.LowPart = This->entry->key->writetime.dwLowDateTime;
|
|
|
|
li.u.HighPart = This->entry->key->writetime.dwHighDateTime;
|
2014-11-18 10:43:10 +01:00
|
|
|
*last_writetime = li.QuadPart;
|
|
|
|
|
|
|
|
return S_OK;
|
2014-08-26 17:11:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteFontFileStreamVtbl localfontfilestreamvtbl =
|
|
|
|
{
|
|
|
|
localfontfilestream_QueryInterface,
|
|
|
|
localfontfilestream_AddRef,
|
|
|
|
localfontfilestream_Release,
|
|
|
|
localfontfilestream_ReadFileFragment,
|
|
|
|
localfontfilestream_ReleaseFileFragment,
|
|
|
|
localfontfilestream_GetFileSize,
|
|
|
|
localfontfilestream_GetLastWriteTime
|
|
|
|
};
|
|
|
|
|
2016-01-15 10:12:24 +01:00
|
|
|
static HRESULT create_localfontfilestream(const void *file_ptr, UINT64 size, struct local_cached_stream *entry, IDWriteFontFileStream **ret)
|
2014-08-26 17:11:59 +02:00
|
|
|
{
|
2016-01-15 10:12:24 +01:00
|
|
|
struct dwrite_localfontfilestream *This;
|
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
|
|
|
|
This = heap_alloc(sizeof(struct dwrite_localfontfilestream));
|
2014-08-26 17:11:59 +02:00
|
|
|
if (!This)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->IDWriteFontFileStream_iface.lpVtbl = &localfontfilestreamvtbl;
|
2014-11-26 06:59:04 +01:00
|
|
|
This->ref = 1;
|
|
|
|
|
|
|
|
This->file_ptr = file_ptr;
|
|
|
|
This->size = size;
|
2014-11-17 10:30:25 +01:00
|
|
|
This->entry = entry;
|
2014-08-26 17:11:59 +02:00
|
|
|
|
2016-01-15 10:12:24 +01:00
|
|
|
*ret = &This->IDWriteFontFileStream_iface;
|
2014-08-26 17:11:59 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI localfontfileloader_QueryInterface(IDWriteLocalFontFileLoader *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct dwrite_localfontfileloader *This = impl_from_IDWriteLocalFontFileLoader(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
|
|
|
|
|
2017-09-24 23:08:40 +02:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteLocalFontFileLoader) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFontFileLoader) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
2014-08-26 17:11:59 +02:00
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
IDWriteLocalFontFileLoader_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2014-08-26 17:11:59 +02:00
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI localfontfileloader_AddRef(IDWriteLocalFontFileLoader *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_localfontfileloader *This = impl_from_IDWriteLocalFontFileLoader(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI localfontfileloader_Release(IDWriteLocalFontFileLoader *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_localfontfileloader *This = impl_from_IDWriteLocalFontFileLoader(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2017-09-24 23:08:40 +02:00
|
|
|
static HRESULT create_local_cached_stream(const void *key, UINT32 key_size, struct local_cached_stream **ret)
|
2014-08-26 17:11:59 +02:00
|
|
|
{
|
2014-11-15 17:19:00 +01:00
|
|
|
const struct local_refkey *refkey = key;
|
2014-11-17 10:30:25 +01:00
|
|
|
struct local_cached_stream *stream;
|
|
|
|
IDWriteFontFileStream *filestream;
|
2014-11-26 06:59:04 +01:00
|
|
|
HANDLE file, mapping;
|
|
|
|
LARGE_INTEGER size;
|
|
|
|
void *file_ptr;
|
2017-09-24 23:08:40 +02:00
|
|
|
HRESULT hr = S_OK;
|
2014-11-17 10:30:25 +01:00
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
|
2014-11-26 06:59:04 +01:00
|
|
|
file = CreateFileW(refkey->name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE,
|
2017-09-24 23:08:40 +02:00
|
|
|
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
if (file == INVALID_HANDLE_VALUE) {
|
|
|
|
WARN_(dwrite_file)("Failed to open the file %s, error %d.\n", debugstr_w(refkey->name), GetLastError());
|
2014-11-26 06:59:04 +01:00
|
|
|
return E_FAIL;
|
2017-09-24 23:08:40 +02:00
|
|
|
}
|
2014-08-26 17:11:59 +02:00
|
|
|
|
2014-11-26 06:59:04 +01:00
|
|
|
GetFileSizeEx(file, &size);
|
|
|
|
mapping = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL);
|
|
|
|
CloseHandle(file);
|
|
|
|
if (!mapping)
|
2014-08-26 17:11:59 +02:00
|
|
|
return E_FAIL;
|
|
|
|
|
2014-11-26 06:59:04 +01:00
|
|
|
file_ptr = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
|
|
|
|
CloseHandle(mapping);
|
2016-08-26 12:47:17 +02:00
|
|
|
if (!file_ptr) {
|
|
|
|
ERR("mapping failed, file size %s, error %d\n", wine_dbgstr_longlong(size.QuadPart), GetLastError());
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2014-11-26 06:59:04 +01:00
|
|
|
|
2014-11-17 10:30:25 +01:00
|
|
|
stream = heap_alloc(sizeof(*stream));
|
2014-11-30 10:45:13 +01:00
|
|
|
if (!stream) {
|
|
|
|
UnmapViewOfFile(file_ptr);
|
2014-11-17 10:30:25 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2014-11-30 10:45:13 +01:00
|
|
|
}
|
2014-11-17 10:30:25 +01:00
|
|
|
|
|
|
|
stream->key = heap_alloc(key_size);
|
|
|
|
if (!stream->key) {
|
2014-11-26 06:59:04 +01:00
|
|
|
UnmapViewOfFile(file_ptr);
|
2014-11-17 10:30:25 +01:00
|
|
|
heap_free(stream);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
stream->key_size = key_size;
|
|
|
|
memcpy(stream->key, key, key_size);
|
|
|
|
|
2014-11-26 06:59:04 +01:00
|
|
|
hr = create_localfontfilestream(file_ptr, size.QuadPart, stream, &filestream);
|
2014-11-17 10:30:25 +01:00
|
|
|
if (FAILED(hr)) {
|
2014-11-26 06:59:04 +01:00
|
|
|
UnmapViewOfFile(file_ptr);
|
2014-11-17 10:30:25 +01:00
|
|
|
heap_free(stream->key);
|
|
|
|
heap_free(stream);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
stream->stream = filestream;
|
|
|
|
|
2017-09-24 23:08:40 +02:00
|
|
|
*ret = stream;
|
2014-11-17 10:30:25 +01:00
|
|
|
|
|
|
|
return S_OK;
|
2014-08-26 17:11:59 +02:00
|
|
|
}
|
|
|
|
|
2017-09-24 23:08:40 +02:00
|
|
|
static HRESULT WINAPI localfontfileloader_CreateStreamFromKey(IDWriteLocalFontFileLoader *iface, const void *key,
|
|
|
|
UINT32 key_size, IDWriteFontFileStream **ret)
|
|
|
|
{
|
|
|
|
struct dwrite_localfontfileloader *This = impl_from_IDWriteLocalFontFileLoader(iface);
|
|
|
|
const struct local_refkey *refkey = key;
|
|
|
|
struct local_cached_stream *stream;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p, %u, %p)\n", This, key, key_size, ret);
|
|
|
|
TRACE("name: %s\n", debugstr_w(refkey->name));
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->cs);
|
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
|
|
|
|
/* search cache first */
|
|
|
|
LIST_FOR_EACH_ENTRY(stream, &This->streams, struct local_cached_stream, entry) {
|
|
|
|
if (key_size == stream->key_size && !memcmp(stream->key, key, key_size)) {
|
|
|
|
IDWriteFontFileStream_QueryInterface(stream->stream, &IID_IDWriteFontFileStream, (void **)ret);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*ret == NULL && (hr = create_local_cached_stream(key, key_size, &stream)) == S_OK) {
|
|
|
|
list_add_head(&This->streams, &stream->entry);
|
|
|
|
*ret = stream->stream;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&This->cs);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2014-08-26 17:11:59 +02:00
|
|
|
static HRESULT WINAPI localfontfileloader_GetFilePathLengthFromKey(IDWriteLocalFontFileLoader *iface, void const *key, UINT32 key_size, UINT32 *length)
|
|
|
|
{
|
|
|
|
struct dwrite_localfontfileloader *This = impl_from_IDWriteLocalFontFileLoader(iface);
|
2014-11-15 17:19:00 +01:00
|
|
|
const struct local_refkey *refkey = key;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p, %i, %p)\n", This, key, key_size, length);
|
|
|
|
|
|
|
|
*length = strlenW(refkey->name);
|
2014-08-26 17:11:59 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI localfontfileloader_GetFilePathFromKey(IDWriteLocalFontFileLoader *iface, void const *key, UINT32 key_size, WCHAR *path, UINT32 length)
|
|
|
|
{
|
|
|
|
struct dwrite_localfontfileloader *This = impl_from_IDWriteLocalFontFileLoader(iface);
|
2014-11-15 17:19:00 +01:00
|
|
|
const struct local_refkey *refkey = key;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p, %i, %p, %i)\n", This, key, key_size, path, length);
|
|
|
|
|
|
|
|
if (length < strlenW(refkey->name))
|
2014-08-26 17:11:59 +02:00
|
|
|
return E_INVALIDARG;
|
2014-11-15 17:19:00 +01:00
|
|
|
|
|
|
|
strcpyW(path, refkey->name);
|
2014-08-26 17:11:59 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-24 23:08:40 +02:00
|
|
|
static HRESULT WINAPI localfontfileloader_GetLastWriteTimeFromKey(IDWriteLocalFontFileLoader *iface, void const *key,
|
|
|
|
UINT32 key_size, FILETIME *writetime)
|
2014-08-26 17:11:59 +02:00
|
|
|
{
|
|
|
|
struct dwrite_localfontfileloader *This = impl_from_IDWriteLocalFontFileLoader(iface);
|
2014-11-15 17:19:00 +01:00
|
|
|
const struct local_refkey *refkey = key;
|
|
|
|
|
2017-09-24 23:08:40 +02:00
|
|
|
TRACE("(%p)->(%p, %u, %p)\n", This, key, key_size, writetime);
|
2014-11-15 17:19:00 +01:00
|
|
|
|
|
|
|
*writetime = refkey->writetime;
|
|
|
|
return S_OK;
|
2014-08-26 17:11:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IDWriteLocalFontFileLoaderVtbl localfontfileloadervtbl = {
|
|
|
|
localfontfileloader_QueryInterface,
|
|
|
|
localfontfileloader_AddRef,
|
|
|
|
localfontfileloader_Release,
|
|
|
|
localfontfileloader_CreateStreamFromKey,
|
|
|
|
localfontfileloader_GetFilePathLengthFromKey,
|
|
|
|
localfontfileloader_GetFilePathFromKey,
|
|
|
|
localfontfileloader_GetLastWriteTimeFromKey
|
|
|
|
};
|
|
|
|
|
2017-09-24 23:08:40 +02:00
|
|
|
void init_local_fontfile_loader(void)
|
2014-08-26 17:11:59 +02:00
|
|
|
{
|
2017-09-24 23:08:40 +02:00
|
|
|
local_fontfile_loader.IDWriteLocalFontFileLoader_iface.lpVtbl = &localfontfileloadervtbl;
|
|
|
|
local_fontfile_loader.ref = 1;
|
|
|
|
list_init(&local_fontfile_loader.streams);
|
|
|
|
InitializeCriticalSection(&local_fontfile_loader.cs);
|
|
|
|
local_fontfile_loader.cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": localfileloader.lock");
|
|
|
|
}
|
2014-08-26 17:11:59 +02:00
|
|
|
|
2017-09-24 23:08:40 +02:00
|
|
|
IDWriteFontFileLoader *get_local_fontfile_loader(void)
|
|
|
|
{
|
|
|
|
return (IDWriteFontFileLoader *)&local_fontfile_loader.IDWriteLocalFontFileLoader_iface;
|
2014-08-26 17:11:59 +02:00
|
|
|
}
|
2014-11-15 17:19:00 +01:00
|
|
|
|
|
|
|
HRESULT get_local_refkey(const WCHAR *path, const FILETIME *writetime, void **key, UINT32 *size)
|
|
|
|
{
|
|
|
|
struct local_refkey *refkey;
|
|
|
|
|
2016-04-20 09:50:59 +02:00
|
|
|
if (!path)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2014-11-15 17:19:00 +01:00
|
|
|
*size = FIELD_OFFSET(struct local_refkey, name) + (strlenW(path)+1)*sizeof(WCHAR);
|
|
|
|
*key = NULL;
|
|
|
|
|
|
|
|
refkey = heap_alloc(*size);
|
|
|
|
if (!refkey)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (writetime)
|
|
|
|
refkey->writetime = *writetime;
|
|
|
|
else {
|
|
|
|
WIN32_FILE_ATTRIBUTE_DATA info;
|
|
|
|
|
|
|
|
if (GetFileAttributesExW(path, GetFileExInfoStandard, &info))
|
|
|
|
refkey->writetime = info.ftLastWriteTime;
|
|
|
|
else
|
|
|
|
memset(&refkey->writetime, 0, sizeof(refkey->writetime));
|
|
|
|
}
|
|
|
|
strcpyW(refkey->name, path);
|
|
|
|
|
|
|
|
*key = refkey;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2015-05-19 14:23:57 +02:00
|
|
|
|
|
|
|
/* IDWriteGlyphRunAnalysis */
|
|
|
|
static HRESULT WINAPI glyphrunanalysis_QueryInterface(IDWriteGlyphRunAnalysis *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
struct dwrite_glyphrunanalysis *This = impl_from_IDWriteGlyphRunAnalysis(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IDWriteGlyphRunAnalysis) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*ppv = iface;
|
|
|
|
IDWriteGlyphRunAnalysis_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2015-05-19 14:23:57 +02:00
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI glyphrunanalysis_AddRef(IDWriteGlyphRunAnalysis *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_glyphrunanalysis *This = impl_from_IDWriteGlyphRunAnalysis(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p)->(%u)\n", This, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI glyphrunanalysis_Release(IDWriteGlyphRunAnalysis *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_glyphrunanalysis *This = impl_from_IDWriteGlyphRunAnalysis(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u)\n", This, ref);
|
|
|
|
|
|
|
|
if (!ref) {
|
2015-08-04 10:16:35 +02:00
|
|
|
if (This->run.fontFace)
|
|
|
|
IDWriteFontFace_Release(This->run.fontFace);
|
2015-07-29 10:57:52 +02:00
|
|
|
heap_free(This->glyphs);
|
2017-04-04 12:13:17 +02:00
|
|
|
heap_free(This->origins);
|
2015-07-31 00:30:08 +02:00
|
|
|
heap_free(This->bitmap);
|
2015-05-19 14:23:57 +02:00
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2017-01-26 05:41:46 +01:00
|
|
|
static BOOL is_natural_rendering_mode(DWRITE_RENDERING_MODE1 mode)
|
|
|
|
{
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case DWRITE_RENDERING_MODE1_NATURAL:
|
|
|
|
case DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC:
|
|
|
|
case DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED:
|
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-05 12:35:29 +02:00
|
|
|
static UINT32 get_glyph_bitmap_pitch(DWRITE_RENDERING_MODE1 rendering_mode, INT width)
|
2017-03-30 14:07:00 +02:00
|
|
|
{
|
2017-09-05 12:35:29 +02:00
|
|
|
return rendering_mode == DWRITE_RENDERING_MODE1_ALIASED ? ((width + 31) >> 5) << 2 : (width + 3) / 4 * 4;
|
2017-03-30 14:07:00 +02:00
|
|
|
}
|
|
|
|
|
2015-07-29 11:00:26 +02:00
|
|
|
static void glyphrunanalysis_get_texturebounds(struct dwrite_glyphrunanalysis *analysis, RECT *bounds)
|
2015-05-19 14:23:57 +02:00
|
|
|
{
|
2015-08-27 07:38:50 +02:00
|
|
|
struct dwrite_glyphbitmap glyph_bitmap;
|
2017-04-04 12:13:17 +02:00
|
|
|
IDWriteFontFace4 *fontface;
|
2015-07-29 10:59:02 +02:00
|
|
|
HRESULT hr;
|
|
|
|
UINT32 i;
|
2015-07-17 10:56:17 +02:00
|
|
|
|
2015-11-02 14:38:41 +01:00
|
|
|
if (analysis->flags & RUNANALYSIS_BOUNDS_READY) {
|
2015-07-29 11:00:26 +02:00
|
|
|
*bounds = analysis->bounds;
|
|
|
|
return;
|
2015-07-29 10:59:02 +02:00
|
|
|
}
|
|
|
|
|
2015-07-29 11:00:26 +02:00
|
|
|
if (analysis->run.isSideways)
|
2015-07-29 10:59:02 +02:00
|
|
|
FIXME("sideways runs are not supported.\n");
|
|
|
|
|
2017-04-04 12:13:17 +02:00
|
|
|
hr = IDWriteFontFace_QueryInterface(analysis->run.fontFace, &IID_IDWriteFontFace4, (void **)&fontface);
|
2015-07-29 10:59:02 +02:00
|
|
|
if (FAILED(hr))
|
2016-10-29 20:25:54 +02:00
|
|
|
WARN("failed to get IDWriteFontFace4, 0x%08x\n", hr);
|
2015-07-29 10:59:02 +02:00
|
|
|
|
2015-08-27 07:38:50 +02:00
|
|
|
memset(&glyph_bitmap, 0, sizeof(glyph_bitmap));
|
2017-04-04 12:13:17 +02:00
|
|
|
glyph_bitmap.fontface = fontface;
|
2017-07-11 15:57:40 +02:00
|
|
|
glyph_bitmap.simulations = IDWriteFontFace4_GetSimulations(fontface);
|
2017-04-04 12:13:18 +02:00
|
|
|
glyph_bitmap.emsize = analysis->run.fontEmSize;
|
2017-01-26 05:41:46 +01:00
|
|
|
glyph_bitmap.nohint = is_natural_rendering_mode(analysis->rendering_mode);
|
2015-11-02 14:38:43 +01:00
|
|
|
if (analysis->flags & RUNANALYSIS_USE_TRANSFORM)
|
|
|
|
glyph_bitmap.m = &analysis->m;
|
2015-08-27 07:38:50 +02:00
|
|
|
|
2015-07-29 11:00:26 +02:00
|
|
|
for (i = 0; i < analysis->run.glyphCount; i++) {
|
2015-08-27 07:38:50 +02:00
|
|
|
RECT *bbox = &glyph_bitmap.bbox;
|
2017-03-30 14:07:00 +02:00
|
|
|
UINT32 bitmap_size;
|
2015-07-29 10:59:02 +02:00
|
|
|
|
2019-01-25 12:56:40 +01:00
|
|
|
glyph_bitmap.glyph = analysis->run.glyphIndices[i];
|
2015-08-27 07:38:50 +02:00
|
|
|
freetype_get_glyph_bbox(&glyph_bitmap);
|
2015-07-29 10:59:02 +02:00
|
|
|
|
2017-09-05 12:35:29 +02:00
|
|
|
bitmap_size = get_glyph_bitmap_pitch(analysis->rendering_mode, bbox->right - bbox->left) *
|
2017-03-30 14:07:00 +02:00
|
|
|
(bbox->bottom - bbox->top);
|
|
|
|
if (bitmap_size > analysis->max_glyph_bitmap_size)
|
|
|
|
analysis->max_glyph_bitmap_size = bitmap_size;
|
|
|
|
|
2017-04-04 12:13:17 +02:00
|
|
|
OffsetRect(bbox, analysis->origins[i].x, analysis->origins[i].y);
|
2015-08-27 07:38:50 +02:00
|
|
|
UnionRect(&analysis->bounds, &analysis->bounds, bbox);
|
2015-07-29 10:59:02 +02:00
|
|
|
}
|
|
|
|
|
2017-04-04 12:13:17 +02:00
|
|
|
IDWriteFontFace4_Release(fontface);
|
2015-07-31 00:29:39 +02:00
|
|
|
|
2015-11-02 14:38:41 +01:00
|
|
|
analysis->flags |= RUNANALYSIS_BOUNDS_READY;
|
2015-07-29 11:00:26 +02:00
|
|
|
*bounds = analysis->bounds;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI glyphrunanalysis_GetAlphaTextureBounds(IDWriteGlyphRunAnalysis *iface, DWRITE_TEXTURE_TYPE type, RECT *bounds)
|
|
|
|
{
|
|
|
|
struct dwrite_glyphrunanalysis *This = impl_from_IDWriteGlyphRunAnalysis(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %p)\n", This, type, bounds);
|
|
|
|
|
|
|
|
if ((UINT32)type > DWRITE_TEXTURE_CLEARTYPE_3x1) {
|
2017-04-12 13:20:29 +02:00
|
|
|
SetRectEmpty(bounds);
|
2015-07-29 11:00:26 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2017-03-30 14:06:59 +02:00
|
|
|
if (type != This->texture_type) {
|
2017-04-12 13:20:29 +02:00
|
|
|
SetRectEmpty(bounds);
|
2015-07-29 11:00:26 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
glyphrunanalysis_get_texturebounds(This, bounds);
|
2015-07-29 10:59:02 +02:00
|
|
|
return S_OK;
|
2015-05-19 14:23:57 +02:00
|
|
|
}
|
|
|
|
|
2015-07-31 00:30:08 +02:00
|
|
|
static inline BYTE *get_pixel_ptr(BYTE *ptr, DWRITE_TEXTURE_TYPE type, const RECT *runbounds, const RECT *bounds)
|
|
|
|
{
|
|
|
|
if (type == DWRITE_TEXTURE_CLEARTYPE_3x1)
|
|
|
|
return ptr + (runbounds->top - bounds->top) * (bounds->right - bounds->left) * 3 +
|
|
|
|
(runbounds->left - bounds->left) * 3;
|
|
|
|
else
|
|
|
|
return ptr + (runbounds->top - bounds->top) * (bounds->right - bounds->left) +
|
|
|
|
runbounds->left - bounds->left;
|
|
|
|
}
|
|
|
|
|
2017-03-30 14:07:00 +02:00
|
|
|
static HRESULT glyphrunanalysis_render(struct dwrite_glyphrunanalysis *analysis)
|
2015-07-31 00:30:08 +02:00
|
|
|
{
|
|
|
|
static const BYTE masks[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
|
2015-08-27 07:38:50 +02:00
|
|
|
struct dwrite_glyphbitmap glyph_bitmap;
|
2017-03-15 20:35:33 +01:00
|
|
|
IDWriteFontFace4 *fontface;
|
2015-11-02 14:38:42 +01:00
|
|
|
D2D_POINT_2F origin;
|
2015-07-31 00:30:08 +02:00
|
|
|
UINT32 i, size;
|
2015-08-22 20:07:17 +02:00
|
|
|
HRESULT hr;
|
2015-08-27 07:38:50 +02:00
|
|
|
RECT *bbox;
|
2015-07-31 00:30:08 +02:00
|
|
|
|
2017-03-15 20:35:33 +01:00
|
|
|
hr = IDWriteFontFace_QueryInterface(analysis->run.fontFace, &IID_IDWriteFontFace4, (void **)&fontface);
|
2015-08-22 20:07:17 +02:00
|
|
|
if (FAILED(hr)) {
|
2016-10-29 20:25:54 +02:00
|
|
|
WARN("failed to get IDWriteFontFace4, 0x%08x\n", hr);
|
2017-03-23 15:04:18 +01:00
|
|
|
return hr;
|
2015-08-22 20:07:17 +02:00
|
|
|
}
|
2015-07-31 00:30:08 +02:00
|
|
|
|
|
|
|
size = (analysis->bounds.right - analysis->bounds.left)*(analysis->bounds.bottom - analysis->bounds.top);
|
2017-03-30 14:07:00 +02:00
|
|
|
if (analysis->texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1)
|
2015-07-31 00:30:08 +02:00
|
|
|
size *= 3;
|
2017-03-23 15:04:18 +01:00
|
|
|
if (!(analysis->bitmap = heap_alloc_zero(size))) {
|
|
|
|
WARN("Failed to allocate run bitmap, %s, type %s.\n", wine_dbgstr_rect(&analysis->bounds),
|
2017-03-30 14:07:00 +02:00
|
|
|
analysis->texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1 ? "3x1" : "1x1");
|
2017-03-23 15:04:18 +01:00
|
|
|
IDWriteFontFace4_Release(fontface);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2015-07-31 00:30:08 +02:00
|
|
|
|
2015-11-02 14:38:42 +01:00
|
|
|
origin.x = origin.y = 0.0f;
|
2015-08-27 07:38:50 +02:00
|
|
|
|
|
|
|
memset(&glyph_bitmap, 0, sizeof(glyph_bitmap));
|
2017-03-15 20:35:33 +01:00
|
|
|
glyph_bitmap.fontface = fontface;
|
2017-07-11 15:57:40 +02:00
|
|
|
glyph_bitmap.simulations = IDWriteFontFace4_GetSimulations(fontface);
|
2017-04-04 12:13:18 +02:00
|
|
|
glyph_bitmap.emsize = analysis->run.fontEmSize;
|
2017-01-26 05:41:46 +01:00
|
|
|
glyph_bitmap.nohint = is_natural_rendering_mode(analysis->rendering_mode);
|
2017-09-05 12:35:29 +02:00
|
|
|
glyph_bitmap.aliased = analysis->rendering_mode == DWRITE_RENDERING_MODE1_ALIASED;
|
2015-11-02 14:38:43 +01:00
|
|
|
if (analysis->flags & RUNANALYSIS_USE_TRANSFORM)
|
|
|
|
glyph_bitmap.m = &analysis->m;
|
2017-03-30 14:07:00 +02:00
|
|
|
if (!(glyph_bitmap.buf = heap_alloc(analysis->max_glyph_bitmap_size))) {
|
|
|
|
IDWriteFontFace4_Release(fontface);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2015-08-27 07:38:50 +02:00
|
|
|
bbox = &glyph_bitmap.bbox;
|
|
|
|
|
2015-07-31 00:30:08 +02:00
|
|
|
for (i = 0; i < analysis->run.glyphCount; i++) {
|
2017-03-30 14:07:00 +02:00
|
|
|
BYTE *src = glyph_bitmap.buf, *dst;
|
2015-08-27 07:38:50 +02:00
|
|
|
int x, y, width, height;
|
2015-08-27 07:39:45 +02:00
|
|
|
BOOL is_1bpp;
|
2015-07-31 00:30:08 +02:00
|
|
|
|
2019-01-25 12:56:40 +01:00
|
|
|
glyph_bitmap.glyph = analysis->run.glyphIndices[i];
|
2015-08-27 07:38:50 +02:00
|
|
|
freetype_get_glyph_bbox(&glyph_bitmap);
|
2015-07-31 00:30:08 +02:00
|
|
|
|
2017-04-04 12:13:17 +02:00
|
|
|
if (IsRectEmpty(bbox))
|
2015-07-31 00:30:08 +02:00
|
|
|
continue;
|
|
|
|
|
2015-08-27 07:38:50 +02:00
|
|
|
width = bbox->right - bbox->left;
|
|
|
|
height = bbox->bottom - bbox->top;
|
2015-08-27 07:39:45 +02:00
|
|
|
|
2017-09-05 12:35:29 +02:00
|
|
|
glyph_bitmap.pitch = get_glyph_bitmap_pitch(analysis->rendering_mode, width);
|
2017-03-30 14:07:00 +02:00
|
|
|
memset(src, 0, height * glyph_bitmap.pitch);
|
2015-08-27 07:39:45 +02:00
|
|
|
is_1bpp = freetype_get_glyph_bitmap(&glyph_bitmap);
|
2015-07-31 00:30:08 +02:00
|
|
|
|
2017-04-04 12:13:17 +02:00
|
|
|
OffsetRect(bbox, analysis->origins[i].x, analysis->origins[i].y);
|
2015-07-31 00:30:08 +02:00
|
|
|
|
|
|
|
/* blit to analysis bitmap */
|
2017-03-30 14:07:00 +02:00
|
|
|
dst = get_pixel_ptr(analysis->bitmap, analysis->texture_type, bbox, &analysis->bounds);
|
2015-07-31 00:30:08 +02:00
|
|
|
|
2015-08-27 07:39:45 +02:00
|
|
|
if (is_1bpp) {
|
|
|
|
/* convert 1bpp to 8bpp/24bpp */
|
2017-03-30 14:07:00 +02:00
|
|
|
if (analysis->texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1) {
|
2015-08-27 07:39:45 +02:00
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++)
|
2015-11-02 21:34:21 +01:00
|
|
|
if (src[x / 8] & masks[x % 8])
|
|
|
|
dst[3*x] = dst[3*x+1] = dst[3*x+2] = DWRITE_ALPHA_MAX;
|
2015-08-27 07:39:45 +02:00
|
|
|
src += glyph_bitmap.pitch;
|
|
|
|
dst += (analysis->bounds.right - analysis->bounds.left) * 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++)
|
2015-11-02 21:34:21 +01:00
|
|
|
if (src[x / 8] & masks[x % 8])
|
|
|
|
dst[x] = DWRITE_ALPHA_MAX;
|
2017-09-05 12:35:29 +02:00
|
|
|
src += glyph_bitmap.pitch;
|
2015-08-27 07:39:45 +02:00
|
|
|
dst += analysis->bounds.right - analysis->bounds.left;
|
|
|
|
}
|
2015-07-31 00:30:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2017-09-05 12:35:29 +02:00
|
|
|
if (analysis->texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1) {
|
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++)
|
|
|
|
dst[3*x] = dst[3*x+1] = dst[3*x+2] = src[x] | dst[3*x];
|
|
|
|
src += glyph_bitmap.pitch;
|
|
|
|
dst += (analysis->bounds.right - analysis->bounds.left) * 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++)
|
|
|
|
dst[x] |= src[x];
|
|
|
|
src += glyph_bitmap.pitch;
|
|
|
|
dst += analysis->bounds.right - analysis->bounds.left;
|
|
|
|
}
|
2015-07-31 00:30:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-30 14:07:00 +02:00
|
|
|
heap_free(glyph_bitmap.buf);
|
2015-07-31 00:30:08 +02:00
|
|
|
|
2017-03-15 20:35:33 +01:00
|
|
|
IDWriteFontFace4_Release(fontface);
|
2015-07-31 00:30:08 +02:00
|
|
|
|
2015-11-02 14:38:41 +01:00
|
|
|
analysis->flags |= RUNANALYSIS_BITMAP_READY;
|
2015-08-04 10:16:35 +02:00
|
|
|
|
|
|
|
/* we don't need this anymore */
|
|
|
|
heap_free(analysis->glyphs);
|
2017-04-04 12:13:17 +02:00
|
|
|
heap_free(analysis->origins);
|
2015-08-04 10:16:35 +02:00
|
|
|
IDWriteFontFace_Release(analysis->run.fontFace);
|
|
|
|
|
|
|
|
analysis->glyphs = NULL;
|
2017-04-04 12:13:17 +02:00
|
|
|
analysis->origins = NULL;
|
2015-08-04 10:16:35 +02:00
|
|
|
analysis->run.glyphIndices = NULL;
|
|
|
|
analysis->run.fontFace = NULL;
|
2017-03-23 15:04:18 +01:00
|
|
|
|
|
|
|
return S_OK;
|
2015-07-31 00:30:08 +02:00
|
|
|
}
|
|
|
|
|
2015-05-19 14:23:57 +02:00
|
|
|
static HRESULT WINAPI glyphrunanalysis_CreateAlphaTexture(IDWriteGlyphRunAnalysis *iface, DWRITE_TEXTURE_TYPE type,
|
2015-07-29 11:00:26 +02:00
|
|
|
RECT const *bounds, BYTE *bitmap, UINT32 size)
|
2015-05-19 14:23:57 +02:00
|
|
|
{
|
|
|
|
struct dwrite_glyphrunanalysis *This = impl_from_IDWriteGlyphRunAnalysis(iface);
|
2015-07-29 11:00:26 +02:00
|
|
|
UINT32 required;
|
|
|
|
RECT runbounds;
|
|
|
|
|
2015-07-31 00:30:08 +02:00
|
|
|
TRACE("(%p)->(%d %s %p %u)\n", This, type, wine_dbgstr_rect(bounds), bitmap, size);
|
2015-07-29 11:00:26 +02:00
|
|
|
|
|
|
|
if (!bounds || !bitmap || (UINT32)type > DWRITE_TEXTURE_CLEARTYPE_3x1)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
/* make sure buffer is large enough for requested texture type */
|
|
|
|
required = (bounds->right - bounds->left) * (bounds->bottom - bounds->top);
|
2017-09-05 12:35:28 +02:00
|
|
|
if (This->texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1)
|
2015-07-29 11:00:26 +02:00
|
|
|
required *= 3;
|
|
|
|
|
|
|
|
if (size < required)
|
|
|
|
return E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
|
2017-03-30 14:06:59 +02:00
|
|
|
/* validate requested texture type */
|
|
|
|
if (This->texture_type != type)
|
|
|
|
return DWRITE_E_UNSUPPORTEDOPERATION;
|
2015-07-29 11:00:26 +02:00
|
|
|
|
2015-07-31 00:30:08 +02:00
|
|
|
memset(bitmap, 0, size);
|
2015-07-29 11:00:26 +02:00
|
|
|
glyphrunanalysis_get_texturebounds(This, &runbounds);
|
2015-07-31 00:30:08 +02:00
|
|
|
if (IntersectRect(&runbounds, &runbounds, bounds)) {
|
|
|
|
int pixel_size = type == DWRITE_TEXTURE_CLEARTYPE_3x1 ? 3 : 1;
|
|
|
|
int src_width = (This->bounds.right - This->bounds.left) * pixel_size;
|
|
|
|
int dst_width = (bounds->right - bounds->left) * pixel_size;
|
|
|
|
int draw_width = (runbounds.right - runbounds.left) * pixel_size;
|
|
|
|
BYTE *src, *dst;
|
|
|
|
int y;
|
|
|
|
|
2017-03-23 15:04:18 +01:00
|
|
|
if (!(This->flags & RUNANALYSIS_BITMAP_READY)) {
|
|
|
|
HRESULT hr;
|
|
|
|
|
2017-03-30 14:07:00 +02:00
|
|
|
if (FAILED(hr = glyphrunanalysis_render(This)))
|
2017-03-23 15:04:18 +01:00
|
|
|
return hr;
|
|
|
|
}
|
2015-07-31 00:30:08 +02:00
|
|
|
|
|
|
|
src = get_pixel_ptr(This->bitmap, type, &runbounds, &This->bounds);
|
|
|
|
dst = get_pixel_ptr(bitmap, type, &runbounds, bounds);
|
|
|
|
|
|
|
|
for (y = 0; y < runbounds.bottom - runbounds.top; y++) {
|
|
|
|
memcpy(dst, src, draw_width);
|
|
|
|
src += src_width;
|
|
|
|
dst += dst_width;
|
|
|
|
}
|
2015-07-29 11:00:26 +02:00
|
|
|
}
|
|
|
|
|
2015-07-31 00:30:08 +02:00
|
|
|
return S_OK;
|
2015-05-19 14:23:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI glyphrunanalysis_GetAlphaBlendParams(IDWriteGlyphRunAnalysis *iface, IDWriteRenderingParams *params,
|
2015-07-29 10:58:24 +02:00
|
|
|
FLOAT *gamma, FLOAT *contrast, FLOAT *cleartypelevel)
|
2015-05-19 14:23:57 +02:00
|
|
|
{
|
|
|
|
struct dwrite_glyphrunanalysis *This = impl_from_IDWriteGlyphRunAnalysis(iface);
|
2015-07-29 10:58:24 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p %p %p)\n", This, params, gamma, contrast, cleartypelevel);
|
|
|
|
|
|
|
|
if (!params)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
switch (This->rendering_mode)
|
|
|
|
{
|
2017-01-26 05:41:46 +01:00
|
|
|
case DWRITE_RENDERING_MODE1_GDI_CLASSIC:
|
|
|
|
case DWRITE_RENDERING_MODE1_GDI_NATURAL:
|
2015-07-29 10:58:24 +02:00
|
|
|
{
|
|
|
|
UINT value = 0;
|
|
|
|
SystemParametersInfoW(SPI_GETFONTSMOOTHINGCONTRAST, 0, &value, 0);
|
|
|
|
*gamma = (FLOAT)value / 1000.0f;
|
|
|
|
*contrast = 0.0f;
|
|
|
|
*cleartypelevel = 1.0f;
|
|
|
|
break;
|
|
|
|
}
|
2017-01-26 05:41:46 +01:00
|
|
|
case DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED:
|
2017-07-20 18:47:32 +02:00
|
|
|
WARN("NATURAL_SYMMETRIC_DOWNSAMPLED mode is ignored.\n");
|
2017-01-26 05:41:46 +01:00
|
|
|
/* fallthrough */
|
|
|
|
case DWRITE_RENDERING_MODE1_ALIASED:
|
|
|
|
case DWRITE_RENDERING_MODE1_NATURAL:
|
|
|
|
case DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC:
|
2015-07-29 10:58:24 +02:00
|
|
|
*gamma = IDWriteRenderingParams_GetGamma(params);
|
|
|
|
*contrast = IDWriteRenderingParams_GetEnhancedContrast(params);
|
|
|
|
*cleartypelevel = IDWriteRenderingParams_GetClearTypeLevel(params);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2015-05-19 14:23:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IDWriteGlyphRunAnalysisVtbl glyphrunanalysisvtbl = {
|
|
|
|
glyphrunanalysis_QueryInterface,
|
|
|
|
glyphrunanalysis_AddRef,
|
|
|
|
glyphrunanalysis_Release,
|
|
|
|
glyphrunanalysis_GetAlphaTextureBounds,
|
|
|
|
glyphrunanalysis_CreateAlphaTexture,
|
|
|
|
glyphrunanalysis_GetAlphaBlendParams
|
|
|
|
};
|
|
|
|
|
2017-04-04 12:13:17 +02:00
|
|
|
static inline void transform_point(D2D_POINT_2F *point, const DWRITE_MATRIX *m)
|
2015-11-02 14:38:43 +01:00
|
|
|
{
|
|
|
|
D2D_POINT_2F ret;
|
2017-04-04 12:13:17 +02:00
|
|
|
ret.x = point->x * m->m11 + point->y * m->m21 + m->dx;
|
|
|
|
ret.y = point->x * m->m12 + point->y * m->m22 + m->dy;
|
|
|
|
*point = ret;
|
2015-11-02 14:38:43 +01:00
|
|
|
}
|
|
|
|
|
2019-01-31 09:35:26 +01:00
|
|
|
float fontface_get_scaled_design_advance(struct dwrite_fontface *fontface, DWRITE_MEASURING_MODE measuring_mode,
|
2019-01-25 12:56:41 +01:00
|
|
|
float emsize, float ppdip, const DWRITE_MATRIX *transform, UINT16 glyph, BOOL is_sideways)
|
|
|
|
{
|
|
|
|
unsigned int upem = fontface->metrics.designUnitsPerEm;
|
|
|
|
int advance;
|
|
|
|
|
|
|
|
if (is_sideways)
|
|
|
|
FIXME("Sideways mode is not supported.\n");
|
|
|
|
|
|
|
|
advance = fontface_get_design_advance(fontface, measuring_mode, emsize, ppdip, transform, glyph, is_sideways);
|
|
|
|
|
|
|
|
switch (measuring_mode)
|
|
|
|
{
|
|
|
|
case DWRITE_MEASURING_MODE_NATURAL:
|
|
|
|
return (float)advance * emsize / (float)upem;
|
|
|
|
case DWRITE_MEASURING_MODE_GDI_NATURAL:
|
|
|
|
case DWRITE_MEASURING_MODE_GDI_CLASSIC:
|
|
|
|
return ppdip > 0.0f ? floorf(advance * emsize * ppdip / upem + 0.5f) / ppdip : 0.0f;
|
|
|
|
default:
|
|
|
|
WARN("Unknown measuring mode %u.\n", measuring_mode);
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-27 10:19:41 +02:00
|
|
|
HRESULT create_glyphrunanalysis(const struct glyphrunanalysis_desc *desc, IDWriteGlyphRunAnalysis **ret)
|
2015-05-19 14:23:57 +02:00
|
|
|
{
|
|
|
|
struct dwrite_glyphrunanalysis *analysis;
|
2019-01-25 12:56:41 +01:00
|
|
|
struct dwrite_fontface *fontface;
|
2017-04-04 12:13:17 +02:00
|
|
|
D2D_POINT_2F origin;
|
2015-11-03 18:32:22 +01:00
|
|
|
FLOAT rtl_factor;
|
2015-10-19 07:43:02 +02:00
|
|
|
UINT32 i;
|
2015-05-19 14:23:57 +02:00
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
|
2019-09-08 06:19:38 +02:00
|
|
|
/* Check rendering, antialiasing, measuring, and grid fitting modes. */
|
2017-01-26 05:41:46 +01:00
|
|
|
if ((UINT32)desc->rendering_mode >= DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED ||
|
|
|
|
desc->rendering_mode == DWRITE_RENDERING_MODE1_OUTLINE ||
|
|
|
|
desc->rendering_mode == DWRITE_RENDERING_MODE1_DEFAULT)
|
2015-05-19 14:23:57 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2017-07-17 22:18:43 +02:00
|
|
|
if ((UINT32)desc->aa_mode > DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if ((UINT32)desc->gridfit_mode > DWRITE_GRID_FIT_MODE_ENABLED)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if ((UINT32)desc->measuring_mode > DWRITE_MEASURING_MODE_GDI_NATURAL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2015-05-19 14:23:57 +02:00
|
|
|
analysis = heap_alloc(sizeof(*analysis));
|
|
|
|
if (!analysis)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
analysis->IDWriteGlyphRunAnalysis_iface.lpVtbl = &glyphrunanalysisvtbl;
|
|
|
|
analysis->ref = 1;
|
2016-04-27 10:19:41 +02:00
|
|
|
analysis->rendering_mode = desc->rendering_mode;
|
2017-03-30 14:06:59 +02:00
|
|
|
|
2017-09-05 12:35:29 +02:00
|
|
|
if (desc->rendering_mode == DWRITE_RENDERING_MODE1_ALIASED
|
|
|
|
|| desc->aa_mode == DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE)
|
2017-03-30 14:06:59 +02:00
|
|
|
analysis->texture_type = DWRITE_TEXTURE_ALIASED_1x1;
|
|
|
|
else
|
|
|
|
analysis->texture_type = DWRITE_TEXTURE_CLEARTYPE_3x1;
|
|
|
|
|
2015-11-02 14:38:41 +01:00
|
|
|
analysis->flags = 0;
|
2015-07-31 00:30:08 +02:00
|
|
|
analysis->bitmap = NULL;
|
2017-04-03 07:14:08 +02:00
|
|
|
analysis->max_glyph_bitmap_size = 0;
|
2015-07-29 10:59:02 +02:00
|
|
|
SetRectEmpty(&analysis->bounds);
|
2016-04-27 10:19:41 +02:00
|
|
|
analysis->run = *desc->run;
|
2015-07-29 10:57:52 +02:00
|
|
|
IDWriteFontFace_AddRef(analysis->run.fontFace);
|
2019-02-13 08:47:10 +01:00
|
|
|
analysis->glyphs = heap_calloc(desc->run->glyphCount, sizeof(*analysis->glyphs));
|
|
|
|
analysis->origins = heap_calloc(desc->run->glyphCount, sizeof(*analysis->origins));
|
2015-11-02 14:38:42 +01:00
|
|
|
|
2017-04-04 12:13:17 +02:00
|
|
|
if (!analysis->glyphs || !analysis->origins) {
|
2015-07-29 10:57:52 +02:00
|
|
|
heap_free(analysis->glyphs);
|
2017-04-04 12:13:17 +02:00
|
|
|
heap_free(analysis->origins);
|
2015-07-29 10:57:52 +02:00
|
|
|
|
|
|
|
analysis->glyphs = NULL;
|
2017-04-04 12:13:17 +02:00
|
|
|
analysis->origins = NULL;
|
2015-07-29 10:57:52 +02:00
|
|
|
|
|
|
|
IDWriteGlyphRunAnalysis_Release(&analysis->IDWriteGlyphRunAnalysis_iface);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2015-11-02 14:38:41 +01:00
|
|
|
/* check if transform is usable */
|
2016-04-27 10:19:41 +02:00
|
|
|
if (desc->transform && memcmp(desc->transform, &identity, sizeof(*desc->transform))) {
|
|
|
|
analysis->m = *desc->transform;
|
2015-11-02 14:38:41 +01:00
|
|
|
analysis->flags |= RUNANALYSIS_USE_TRANSFORM;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
memset(&analysis->m, 0, sizeof(analysis->m));
|
|
|
|
|
2015-07-29 10:57:52 +02:00
|
|
|
analysis->run.glyphIndices = analysis->glyphs;
|
2015-11-02 14:38:42 +01:00
|
|
|
analysis->run.glyphAdvances = NULL;
|
|
|
|
analysis->run.glyphOffsets = NULL;
|
2015-07-29 10:57:52 +02:00
|
|
|
|
2016-04-27 10:19:41 +02:00
|
|
|
rtl_factor = desc->run->bidiLevel & 1 ? -1.0f : 1.0f;
|
2015-11-03 18:32:22 +01:00
|
|
|
|
2016-04-27 10:19:41 +02:00
|
|
|
memcpy(analysis->glyphs, desc->run->glyphIndices, desc->run->glyphCount*sizeof(*desc->run->glyphIndices));
|
2015-08-04 10:16:10 +02:00
|
|
|
|
2019-01-25 12:56:41 +01:00
|
|
|
fontface = unsafe_impl_from_IDWriteFontFace(desc->run->fontFace);
|
2015-08-04 10:16:10 +02:00
|
|
|
|
2018-08-16 12:34:44 +02:00
|
|
|
origin.x = desc->origin.x;
|
|
|
|
origin.y = desc->origin.y;
|
2019-01-25 12:56:41 +01:00
|
|
|
for (i = 0; i < desc->run->glyphCount; ++i)
|
|
|
|
{
|
|
|
|
float advance;
|
2015-08-04 10:16:10 +02:00
|
|
|
|
2017-04-04 12:13:17 +02:00
|
|
|
/* Use nominal advances if not provided by caller. */
|
|
|
|
if (desc->run->glyphAdvances)
|
2018-08-16 12:34:44 +02:00
|
|
|
advance = rtl_factor * desc->run->glyphAdvances[i];
|
2019-01-25 12:56:41 +01:00
|
|
|
else
|
|
|
|
advance = rtl_factor * fontface_get_scaled_design_advance(fontface, desc->measuring_mode,
|
|
|
|
desc->run->fontEmSize, 1.0f, desc->transform, desc->run->glyphIndices[i], desc->run->isSideways);
|
2015-08-04 10:16:10 +02:00
|
|
|
|
2017-04-04 12:13:17 +02:00
|
|
|
analysis->origins[i] = origin;
|
2019-01-25 12:56:41 +01:00
|
|
|
if (desc->run->bidiLevel & 1)
|
|
|
|
{
|
|
|
|
if (desc->run->isSideways)
|
|
|
|
analysis->origins[i].y += advance;
|
|
|
|
else
|
|
|
|
analysis->origins[i].x += advance;
|
|
|
|
}
|
2015-08-04 10:16:10 +02:00
|
|
|
|
2017-04-04 12:13:17 +02:00
|
|
|
/* Offsets are optional, appled to pre-transformed origin. */
|
|
|
|
if (desc->run->glyphOffsets) {
|
2018-08-16 12:34:44 +02:00
|
|
|
FLOAT advanceoffset = rtl_factor * desc->run->glyphOffsets[i].advanceOffset;
|
|
|
|
FLOAT ascenderoffset = -desc->run->glyphOffsets[i].ascenderOffset;
|
2017-04-04 12:13:17 +02:00
|
|
|
|
|
|
|
if (desc->run->isSideways) {
|
|
|
|
analysis->origins[i].x += ascenderoffset;
|
|
|
|
analysis->origins[i].y += advanceoffset;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
analysis->origins[i].x += advanceoffset;
|
|
|
|
analysis->origins[i].y += ascenderoffset;
|
2015-11-02 14:38:43 +01:00
|
|
|
}
|
2015-10-19 07:43:02 +02:00
|
|
|
}
|
2017-04-04 12:13:17 +02:00
|
|
|
|
|
|
|
if (analysis->flags & RUNANALYSIS_USE_TRANSFORM)
|
|
|
|
transform_point(analysis->origins + i, &analysis->m);
|
|
|
|
|
|
|
|
if (desc->run->isSideways)
|
|
|
|
origin.y += advance;
|
|
|
|
else
|
|
|
|
origin.x += advance;
|
2015-10-19 07:43:02 +02:00
|
|
|
}
|
2015-05-19 14:23:57 +02:00
|
|
|
|
|
|
|
*ret = &analysis->IDWriteGlyphRunAnalysis_iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2015-08-06 18:44:53 +02:00
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
/* IDWriteColorGlyphRunEnumerator1 */
|
|
|
|
static HRESULT WINAPI colorglyphenum_QueryInterface(IDWriteColorGlyphRunEnumerator1 *iface, REFIID riid, void **ppv)
|
2015-08-06 18:44:53 +02:00
|
|
|
{
|
2019-11-29 10:54:25 +01:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), ppv);
|
2015-08-06 18:44:53 +02:00
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteColorGlyphRunEnumerator1) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteColorGlyphRunEnumerator) ||
|
2015-08-06 18:44:53 +02:00
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*ppv = iface;
|
2019-11-29 10:54:25 +01:00
|
|
|
IDWriteColorGlyphRunEnumerator1_AddRef(iface);
|
2015-08-06 18:44:53 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2015-08-06 18:44:53 +02:00
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
static ULONG WINAPI colorglyphenum_AddRef(IDWriteColorGlyphRunEnumerator1 *iface)
|
2015-08-06 18:44:53 +02:00
|
|
|
{
|
2019-11-29 10:54:25 +01:00
|
|
|
struct dwrite_colorglyphenum *glyphenum = impl_from_IDWriteColorGlyphRunEnumerator1(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&glyphenum->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
2015-08-06 18:44:53 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
static ULONG WINAPI colorglyphenum_Release(IDWriteColorGlyphRunEnumerator1 *iface)
|
2015-08-06 18:44:53 +02:00
|
|
|
{
|
2019-11-29 10:54:25 +01:00
|
|
|
struct dwrite_colorglyphenum *glyphenum = impl_from_IDWriteColorGlyphRunEnumerator1(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&glyphenum->refcount);
|
2015-08-06 18:44:53 +02:00
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
2015-08-06 18:44:53 +02:00
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
heap_free(glyphenum->advances);
|
|
|
|
heap_free(glyphenum->color_advances);
|
|
|
|
heap_free(glyphenum->offsets);
|
|
|
|
heap_free(glyphenum->color_offsets);
|
|
|
|
heap_free(glyphenum->glyphindices);
|
|
|
|
heap_free(glyphenum->glyphs);
|
|
|
|
if (glyphenum->colr.context)
|
2019-12-02 13:53:53 +01:00
|
|
|
IDWriteFontFace5_ReleaseFontTable(glyphenum->fontface, glyphenum->colr.context);
|
|
|
|
IDWriteFontFace5_Release(glyphenum->fontface);
|
2019-11-29 10:54:25 +01:00
|
|
|
heap_free(glyphenum);
|
2016-02-08 10:31:35 +01:00
|
|
|
}
|
2015-08-06 18:44:53 +02:00
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
return refcount;
|
2015-08-06 18:44:53 +02:00
|
|
|
}
|
|
|
|
|
2016-02-08 10:31:35 +01:00
|
|
|
static FLOAT get_glyph_origin(const struct dwrite_colorglyphenum *glyphenum, UINT32 g)
|
|
|
|
{
|
|
|
|
BOOL is_rtl = glyphenum->run.bidiLevel & 1;
|
|
|
|
FLOAT origin = 0.0f;
|
|
|
|
|
|
|
|
if (g == 0)
|
|
|
|
return 0.0f;
|
|
|
|
|
|
|
|
while (g--)
|
|
|
|
origin += is_rtl ? -glyphenum->advances[g] : glyphenum->advances[g];
|
|
|
|
return origin;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL colorglyphenum_build_color_run(struct dwrite_colorglyphenum *glyphenum)
|
|
|
|
{
|
2019-11-29 10:54:25 +01:00
|
|
|
DWRITE_COLOR_GLYPH_RUN1 *colorrun = &glyphenum->colorrun;
|
2016-02-08 10:31:35 +01:00
|
|
|
FLOAT advance_adj = 0.0f;
|
|
|
|
BOOL got_palette_index;
|
|
|
|
UINT32 g;
|
|
|
|
|
|
|
|
/* start with regular glyphs */
|
|
|
|
if (glyphenum->current_layer == 0 && glyphenum->has_regular_glyphs) {
|
|
|
|
UINT32 first_glyph = 0;
|
|
|
|
|
|
|
|
for (g = 0; g < glyphenum->run.glyphCount; g++) {
|
|
|
|
if (glyphenum->glyphs[g].num_layers == 0) {
|
|
|
|
glyphenum->glyphindices[g] = glyphenum->glyphs[g].glyph;
|
|
|
|
first_glyph = min(first_glyph, g);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
glyphenum->glyphindices[g] = 1;
|
|
|
|
glyphenum->color_advances[g] = glyphenum->advances[g];
|
2016-02-09 15:11:19 +01:00
|
|
|
if (glyphenum->color_offsets)
|
|
|
|
glyphenum->color_offsets[g] = glyphenum->offsets[g];
|
2016-02-08 10:31:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
colorrun->baselineOriginX = glyphenum->origin_x + get_glyph_origin(glyphenum, first_glyph);
|
|
|
|
colorrun->baselineOriginY = glyphenum->origin_y;
|
|
|
|
colorrun->glyphRun.glyphCount = glyphenum->run.glyphCount;
|
|
|
|
colorrun->paletteIndex = 0xffff;
|
|
|
|
memset(&colorrun->runColor, 0, sizeof(colorrun->runColor));
|
|
|
|
glyphenum->has_regular_glyphs = FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
colorrun->glyphRun.glyphCount = 0;
|
|
|
|
got_palette_index = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
advance_adj = 0.0f;
|
|
|
|
for (g = 0; g < glyphenum->run.glyphCount; g++) {
|
|
|
|
|
|
|
|
glyphenum->glyphindices[g] = 1;
|
|
|
|
|
|
|
|
/* all glyph layers were returned */
|
|
|
|
if (glyphenum->glyphs[g].layer == glyphenum->glyphs[g].num_layers) {
|
|
|
|
advance_adj += glyphenum->advances[g];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (glyphenum->current_layer == glyphenum->glyphs[g].layer && (!got_palette_index || colorrun->paletteIndex == glyphenum->glyphs[g].palette_index)) {
|
|
|
|
UINT32 index = colorrun->glyphRun.glyphCount;
|
|
|
|
if (!got_palette_index) {
|
|
|
|
colorrun->paletteIndex = glyphenum->glyphs[g].palette_index;
|
|
|
|
/* use foreground color or request one from the font */
|
2016-02-20 08:51:04 +01:00
|
|
|
memset(&colorrun->runColor, 0, sizeof(colorrun->runColor));
|
2019-12-02 13:53:53 +01:00
|
|
|
if (colorrun->paletteIndex != 0xffff)
|
|
|
|
{
|
|
|
|
HRESULT hr = IDWriteFontFace5_GetPaletteEntries(glyphenum->fontface, glyphenum->palette,
|
|
|
|
colorrun->paletteIndex, 1, &colorrun->runColor);
|
2016-02-20 08:51:04 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
WARN("failed to get palette entry, fontface %p, palette %u, index %u, 0x%08x\n", glyphenum->fontface,
|
|
|
|
glyphenum->palette, colorrun->paletteIndex, hr);
|
|
|
|
}
|
2016-02-08 10:31:35 +01:00
|
|
|
/* found a glyph position new color run starts from, origin is "original origin + distance to this glyph" */
|
|
|
|
colorrun->baselineOriginX = glyphenum->origin_x + get_glyph_origin(glyphenum, g);
|
|
|
|
colorrun->baselineOriginY = glyphenum->origin_y;
|
|
|
|
glyphenum->color_advances[index] = glyphenum->advances[g];
|
|
|
|
got_palette_index = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
glyphenum->glyphindices[index] = glyphenum->glyphs[g].glyph;
|
2016-02-09 15:11:19 +01:00
|
|
|
/* offsets are relative to glyph origin, nothing to fix up */
|
|
|
|
if (glyphenum->color_offsets)
|
|
|
|
glyphenum->color_offsets[index] = glyphenum->offsets[g];
|
2019-01-29 08:06:42 +01:00
|
|
|
opentype_colr_next_glyph(&glyphenum->colr, glyphenum->glyphs + g);
|
2016-02-08 10:31:35 +01:00
|
|
|
if (index)
|
|
|
|
glyphenum->color_advances[index-1] += advance_adj;
|
|
|
|
colorrun->glyphRun.glyphCount++;
|
|
|
|
advance_adj = 0.0f;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
advance_adj += glyphenum->advances[g];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reset last advance */
|
|
|
|
if (colorrun->glyphRun.glyphCount)
|
|
|
|
glyphenum->color_advances[colorrun->glyphRun.glyphCount-1] = 0.0f;
|
|
|
|
|
|
|
|
return colorrun->glyphRun.glyphCount > 0;
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
static HRESULT WINAPI colorglyphenum_MoveNext(IDWriteColorGlyphRunEnumerator1 *iface, BOOL *has_run)
|
2015-08-06 18:44:53 +02:00
|
|
|
{
|
2019-11-29 10:54:25 +01:00
|
|
|
struct dwrite_colorglyphenum *glyphenum = impl_from_IDWriteColorGlyphRunEnumerator1(iface);
|
2016-02-08 10:31:35 +01:00
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
TRACE("%p, %p.\n", iface, has_run);
|
2016-02-08 10:31:35 +01:00
|
|
|
|
|
|
|
*has_run = FALSE;
|
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
glyphenum->colorrun.glyphRun.glyphCount = 0;
|
|
|
|
while (glyphenum->current_layer < glyphenum->max_layer_num)
|
|
|
|
{
|
|
|
|
if (colorglyphenum_build_color_run(glyphenum))
|
2016-02-08 10:31:35 +01:00
|
|
|
break;
|
|
|
|
else
|
2019-11-29 10:54:25 +01:00
|
|
|
glyphenum->current_layer++;
|
2016-02-08 10:31:35 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
*has_run = glyphenum->colorrun.glyphRun.glyphCount > 0;
|
2016-02-08 10:31:35 +01:00
|
|
|
|
|
|
|
return S_OK;
|
2015-08-06 18:44:53 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
static HRESULT colorglyphenum_get_current_run(const struct dwrite_colorglyphenum *glyphenum,
|
|
|
|
DWRITE_COLOR_GLYPH_RUN1 const **run)
|
2015-08-06 18:44:53 +02:00
|
|
|
{
|
2019-11-29 10:54:25 +01:00
|
|
|
if (glyphenum->colorrun.glyphRun.glyphCount == 0)
|
|
|
|
{
|
2016-02-08 10:31:35 +01:00
|
|
|
*run = NULL;
|
|
|
|
return E_NOT_VALID_STATE;
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
*run = &glyphenum->colorrun;
|
2016-02-08 10:31:35 +01:00
|
|
|
return S_OK;
|
2015-08-06 18:44:53 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
static HRESULT WINAPI colorglyphenum_GetCurrentRun(IDWriteColorGlyphRunEnumerator1 *iface,
|
|
|
|
DWRITE_COLOR_GLYPH_RUN const **run)
|
|
|
|
{
|
|
|
|
struct dwrite_colorglyphenum *glyphenum = impl_from_IDWriteColorGlyphRunEnumerator1(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, run);
|
|
|
|
|
|
|
|
return colorglyphenum_get_current_run(glyphenum, (DWRITE_COLOR_GLYPH_RUN1 const **)run);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI colorglyphenum1_GetCurrentRun(IDWriteColorGlyphRunEnumerator1 *iface,
|
|
|
|
DWRITE_COLOR_GLYPH_RUN1 const **run)
|
|
|
|
{
|
|
|
|
struct dwrite_colorglyphenum *glyphenum = impl_from_IDWriteColorGlyphRunEnumerator1(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, run);
|
|
|
|
|
|
|
|
return colorglyphenum_get_current_run(glyphenum, run);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteColorGlyphRunEnumerator1Vtbl colorglyphenumvtbl =
|
|
|
|
{
|
2015-08-06 18:44:53 +02:00
|
|
|
colorglyphenum_QueryInterface,
|
|
|
|
colorglyphenum_AddRef,
|
|
|
|
colorglyphenum_Release,
|
|
|
|
colorglyphenum_MoveNext,
|
2019-11-29 10:54:25 +01:00
|
|
|
colorglyphenum_GetCurrentRun,
|
|
|
|
colorglyphenum1_GetCurrentRun,
|
2015-08-06 18:44:53 +02:00
|
|
|
};
|
|
|
|
|
2019-01-25 12:56:41 +01:00
|
|
|
HRESULT create_colorglyphenum(float originX, float originY, const DWRITE_GLYPH_RUN *run,
|
|
|
|
const DWRITE_GLYPH_RUN_DESCRIPTION *rundescr, DWRITE_MEASURING_MODE measuring_mode,
|
|
|
|
const DWRITE_MATRIX *transform, unsigned int palette, IDWriteColorGlyphRunEnumerator **ret)
|
2015-08-06 18:44:53 +02:00
|
|
|
{
|
|
|
|
struct dwrite_colorglyphenum *colorglyphenum;
|
2016-02-08 10:31:35 +01:00
|
|
|
BOOL colorfont, has_colored_glyph;
|
2019-01-25 12:56:41 +01:00
|
|
|
struct dwrite_fontface *fontface;
|
|
|
|
unsigned int i;
|
2015-08-06 18:44:53 +02:00
|
|
|
|
|
|
|
*ret = NULL;
|
2015-10-29 08:20:54 +01:00
|
|
|
|
2019-01-25 12:56:41 +01:00
|
|
|
fontface = unsafe_impl_from_IDWriteFontFace(run->fontFace);
|
2015-10-29 08:20:54 +01:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
colorfont = IDWriteFontFace5_IsColorFont(&fontface->IDWriteFontFace5_iface) &&
|
|
|
|
IDWriteFontFace5_GetColorPaletteCount(&fontface->IDWriteFontFace5_iface) > palette;
|
2019-01-25 12:56:41 +01:00
|
|
|
if (!colorfont)
|
|
|
|
return DWRITE_E_NOCOLOR;
|
2015-10-29 08:20:54 +01:00
|
|
|
|
2016-02-08 10:31:35 +01:00
|
|
|
colorglyphenum = heap_alloc_zero(sizeof(*colorglyphenum));
|
2019-01-25 12:56:41 +01:00
|
|
|
if (!colorglyphenum)
|
|
|
|
return E_OUTOFMEMORY;
|
2015-08-06 18:44:53 +02:00
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
colorglyphenum->IDWriteColorGlyphRunEnumerator1_iface.lpVtbl = &colorglyphenumvtbl;
|
|
|
|
colorglyphenum->refcount = 1;
|
2016-02-08 10:31:35 +01:00
|
|
|
colorglyphenum->origin_x = originX;
|
|
|
|
colorglyphenum->origin_y = originY;
|
2019-12-02 13:53:53 +01:00
|
|
|
colorglyphenum->fontface = &fontface->IDWriteFontFace5_iface;
|
|
|
|
IDWriteFontFace5_AddRef(colorglyphenum->fontface);
|
2016-02-08 10:31:35 +01:00
|
|
|
colorglyphenum->glyphs = NULL;
|
|
|
|
colorglyphenum->run = *run;
|
|
|
|
colorglyphenum->run.glyphIndices = NULL;
|
|
|
|
colorglyphenum->run.glyphAdvances = NULL;
|
|
|
|
colorglyphenum->run.glyphOffsets = NULL;
|
|
|
|
colorglyphenum->palette = palette;
|
|
|
|
memset(&colorglyphenum->colr, 0, sizeof(colorglyphenum->colr));
|
|
|
|
colorglyphenum->colr.exists = TRUE;
|
2019-12-02 13:53:53 +01:00
|
|
|
get_fontface_table(&fontface->IDWriteFontFace5_iface, MS_COLR_TAG, &colorglyphenum->colr);
|
2016-02-08 10:31:35 +01:00
|
|
|
colorglyphenum->current_layer = 0;
|
|
|
|
colorglyphenum->max_layer_num = 0;
|
|
|
|
|
|
|
|
colorglyphenum->glyphs = heap_alloc_zero(run->glyphCount * sizeof(*colorglyphenum->glyphs));
|
|
|
|
|
|
|
|
has_colored_glyph = FALSE;
|
|
|
|
colorglyphenum->has_regular_glyphs = FALSE;
|
|
|
|
for (i = 0; i < run->glyphCount; i++) {
|
2019-01-29 08:06:42 +01:00
|
|
|
if (opentype_get_colr_glyph(&colorglyphenum->colr, run->glyphIndices[i], colorglyphenum->glyphs + i) == S_OK) {
|
2016-02-08 10:31:35 +01:00
|
|
|
colorglyphenum->max_layer_num = max(colorglyphenum->max_layer_num, colorglyphenum->glyphs[i].num_layers);
|
|
|
|
has_colored_glyph = TRUE;
|
|
|
|
}
|
|
|
|
if (colorglyphenum->glyphs[i].num_layers == 0)
|
|
|
|
colorglyphenum->has_regular_glyphs = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* It's acceptable to have a subset of glyphs mapped to color layers, for regular runs client
|
|
|
|
is supposed to proceed normally, like if font had no color info at all. */
|
|
|
|
if (!has_colored_glyph) {
|
2019-11-29 10:54:25 +01:00
|
|
|
IDWriteColorGlyphRunEnumerator1_Release(&colorglyphenum->IDWriteColorGlyphRunEnumerator1_iface);
|
2016-02-08 10:31:35 +01:00
|
|
|
return DWRITE_E_NOCOLOR;
|
|
|
|
}
|
|
|
|
|
2019-02-13 08:47:10 +01:00
|
|
|
colorglyphenum->advances = heap_calloc(run->glyphCount, sizeof(*colorglyphenum->advances));
|
|
|
|
colorglyphenum->color_advances = heap_calloc(run->glyphCount, sizeof(*colorglyphenum->color_advances));
|
|
|
|
colorglyphenum->glyphindices = heap_calloc(run->glyphCount, sizeof(*colorglyphenum->glyphindices));
|
2016-02-09 15:11:19 +01:00
|
|
|
if (run->glyphOffsets) {
|
2019-02-13 08:47:10 +01:00
|
|
|
colorglyphenum->offsets = heap_calloc(run->glyphCount, sizeof(*colorglyphenum->offsets));
|
|
|
|
colorglyphenum->color_offsets = heap_calloc(run->glyphCount, sizeof(*colorglyphenum->color_offsets));
|
2016-02-09 15:11:19 +01:00
|
|
|
memcpy(colorglyphenum->offsets, run->glyphOffsets, run->glyphCount * sizeof(*run->glyphOffsets));
|
|
|
|
}
|
2016-02-08 10:31:35 +01:00
|
|
|
|
2019-01-25 12:56:41 +01:00
|
|
|
colorglyphenum->colorrun.glyphRun.fontFace = run->fontFace;
|
2016-11-05 22:12:38 +01:00
|
|
|
colorglyphenum->colorrun.glyphRun.fontEmSize = run->fontEmSize;
|
2016-02-08 10:31:35 +01:00
|
|
|
colorglyphenum->colorrun.glyphRun.glyphIndices = colorglyphenum->glyphindices;
|
|
|
|
colorglyphenum->colorrun.glyphRun.glyphAdvances = colorglyphenum->color_advances;
|
2016-02-09 15:11:19 +01:00
|
|
|
colorglyphenum->colorrun.glyphRun.glyphOffsets = colorglyphenum->color_offsets;
|
2016-02-08 10:31:35 +01:00
|
|
|
colorglyphenum->colorrun.glyphRunDescription = NULL; /* FIXME */
|
2019-11-29 10:54:25 +01:00
|
|
|
colorglyphenum->colorrun.measuringMode = measuring_mode;
|
|
|
|
colorglyphenum->colorrun.glyphImageFormat = DWRITE_GLYPH_IMAGE_FORMATS_NONE; /* FIXME */
|
2016-02-08 10:31:35 +01:00
|
|
|
|
|
|
|
if (run->glyphAdvances)
|
|
|
|
memcpy(colorglyphenum->advances, run->glyphAdvances, run->glyphCount * sizeof(FLOAT));
|
2019-01-25 12:56:41 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < run->glyphCount; ++i)
|
|
|
|
colorglyphenum->advances[i] = fontface_get_scaled_design_advance(fontface, measuring_mode,
|
|
|
|
run->fontEmSize, 1.0f, transform, run->glyphIndices[i], run->isSideways);
|
2016-02-08 10:31:35 +01:00
|
|
|
}
|
2015-08-06 18:44:53 +02:00
|
|
|
|
2019-11-29 10:54:25 +01:00
|
|
|
*ret = (IDWriteColorGlyphRunEnumerator *)&colorglyphenum->IDWriteColorGlyphRunEnumerator1_iface;
|
2016-02-08 10:31:35 +01:00
|
|
|
|
2019-01-25 12:56:41 +01:00
|
|
|
return S_OK;
|
2015-08-06 18:44:53 +02:00
|
|
|
}
|
2016-04-20 09:51:01 +02:00
|
|
|
|
|
|
|
/* IDWriteFontFaceReference */
|
2019-10-09 10:04:54 +02:00
|
|
|
static HRESULT WINAPI fontfacereference_QueryInterface(IDWriteFontFaceReference1 *iface, REFIID riid, void **obj)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteFontFaceReference1) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFontFaceReference) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
2016-04-20 09:51:01 +02:00
|
|
|
*obj = iface;
|
2019-10-09 10:04:54 +02:00
|
|
|
IDWriteFontFaceReference1_AddRef(iface);
|
2016-04-20 09:51:01 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2016-04-20 09:51:01 +02:00
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static ULONG WINAPI fontfacereference_AddRef(IDWriteFontFaceReference1 *iface)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
struct dwrite_fontfacereference *reference = impl_from_IDWriteFontFaceReference1(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&reference->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
2016-04-20 09:51:01 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static ULONG WINAPI fontfacereference_Release(IDWriteFontFaceReference1 *iface)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
struct dwrite_fontfacereference *reference = impl_from_IDWriteFontFaceReference1(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&reference->refcount);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
IDWriteFontFile_Release(reference->file);
|
2019-12-05 09:56:02 +01:00
|
|
|
IDWriteFactory7_Release(reference->factory);
|
2019-12-05 09:56:01 +01:00
|
|
|
heap_free(reference->axis_values);
|
2019-10-09 10:04:54 +02:00
|
|
|
heap_free(reference);
|
2016-04-20 09:51:01 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
return refcount;
|
2016-04-20 09:51:01 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static HRESULT WINAPI fontfacereference_CreateFontFace(IDWriteFontFaceReference1 *iface, IDWriteFontFace3 **fontface)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
struct dwrite_fontfacereference *reference = impl_from_IDWriteFontFaceReference1(iface);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
TRACE("%p, %p.\n", iface, fontface);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
return IDWriteFontFaceReference1_CreateFontFaceWithSimulations(iface, reference->simulations, fontface);
|
2016-04-20 09:51:01 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static HRESULT WINAPI fontfacereference_CreateFontFaceWithSimulations(IDWriteFontFaceReference1 *iface,
|
2016-04-20 09:51:01 +02:00
|
|
|
DWRITE_FONT_SIMULATIONS simulations, IDWriteFontFace3 **ret)
|
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
struct dwrite_fontfacereference *reference = impl_from_IDWriteFontFaceReference1(iface);
|
2016-04-20 09:51:01 +02:00
|
|
|
DWRITE_FONT_FILE_TYPE file_type;
|
|
|
|
DWRITE_FONT_FACE_TYPE face_type;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
BOOL is_supported;
|
|
|
|
UINT32 face_num;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
TRACE("%p, %#x, %p.\n", iface, simulations, ret);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
hr = IDWriteFontFile_Analyze(reference->file, &is_supported, &file_type, &face_type, &face_num);
|
2016-04-20 09:51:01 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2019-12-05 09:56:02 +01:00
|
|
|
hr = IDWriteFactory7_CreateFontFace(reference->factory, face_type, 1, &reference->file, reference->index,
|
2019-10-09 10:04:54 +02:00
|
|
|
simulations, &fontface);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2017-04-11 13:21:32 +02:00
|
|
|
hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace3, (void **)ret);
|
2016-04-20 09:51:01 +02:00
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static BOOL WINAPI fontfacereference_Equals(IDWriteFontFaceReference1 *iface, IDWriteFontFaceReference *ref)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
struct dwrite_fontfacereference *reference = impl_from_IDWriteFontFaceReference1(iface);
|
2019-12-09 09:09:36 +01:00
|
|
|
struct dwrite_fontfacereference *other = unsafe_impl_from_IDWriteFontFaceReference(ref);
|
2016-04-20 20:38:17 +02:00
|
|
|
BOOL ret;
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
TRACE("%p, %p.\n", iface, ref);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-12-09 09:09:36 +01:00
|
|
|
ret = is_same_fontfile(reference->file, other->file) && reference->index == other->index &&
|
|
|
|
reference->simulations == other->simulations;
|
|
|
|
if (reference->axis_values_count)
|
|
|
|
{
|
|
|
|
ret &= reference->axis_values_count == other->axis_values_count &&
|
|
|
|
!memcmp(reference->axis_values, other->axis_values, reference->axis_values_count * sizeof(*reference->axis_values));
|
|
|
|
}
|
2016-04-20 20:38:17 +02:00
|
|
|
|
|
|
|
return ret;
|
2016-04-20 09:51:01 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static UINT32 WINAPI fontfacereference_GetFontFaceIndex(IDWriteFontFaceReference1 *iface)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
struct dwrite_fontfacereference *reference = impl_from_IDWriteFontFaceReference1(iface);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
TRACE("%p.\n", iface);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
return reference->index;
|
2016-04-20 09:51:01 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static DWRITE_FONT_SIMULATIONS WINAPI fontfacereference_GetSimulations(IDWriteFontFaceReference1 *iface)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
struct dwrite_fontfacereference *reference = impl_from_IDWriteFontFaceReference1(iface);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
TRACE("%p.\n", iface);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
return reference->simulations;
|
2016-04-20 09:51:01 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static HRESULT WINAPI fontfacereference_GetFontFile(IDWriteFontFaceReference1 *iface, IDWriteFontFile **file)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
struct dwrite_fontfacereference *reference = impl_from_IDWriteFontFaceReference1(iface);
|
2016-04-20 09:51:01 +02:00
|
|
|
IDWriteFontFileLoader *loader;
|
|
|
|
const void *key;
|
|
|
|
UINT32 key_size;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
TRACE("%p, %p.\n", iface, file);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
hr = IDWriteFontFile_GetReferenceKey(reference->file, &key, &key_size);
|
2016-04-20 09:51:01 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
hr = IDWriteFontFile_GetLoader(reference->file, &loader);
|
2016-04-20 09:51:01 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2019-12-05 09:56:02 +01:00
|
|
|
hr = IDWriteFactory7_CreateCustomFontFileReference(reference->factory, key, key_size, loader, file);
|
2016-04-20 09:51:01 +02:00
|
|
|
IDWriteFontFileLoader_Release(loader);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static UINT64 WINAPI fontfacereference_GetLocalFileSize(IDWriteFontFaceReference1 *iface)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
FIXME("%p.\n", iface);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static UINT64 WINAPI fontfacereference_GetFileSize(IDWriteFontFaceReference1 *iface)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
FIXME("%p.\n", iface);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static HRESULT WINAPI fontfacereference_GetFileTime(IDWriteFontFaceReference1 *iface, FILETIME *writetime)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
FIXME("%p, %p.\n", iface, writetime);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static DWRITE_LOCALITY WINAPI fontfacereference_GetLocality(IDWriteFontFaceReference1 *iface)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
FIXME("%p.\n", iface);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
|
|
|
return DWRITE_LOCALITY_LOCAL;
|
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static HRESULT WINAPI fontfacereference_EnqueueFontDownloadRequest(IDWriteFontFaceReference1 *iface)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
FIXME("%p.\n", iface);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static HRESULT WINAPI fontfacereference_EnqueueCharacterDownloadRequest(IDWriteFontFaceReference1 *iface,
|
|
|
|
WCHAR const *chars, UINT32 count)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
FIXME("%p, %s, %u.\n", iface, debugstr_wn(chars, count), count);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI fontfacereference_EnqueueGlyphDownloadRequest(IDWriteFontFaceReference1 *iface,
|
|
|
|
UINT16 const *glyphs, UINT32 count)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p, %u.\n", iface, glyphs, count);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static HRESULT WINAPI fontfacereference_EnqueueFileFragmentDownloadRequest(IDWriteFontFaceReference1 *iface,
|
|
|
|
UINT64 offset, UINT64 size)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
FIXME("%p, 0x%s, 0x%s.\n", iface, wine_dbgstr_longlong(offset), wine_dbgstr_longlong(size));
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI fontfacereference1_CreateFontFace(IDWriteFontFaceReference1 *iface, IDWriteFontFace5 **fontface)
|
|
|
|
{
|
2020-02-11 10:24:59 +01:00
|
|
|
struct dwrite_fontfacereference *reference = impl_from_IDWriteFontFaceReference1(iface);
|
|
|
|
IDWriteFontFace3 *fontface3;
|
|
|
|
HRESULT hr;
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2020-02-11 10:24:59 +01:00
|
|
|
TRACE("%p, %p.\n", iface, fontface);
|
|
|
|
|
|
|
|
/* FIXME: created instance should likely respect given axis. */
|
|
|
|
if (SUCCEEDED(hr = IDWriteFontFaceReference1_CreateFontFaceWithSimulations(iface, reference->simulations,
|
|
|
|
&fontface3)))
|
|
|
|
{
|
|
|
|
hr = IDWriteFontFace3_QueryInterface(fontface3, &IID_IDWriteFontFace5, (void **)fontface);
|
|
|
|
IDWriteFontFace3_Release(fontface3);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2016-04-20 09:51:01 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static UINT32 WINAPI fontfacereference1_GetFontAxisValueCount(IDWriteFontFaceReference1 *iface)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-12-05 09:56:01 +01:00
|
|
|
struct dwrite_fontfacereference *reference = impl_from_IDWriteFontFaceReference1(iface);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-12-05 09:56:01 +01:00
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return reference->axis_values_count;
|
2019-10-09 10:04:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI fontfacereference1_GetFontAxisValues(IDWriteFontFaceReference1 *iface,
|
|
|
|
DWRITE_FONT_AXIS_VALUE *axis_values, UINT32 value_count)
|
|
|
|
{
|
2019-12-09 09:09:37 +01:00
|
|
|
struct dwrite_fontfacereference *reference = impl_from_IDWriteFontFaceReference1(iface);
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-12-09 09:09:37 +01:00
|
|
|
TRACE("%p, %p, %u.\n", iface, axis_values, value_count);
|
|
|
|
|
|
|
|
if (value_count < reference->axis_values_count)
|
|
|
|
return E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
|
|
|
|
memcpy(axis_values, reference->axis_values, value_count * sizeof(*axis_values));
|
|
|
|
|
|
|
|
return S_OK;
|
2016-04-20 09:51:01 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
static const IDWriteFontFaceReference1Vtbl fontfacereferencevtbl =
|
|
|
|
{
|
2016-04-20 09:51:01 +02:00
|
|
|
fontfacereference_QueryInterface,
|
|
|
|
fontfacereference_AddRef,
|
|
|
|
fontfacereference_Release,
|
|
|
|
fontfacereference_CreateFontFace,
|
|
|
|
fontfacereference_CreateFontFaceWithSimulations,
|
|
|
|
fontfacereference_Equals,
|
|
|
|
fontfacereference_GetFontFaceIndex,
|
|
|
|
fontfacereference_GetSimulations,
|
|
|
|
fontfacereference_GetFontFile,
|
|
|
|
fontfacereference_GetLocalFileSize,
|
|
|
|
fontfacereference_GetFileSize,
|
|
|
|
fontfacereference_GetFileTime,
|
|
|
|
fontfacereference_GetLocality,
|
|
|
|
fontfacereference_EnqueueFontDownloadRequest,
|
|
|
|
fontfacereference_EnqueueCharacterDownloadRequest,
|
|
|
|
fontfacereference_EnqueueGlyphDownloadRequest,
|
2019-10-09 10:04:54 +02:00
|
|
|
fontfacereference_EnqueueFileFragmentDownloadRequest,
|
|
|
|
fontfacereference1_CreateFontFace,
|
|
|
|
fontfacereference1_GetFontAxisValueCount,
|
|
|
|
fontfacereference1_GetFontAxisValues,
|
2016-04-20 09:51:01 +02:00
|
|
|
};
|
|
|
|
|
2019-12-05 09:56:02 +01:00
|
|
|
HRESULT create_fontfacereference(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 index,
|
2019-12-05 09:56:01 +01:00
|
|
|
DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 axis_values_count,
|
|
|
|
IDWriteFontFaceReference1 **ret)
|
2016-04-20 09:51:01 +02:00
|
|
|
{
|
2019-10-09 10:04:54 +02:00
|
|
|
struct dwrite_fontfacereference *object;
|
2016-04-20 09:51:01 +02:00
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
|
2016-05-05 13:35:24 +02:00
|
|
|
if (!is_simulation_valid(simulations))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-12-05 09:56:01 +01:00
|
|
|
object = heap_alloc_zero(sizeof(*object));
|
2019-10-09 10:04:54 +02:00
|
|
|
if (!object)
|
2016-04-20 09:51:01 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2019-10-09 10:04:54 +02:00
|
|
|
object->IDWriteFontFaceReference1_iface.lpVtbl = &fontfacereferencevtbl;
|
|
|
|
object->refcount = 1;
|
|
|
|
|
|
|
|
object->factory = factory;
|
2019-12-05 09:56:02 +01:00
|
|
|
IDWriteFactory7_AddRef(object->factory);
|
2019-10-09 10:04:54 +02:00
|
|
|
object->file = file;
|
|
|
|
IDWriteFontFile_AddRef(object->file);
|
|
|
|
object->index = index;
|
|
|
|
object->simulations = simulations;
|
2019-12-05 09:56:01 +01:00
|
|
|
if (axis_values_count)
|
|
|
|
{
|
|
|
|
if (!(object->axis_values = heap_alloc(axis_values_count * sizeof(*axis_values))))
|
|
|
|
{
|
|
|
|
IDWriteFontFaceReference1_Release(&object->IDWriteFontFaceReference1_iface);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
memcpy(object->axis_values, axis_values, axis_values_count * sizeof(*axis_values));
|
|
|
|
object->axis_values_count = axis_values_count;
|
|
|
|
}
|
2016-04-20 09:51:01 +02:00
|
|
|
|
2019-12-05 09:56:01 +01:00
|
|
|
*ret = &object->IDWriteFontFaceReference1_iface;
|
2016-04-20 09:51:01 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2017-10-06 11:45:20 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI inmemoryfilestream_QueryInterface(IDWriteFontFileStream *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct dwrite_inmemory_filestream *stream = inmemory_impl_from_IDWriteFontFileStream(iface);
|
|
|
|
|
|
|
|
TRACE_(dwrite_file)("(%p)->(%s, %p)\n", stream, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IDWriteFontFileStream) || IsEqualIID(riid, &IID_IUnknown)) {
|
|
|
|
*obj = iface;
|
|
|
|
IDWriteFontFileStream_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI inmemoryfilestream_AddRef(IDWriteFontFileStream *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_inmemory_filestream *stream = inmemory_impl_from_IDWriteFontFileStream(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&stream->ref);
|
|
|
|
TRACE_(dwrite_file)("(%p)->(%u)\n", stream, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI inmemoryfilestream_Release(IDWriteFontFileStream *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_inmemory_filestream *stream = inmemory_impl_from_IDWriteFontFileStream(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&stream->ref);
|
|
|
|
|
|
|
|
TRACE_(dwrite_file)("(%p)->(%u)\n", stream, ref);
|
|
|
|
|
|
|
|
if (!ref) {
|
|
|
|
release_inmemory_stream(stream->data);
|
|
|
|
heap_free(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI inmemoryfilestream_ReadFileFragment(IDWriteFontFileStream *iface, void const **fragment_start,
|
|
|
|
UINT64 offset, UINT64 fragment_size, void **fragment_context)
|
|
|
|
{
|
|
|
|
struct dwrite_inmemory_filestream *stream = inmemory_impl_from_IDWriteFontFileStream(iface);
|
|
|
|
|
|
|
|
TRACE_(dwrite_file)("(%p)->(%p, 0x%s, 0x%s, %p)\n", stream, fragment_start,
|
|
|
|
wine_dbgstr_longlong(offset), wine_dbgstr_longlong(fragment_size), fragment_context);
|
|
|
|
|
|
|
|
*fragment_context = NULL;
|
|
|
|
|
|
|
|
if ((offset >= stream->data->size - 1) || (fragment_size > stream->data->size - offset)) {
|
|
|
|
*fragment_start = NULL;
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*fragment_start = (char *)stream->data->data + offset;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI inmemoryfilestream_ReleaseFileFragment(IDWriteFontFileStream *iface, void *fragment_context)
|
|
|
|
{
|
|
|
|
struct dwrite_inmemory_filestream *stream = inmemory_impl_from_IDWriteFontFileStream(iface);
|
|
|
|
|
|
|
|
TRACE_(dwrite_file)("(%p)->(%p)\n", stream, fragment_context);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI inmemoryfilestream_GetFileSize(IDWriteFontFileStream *iface, UINT64 *size)
|
|
|
|
{
|
|
|
|
struct dwrite_inmemory_filestream *stream = inmemory_impl_from_IDWriteFontFileStream(iface);
|
|
|
|
|
|
|
|
TRACE_(dwrite_file)("(%p)->(%p)\n", stream, size);
|
|
|
|
|
|
|
|
*size = stream->data->size;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI inmemoryfilestream_GetLastWriteTime(IDWriteFontFileStream *iface, UINT64 *last_writetime)
|
|
|
|
{
|
|
|
|
struct dwrite_inmemory_filestream *stream = inmemory_impl_from_IDWriteFontFileStream(iface);
|
|
|
|
|
|
|
|
TRACE_(dwrite_file)("(%p)->(%p)\n", stream, last_writetime);
|
|
|
|
|
|
|
|
*last_writetime = 0;
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteFontFileStreamVtbl inmemoryfilestreamvtbl = {
|
|
|
|
inmemoryfilestream_QueryInterface,
|
|
|
|
inmemoryfilestream_AddRef,
|
|
|
|
inmemoryfilestream_Release,
|
|
|
|
inmemoryfilestream_ReadFileFragment,
|
|
|
|
inmemoryfilestream_ReleaseFileFragment,
|
|
|
|
inmemoryfilestream_GetFileSize,
|
|
|
|
inmemoryfilestream_GetLastWriteTime,
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI inmemoryfontfileloader_QueryInterface(IDWriteInMemoryFontFileLoader *iface,
|
|
|
|
REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct dwrite_inmemory_fileloader *loader = impl_from_IDWriteInMemoryFontFileLoader(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s, %p)\n", loader, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IDWriteInMemoryFontFileLoader) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFontFileLoader) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
IDWriteInMemoryFontFileLoader_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI inmemoryfontfileloader_AddRef(IDWriteInMemoryFontFileLoader *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_inmemory_fileloader *loader = impl_from_IDWriteInMemoryFontFileLoader(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&loader->ref);
|
|
|
|
TRACE("(%p)->(%u)\n", loader, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI inmemoryfontfileloader_Release(IDWriteInMemoryFontFileLoader *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_inmemory_fileloader *loader = impl_from_IDWriteInMemoryFontFileLoader(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&loader->ref);
|
2019-05-14 12:27:25 +02:00
|
|
|
size_t i;
|
2017-10-06 11:45:20 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%u)\n", loader, ref);
|
|
|
|
|
|
|
|
if (!ref) {
|
2019-05-14 12:27:25 +02:00
|
|
|
for (i = 0; i < loader->count; ++i)
|
2017-10-06 11:45:20 +02:00
|
|
|
release_inmemory_stream(loader->streams[i]);
|
|
|
|
heap_free(loader->streams);
|
|
|
|
heap_free(loader);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI inmemoryfontfileloader_CreateStreamFromKey(IDWriteInMemoryFontFileLoader *iface,
|
|
|
|
void const *key, UINT32 key_size, IDWriteFontFileStream **ret)
|
|
|
|
{
|
|
|
|
struct dwrite_inmemory_fileloader *loader = impl_from_IDWriteInMemoryFontFileLoader(iface);
|
|
|
|
struct dwrite_inmemory_filestream *stream;
|
|
|
|
DWORD index;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p, %u, %p)\n", loader, key, key_size, ret);
|
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
|
|
|
|
if (key_size != sizeof(DWORD))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
index = *(DWORD *)key;
|
|
|
|
|
2019-05-14 12:27:25 +02:00
|
|
|
if (index >= loader->count)
|
2017-10-06 11:45:20 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (!(stream = heap_alloc(sizeof(*stream))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
stream->IDWriteFontFileStream_iface.lpVtbl = &inmemoryfilestreamvtbl;
|
|
|
|
stream->ref = 1;
|
|
|
|
stream->data = loader->streams[index];
|
|
|
|
InterlockedIncrement(&stream->data->ref);
|
|
|
|
|
|
|
|
*ret = &stream->IDWriteFontFileStream_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI inmemoryfontfileloader_CreateInMemoryFontFileReference(IDWriteInMemoryFontFileLoader *iface,
|
|
|
|
IDWriteFactory *factory, void const *data, UINT32 data_size, IUnknown *owner, IDWriteFontFile **fontfile)
|
|
|
|
{
|
|
|
|
struct dwrite_inmemory_fileloader *loader = impl_from_IDWriteInMemoryFontFileLoader(iface);
|
|
|
|
struct dwrite_inmemory_stream_data *stream;
|
|
|
|
DWORD key;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p, %p, %u, %p, %p)\n", loader, factory, data, data_size, owner, fontfile);
|
|
|
|
|
|
|
|
*fontfile = NULL;
|
|
|
|
|
2019-05-14 12:27:25 +02:00
|
|
|
if (!dwrite_array_reserve((void **)&loader->streams, &loader->size, loader->count + 1, sizeof(*loader->streams)))
|
|
|
|
return E_OUTOFMEMORY;
|
2017-10-06 11:45:20 +02:00
|
|
|
|
|
|
|
if (!(stream = heap_alloc(sizeof(*stream))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
stream->ref = 1;
|
|
|
|
stream->size = data_size;
|
|
|
|
stream->owner = owner;
|
|
|
|
if (stream->owner) {
|
|
|
|
IUnknown_AddRef(stream->owner);
|
|
|
|
stream->data = (void *)data;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!(stream->data = heap_alloc(data_size))) {
|
|
|
|
heap_free(stream);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
memcpy(stream->data, data, data_size);
|
|
|
|
}
|
|
|
|
|
2019-05-14 12:27:25 +02:00
|
|
|
key = loader->count;
|
|
|
|
loader->streams[loader->count++] = stream;
|
2017-10-06 11:45:20 +02:00
|
|
|
|
|
|
|
return IDWriteFactory_CreateCustomFontFileReference(factory, &key, sizeof(key),
|
|
|
|
(IDWriteFontFileLoader *)&loader->IDWriteInMemoryFontFileLoader_iface, fontfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 WINAPI inmemoryfontfileloader_GetFileCount(IDWriteInMemoryFontFileLoader *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_inmemory_fileloader *loader = impl_from_IDWriteInMemoryFontFileLoader(iface);
|
|
|
|
|
2019-05-14 12:27:25 +02:00
|
|
|
TRACE("%p.\n", iface);
|
2017-10-06 11:45:20 +02:00
|
|
|
|
2019-05-14 12:27:25 +02:00
|
|
|
return loader->count;
|
2017-10-06 11:45:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteInMemoryFontFileLoaderVtbl inmemoryfontfileloadervtbl =
|
|
|
|
{
|
|
|
|
inmemoryfontfileloader_QueryInterface,
|
|
|
|
inmemoryfontfileloader_AddRef,
|
|
|
|
inmemoryfontfileloader_Release,
|
|
|
|
inmemoryfontfileloader_CreateStreamFromKey,
|
|
|
|
inmemoryfontfileloader_CreateInMemoryFontFileReference,
|
|
|
|
inmemoryfontfileloader_GetFileCount,
|
|
|
|
};
|
|
|
|
|
2020-06-10 16:21:32 +02:00
|
|
|
HRESULT create_inmemory_fileloader(IDWriteInMemoryFontFileLoader **ret)
|
2017-10-06 11:45:20 +02:00
|
|
|
{
|
|
|
|
struct dwrite_inmemory_fileloader *loader;
|
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
|
|
|
|
loader = heap_alloc_zero(sizeof(*loader));
|
|
|
|
if (!loader)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
loader->IDWriteInMemoryFontFileLoader_iface.lpVtbl = &inmemoryfontfileloadervtbl;
|
|
|
|
loader->ref = 1;
|
|
|
|
|
2020-06-10 16:21:32 +02:00
|
|
|
*ret = &loader->IDWriteInMemoryFontFileLoader_iface;
|
2017-10-06 11:45:20 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2019-12-05 09:55:57 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontresource_QueryInterface(IDWriteFontResource *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IDWriteFontResource) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
IDWriteFontResource_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("Unsupported interface %s.\n", debugstr_guid(riid));
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritefontresource_AddRef(IDWriteFontResource *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_fontresource *resource = impl_from_IDWriteFontResource(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&resource->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritefontresource_Release(IDWriteFontResource *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_fontresource *resource = impl_from_IDWriteFontResource(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&resource->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
IDWriteFactory7_Release(resource->factory);
|
|
|
|
IDWriteFontFile_Release(resource->file);
|
|
|
|
heap_free(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontresource_GetFontFile(IDWriteFontResource *iface, IDWriteFontFile **fontfile)
|
|
|
|
{
|
|
|
|
struct dwrite_fontresource *resource = impl_from_IDWriteFontResource(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, fontfile);
|
|
|
|
|
|
|
|
*fontfile = resource->file;
|
|
|
|
IDWriteFontFile_AddRef(*fontfile);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 WINAPI dwritefontresource_GetFontFaceIndex(IDWriteFontResource *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_fontresource *resource = impl_from_IDWriteFontResource(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return resource->face_index;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 WINAPI dwritefontresource_GetFontAxisCount(IDWriteFontResource *iface)
|
|
|
|
{
|
|
|
|
FIXME("%p.\n", iface);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontresource_GetDefaultFontAxisValues(IDWriteFontResource *iface,
|
|
|
|
DWRITE_FONT_AXIS_VALUE const *values, UINT32 num_values)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p, %u.\n", iface, values, num_values);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontresource_GetFontAxisRanges(IDWriteFontResource *iface,
|
|
|
|
DWRITE_FONT_AXIS_RANGE const *ranges, UINT32 num_ranges)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p, %u.\n", iface, ranges, num_ranges);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_FONT_AXIS_ATTRIBUTES WINAPI dwritefontresource_GetFontAxisAttributes(IDWriteFontResource *iface,
|
|
|
|
UINT32 axis)
|
|
|
|
{
|
|
|
|
FIXME("%p, %u.\n", iface, axis);
|
|
|
|
|
|
|
|
return DWRITE_FONT_AXIS_ATTRIBUTES_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontresource_GetAxisNames(IDWriteFontResource *iface, UINT32 axis,
|
|
|
|
IDWriteLocalizedStrings **names)
|
|
|
|
{
|
|
|
|
FIXME("%p, %u, %p.\n", iface, axis, names);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 WINAPI dwritefontresource_GetAxisValueNameCount(IDWriteFontResource *iface, UINT32 axis)
|
|
|
|
{
|
|
|
|
FIXME("%p, %u.\n", iface, axis);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontresource_GetAxisValueNames(IDWriteFontResource *iface, UINT32 axis,
|
|
|
|
UINT32 axis_value, DWRITE_FONT_AXIS_RANGE *axis_range, IDWriteLocalizedStrings **names)
|
|
|
|
{
|
|
|
|
FIXME("%p, %u, %u, %p, %p.\n", iface, axis, axis_value, axis_range, names);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL WINAPI dwritefontresource_HasVariations(IDWriteFontResource *iface)
|
|
|
|
{
|
|
|
|
FIXME("%p.\n", iface);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontresource_CreateFontFace(IDWriteFontResource *iface,
|
|
|
|
DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 num_values,
|
|
|
|
IDWriteFontFace5 **fontface)
|
|
|
|
{
|
|
|
|
struct dwrite_fontresource *resource = impl_from_IDWriteFontResource(iface);
|
|
|
|
IDWriteFontFaceReference1 *reference;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p, %#x, %p, %u, %p.\n", iface, simulations, axis_values, num_values, fontface);
|
|
|
|
|
|
|
|
hr = IDWriteFactory7_CreateFontFaceReference(resource->factory, resource->file, resource->face_index,
|
|
|
|
simulations, axis_values, num_values, &reference);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IDWriteFontFaceReference1_CreateFontFace(reference, fontface);
|
|
|
|
IDWriteFontFaceReference1_Release(reference);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefontresource_CreateFontFaceReference(IDWriteFontResource *iface,
|
|
|
|
DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 num_values,
|
|
|
|
IDWriteFontFaceReference1 **reference)
|
|
|
|
{
|
|
|
|
struct dwrite_fontresource *resource = impl_from_IDWriteFontResource(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %#x, %p, %u, %p.\n", iface, simulations, axis_values, num_values, reference);
|
|
|
|
|
|
|
|
return IDWriteFactory7_CreateFontFaceReference(resource->factory, resource->file, resource->face_index,
|
|
|
|
simulations, axis_values, num_values, reference);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteFontResourceVtbl fontresourcevtbl =
|
|
|
|
{
|
|
|
|
dwritefontresource_QueryInterface,
|
|
|
|
dwritefontresource_AddRef,
|
|
|
|
dwritefontresource_Release,
|
|
|
|
dwritefontresource_GetFontFile,
|
|
|
|
dwritefontresource_GetFontFaceIndex,
|
|
|
|
dwritefontresource_GetFontAxisCount,
|
|
|
|
dwritefontresource_GetDefaultFontAxisValues,
|
|
|
|
dwritefontresource_GetFontAxisRanges,
|
|
|
|
dwritefontresource_GetFontAxisAttributes,
|
|
|
|
dwritefontresource_GetAxisNames,
|
|
|
|
dwritefontresource_GetAxisValueNameCount,
|
|
|
|
dwritefontresource_GetAxisValueNames,
|
|
|
|
dwritefontresource_HasVariations,
|
|
|
|
dwritefontresource_CreateFontFace,
|
|
|
|
dwritefontresource_CreateFontFaceReference,
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT create_font_resource(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 face_index,
|
|
|
|
IDWriteFontResource **ret)
|
|
|
|
{
|
|
|
|
struct dwrite_fontresource *resource;
|
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
|
|
|
|
resource = heap_alloc_zero(sizeof(*resource));
|
|
|
|
if (!resource)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
resource->IDWriteFontResource_iface.lpVtbl = &fontresourcevtbl;
|
|
|
|
resource->refcount = 1;
|
|
|
|
resource->face_index = face_index;
|
|
|
|
resource->file = file;
|
|
|
|
IDWriteFontFile_AddRef(resource->file);
|
|
|
|
resource->factory = factory;
|
|
|
|
IDWriteFactory7_AddRef(resource->factory);
|
|
|
|
|
|
|
|
*ret = &resource->IDWriteFontResource_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|