2012-09-28 10:13:17 +02:00
|
|
|
/*
|
|
|
|
* Text format and layout
|
|
|
|
*
|
2017-02-23 14:39:25 +01:00
|
|
|
* Copyright 2012, 2014-2017 Nikolay Sivov for CodeWeavers
|
2012-09-28 10:13:17 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
2017-08-22 11:42:10 +02:00
|
|
|
#include <assert.h>
|
2012-09-28 10:13:17 +02:00
|
|
|
#include <stdarg.h>
|
2015-07-12 22:22:50 +02:00
|
|
|
#include <math.h>
|
2012-09-28 10:13:17 +02:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "dwrite_private.h"
|
2014-12-25 11:34:35 +01:00
|
|
|
#include "scripts.h"
|
2012-09-28 10:13:17 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
|
|
|
|
|
2012-10-23 14:32:34 +02:00
|
|
|
struct dwrite_textformat_data {
|
2012-10-12 15:12:57 +02:00
|
|
|
WCHAR *family_name;
|
2012-11-26 16:43:49 +01:00
|
|
|
UINT32 family_len;
|
2012-10-12 15:12:57 +02:00
|
|
|
WCHAR *locale;
|
2012-10-26 18:50:12 +02:00
|
|
|
UINT32 locale_len;
|
2012-10-12 15:12:57 +02:00
|
|
|
|
|
|
|
DWRITE_FONT_WEIGHT weight;
|
|
|
|
DWRITE_FONT_STYLE style;
|
|
|
|
DWRITE_FONT_STRETCH stretch;
|
|
|
|
|
2014-04-07 07:18:30 +02:00
|
|
|
DWRITE_PARAGRAPH_ALIGNMENT paralign;
|
|
|
|
DWRITE_READING_DIRECTION readingdir;
|
|
|
|
DWRITE_WORD_WRAPPING wrapping;
|
2015-12-25 13:57:59 +01:00
|
|
|
BOOL last_line_wrapping;
|
2014-04-07 07:18:30 +02:00
|
|
|
DWRITE_TEXT_ALIGNMENT textalignment;
|
|
|
|
DWRITE_FLOW_DIRECTION flow;
|
2015-03-13 09:58:32 +01:00
|
|
|
DWRITE_VERTICAL_GLYPH_ORIENTATION vertical_orientation;
|
2015-12-25 13:58:00 +01:00
|
|
|
DWRITE_OPTICAL_ALIGNMENT optical_alignment;
|
2016-07-25 10:42:54 +02:00
|
|
|
DWRITE_LINE_SPACING spacing;
|
2014-04-07 07:18:30 +02:00
|
|
|
|
2014-08-24 18:46:16 +02:00
|
|
|
FLOAT fontsize;
|
2018-11-05 13:01:07 +01:00
|
|
|
FLOAT tabstop;
|
2012-10-22 05:49:27 +02:00
|
|
|
|
2014-04-08 05:42:06 +02:00
|
|
|
DWRITE_TRIMMING trimming;
|
|
|
|
IDWriteInlineObject *trimmingsign;
|
|
|
|
|
2012-10-22 05:49:27 +02:00
|
|
|
IDWriteFontCollection *collection;
|
2015-03-14 22:43:20 +01:00
|
|
|
IDWriteFontFallback *fallback;
|
2012-10-10 20:58:20 +02:00
|
|
|
};
|
|
|
|
|
2014-08-13 21:15:46 +02:00
|
|
|
enum layout_range_attr_kind {
|
2014-08-13 21:29:07 +02:00
|
|
|
LAYOUT_RANGE_ATTR_WEIGHT,
|
|
|
|
LAYOUT_RANGE_ATTR_STYLE,
|
2014-08-24 17:24:18 +02:00
|
|
|
LAYOUT_RANGE_ATTR_STRETCH,
|
2014-08-24 18:46:16 +02:00
|
|
|
LAYOUT_RANGE_ATTR_FONTSIZE,
|
2014-08-13 21:29:07 +02:00
|
|
|
LAYOUT_RANGE_ATTR_EFFECT,
|
2014-08-13 21:15:46 +02:00
|
|
|
LAYOUT_RANGE_ATTR_INLINE,
|
2014-08-13 21:29:07 +02:00
|
|
|
LAYOUT_RANGE_ATTR_UNDERLINE,
|
2014-08-24 17:24:18 +02:00
|
|
|
LAYOUT_RANGE_ATTR_STRIKETHROUGH,
|
2015-03-13 09:25:18 +01:00
|
|
|
LAYOUT_RANGE_ATTR_PAIR_KERNING,
|
2015-01-01 19:50:59 +01:00
|
|
|
LAYOUT_RANGE_ATTR_FONTCOLL,
|
2015-01-02 20:22:40 +01:00
|
|
|
LAYOUT_RANGE_ATTR_LOCALE,
|
2015-06-18 18:52:15 +02:00
|
|
|
LAYOUT_RANGE_ATTR_FONTFAMILY,
|
2015-12-25 13:57:57 +01:00
|
|
|
LAYOUT_RANGE_ATTR_SPACING,
|
|
|
|
LAYOUT_RANGE_ATTR_TYPOGRAPHY
|
2014-08-13 21:15:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct layout_range_attr_value {
|
|
|
|
DWRITE_TEXT_RANGE range;
|
|
|
|
union {
|
|
|
|
DWRITE_FONT_WEIGHT weight;
|
2014-08-13 21:29:07 +02:00
|
|
|
DWRITE_FONT_STYLE style;
|
2014-08-24 17:24:18 +02:00
|
|
|
DWRITE_FONT_STRETCH stretch;
|
2014-08-24 18:46:16 +02:00
|
|
|
FLOAT fontsize;
|
2014-08-13 21:15:46 +02:00
|
|
|
IDWriteInlineObject *object;
|
2014-08-13 21:29:07 +02:00
|
|
|
IUnknown *effect;
|
|
|
|
BOOL underline;
|
|
|
|
BOOL strikethrough;
|
2015-03-13 09:25:18 +01:00
|
|
|
BOOL pair_kerning;
|
2014-08-24 17:24:18 +02:00
|
|
|
IDWriteFontCollection *collection;
|
2015-01-01 19:50:59 +01:00
|
|
|
const WCHAR *locale;
|
2015-01-02 20:22:40 +01:00
|
|
|
const WCHAR *fontfamily;
|
2017-08-22 11:42:09 +02:00
|
|
|
struct {
|
|
|
|
FLOAT leading;
|
|
|
|
FLOAT trailing;
|
|
|
|
FLOAT min_advance;
|
|
|
|
} spacing;
|
2015-12-25 13:57:57 +01:00
|
|
|
IDWriteTypography *typography;
|
2014-08-13 21:15:46 +02:00
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
2015-06-04 12:37:01 +02:00
|
|
|
enum layout_range_kind {
|
2015-06-04 16:55:26 +02:00
|
|
|
LAYOUT_RANGE_REGULAR,
|
2016-01-12 21:12:06 +01:00
|
|
|
LAYOUT_RANGE_UNDERLINE,
|
2015-06-15 00:15:25 +02:00
|
|
|
LAYOUT_RANGE_STRIKETHROUGH,
|
2015-06-18 18:52:15 +02:00
|
|
|
LAYOUT_RANGE_EFFECT,
|
2015-12-25 13:57:57 +01:00
|
|
|
LAYOUT_RANGE_SPACING,
|
|
|
|
LAYOUT_RANGE_TYPOGRAPHY
|
2015-06-04 12:37:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct layout_range_header {
|
2014-08-13 21:15:46 +02:00
|
|
|
struct list entry;
|
2015-06-04 12:37:01 +02:00
|
|
|
enum layout_range_kind kind;
|
2015-06-04 16:55:26 +02:00
|
|
|
DWRITE_TEXT_RANGE range;
|
2015-06-04 12:37:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct layout_range {
|
|
|
|
struct layout_range_header h;
|
2014-08-13 21:15:46 +02:00
|
|
|
DWRITE_FONT_WEIGHT weight;
|
2014-08-13 21:29:07 +02:00
|
|
|
DWRITE_FONT_STYLE style;
|
2014-08-24 18:46:16 +02:00
|
|
|
FLOAT fontsize;
|
2014-08-24 17:24:18 +02:00
|
|
|
DWRITE_FONT_STRETCH stretch;
|
2014-08-13 21:15:46 +02:00
|
|
|
IDWriteInlineObject *object;
|
2015-03-13 09:25:18 +01:00
|
|
|
BOOL pair_kerning;
|
2014-08-24 17:24:18 +02:00
|
|
|
IDWriteFontCollection *collection;
|
2015-01-01 19:50:59 +01:00
|
|
|
WCHAR locale[LOCALE_NAME_MAX_LENGTH];
|
2015-01-02 20:22:40 +01:00
|
|
|
WCHAR *fontfamily;
|
2014-08-13 21:15:46 +02:00
|
|
|
};
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
struct layout_range_bool {
|
|
|
|
struct layout_range_header h;
|
|
|
|
BOOL value;
|
|
|
|
};
|
|
|
|
|
2015-12-25 13:57:57 +01:00
|
|
|
struct layout_range_iface {
|
2015-06-15 00:15:25 +02:00
|
|
|
struct layout_range_header h;
|
2015-12-25 13:57:57 +01:00
|
|
|
IUnknown *iface;
|
2015-06-15 00:15:25 +02:00
|
|
|
};
|
|
|
|
|
2015-06-18 18:52:15 +02:00
|
|
|
struct layout_range_spacing {
|
|
|
|
struct layout_range_header h;
|
|
|
|
FLOAT leading;
|
|
|
|
FLOAT trailing;
|
|
|
|
FLOAT min_advance;
|
|
|
|
};
|
|
|
|
|
2015-04-04 13:05:52 +02:00
|
|
|
enum layout_run_kind {
|
|
|
|
LAYOUT_RUN_REGULAR,
|
|
|
|
LAYOUT_RUN_INLINE
|
|
|
|
};
|
|
|
|
|
|
|
|
struct inline_object_run {
|
|
|
|
IDWriteInlineObject *object;
|
|
|
|
UINT16 length;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct regular_layout_run {
|
2014-12-23 13:36:32 +01:00
|
|
|
DWRITE_GLYPH_RUN_DESCRIPTION descr;
|
2014-12-25 11:34:35 +01:00
|
|
|
DWRITE_GLYPH_RUN run;
|
2014-12-23 13:36:32 +01:00
|
|
|
DWRITE_SCRIPT_ANALYSIS sa;
|
2015-01-08 10:33:17 +01:00
|
|
|
UINT16 *glyphs;
|
|
|
|
UINT16 *clustermap;
|
2015-01-08 11:25:35 +01:00
|
|
|
FLOAT *advances;
|
|
|
|
DWRITE_GLYPH_OFFSET *offsets;
|
2017-08-22 11:42:10 +02:00
|
|
|
UINT32 glyphcount; /* actual glyph count after shaping, not necessarily the same as reported to Draw() */
|
2014-12-23 13:36:32 +01:00
|
|
|
};
|
|
|
|
|
2015-04-04 13:05:52 +02:00
|
|
|
struct layout_run {
|
|
|
|
struct list entry;
|
|
|
|
enum layout_run_kind kind;
|
|
|
|
union {
|
|
|
|
struct inline_object_run object;
|
|
|
|
struct regular_layout_run regular;
|
|
|
|
} u;
|
2015-06-21 14:34:02 +02:00
|
|
|
FLOAT baseline;
|
|
|
|
FLOAT height;
|
2017-08-22 11:42:10 +02:00
|
|
|
UINT32 start_position; /* run text position in range [0, layout-text-length) */
|
2015-04-04 13:05:52 +02:00
|
|
|
};
|
|
|
|
|
2015-05-05 14:23:17 +02:00
|
|
|
struct layout_effective_run {
|
|
|
|
struct list entry;
|
|
|
|
const struct layout_run *run; /* nominal run this one is based on */
|
|
|
|
UINT32 start; /* relative text position, 0 means first text position of a nominal run */
|
|
|
|
UINT32 length; /* length in codepoints that this run covers */
|
|
|
|
UINT32 glyphcount; /* total glyph count in this run */
|
2016-01-12 21:12:07 +01:00
|
|
|
IUnknown *effect; /* original reference is kept only at range level */
|
2017-04-19 14:15:24 +02:00
|
|
|
D2D1_POINT_2F origin; /* baseline origin */
|
2015-07-06 08:05:41 +02:00
|
|
|
FLOAT align_dx; /* adjustment from text alignment */
|
|
|
|
FLOAT width; /* run width */
|
2015-05-05 14:23:17 +02:00
|
|
|
UINT16 *clustermap; /* effective clustermap, allocated separately, is not reused from nominal map */
|
2016-01-14 22:24:23 +01:00
|
|
|
UINT32 line; /* 0-based line index in line metrics array */
|
|
|
|
BOOL underlined; /* set if this run is underlined */
|
2017-04-25 07:54:43 +02:00
|
|
|
D2D1_RECT_F bbox; /* ink run box, top == bottom means it wasn't estimated yet */
|
2015-05-05 14:23:17 +02:00
|
|
|
};
|
|
|
|
|
2015-05-30 17:44:54 +02:00
|
|
|
struct layout_effective_inline {
|
|
|
|
struct list entry;
|
2017-01-26 05:41:50 +01:00
|
|
|
IDWriteInlineObject *object; /* inline object, set explicitly or added when trimming a line */
|
2016-01-28 02:17:18 +01:00
|
|
|
IUnknown *effect; /* original reference is kept only at range level */
|
2017-01-26 05:41:50 +01:00
|
|
|
FLOAT baseline;
|
2017-04-19 14:15:24 +02:00
|
|
|
D2D1_POINT_2F origin; /* left top corner */
|
2016-01-28 02:17:18 +01:00
|
|
|
FLOAT align_dx; /* adjustment from text alignment */
|
|
|
|
FLOAT width; /* object width as it's reported it */
|
|
|
|
BOOL is_sideways; /* vertical flow direction flag passed to Draw */
|
|
|
|
BOOL is_rtl; /* bidi flag passed to Draw */
|
|
|
|
UINT32 line; /* 0-based line index in line metrics array */
|
2015-05-30 17:44:54 +02:00
|
|
|
};
|
|
|
|
|
2016-01-14 22:24:23 +01:00
|
|
|
struct layout_underline {
|
|
|
|
struct list entry;
|
|
|
|
const struct layout_effective_run *run;
|
|
|
|
DWRITE_UNDERLINE u;
|
|
|
|
};
|
|
|
|
|
2015-06-04 22:32:30 +02:00
|
|
|
struct layout_strikethrough {
|
|
|
|
struct list entry;
|
|
|
|
const struct layout_effective_run *run;
|
|
|
|
DWRITE_STRIKETHROUGH s;
|
|
|
|
};
|
|
|
|
|
2015-04-23 12:02:43 +02:00
|
|
|
struct layout_cluster {
|
2015-05-05 14:23:17 +02:00
|
|
|
const struct layout_run *run; /* link to nominal run this cluster belongs to */
|
2015-04-23 12:02:43 +02:00
|
|
|
UINT32 position; /* relative to run, first cluster has 0 position */
|
|
|
|
};
|
|
|
|
|
2019-05-14 12:27:28 +02:00
|
|
|
struct layout_line
|
|
|
|
{
|
|
|
|
float height; /* height based on content */
|
|
|
|
float baseline; /* baseline based on content */
|
|
|
|
DWRITE_LINE_METRICS1 metrics;
|
2017-02-02 00:11:34 +01:00
|
|
|
};
|
|
|
|
|
2015-03-30 09:15:48 +02:00
|
|
|
enum layout_recompute_mask {
|
2017-01-26 22:42:13 +01:00
|
|
|
RECOMPUTE_CLUSTERS = 1 << 0,
|
|
|
|
RECOMPUTE_MINIMAL_WIDTH = 1 << 1,
|
|
|
|
RECOMPUTE_LINES = 1 << 2,
|
|
|
|
RECOMPUTE_OVERHANGS = 1 << 3,
|
|
|
|
RECOMPUTE_LINES_AND_OVERHANGS = RECOMPUTE_LINES | RECOMPUTE_OVERHANGS,
|
|
|
|
RECOMPUTE_EVERYTHING = 0xffff
|
2015-03-30 09:15:48 +02:00
|
|
|
};
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout
|
|
|
|
{
|
|
|
|
IDWriteTextLayout4 IDWriteTextLayout4_iface;
|
2019-11-29 10:54:27 +01:00
|
|
|
IDWriteTextFormat3 IDWriteTextFormat3_iface;
|
2016-02-01 12:59:10 +01:00
|
|
|
IDWriteTextAnalysisSink1 IDWriteTextAnalysisSink1_iface;
|
|
|
|
IDWriteTextAnalysisSource1 IDWriteTextAnalysisSource1_iface;
|
2019-11-29 10:54:26 +01:00
|
|
|
LONG refcount;
|
2012-10-23 14:32:34 +02:00
|
|
|
|
2017-05-07 21:38:15 +02:00
|
|
|
IDWriteFactory5 *factory;
|
2016-02-14 17:05:07 +01:00
|
|
|
|
2012-10-23 14:32:34 +02:00
|
|
|
WCHAR *str;
|
2012-10-26 18:09:50 +02:00
|
|
|
UINT32 len;
|
2012-10-23 14:32:34 +02:00
|
|
|
struct dwrite_textformat_data format;
|
2015-06-04 16:55:26 +02:00
|
|
|
struct list strike_ranges;
|
2016-01-12 21:12:06 +01:00
|
|
|
struct list underline_ranges;
|
2015-12-25 13:57:57 +01:00
|
|
|
struct list typographies;
|
2015-06-15 00:15:25 +02:00
|
|
|
struct list effects;
|
2015-06-18 18:52:15 +02:00
|
|
|
struct list spacing;
|
2014-08-13 21:15:46 +02:00
|
|
|
struct list ranges;
|
2014-12-23 13:36:32 +01:00
|
|
|
struct list runs;
|
2015-05-30 17:44:54 +02:00
|
|
|
/* lists ready to use by Draw() */
|
|
|
|
struct list eruns;
|
|
|
|
struct list inlineobjects;
|
2016-01-14 22:24:23 +01:00
|
|
|
struct list underlines;
|
2015-06-04 22:32:30 +02:00
|
|
|
struct list strikethrough;
|
2015-03-30 09:15:48 +02:00
|
|
|
USHORT recompute;
|
2014-12-25 12:03:19 +01:00
|
|
|
|
2014-12-25 22:01:28 +01:00
|
|
|
DWRITE_LINE_BREAKPOINT *nominal_breakpoints;
|
|
|
|
DWRITE_LINE_BREAKPOINT *actual_breakpoints;
|
2015-01-08 22:35:14 +01:00
|
|
|
|
2015-04-23 12:02:43 +02:00
|
|
|
struct layout_cluster *clusters;
|
|
|
|
DWRITE_CLUSTER_METRICS *clustermetrics;
|
2015-05-05 14:23:17 +02:00
|
|
|
UINT32 cluster_count;
|
2015-03-30 09:15:48 +02:00
|
|
|
FLOAT minwidth;
|
2015-01-11 22:03:31 +01:00
|
|
|
|
2017-02-02 00:11:34 +01:00
|
|
|
struct layout_line *lines;
|
2019-05-14 12:27:28 +02:00
|
|
|
size_t lines_size;
|
2015-05-05 14:23:17 +02:00
|
|
|
|
2015-07-01 19:43:30 +02:00
|
|
|
DWRITE_TEXT_METRICS1 metrics;
|
2017-01-26 22:42:13 +01:00
|
|
|
DWRITE_OVERHANG_METRICS overhangs;
|
2015-07-01 19:43:30 +02:00
|
|
|
|
2015-07-16 12:10:54 +02:00
|
|
|
DWRITE_MEASURING_MODE measuringmode;
|
|
|
|
|
2015-01-08 22:35:14 +01:00
|
|
|
/* gdi-compatible layout specifics */
|
2015-07-20 14:15:01 +02:00
|
|
|
FLOAT ppdip;
|
2015-01-08 22:35:14 +01:00
|
|
|
DWRITE_MATRIX transform;
|
2012-10-23 14:32:34 +02:00
|
|
|
};
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat
|
|
|
|
{
|
|
|
|
IDWriteTextFormat3 IDWriteTextFormat3_iface;
|
|
|
|
LONG refcount;
|
2012-10-23 14:32:34 +02:00
|
|
|
struct dwrite_textformat_data format;
|
|
|
|
};
|
|
|
|
|
2014-04-08 05:42:24 +02:00
|
|
|
struct dwrite_trimmingsign {
|
|
|
|
IDWriteInlineObject IDWriteInlineObject_iface;
|
|
|
|
LONG ref;
|
2015-06-15 00:13:00 +02:00
|
|
|
|
|
|
|
IDWriteTextLayout *layout;
|
2014-04-08 05:42:24 +02:00
|
|
|
};
|
|
|
|
|
2014-09-19 05:54:00 +02:00
|
|
|
struct dwrite_typography {
|
|
|
|
IDWriteTypography IDWriteTypography_iface;
|
2019-05-13 13:21:43 +02:00
|
|
|
LONG refcount;
|
2014-09-19 05:54:00 +02:00
|
|
|
|
|
|
|
DWRITE_FONT_FEATURE *features;
|
2019-05-13 13:21:43 +02:00
|
|
|
size_t capacity;
|
|
|
|
size_t count;
|
2014-09-19 05:54:00 +02:00
|
|
|
};
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static const IDWriteTextFormat3Vtbl dwritetextformatvtbl;
|
2012-11-26 17:01:58 +01:00
|
|
|
|
2012-10-23 14:32:34 +02:00
|
|
|
static void release_format_data(struct dwrite_textformat_data *data)
|
|
|
|
{
|
|
|
|
if (data->collection) IDWriteFontCollection_Release(data->collection);
|
2015-03-14 22:43:20 +01:00
|
|
|
if (data->fallback) IDWriteFontFallback_Release(data->fallback);
|
2014-04-08 05:42:06 +02:00
|
|
|
if (data->trimmingsign) IDWriteInlineObject_Release(data->trimmingsign);
|
2012-10-23 14:32:34 +02:00
|
|
|
heap_free(data->family_name);
|
|
|
|
heap_free(data->locale);
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static inline struct dwrite_textlayout *impl_from_IDWriteTextLayout4(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_textlayout, IDWriteTextLayout4_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static inline struct dwrite_textlayout *impl_layout_from_IDWriteTextFormat3(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_textlayout, IDWriteTextFormat3_iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static inline struct dwrite_textlayout *impl_from_IDWriteTextAnalysisSink1(IDWriteTextAnalysisSink1 *iface)
|
2014-12-23 13:36:32 +01:00
|
|
|
{
|
2016-02-01 12:59:10 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_textlayout, IDWriteTextAnalysisSink1_iface);
|
2014-12-23 13:36:32 +01:00
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static inline struct dwrite_textlayout *impl_from_IDWriteTextAnalysisSource1(IDWriteTextAnalysisSource1 *iface)
|
2014-12-23 13:36:32 +01:00
|
|
|
{
|
2016-02-01 12:59:10 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_textlayout, IDWriteTextAnalysisSource1_iface);
|
2014-12-23 13:36:32 +01:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static inline struct dwrite_textformat *impl_from_IDWriteTextFormat3(IDWriteTextFormat3 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_textformat, IDWriteTextFormat3_iface);
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2015-12-25 13:57:58 +01:00
|
|
|
static struct dwrite_textformat *unsafe_impl_from_IDWriteTextFormat(IDWriteTextFormat*);
|
|
|
|
|
2014-04-08 05:42:24 +02:00
|
|
|
static inline struct dwrite_trimmingsign *impl_from_IDWriteInlineObject(IDWriteInlineObject *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_trimmingsign, IDWriteInlineObject_iface);
|
|
|
|
}
|
|
|
|
|
2014-09-19 05:54:00 +02:00
|
|
|
static inline struct dwrite_typography *impl_from_IDWriteTypography(IDWriteTypography *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_typography, IDWriteTypography_iface);
|
|
|
|
}
|
|
|
|
|
2016-01-28 02:17:17 +01:00
|
|
|
static inline const char *debugstr_rundescr(const DWRITE_GLYPH_RUN_DESCRIPTION *descr)
|
2015-01-11 22:03:31 +01:00
|
|
|
{
|
2016-01-28 02:17:17 +01:00
|
|
|
return wine_dbg_sprintf("[%u,%u)", descr->textPosition, descr->textPosition + descr->stringLength);
|
2015-01-11 22:03:31 +01:00
|
|
|
}
|
|
|
|
|
2015-07-16 12:10:54 +02:00
|
|
|
static inline BOOL is_layout_gdi_compatible(struct dwrite_textlayout *layout)
|
|
|
|
{
|
|
|
|
return layout->measuringmode != DWRITE_MEASURING_MODE_NATURAL;
|
|
|
|
}
|
|
|
|
|
2015-07-06 08:05:41 +02:00
|
|
|
static inline HRESULT format_set_textalignment(struct dwrite_textformat_data *format, DWRITE_TEXT_ALIGNMENT alignment,
|
|
|
|
BOOL *changed)
|
2015-07-06 08:05:10 +02:00
|
|
|
{
|
|
|
|
if ((UINT32)alignment > DWRITE_TEXT_ALIGNMENT_JUSTIFIED)
|
|
|
|
return E_INVALIDARG;
|
2015-07-06 08:05:41 +02:00
|
|
|
if (changed) *changed = format->textalignment != alignment;
|
2015-07-06 08:05:10 +02:00
|
|
|
format->textalignment = alignment;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-07-06 08:06:08 +02:00
|
|
|
static inline HRESULT format_set_paralignment(struct dwrite_textformat_data *format,
|
|
|
|
DWRITE_PARAGRAPH_ALIGNMENT alignment, BOOL *changed)
|
|
|
|
{
|
|
|
|
if ((UINT32)alignment > DWRITE_PARAGRAPH_ALIGNMENT_CENTER)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if (changed) *changed = format->paralign != alignment;
|
|
|
|
format->paralign = alignment;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-07-09 11:25:54 +02:00
|
|
|
static inline HRESULT format_set_readingdirection(struct dwrite_textformat_data *format,
|
|
|
|
DWRITE_READING_DIRECTION direction, BOOL *changed)
|
|
|
|
{
|
|
|
|
if ((UINT32)direction > DWRITE_READING_DIRECTION_BOTTOM_TO_TOP)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if (changed) *changed = format->readingdir != direction;
|
|
|
|
format->readingdir = direction;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-07-12 22:35:32 +02:00
|
|
|
static inline HRESULT format_set_wordwrapping(struct dwrite_textformat_data *format,
|
|
|
|
DWRITE_WORD_WRAPPING wrapping, BOOL *changed)
|
|
|
|
{
|
|
|
|
if ((UINT32)wrapping > DWRITE_WORD_WRAPPING_CHARACTER)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if (changed) *changed = format->wrapping != wrapping;
|
|
|
|
format->wrapping = wrapping;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2016-02-02 21:14:39 +01:00
|
|
|
static inline HRESULT format_set_flowdirection(struct dwrite_textformat_data *format,
|
|
|
|
DWRITE_FLOW_DIRECTION direction, BOOL *changed)
|
|
|
|
{
|
|
|
|
if ((UINT32)direction > DWRITE_FLOW_DIRECTION_RIGHT_TO_LEFT)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if (changed) *changed = format->flow != direction;
|
|
|
|
format->flow = direction;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2016-07-18 23:10:36 +02:00
|
|
|
static inline HRESULT format_set_trimming(struct dwrite_textformat_data *format,
|
|
|
|
DWRITE_TRIMMING const *trimming, IDWriteInlineObject *trimming_sign, BOOL *changed)
|
|
|
|
{
|
|
|
|
if (changed)
|
|
|
|
*changed = FALSE;
|
|
|
|
|
|
|
|
if ((UINT32)trimming->granularity > DWRITE_TRIMMING_GRANULARITY_WORD)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (changed) {
|
|
|
|
*changed = !!memcmp(&format->trimming, trimming, sizeof(*trimming));
|
|
|
|
if (format->trimmingsign != trimming_sign)
|
|
|
|
*changed = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
format->trimming = *trimming;
|
|
|
|
if (format->trimmingsign)
|
|
|
|
IDWriteInlineObject_Release(format->trimmingsign);
|
|
|
|
format->trimmingsign = trimming_sign;
|
|
|
|
if (format->trimmingsign)
|
|
|
|
IDWriteInlineObject_AddRef(format->trimmingsign);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2016-02-02 21:14:40 +01:00
|
|
|
static inline HRESULT format_set_linespacing(struct dwrite_textformat_data *format,
|
2016-07-25 10:42:54 +02:00
|
|
|
DWRITE_LINE_SPACING const *spacing, BOOL *changed)
|
2016-02-02 21:14:40 +01:00
|
|
|
{
|
2016-07-25 10:42:54 +02:00
|
|
|
if (spacing->height < 0.0f || spacing->leadingBefore < 0.0f || spacing->leadingBefore > 1.0f ||
|
|
|
|
(UINT32)spacing->method > DWRITE_LINE_SPACING_METHOD_PROPORTIONAL)
|
2016-02-02 21:14:40 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2016-07-25 10:42:54 +02:00
|
|
|
if (changed)
|
|
|
|
*changed = memcmp(spacing, &format->spacing, sizeof(*spacing));
|
2016-02-02 21:14:40 +01:00
|
|
|
|
2016-07-25 10:42:54 +02:00
|
|
|
format->spacing = *spacing;
|
2016-02-02 21:14:40 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-03-14 22:43:20 +01:00
|
|
|
static HRESULT get_fontfallback_from_format(const struct dwrite_textformat_data *format, IDWriteFontFallback **fallback)
|
|
|
|
{
|
|
|
|
*fallback = format->fallback;
|
|
|
|
if (*fallback)
|
|
|
|
IDWriteFontFallback_AddRef(*fallback);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-03-15 01:52:35 +01:00
|
|
|
static HRESULT set_fontfallback_for_format(struct dwrite_textformat_data *format, IDWriteFontFallback *fallback)
|
|
|
|
{
|
|
|
|
if (format->fallback)
|
|
|
|
IDWriteFontFallback_Release(format->fallback);
|
|
|
|
format->fallback = fallback;
|
|
|
|
if (fallback)
|
|
|
|
IDWriteFontFallback_AddRef(fallback);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-12-25 13:58:00 +01:00
|
|
|
static HRESULT format_set_optical_alignment(struct dwrite_textformat_data *format,
|
|
|
|
DWRITE_OPTICAL_ALIGNMENT alignment)
|
|
|
|
{
|
|
|
|
if ((UINT32)alignment > DWRITE_OPTICAL_ALIGNMENT_NO_SIDE_BEARINGS)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
format->optical_alignment = alignment;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2016-01-19 21:23:00 +01:00
|
|
|
static BOOL is_run_rtl(const struct layout_effective_run *run)
|
|
|
|
{
|
|
|
|
return run->run->u.regular.run.bidiLevel & 1;
|
|
|
|
}
|
|
|
|
|
2017-08-22 11:42:10 +02:00
|
|
|
static struct layout_run *alloc_layout_run(enum layout_run_kind kind, UINT32 start_position)
|
2014-12-23 13:36:32 +01:00
|
|
|
{
|
|
|
|
struct layout_run *ret;
|
|
|
|
|
|
|
|
ret = heap_alloc(sizeof(*ret));
|
|
|
|
if (!ret) return NULL;
|
|
|
|
|
2015-04-04 13:05:52 +02:00
|
|
|
memset(ret, 0, sizeof(*ret));
|
|
|
|
ret->kind = kind;
|
|
|
|
if (kind == LAYOUT_RUN_REGULAR) {
|
|
|
|
ret->u.regular.sa.script = Script_Unknown;
|
|
|
|
ret->u.regular.sa.shapes = DWRITE_SCRIPT_SHAPES_DEFAULT;
|
|
|
|
}
|
2017-08-22 11:42:10 +02:00
|
|
|
ret->start_position = start_position;
|
2015-01-08 10:33:17 +01:00
|
|
|
|
2014-12-23 13:36:32 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void free_layout_runs(struct dwrite_textlayout *layout)
|
|
|
|
{
|
|
|
|
struct layout_run *cur, *cur2;
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(cur, cur2, &layout->runs, struct layout_run, entry) {
|
|
|
|
list_remove(&cur->entry);
|
2015-04-04 13:05:52 +02:00
|
|
|
if (cur->kind == LAYOUT_RUN_REGULAR) {
|
|
|
|
if (cur->u.regular.run.fontFace)
|
|
|
|
IDWriteFontFace_Release(cur->u.regular.run.fontFace);
|
|
|
|
heap_free(cur->u.regular.glyphs);
|
|
|
|
heap_free(cur->u.regular.clustermap);
|
|
|
|
heap_free(cur->u.regular.advances);
|
|
|
|
heap_free(cur->u.regular.offsets);
|
|
|
|
}
|
2014-12-23 13:36:32 +01:00
|
|
|
heap_free(cur);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-05 14:23:17 +02:00
|
|
|
static void free_layout_eruns(struct dwrite_textlayout *layout)
|
|
|
|
{
|
2015-05-30 17:44:54 +02:00
|
|
|
struct layout_effective_inline *in, *in2;
|
2015-05-05 14:23:17 +02:00
|
|
|
struct layout_effective_run *cur, *cur2;
|
2015-06-04 22:32:30 +02:00
|
|
|
struct layout_strikethrough *s, *s2;
|
2016-01-14 22:24:23 +01:00
|
|
|
struct layout_underline *u, *u2;
|
2015-05-30 17:44:54 +02:00
|
|
|
|
2015-05-05 14:23:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(cur, cur2, &layout->eruns, struct layout_effective_run, entry) {
|
|
|
|
list_remove(&cur->entry);
|
|
|
|
heap_free(cur->clustermap);
|
|
|
|
heap_free(cur);
|
|
|
|
}
|
2015-05-30 17:44:54 +02:00
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(in, in2, &layout->inlineobjects, struct layout_effective_inline, entry) {
|
|
|
|
list_remove(&in->entry);
|
|
|
|
heap_free(in);
|
|
|
|
}
|
2015-06-04 22:32:30 +02:00
|
|
|
|
2016-01-14 22:24:23 +01:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(u, u2, &layout->underlines, struct layout_underline, entry) {
|
|
|
|
list_remove(&u->entry);
|
|
|
|
heap_free(u);
|
|
|
|
}
|
|
|
|
|
2015-06-04 22:32:30 +02:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(s, s2, &layout->strikethrough, struct layout_strikethrough, entry) {
|
|
|
|
list_remove(&s->entry);
|
|
|
|
heap_free(s);
|
|
|
|
}
|
2015-05-05 14:23:17 +02:00
|
|
|
}
|
|
|
|
|
2015-01-11 22:03:31 +01:00
|
|
|
/* Used to resolve break condition by forcing stronger condition over weaker. */
|
2014-12-25 22:01:28 +01:00
|
|
|
static inline DWRITE_BREAK_CONDITION override_break_condition(DWRITE_BREAK_CONDITION existingbreak, DWRITE_BREAK_CONDITION newbreak)
|
|
|
|
{
|
|
|
|
switch (existingbreak) {
|
|
|
|
case DWRITE_BREAK_CONDITION_NEUTRAL:
|
|
|
|
return newbreak;
|
|
|
|
case DWRITE_BREAK_CONDITION_CAN_BREAK:
|
|
|
|
return newbreak == DWRITE_BREAK_CONDITION_NEUTRAL ? existingbreak : newbreak;
|
|
|
|
/* let's keep stronger conditions as is */
|
|
|
|
case DWRITE_BREAK_CONDITION_MAY_NOT_BREAK:
|
|
|
|
case DWRITE_BREAK_CONDITION_MUST_BREAK:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("unknown break condition %d\n", existingbreak);
|
|
|
|
}
|
|
|
|
|
|
|
|
return existingbreak;
|
|
|
|
}
|
|
|
|
|
2015-06-29 11:52:04 +02:00
|
|
|
/* This helper should be used to get effective range length, in other words it returns number of text
|
|
|
|
positions from range starting point to the end of the range, limited by layout text length */
|
|
|
|
static inline UINT32 get_clipped_range_length(const struct dwrite_textlayout *layout, const struct layout_range *range)
|
|
|
|
{
|
|
|
|
if (range->h.range.startPosition + range->h.range.length <= layout->len)
|
|
|
|
return range->h.range.length;
|
|
|
|
return layout->len - range->h.range.startPosition;
|
|
|
|
}
|
|
|
|
|
2015-01-11 22:03:31 +01:00
|
|
|
/* Actual breakpoint data gets updated with break condition required by inline object set for range 'cur'. */
|
2014-12-25 22:01:28 +01:00
|
|
|
static HRESULT layout_update_breakpoints_range(struct dwrite_textlayout *layout, const struct layout_range *cur)
|
|
|
|
{
|
|
|
|
DWRITE_BREAK_CONDITION before, after;
|
2015-06-29 11:52:04 +02:00
|
|
|
UINT32 i, length;
|
2014-12-25 22:01:28 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2015-05-31 10:57:37 +02:00
|
|
|
/* ignore returned conditions if failed */
|
2014-12-25 22:01:28 +01:00
|
|
|
hr = IDWriteInlineObject_GetBreakConditions(cur->object, &before, &after);
|
|
|
|
if (FAILED(hr))
|
2015-05-31 10:57:37 +02:00
|
|
|
after = before = DWRITE_BREAK_CONDITION_NEUTRAL;
|
2014-12-25 22:01:28 +01:00
|
|
|
|
|
|
|
if (!layout->actual_breakpoints) {
|
2019-02-13 08:47:10 +01:00
|
|
|
layout->actual_breakpoints = heap_calloc(layout->len, sizeof(*layout->actual_breakpoints));
|
2014-12-25 22:01:28 +01:00
|
|
|
if (!layout->actual_breakpoints)
|
|
|
|
return E_OUTOFMEMORY;
|
2015-05-24 12:53:49 +02:00
|
|
|
memcpy(layout->actual_breakpoints, layout->nominal_breakpoints, sizeof(DWRITE_LINE_BREAKPOINT)*layout->len);
|
2014-12-25 22:01:28 +01:00
|
|
|
}
|
|
|
|
|
2015-06-29 11:52:04 +02:00
|
|
|
length = get_clipped_range_length(layout, cur);
|
|
|
|
for (i = cur->h.range.startPosition; i < length + cur->h.range.startPosition; i++) {
|
2015-05-24 12:53:49 +02:00
|
|
|
/* for first codepoint check if there's anything before it and update accordingly */
|
2015-06-04 16:55:26 +02:00
|
|
|
if (i == cur->h.range.startPosition) {
|
2015-05-24 12:53:49 +02:00
|
|
|
if (i > 0)
|
|
|
|
layout->actual_breakpoints[i].breakConditionBefore = layout->actual_breakpoints[i-1].breakConditionAfter =
|
|
|
|
override_break_condition(layout->actual_breakpoints[i-1].breakConditionAfter, before);
|
2014-12-25 22:01:28 +01:00
|
|
|
else
|
2015-05-24 12:53:49 +02:00
|
|
|
layout->actual_breakpoints[i].breakConditionBefore = before;
|
|
|
|
layout->actual_breakpoints[i].breakConditionAfter = DWRITE_BREAK_CONDITION_MAY_NOT_BREAK;
|
2014-12-25 22:01:28 +01:00
|
|
|
}
|
2015-05-24 12:53:49 +02:00
|
|
|
/* similar check for last codepoint */
|
2015-06-29 11:52:04 +02:00
|
|
|
else if (i == cur->h.range.startPosition + length - 1) {
|
2015-05-24 12:53:49 +02:00
|
|
|
if (i == layout->len - 1)
|
|
|
|
layout->actual_breakpoints[i].breakConditionAfter = after;
|
2014-12-25 22:01:28 +01:00
|
|
|
else
|
2015-05-24 12:53:49 +02:00
|
|
|
layout->actual_breakpoints[i].breakConditionAfter = layout->actual_breakpoints[i+1].breakConditionBefore =
|
|
|
|
override_break_condition(layout->actual_breakpoints[i+1].breakConditionBefore, after);
|
|
|
|
layout->actual_breakpoints[i].breakConditionBefore = DWRITE_BREAK_CONDITION_MAY_NOT_BREAK;
|
2014-12-25 22:01:28 +01:00
|
|
|
}
|
2015-05-24 12:53:49 +02:00
|
|
|
/* for all positions within a range disable breaks */
|
|
|
|
else {
|
|
|
|
layout->actual_breakpoints[i].breakConditionBefore = DWRITE_BREAK_CONDITION_MAY_NOT_BREAK;
|
|
|
|
layout->actual_breakpoints[i].breakConditionAfter = DWRITE_BREAK_CONDITION_MAY_NOT_BREAK;
|
|
|
|
}
|
|
|
|
|
2016-02-01 23:41:10 +01:00
|
|
|
layout->actual_breakpoints[i].isWhitespace = 0;
|
|
|
|
layout->actual_breakpoints[i].isSoftHyphen = 0;
|
2014-12-25 22:01:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-01-06 21:57:15 +01:00
|
|
|
static struct layout_range *get_layout_range_by_pos(struct dwrite_textlayout *layout, UINT32 pos);
|
|
|
|
|
2015-04-03 10:38:23 +02:00
|
|
|
static inline DWRITE_LINE_BREAKPOINT get_effective_breakpoint(const struct dwrite_textlayout *layout, UINT32 pos)
|
2015-01-11 22:03:31 +01:00
|
|
|
{
|
2015-04-03 10:38:23 +02:00
|
|
|
if (layout->actual_breakpoints)
|
|
|
|
return layout->actual_breakpoints[pos];
|
|
|
|
return layout->nominal_breakpoints[pos];
|
|
|
|
}
|
|
|
|
|
2015-04-04 13:05:52 +02:00
|
|
|
static inline void init_cluster_metrics(const struct dwrite_textlayout *layout, const struct regular_layout_run *run,
|
2015-06-17 20:51:01 +02:00
|
|
|
UINT16 start_glyph, UINT16 stop_glyph, UINT32 stop_position, UINT16 length, DWRITE_CLUSTER_METRICS *metrics)
|
2015-04-03 10:38:23 +02:00
|
|
|
{
|
|
|
|
UINT8 breakcondition;
|
2015-04-23 12:01:18 +02:00
|
|
|
UINT32 position;
|
2015-04-03 10:38:23 +02:00
|
|
|
UINT16 j;
|
|
|
|
|
2015-06-17 20:51:01 +02:00
|
|
|
/* For clusters made of control chars we report zero glyphs, and we need zero cluster
|
2015-05-30 22:51:01 +02:00
|
|
|
width as well; advances are already computed at this point and are not necessary zero. */
|
2016-01-11 14:15:53 +01:00
|
|
|
metrics->width = 0.0f;
|
2015-05-30 22:51:01 +02:00
|
|
|
if (run->run.glyphCount) {
|
|
|
|
for (j = start_glyph; j < stop_glyph; j++)
|
|
|
|
metrics->width += run->run.glyphAdvances[j];
|
|
|
|
}
|
2015-06-17 20:51:01 +02:00
|
|
|
metrics->length = length;
|
2015-04-03 10:38:23 +02:00
|
|
|
|
2016-01-24 16:10:57 +01:00
|
|
|
position = run->descr.textPosition + stop_position;
|
2015-05-30 22:51:01 +02:00
|
|
|
if (stop_glyph == run->glyphcount)
|
2016-01-26 13:44:47 +01:00
|
|
|
breakcondition = get_effective_breakpoint(layout, position).breakConditionAfter;
|
2015-04-23 12:01:18 +02:00
|
|
|
else {
|
2016-01-26 13:44:47 +01:00
|
|
|
breakcondition = get_effective_breakpoint(layout, position).breakConditionBefore;
|
|
|
|
if (stop_position) position -= 1;
|
2015-04-23 12:01:18 +02:00
|
|
|
}
|
2015-04-03 10:38:23 +02:00
|
|
|
|
|
|
|
metrics->canWrapLineAfter = breakcondition == DWRITE_BREAK_CONDITION_CAN_BREAK ||
|
|
|
|
breakcondition == DWRITE_BREAK_CONDITION_MUST_BREAK;
|
2015-04-23 12:01:18 +02:00
|
|
|
if (metrics->length == 1) {
|
2016-01-26 13:44:46 +01:00
|
|
|
DWRITE_LINE_BREAKPOINT bp = get_effective_breakpoint(layout, position);
|
|
|
|
metrics->isWhitespace = bp.isWhitespace;
|
2016-01-28 21:27:21 +01:00
|
|
|
metrics->isNewline = metrics->canWrapLineAfter && lb_is_newline_char(layout->str[position]);
|
2016-01-26 13:44:46 +01:00
|
|
|
metrics->isSoftHyphen = bp.isSoftHyphen;
|
2015-04-23 12:01:18 +02:00
|
|
|
}
|
|
|
|
else {
|
2016-01-28 02:17:19 +01:00
|
|
|
metrics->isWhitespace = 0;
|
|
|
|
metrics->isNewline = 0;
|
|
|
|
metrics->isSoftHyphen = 0;
|
2015-04-23 12:01:18 +02:00
|
|
|
}
|
2015-01-11 22:03:31 +01:00
|
|
|
metrics->isRightToLeft = run->run.bidiLevel & 1;
|
|
|
|
metrics->padding = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
All clusters in a 'run' will be added to 'layout' data, starting at index pointed to by 'cluster'.
|
|
|
|
On return 'cluster' is updated to point to next metrics struct to be filled in on next call.
|
2015-04-03 10:38:23 +02:00
|
|
|
Note that there's no need to reallocate anything at this point as we allocate one cluster per
|
|
|
|
codepoint initially.
|
2015-01-11 22:03:31 +01:00
|
|
|
|
|
|
|
*/
|
2015-04-23 12:02:43 +02:00
|
|
|
static void layout_set_cluster_metrics(struct dwrite_textlayout *layout, const struct layout_run *r, UINT32 *cluster)
|
2015-01-11 22:03:31 +01:00
|
|
|
{
|
2015-04-23 12:02:43 +02:00
|
|
|
DWRITE_CLUSTER_METRICS *metrics = &layout->clustermetrics[*cluster];
|
|
|
|
struct layout_cluster *c = &layout->clusters[*cluster];
|
|
|
|
const struct regular_layout_run *run = &r->u.regular;
|
2015-04-03 10:38:23 +02:00
|
|
|
UINT32 i, start = 0;
|
2015-01-11 22:03:31 +01:00
|
|
|
|
2017-08-22 11:42:10 +02:00
|
|
|
assert(r->kind == LAYOUT_RUN_REGULAR);
|
|
|
|
|
2015-01-11 22:03:31 +01:00
|
|
|
for (i = 0; i < run->descr.stringLength; i++) {
|
2015-04-03 10:38:23 +02:00
|
|
|
BOOL end = i == run->descr.stringLength - 1;
|
2015-01-11 22:03:31 +01:00
|
|
|
|
2015-04-03 10:38:23 +02:00
|
|
|
if (run->descr.clusterMap[start] != run->descr.clusterMap[i]) {
|
2015-06-17 20:51:01 +02:00
|
|
|
init_cluster_metrics(layout, run, run->descr.clusterMap[start], run->descr.clusterMap[i], i,
|
|
|
|
i - start, metrics);
|
2015-04-23 12:02:43 +02:00
|
|
|
c->position = start;
|
|
|
|
c->run = r;
|
2015-01-11 22:03:31 +01:00
|
|
|
|
2015-04-03 10:38:23 +02:00
|
|
|
*cluster += 1;
|
|
|
|
metrics++;
|
2015-04-23 12:02:43 +02:00
|
|
|
c++;
|
2015-04-03 10:38:23 +02:00
|
|
|
start = i;
|
|
|
|
}
|
2015-01-11 22:03:31 +01:00
|
|
|
|
2015-04-03 10:38:23 +02:00
|
|
|
if (end) {
|
2015-06-17 20:51:01 +02:00
|
|
|
init_cluster_metrics(layout, run, run->descr.clusterMap[start], run->glyphcount, i,
|
|
|
|
i - start + 1, metrics);
|
2015-04-23 12:02:43 +02:00
|
|
|
c->position = start;
|
|
|
|
c->run = r;
|
2015-01-11 22:03:31 +01:00
|
|
|
|
|
|
|
*cluster += 1;
|
2015-04-03 10:38:23 +02:00
|
|
|
return;
|
2015-01-11 22:03:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-13 23:04:54 +01:00
|
|
|
#define SCALE_FONT_METRIC(metric, emSize, metrics) ((FLOAT)(metric) * (emSize) / (FLOAT)(metrics)->designUnitsPerEm)
|
2015-06-21 14:34:02 +02:00
|
|
|
|
2016-01-28 02:17:17 +01:00
|
|
|
static void layout_get_font_metrics(struct dwrite_textlayout *layout, IDWriteFontFace *fontface, FLOAT emsize,
|
|
|
|
DWRITE_FONT_METRICS *fontmetrics)
|
|
|
|
{
|
|
|
|
if (is_layout_gdi_compatible(layout)) {
|
|
|
|
HRESULT hr = IDWriteFontFace_GetGdiCompatibleMetrics(fontface, emsize, layout->ppdip, &layout->transform, fontmetrics);
|
|
|
|
if (FAILED(hr))
|
|
|
|
WARN("failed to get compat metrics, 0x%08x\n", hr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
IDWriteFontFace_GetMetrics(fontface, fontmetrics);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layout_get_font_height(FLOAT emsize, DWRITE_FONT_METRICS *fontmetrics, FLOAT *baseline, FLOAT *height)
|
|
|
|
{
|
|
|
|
*baseline = SCALE_FONT_METRIC(fontmetrics->ascent + fontmetrics->lineGap, emsize, fontmetrics);
|
|
|
|
*height = SCALE_FONT_METRIC(fontmetrics->ascent + fontmetrics->descent + fontmetrics->lineGap, emsize, fontmetrics);
|
|
|
|
}
|
|
|
|
|
2017-08-22 11:42:11 +02:00
|
|
|
static HRESULT layout_itemize(struct dwrite_textlayout *layout)
|
2014-12-23 13:36:32 +01:00
|
|
|
{
|
|
|
|
IDWriteTextAnalyzer *analyzer;
|
2015-01-06 21:57:15 +01:00
|
|
|
struct layout_range *range;
|
2015-04-04 13:05:52 +02:00
|
|
|
struct layout_run *r;
|
2017-08-22 11:42:11 +02:00
|
|
|
HRESULT hr = S_OK;
|
2015-04-23 12:02:43 +02:00
|
|
|
|
2017-08-22 11:42:11 +02:00
|
|
|
analyzer = get_text_analyzer();
|
2014-12-23 13:36:32 +01:00
|
|
|
|
2015-06-04 12:37:01 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(range, &layout->ranges, struct layout_range, h.entry) {
|
2017-08-22 11:42:11 +02:00
|
|
|
/* We don't care about ranges that don't contain any text. */
|
2015-06-06 17:50:04 +02:00
|
|
|
if (range->h.range.startPosition >= layout->len)
|
|
|
|
break;
|
|
|
|
|
2017-08-22 11:42:11 +02:00
|
|
|
/* Inline objects override actual text in range. */
|
2015-01-06 21:57:15 +01:00
|
|
|
if (range->object) {
|
|
|
|
hr = layout_update_breakpoints_range(layout, range);
|
2014-12-25 22:01:28 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2015-04-04 13:05:52 +02:00
|
|
|
|
2017-08-22 11:42:10 +02:00
|
|
|
r = alloc_layout_run(LAYOUT_RUN_INLINE, range->h.range.startPosition);
|
2015-04-04 13:05:52 +02:00
|
|
|
if (!r)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
r->u.object.object = range->object;
|
2015-06-06 17:50:04 +02:00
|
|
|
r->u.object.length = get_clipped_range_length(layout, range);
|
2015-04-04 13:05:52 +02:00
|
|
|
list_add_tail(&layout->runs, &r->entry);
|
2014-12-23 13:36:32 +01:00
|
|
|
continue;
|
2014-12-25 22:01:28 +01:00
|
|
|
}
|
2014-12-23 13:36:32 +01:00
|
|
|
|
2017-08-22 11:42:11 +02:00
|
|
|
/* Initial splitting by script. */
|
|
|
|
hr = IDWriteTextAnalyzer_AnalyzeScript(analyzer, (IDWriteTextAnalysisSource *)&layout->IDWriteTextAnalysisSource1_iface,
|
|
|
|
range->h.range.startPosition, get_clipped_range_length(layout, range),
|
|
|
|
(IDWriteTextAnalysisSink *)&layout->IDWriteTextAnalysisSink1_iface);
|
2014-12-23 13:36:32 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
break;
|
2014-12-25 11:34:35 +01:00
|
|
|
|
2017-08-22 11:42:11 +02:00
|
|
|
/* Splitting further by bidi levels. */
|
|
|
|
hr = IDWriteTextAnalyzer_AnalyzeBidi(analyzer, (IDWriteTextAnalysisSource *)&layout->IDWriteTextAnalysisSource1_iface,
|
|
|
|
range->h.range.startPosition, get_clipped_range_length(layout, range),
|
|
|
|
(IDWriteTextAnalysisSink *)&layout->IDWriteTextAnalysisSink1_iface);
|
2014-12-25 11:34:35 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
break;
|
2014-12-23 13:36:32 +01:00
|
|
|
}
|
|
|
|
|
2017-08-22 11:42:11 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT layout_resolve_fonts(struct dwrite_textlayout *layout)
|
|
|
|
{
|
|
|
|
IDWriteFontCollection *sys_collection;
|
|
|
|
IDWriteFontFallback *fallback = NULL;
|
|
|
|
struct layout_range *range;
|
|
|
|
struct layout_run *r;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (FAILED(hr = IDWriteFactory5_GetSystemFontCollection(layout->factory, FALSE,
|
|
|
|
(IDWriteFontCollection1 **)&sys_collection, FALSE))) {
|
|
|
|
WARN("Failed to get system collection, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2016-02-14 17:05:10 +01:00
|
|
|
if (layout->format.fallback) {
|
|
|
|
fallback = layout->format.fallback;
|
|
|
|
IDWriteFontFallback_AddRef(fallback);
|
|
|
|
}
|
|
|
|
else {
|
2017-08-22 11:42:11 +02:00
|
|
|
if (FAILED(hr = IDWriteFactory5_GetSystemFontFallback(layout->factory, &fallback))) {
|
|
|
|
WARN("Failed to get system fallback, hr %#x.\n", hr);
|
|
|
|
goto fatal;
|
|
|
|
}
|
2016-02-14 17:05:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(r, &layout->runs, struct layout_run, entry) {
|
|
|
|
struct regular_layout_run *run = &r->u.regular;
|
2016-06-16 19:47:10 +02:00
|
|
|
IDWriteFont *font;
|
2016-02-14 17:05:10 +01:00
|
|
|
UINT32 length;
|
|
|
|
|
|
|
|
if (r->kind == LAYOUT_RUN_INLINE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
range = get_layout_range_by_pos(layout, run->descr.textPosition);
|
2016-06-16 19:47:10 +02:00
|
|
|
|
|
|
|
if (run->sa.shapes == DWRITE_SCRIPT_SHAPES_NO_VISUAL) {
|
|
|
|
IDWriteFontCollection *collection;
|
|
|
|
|
2017-08-22 11:42:11 +02:00
|
|
|
collection = range->collection ? range->collection : sys_collection;
|
2016-06-16 19:47:10 +02:00
|
|
|
|
2017-08-22 11:42:11 +02:00
|
|
|
if (FAILED(hr = create_matching_font(collection, range->fontfamily, range->weight, range->style,
|
|
|
|
range->stretch, &font))) {
|
|
|
|
WARN("%s: failed to create matching font for non visual run, family %s, collection %p\n",
|
|
|
|
debugstr_rundescr(&run->descr), debugstr_w(range->fontfamily), range->collection);
|
|
|
|
break;
|
2016-06-16 19:47:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &run->run.fontFace);
|
|
|
|
IDWriteFont_Release(font);
|
2017-08-22 11:42:11 +02:00
|
|
|
if (FAILED(hr)) {
|
|
|
|
WARN("Failed to create font face, hr %#x.\n", hr);
|
|
|
|
break;
|
|
|
|
}
|
2016-06-16 19:47:10 +02:00
|
|
|
|
|
|
|
run->run.fontEmSize = range->fontsize;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-02-14 17:05:10 +01:00
|
|
|
length = run->descr.stringLength;
|
|
|
|
|
|
|
|
while (length) {
|
|
|
|
UINT32 mapped_length;
|
|
|
|
FLOAT scale;
|
|
|
|
|
|
|
|
run = &r->u.regular;
|
|
|
|
|
|
|
|
hr = IDWriteFontFallback_MapCharacters(fallback,
|
2017-08-22 11:42:11 +02:00
|
|
|
(IDWriteTextAnalysisSource *)&layout->IDWriteTextAnalysisSource1_iface,
|
2016-02-14 17:05:10 +01:00
|
|
|
run->descr.textPosition,
|
|
|
|
run->descr.stringLength,
|
|
|
|
range->collection,
|
|
|
|
range->fontfamily,
|
|
|
|
range->weight,
|
|
|
|
range->style,
|
|
|
|
range->stretch,
|
|
|
|
&mapped_length,
|
|
|
|
&font,
|
|
|
|
&scale);
|
|
|
|
if (FAILED(hr)) {
|
2017-08-22 11:42:11 +02:00
|
|
|
WARN("%s: failed to map family %s, collection %p, hr %#x.\n", debugstr_rundescr(&run->descr),
|
|
|
|
debugstr_w(range->fontfamily), range->collection, hr);
|
|
|
|
goto fatal;
|
2016-02-14 17:05:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &run->run.fontFace);
|
|
|
|
IDWriteFont_Release(font);
|
2017-08-22 11:42:11 +02:00
|
|
|
if (FAILED(hr)) {
|
|
|
|
WARN("Failed to create font face, hr %#x.\n", hr);
|
|
|
|
goto fatal;
|
|
|
|
}
|
|
|
|
|
2016-02-14 17:05:10 +01:00
|
|
|
run->run.fontEmSize = range->fontsize * scale;
|
|
|
|
|
|
|
|
if (mapped_length < length) {
|
2017-01-30 23:11:06 +01:00
|
|
|
struct regular_layout_run *nextrun;
|
2016-02-14 17:05:10 +01:00
|
|
|
struct layout_run *nextr;
|
|
|
|
|
|
|
|
/* keep mapped part for current run, add another run for the rest */
|
2017-08-22 11:42:10 +02:00
|
|
|
nextr = alloc_layout_run(LAYOUT_RUN_REGULAR, 0);
|
2017-08-22 11:42:11 +02:00
|
|
|
if (!nextr) {
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto fatal;
|
|
|
|
}
|
2016-02-14 17:05:10 +01:00
|
|
|
|
|
|
|
*nextr = *r;
|
2017-08-22 11:42:10 +02:00
|
|
|
nextr->start_position = run->descr.textPosition + mapped_length;
|
2016-02-14 17:05:10 +01:00
|
|
|
nextrun = &nextr->u.regular;
|
2017-08-22 11:42:10 +02:00
|
|
|
nextrun->descr.textPosition = nextr->start_position;
|
2016-02-14 17:05:10 +01:00
|
|
|
nextrun->descr.stringLength = run->descr.stringLength - mapped_length;
|
|
|
|
nextrun->descr.string = &layout->str[nextrun->descr.textPosition];
|
|
|
|
run->descr.stringLength = mapped_length;
|
|
|
|
list_add_after(&r->entry, &nextr->entry);
|
|
|
|
r = nextr;
|
|
|
|
}
|
|
|
|
|
|
|
|
length -= mapped_length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-22 11:42:11 +02:00
|
|
|
fatal:
|
|
|
|
IDWriteFontCollection_Release(sys_collection);
|
|
|
|
if (fallback)
|
|
|
|
IDWriteFontFallback_Release(fallback);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT layout_shape_run(struct dwrite_textlayout *layout, struct regular_layout_run *run)
|
|
|
|
{
|
|
|
|
DWRITE_SHAPING_GLYPH_PROPERTIES *glyph_props;
|
|
|
|
DWRITE_SHAPING_TEXT_PROPERTIES *text_props;
|
|
|
|
IDWriteTextAnalyzer *analyzer;
|
|
|
|
struct layout_range *range;
|
|
|
|
UINT32 max_count;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
range = get_layout_range_by_pos(layout, run->descr.textPosition);
|
|
|
|
run->descr.localeName = range->locale;
|
2019-02-13 08:47:10 +01:00
|
|
|
run->clustermap = heap_calloc(run->descr.stringLength, sizeof(*run->clustermap));
|
2017-08-22 11:42:11 +02:00
|
|
|
|
|
|
|
max_count = 3 * run->descr.stringLength / 2 + 16;
|
2019-02-13 08:47:10 +01:00
|
|
|
run->glyphs = heap_calloc(max_count, sizeof(*run->glyphs));
|
2017-08-22 11:42:11 +02:00
|
|
|
if (!run->clustermap || !run->glyphs)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2019-02-13 08:47:10 +01:00
|
|
|
text_props = heap_calloc(run->descr.stringLength, sizeof(*text_props));
|
|
|
|
glyph_props = heap_calloc(max_count, sizeof(*glyph_props));
|
2017-08-22 11:42:11 +02:00
|
|
|
if (!text_props || !glyph_props) {
|
|
|
|
heap_free(text_props);
|
|
|
|
heap_free(glyph_props);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
analyzer = get_text_analyzer();
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
hr = IDWriteTextAnalyzer_GetGlyphs(analyzer, run->descr.string, run->descr.stringLength, run->run.fontFace,
|
|
|
|
run->run.isSideways, run->run.bidiLevel & 1, &run->sa, run->descr.localeName, NULL /* FIXME */, NULL,
|
|
|
|
NULL, 0, max_count, run->clustermap, text_props, run->glyphs, glyph_props, &run->glyphcount);
|
|
|
|
if (hr == E_NOT_SUFFICIENT_BUFFER) {
|
|
|
|
heap_free(run->glyphs);
|
|
|
|
heap_free(glyph_props);
|
|
|
|
|
|
|
|
max_count = run->glyphcount;
|
|
|
|
|
2019-02-13 08:47:10 +01:00
|
|
|
run->glyphs = heap_calloc(max_count, sizeof(*run->glyphs));
|
|
|
|
glyph_props = heap_calloc(max_count, sizeof(*glyph_props));
|
2017-08-22 11:42:11 +02:00
|
|
|
if (!run->glyphs || !glyph_props) {
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
heap_free(text_props);
|
|
|
|
heap_free(glyph_props);
|
|
|
|
WARN("%s: shaping failed, hr %#x.\n", debugstr_rundescr(&run->descr), hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
run->run.glyphIndices = run->glyphs;
|
|
|
|
run->descr.clusterMap = run->clustermap;
|
|
|
|
|
2019-02-13 08:47:10 +01:00
|
|
|
run->advances = heap_calloc(run->glyphcount, sizeof(*run->advances));
|
|
|
|
run->offsets = heap_calloc(run->glyphcount, sizeof(*run->offsets));
|
2017-08-22 11:42:11 +02:00
|
|
|
if (!run->advances || !run->offsets)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
/* Get advances and offsets. */
|
|
|
|
if (is_layout_gdi_compatible(layout))
|
|
|
|
hr = IDWriteTextAnalyzer_GetGdiCompatibleGlyphPlacements(analyzer, run->descr.string, run->descr.clusterMap,
|
|
|
|
text_props, run->descr.stringLength, run->run.glyphIndices, glyph_props, run->glyphcount,
|
|
|
|
run->run.fontFace, run->run.fontEmSize, layout->ppdip, &layout->transform,
|
|
|
|
layout->measuringmode == DWRITE_MEASURING_MODE_GDI_NATURAL, run->run.isSideways, run->run.bidiLevel & 1,
|
|
|
|
&run->sa, run->descr.localeName, NULL, NULL, 0, run->advances, run->offsets);
|
|
|
|
else
|
|
|
|
hr = IDWriteTextAnalyzer_GetGlyphPlacements(analyzer, run->descr.string, run->descr.clusterMap, text_props,
|
|
|
|
run->descr.stringLength, run->run.glyphIndices, glyph_props, run->glyphcount, run->run.fontFace,
|
|
|
|
run->run.fontEmSize, run->run.isSideways, run->run.bidiLevel & 1, &run->sa, run->descr.localeName,
|
|
|
|
NULL, NULL, 0, run->advances, run->offsets);
|
|
|
|
|
|
|
|
heap_free(text_props);
|
|
|
|
heap_free(glyph_props);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
memset(run->advances, 0, run->glyphcount * sizeof(*run->advances));
|
|
|
|
memset(run->offsets, 0, run->glyphcount * sizeof(*run->offsets));
|
|
|
|
WARN("%s: failed to get glyph placement info, hr %#x.\n", debugstr_rundescr(&run->descr), hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
run->run.glyphAdvances = run->advances;
|
|
|
|
run->run.glyphOffsets = run->offsets;
|
|
|
|
|
|
|
|
/* Special treatment for runs that don't produce visual output, shaping code adds normal glyphs for them,
|
|
|
|
with valid cluster map and potentially with non-zero advances; layout code exposes those as zero
|
|
|
|
width clusters. */
|
|
|
|
if (run->sa.shapes == DWRITE_SCRIPT_SHAPES_NO_VISUAL)
|
|
|
|
run->run.glyphCount = 0;
|
|
|
|
else
|
|
|
|
run->run.glyphCount = run->glyphcount;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT layout_compute_runs(struct dwrite_textlayout *layout)
|
|
|
|
{
|
|
|
|
struct layout_run *r;
|
|
|
|
UINT32 cluster = 0;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
free_layout_eruns(layout);
|
|
|
|
free_layout_runs(layout);
|
|
|
|
|
|
|
|
/* Cluster data arrays are allocated once, assuming one text position per cluster. */
|
|
|
|
if (!layout->clustermetrics && layout->len) {
|
2019-02-13 08:47:10 +01:00
|
|
|
layout->clustermetrics = heap_calloc(layout->len, sizeof(*layout->clustermetrics));
|
|
|
|
layout->clusters = heap_calloc(layout->len, sizeof(*layout->clusters));
|
2017-08-22 11:42:11 +02:00
|
|
|
if (!layout->clustermetrics || !layout->clusters) {
|
|
|
|
heap_free(layout->clustermetrics);
|
|
|
|
heap_free(layout->clusters);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
layout->cluster_count = 0;
|
|
|
|
|
|
|
|
if (FAILED(hr = layout_itemize(layout))) {
|
|
|
|
WARN("Itemization failed, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hr = layout_resolve_fonts(layout))) {
|
|
|
|
WARN("Failed to resolve layout fonts, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
2016-02-14 17:05:10 +01:00
|
|
|
|
2015-01-06 21:57:15 +01:00
|
|
|
/* fill run info */
|
2015-04-04 13:05:52 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(r, &layout->runs, struct layout_run, entry) {
|
|
|
|
struct regular_layout_run *run = &r->u.regular;
|
2015-06-21 14:34:02 +02:00
|
|
|
DWRITE_FONT_METRICS fontmetrics = { 0 };
|
2015-01-06 21:57:15 +01:00
|
|
|
|
2015-04-04 13:05:52 +02:00
|
|
|
/* we need to do very little in case of inline objects */
|
|
|
|
if (r->kind == LAYOUT_RUN_INLINE) {
|
2015-04-23 12:02:43 +02:00
|
|
|
DWRITE_CLUSTER_METRICS *metrics = &layout->clustermetrics[cluster];
|
|
|
|
struct layout_cluster *c = &layout->clusters[cluster];
|
2015-04-04 13:05:52 +02:00
|
|
|
DWRITE_INLINE_OBJECT_METRICS inlinemetrics;
|
|
|
|
|
2016-01-11 14:15:53 +01:00
|
|
|
metrics->width = 0.0f;
|
2015-04-04 13:05:52 +02:00
|
|
|
metrics->length = r->u.object.length;
|
2016-02-01 23:41:10 +01:00
|
|
|
metrics->canWrapLineAfter = 0;
|
|
|
|
metrics->isWhitespace = 0;
|
|
|
|
metrics->isNewline = 0;
|
|
|
|
metrics->isSoftHyphen = 0;
|
|
|
|
metrics->isRightToLeft = 0;
|
2015-04-04 13:05:52 +02:00
|
|
|
metrics->padding = 0;
|
2015-04-23 12:02:43 +02:00
|
|
|
c->run = r;
|
|
|
|
c->position = 0; /* there's always one cluster per inline object, so 0 is valid value */
|
2015-04-04 13:05:52 +02:00
|
|
|
cluster++;
|
|
|
|
|
2015-05-31 10:40:59 +02:00
|
|
|
/* it's not fatal if GetMetrics() fails, all returned metrics are ignored */
|
2015-04-04 13:05:52 +02:00
|
|
|
hr = IDWriteInlineObject_GetMetrics(r->u.object.object, &inlinemetrics);
|
|
|
|
if (FAILED(hr)) {
|
2015-05-31 10:40:59 +02:00
|
|
|
memset(&inlinemetrics, 0, sizeof(inlinemetrics));
|
|
|
|
hr = S_OK;
|
2015-04-04 13:05:52 +02:00
|
|
|
}
|
|
|
|
metrics->width = inlinemetrics.width;
|
2015-06-21 14:34:02 +02:00
|
|
|
r->baseline = inlinemetrics.baseline;
|
|
|
|
r->height = inlinemetrics.height;
|
2015-04-04 13:05:52 +02:00
|
|
|
|
|
|
|
/* FIXME: use resolved breakpoints in this case too */
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-08-22 11:42:11 +02:00
|
|
|
if (FAILED(hr = layout_shape_run(layout, run)))
|
|
|
|
WARN("%s: shaping failed, hr %#x.\n", debugstr_rundescr(&run->descr), hr);
|
2015-06-21 14:34:02 +02:00
|
|
|
|
|
|
|
/* baseline derived from font metrics */
|
2016-01-28 02:17:17 +01:00
|
|
|
layout_get_font_metrics(layout, run->run.fontFace, run->run.fontEmSize, &fontmetrics);
|
|
|
|
layout_get_font_height(run->run.fontEmSize, &fontmetrics, &r->baseline, &r->height);
|
2015-06-21 14:34:02 +02:00
|
|
|
|
2015-04-23 12:02:43 +02:00
|
|
|
layout_set_cluster_metrics(layout, r, &cluster);
|
2015-01-06 21:57:15 +01:00
|
|
|
}
|
|
|
|
|
2015-06-29 11:52:38 +02:00
|
|
|
if (hr == S_OK) {
|
2015-05-05 14:23:17 +02:00
|
|
|
layout->cluster_count = cluster;
|
2015-06-29 11:52:38 +02:00
|
|
|
if (cluster)
|
2016-02-01 23:41:10 +01:00
|
|
|
layout->clustermetrics[cluster-1].canWrapLineAfter = 1;
|
2015-06-29 11:52:38 +02:00
|
|
|
}
|
2015-01-11 22:03:31 +01:00
|
|
|
|
2014-12-23 13:36:32 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT layout_compute(struct dwrite_textlayout *layout)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
2016-07-18 12:03:44 +02:00
|
|
|
if (!(layout->recompute & RECOMPUTE_CLUSTERS))
|
2014-12-23 13:36:32 +01:00
|
|
|
return S_OK;
|
|
|
|
|
2014-12-25 12:03:19 +01:00
|
|
|
/* nominal breakpoints are evaluated only once, because string never changes */
|
2014-12-25 22:01:28 +01:00
|
|
|
if (!layout->nominal_breakpoints) {
|
2014-12-25 12:03:19 +01:00
|
|
|
IDWriteTextAnalyzer *analyzer;
|
|
|
|
|
2019-02-13 08:47:10 +01:00
|
|
|
layout->nominal_breakpoints = heap_calloc(layout->len, sizeof(*layout->nominal_breakpoints));
|
2014-12-25 22:01:28 +01:00
|
|
|
if (!layout->nominal_breakpoints)
|
2014-12-25 12:03:19 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2017-08-22 11:42:11 +02:00
|
|
|
analyzer = get_text_analyzer();
|
2014-12-25 12:03:19 +01:00
|
|
|
|
2017-08-22 11:42:11 +02:00
|
|
|
if (FAILED(hr = IDWriteTextAnalyzer_AnalyzeLineBreakpoints(analyzer,
|
|
|
|
(IDWriteTextAnalysisSource *)&layout->IDWriteTextAnalysisSource1_iface,
|
|
|
|
0, layout->len, (IDWriteTextAnalysisSink *)&layout->IDWriteTextAnalysisSink1_iface)))
|
|
|
|
WARN("Line breakpoints analysis failed, hr %#x.\n", hr);
|
2015-04-03 10:38:23 +02:00
|
|
|
}
|
2014-12-25 12:03:19 +01:00
|
|
|
|
2017-08-22 11:42:11 +02:00
|
|
|
heap_free(layout->actual_breakpoints);
|
|
|
|
layout->actual_breakpoints = NULL;
|
|
|
|
|
2014-12-25 22:01:28 +01:00
|
|
|
hr = layout_compute_runs(layout);
|
|
|
|
|
|
|
|
if (TRACE_ON(dwrite)) {
|
|
|
|
struct layout_run *cur;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(cur, &layout->runs, struct layout_run, entry) {
|
2015-04-04 13:05:52 +02:00
|
|
|
if (cur->kind == LAYOUT_RUN_INLINE)
|
|
|
|
TRACE("run inline object %p, len %u\n", cur->u.object.object, cur->u.object.length);
|
|
|
|
else
|
|
|
|
TRACE("run [%u,%u], len %u, bidilevel %u\n", cur->u.regular.descr.textPosition, cur->u.regular.descr.textPosition +
|
|
|
|
cur->u.regular.descr.stringLength-1, cur->u.regular.descr.stringLength, cur->u.regular.run.bidiLevel);
|
2014-12-25 22:01:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-18 12:03:44 +02:00
|
|
|
layout->recompute &= ~RECOMPUTE_CLUSTERS;
|
2014-12-23 13:36:32 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2015-06-04 22:32:30 +02:00
|
|
|
static inline FLOAT get_cluster_range_width(struct dwrite_textlayout *layout, UINT32 start, UINT32 end)
|
|
|
|
{
|
2016-01-11 14:15:53 +01:00
|
|
|
FLOAT width = 0.0f;
|
2015-06-04 22:32:30 +02:00
|
|
|
for (; start < end; start++)
|
|
|
|
width += layout->clustermetrics[start].width;
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
2015-06-15 00:15:25 +02:00
|
|
|
static struct layout_range_header *get_layout_range_header_by_pos(struct list *ranges, UINT32 pos)
|
|
|
|
{
|
|
|
|
struct layout_range_header *cur;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(cur, ranges, struct layout_range_header, entry) {
|
|
|
|
DWRITE_TEXT_RANGE *r = &cur->range;
|
|
|
|
if (r->startPosition <= pos && pos < r->startPosition + r->length)
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline IUnknown *layout_get_effect_from_pos(struct dwrite_textlayout *layout, UINT32 pos)
|
|
|
|
{
|
|
|
|
struct layout_range_header *h = get_layout_range_header_by_pos(&layout->effects, pos);
|
2015-12-25 13:57:57 +01:00
|
|
|
return ((struct layout_range_iface*)h)->iface;
|
2015-06-15 00:15:25 +02:00
|
|
|
}
|
|
|
|
|
2015-07-09 11:29:09 +02:00
|
|
|
static inline BOOL layout_is_erun_rtl(const struct layout_effective_run *erun)
|
|
|
|
{
|
|
|
|
return erun->run->u.regular.run.bidiLevel & 1;
|
|
|
|
}
|
|
|
|
|
2016-01-17 19:41:56 +01:00
|
|
|
/* A set of parameters that additionally splits resulting runs. It happens after shaping and all text processing,
|
|
|
|
no glyph changes are possible. It's understandable for drawing effects, because DrawGlyphRun() reports them as
|
|
|
|
one of the arguments, but it also happens for decorations, so every effective run has uniform
|
|
|
|
underline/strikethough/effect tuple. */
|
2016-01-12 21:12:05 +01:00
|
|
|
struct layout_final_splitting_params {
|
|
|
|
BOOL strikethrough;
|
|
|
|
BOOL underline;
|
|
|
|
IUnknown *effect;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline BOOL layout_get_strikethrough_from_pos(struct dwrite_textlayout *layout, UINT32 pos)
|
|
|
|
{
|
|
|
|
struct layout_range_header *h = get_layout_range_header_by_pos(&layout->strike_ranges, pos);
|
|
|
|
return ((struct layout_range_bool*)h)->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline BOOL layout_get_underline_from_pos(struct dwrite_textlayout *layout, UINT32 pos)
|
|
|
|
{
|
2016-01-14 22:24:23 +01:00
|
|
|
struct layout_range_header *h = get_layout_range_header_by_pos(&layout->underline_ranges, pos);
|
2016-01-12 21:12:05 +01:00
|
|
|
return ((struct layout_range_bool*)h)->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void layout_splitting_params_from_pos(struct dwrite_textlayout *layout, UINT32 pos,
|
|
|
|
struct layout_final_splitting_params *params)
|
|
|
|
{
|
|
|
|
params->strikethrough = layout_get_strikethrough_from_pos(layout, pos);
|
|
|
|
params->underline = layout_get_underline_from_pos(layout, pos);
|
|
|
|
params->effect = layout_get_effect_from_pos(layout, pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_same_splitting_params(const struct layout_final_splitting_params *left,
|
|
|
|
const struct layout_final_splitting_params *right)
|
|
|
|
{
|
|
|
|
return left->strikethrough == right->strikethrough &&
|
|
|
|
left->underline == right->underline &&
|
|
|
|
left->effect == right->effect;
|
|
|
|
}
|
|
|
|
|
2016-01-14 22:24:23 +01:00
|
|
|
static void layout_get_erun_font_metrics(struct dwrite_textlayout *layout, struct layout_effective_run *erun,
|
|
|
|
DWRITE_FONT_METRICS *metrics)
|
|
|
|
{
|
|
|
|
memset(metrics, 0, sizeof(*metrics));
|
|
|
|
if (is_layout_gdi_compatible(layout)) {
|
|
|
|
HRESULT hr = IDWriteFontFace_GetGdiCompatibleMetrics(
|
|
|
|
erun->run->u.regular.run.fontFace,
|
|
|
|
erun->run->u.regular.run.fontEmSize,
|
|
|
|
layout->ppdip,
|
|
|
|
&layout->transform,
|
|
|
|
metrics);
|
|
|
|
if (FAILED(hr))
|
|
|
|
WARN("failed to get font metrics, 0x%08x\n", hr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
IDWriteFontFace_GetMetrics(erun->run->u.regular.run.fontFace, metrics);
|
|
|
|
}
|
|
|
|
|
2015-05-30 22:51:01 +02:00
|
|
|
/* Effective run is built from consecutive clusters of a single nominal run, 'first_cluster' is 0 based cluster index,
|
|
|
|
'cluster_count' indicates how many clusters to add, including first one. */
|
|
|
|
static HRESULT layout_add_effective_run(struct dwrite_textlayout *layout, const struct layout_run *r, UINT32 first_cluster,
|
2016-01-12 21:12:05 +01:00
|
|
|
UINT32 cluster_count, UINT32 line, FLOAT origin_x, struct layout_final_splitting_params *params)
|
2015-05-05 14:23:17 +02:00
|
|
|
{
|
2015-07-09 11:29:09 +02:00
|
|
|
BOOL is_rtl = layout->format.readingdir == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT;
|
2015-05-30 22:51:01 +02:00
|
|
|
UINT32 i, start, length, last_cluster;
|
2015-05-05 14:23:17 +02:00
|
|
|
struct layout_effective_run *run;
|
|
|
|
|
2015-05-30 17:44:54 +02:00
|
|
|
if (r->kind == LAYOUT_RUN_INLINE) {
|
|
|
|
struct layout_effective_inline *inlineobject;
|
|
|
|
|
|
|
|
inlineobject = heap_alloc(sizeof(*inlineobject));
|
|
|
|
if (!inlineobject)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2017-01-26 05:41:50 +01:00
|
|
|
inlineobject->object = r->u.object.object;
|
2015-07-06 08:05:41 +02:00
|
|
|
inlineobject->width = get_cluster_range_width(layout, first_cluster, first_cluster + cluster_count);
|
2017-04-19 14:15:24 +02:00
|
|
|
inlineobject->origin.x = is_rtl ? origin_x - inlineobject->width : origin_x;
|
|
|
|
inlineobject->origin.y = 0.0f; /* set after line is built */
|
2016-01-11 14:15:53 +01:00
|
|
|
inlineobject->align_dx = 0.0f;
|
2017-01-26 05:41:50 +01:00
|
|
|
inlineobject->baseline = r->baseline;
|
2015-07-09 11:29:09 +02:00
|
|
|
|
2015-05-30 17:44:54 +02:00
|
|
|
/* It's not clear how these two are set, possibly directionality
|
|
|
|
is derived from surrounding text (replaced text could have
|
|
|
|
different ranges which differ in reading direction). */
|
|
|
|
inlineobject->is_sideways = FALSE;
|
|
|
|
inlineobject->is_rtl = FALSE;
|
2015-06-22 10:56:25 +02:00
|
|
|
inlineobject->line = line;
|
2015-06-15 00:15:25 +02:00
|
|
|
|
|
|
|
/* effect assigned from start position and on is used for inline objects */
|
2017-08-22 11:42:10 +02:00
|
|
|
inlineobject->effect = layout_get_effect_from_pos(layout, layout->clusters[first_cluster].position +
|
|
|
|
layout->clusters[first_cluster].run->start_position);
|
2015-06-15 00:15:25 +02:00
|
|
|
|
2015-05-30 17:44:54 +02:00
|
|
|
list_add_tail(&layout->inlineobjects, &inlineobject->entry);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-05 14:23:17 +02:00
|
|
|
run = heap_alloc(sizeof(*run));
|
|
|
|
if (!run)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2015-06-04 22:32:30 +02:00
|
|
|
/* No need to iterate for that, use simple fact that:
|
2017-01-26 05:41:49 +01:00
|
|
|
<last cluster position> = <first cluster position> + <sum of cluster lengths not including last one> */
|
2015-05-30 22:51:01 +02:00
|
|
|
last_cluster = first_cluster + cluster_count - 1;
|
2015-06-04 22:32:30 +02:00
|
|
|
length = layout->clusters[last_cluster].position - layout->clusters[first_cluster].position +
|
|
|
|
layout->clustermetrics[last_cluster].length;
|
2015-05-30 22:51:01 +02:00
|
|
|
|
2019-02-13 08:47:10 +01:00
|
|
|
run->clustermap = heap_calloc(length, sizeof(*run->clustermap));
|
2015-05-05 14:23:17 +02:00
|
|
|
if (!run->clustermap) {
|
|
|
|
heap_free(run);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
run->run = r;
|
2015-05-30 22:51:01 +02:00
|
|
|
run->start = start = layout->clusters[first_cluster].position;
|
2015-05-05 14:23:17 +02:00
|
|
|
run->length = length;
|
2015-07-09 11:29:09 +02:00
|
|
|
run->width = get_cluster_range_width(layout, first_cluster, first_cluster + cluster_count);
|
2017-04-25 07:54:43 +02:00
|
|
|
memset(&run->bbox, 0, sizeof(run->bbox));
|
2015-07-09 11:29:09 +02:00
|
|
|
|
|
|
|
/* Check if run direction matches paragraph direction, if it doesn't adjust by
|
|
|
|
run width */
|
|
|
|
if (layout_is_erun_rtl(run) ^ is_rtl)
|
2017-04-19 14:15:24 +02:00
|
|
|
run->origin.x = is_rtl ? origin_x - run->width : origin_x + run->width;
|
2015-07-09 11:29:09 +02:00
|
|
|
else
|
2017-04-19 14:15:24 +02:00
|
|
|
run->origin.x = origin_x;
|
2015-07-09 11:29:09 +02:00
|
|
|
|
2017-04-19 14:15:24 +02:00
|
|
|
run->origin.y = 0.0f; /* set after line is built */
|
2016-01-11 14:15:53 +01:00
|
|
|
run->align_dx = 0.0f;
|
2015-06-22 10:56:25 +02:00
|
|
|
run->line = line;
|
2015-05-05 14:23:17 +02:00
|
|
|
|
2015-05-30 22:51:01 +02:00
|
|
|
if (r->u.regular.run.glyphCount) {
|
2017-03-30 14:07:02 +02:00
|
|
|
/* Trim leading and trailing clusters. */
|
2015-05-30 22:51:01 +02:00
|
|
|
run->glyphcount = r->u.regular.run.glyphCount - r->u.regular.clustermap[start];
|
2017-03-30 14:07:02 +02:00
|
|
|
if (start + length < r->u.regular.descr.stringLength)
|
2015-06-25 10:10:39 +02:00
|
|
|
run->glyphcount -= r->u.regular.run.glyphCount - r->u.regular.clustermap[start + length];
|
2015-05-30 22:51:01 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
run->glyphcount = 0;
|
2015-05-05 14:23:17 +02:00
|
|
|
|
|
|
|
/* cluster map needs to be shifted */
|
|
|
|
for (i = 0; i < length; i++)
|
2015-06-26 11:32:58 +02:00
|
|
|
run->clustermap[i] = r->u.regular.clustermap[start + i] - r->u.regular.clustermap[start];
|
2015-05-05 14:23:17 +02:00
|
|
|
|
2016-01-12 21:12:07 +01:00
|
|
|
run->effect = params->effect;
|
2016-01-14 22:24:23 +01:00
|
|
|
run->underlined = params->underline;
|
2015-05-05 14:23:17 +02:00
|
|
|
list_add_tail(&layout->eruns, &run->entry);
|
2015-06-04 22:32:30 +02:00
|
|
|
|
|
|
|
/* Strikethrough style is guaranteed to be consistent within effective run,
|
2016-01-17 19:41:56 +01:00
|
|
|
its width equals to run width, thickness and offset are derived from
|
2015-06-04 22:32:30 +02:00
|
|
|
font metrics, rest of the values are from layout or run itself */
|
2016-01-12 21:12:05 +01:00
|
|
|
if (params->strikethrough) {
|
2015-06-04 22:32:30 +02:00
|
|
|
struct layout_strikethrough *s;
|
2016-01-14 22:24:23 +01:00
|
|
|
DWRITE_FONT_METRICS metrics;
|
2015-06-04 22:32:30 +02:00
|
|
|
|
|
|
|
s = heap_alloc(sizeof(*s));
|
|
|
|
if (!s)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2016-01-14 22:24:23 +01:00
|
|
|
layout_get_erun_font_metrics(layout, run, &metrics);
|
2015-06-04 22:32:30 +02:00
|
|
|
s->s.width = get_cluster_range_width(layout, first_cluster, first_cluster + cluster_count);
|
2016-01-13 23:04:54 +01:00
|
|
|
s->s.thickness = SCALE_FONT_METRIC(metrics.strikethroughThickness, r->u.regular.run.fontEmSize, &metrics);
|
|
|
|
/* Negative offset moves it above baseline as Y coordinate grows downward. */
|
|
|
|
s->s.offset = -SCALE_FONT_METRIC(metrics.strikethroughPosition, r->u.regular.run.fontEmSize, &metrics);
|
2015-06-04 22:32:30 +02:00
|
|
|
s->s.readingDirection = layout->format.readingdir;
|
|
|
|
s->s.flowDirection = layout->format.flow;
|
|
|
|
s->s.localeName = r->u.regular.descr.localeName;
|
2015-07-16 12:10:54 +02:00
|
|
|
s->s.measuringMode = layout->measuringmode;
|
2015-06-04 22:32:30 +02:00
|
|
|
s->run = run;
|
|
|
|
|
|
|
|
list_add_tail(&layout->strikethrough, &s->entry);
|
|
|
|
}
|
|
|
|
|
2015-05-05 14:23:17 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-08-28 13:18:04 +02:00
|
|
|
static void layout_apply_line_spacing(struct dwrite_textlayout *layout, UINT32 line)
|
|
|
|
{
|
|
|
|
switch (layout->format.spacing.method)
|
|
|
|
{
|
|
|
|
case DWRITE_LINE_SPACING_METHOD_DEFAULT:
|
2019-05-14 12:27:28 +02:00
|
|
|
layout->lines[line].metrics.height = layout->lines[line].height;
|
|
|
|
layout->lines[line].metrics.baseline = layout->lines[line].baseline;
|
2017-08-28 13:18:04 +02:00
|
|
|
break;
|
|
|
|
case DWRITE_LINE_SPACING_METHOD_UNIFORM:
|
2019-05-14 12:27:28 +02:00
|
|
|
layout->lines[line].metrics.height = layout->format.spacing.height;
|
|
|
|
layout->lines[line].metrics.baseline = layout->format.spacing.baseline;
|
2017-08-28 13:18:04 +02:00
|
|
|
break;
|
|
|
|
case DWRITE_LINE_SPACING_METHOD_PROPORTIONAL:
|
2019-05-14 12:27:28 +02:00
|
|
|
layout->lines[line].metrics.height = layout->lines[line].height * layout->format.spacing.height;
|
|
|
|
layout->lines[line].metrics.baseline = layout->lines[line].baseline * layout->format.spacing.baseline;
|
2017-08-28 13:18:04 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Unknown spacing method %u\n", layout->format.spacing.method);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
static HRESULT layout_set_line_metrics(struct dwrite_textlayout *layout, DWRITE_LINE_METRICS1 *metrics)
|
2015-05-05 14:23:17 +02:00
|
|
|
{
|
2019-05-14 12:27:28 +02:00
|
|
|
size_t i = layout->metrics.lineCount;
|
2017-02-02 00:11:34 +01:00
|
|
|
|
2019-05-14 12:27:28 +02:00
|
|
|
if (!dwrite_array_reserve((void **)&layout->lines, &layout->lines_size, layout->metrics.lineCount + 1,
|
|
|
|
sizeof(*layout->lines)))
|
|
|
|
{
|
|
|
|
return E_OUTOFMEMORY;
|
2015-05-05 14:23:17 +02:00
|
|
|
}
|
|
|
|
|
2019-05-14 12:27:28 +02:00
|
|
|
layout->lines[i].metrics = *metrics;
|
2017-02-02 00:11:35 +01:00
|
|
|
layout->lines[i].height = metrics->height;
|
|
|
|
layout->lines[i].baseline = metrics->baseline;
|
2017-02-02 00:11:34 +01:00
|
|
|
|
2017-08-28 13:18:04 +02:00
|
|
|
if (layout->format.spacing.method != DWRITE_LINE_SPACING_METHOD_DEFAULT)
|
|
|
|
layout_apply_line_spacing(layout, i);
|
|
|
|
|
2017-02-02 00:11:34 +01:00
|
|
|
layout->metrics.lineCount++;
|
2015-05-05 14:23:17 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-06-22 10:56:25 +02:00
|
|
|
static inline struct layout_effective_run *layout_get_next_erun(struct dwrite_textlayout *layout,
|
|
|
|
const struct layout_effective_run *cur)
|
|
|
|
{
|
|
|
|
struct list *e;
|
|
|
|
|
|
|
|
if (!cur)
|
|
|
|
e = list_head(&layout->eruns);
|
|
|
|
else
|
|
|
|
e = list_next(&layout->eruns, &cur->entry);
|
|
|
|
if (!e)
|
|
|
|
return NULL;
|
|
|
|
return LIST_ENTRY(e, struct layout_effective_run, entry);
|
|
|
|
}
|
|
|
|
|
2016-01-14 22:24:23 +01:00
|
|
|
static inline struct layout_effective_run *layout_get_prev_erun(struct dwrite_textlayout *layout,
|
|
|
|
const struct layout_effective_run *cur)
|
|
|
|
{
|
|
|
|
struct list *e;
|
|
|
|
|
|
|
|
if (!cur)
|
|
|
|
e = list_tail(&layout->eruns);
|
|
|
|
else
|
|
|
|
e = list_prev(&layout->eruns, &cur->entry);
|
|
|
|
if (!e)
|
|
|
|
return NULL;
|
|
|
|
return LIST_ENTRY(e, struct layout_effective_run, entry);
|
|
|
|
}
|
|
|
|
|
2015-06-22 10:56:25 +02:00
|
|
|
static inline struct layout_effective_inline *layout_get_next_inline_run(struct dwrite_textlayout *layout,
|
|
|
|
const struct layout_effective_inline *cur)
|
|
|
|
{
|
|
|
|
struct list *e;
|
|
|
|
|
|
|
|
if (!cur)
|
|
|
|
e = list_head(&layout->inlineobjects);
|
|
|
|
else
|
|
|
|
e = list_next(&layout->inlineobjects, &cur->entry);
|
|
|
|
if (!e)
|
|
|
|
return NULL;
|
|
|
|
return LIST_ENTRY(e, struct layout_effective_inline, entry);
|
|
|
|
}
|
|
|
|
|
2015-07-06 08:05:41 +02:00
|
|
|
static FLOAT layout_get_line_width(struct dwrite_textlayout *layout,
|
|
|
|
struct layout_effective_run *erun, struct layout_effective_inline *inrun, UINT32 line)
|
|
|
|
{
|
2016-01-11 14:15:53 +01:00
|
|
|
FLOAT width = 0.0f;
|
2015-07-06 08:05:41 +02:00
|
|
|
|
|
|
|
while (erun && erun->line == line) {
|
|
|
|
width += erun->width;
|
|
|
|
erun = layout_get_next_erun(layout, erun);
|
|
|
|
if (!erun)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (inrun && inrun->line == line) {
|
|
|
|
width += inrun->width;
|
|
|
|
inrun = layout_get_next_inline_run(layout, inrun);
|
|
|
|
if (!inrun)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
2015-07-20 14:15:01 +02:00
|
|
|
static inline BOOL should_skip_transform(const DWRITE_MATRIX *m, FLOAT *det)
|
|
|
|
{
|
|
|
|
*det = m->m11 * m->m22 - m->m12 * m->m21;
|
|
|
|
/* on certain conditions we can skip transform */
|
|
|
|
return (!memcmp(m, &identity, sizeof(*m)) || fabsf(*det) <= 1e-10f);
|
|
|
|
}
|
|
|
|
|
2017-04-19 14:15:24 +02:00
|
|
|
static inline void layout_apply_snapping(D2D1_POINT_2F *vec, BOOL skiptransform, FLOAT ppdip,
|
2015-07-20 14:15:01 +02:00
|
|
|
const DWRITE_MATRIX *m, FLOAT det)
|
|
|
|
{
|
|
|
|
if (!skiptransform) {
|
2017-04-19 14:15:24 +02:00
|
|
|
D2D1_POINT_2F vec2;
|
2015-07-20 14:15:01 +02:00
|
|
|
|
|
|
|
/* apply transform */
|
|
|
|
vec->x *= ppdip;
|
|
|
|
vec->y *= ppdip;
|
|
|
|
|
2017-04-19 14:15:24 +02:00
|
|
|
vec2.x = m->m11 * vec->x + m->m21 * vec->y + m->dx;
|
|
|
|
vec2.y = m->m12 * vec->x + m->m22 * vec->y + m->dy;
|
2015-07-20 14:15:01 +02:00
|
|
|
|
|
|
|
/* snap */
|
2017-04-19 14:15:24 +02:00
|
|
|
vec2.x = floorf(vec2.x + 0.5f);
|
|
|
|
vec2.y = floorf(vec2.y + 0.5f);
|
2015-07-20 14:15:01 +02:00
|
|
|
|
|
|
|
/* apply inverted transform, we don't care about X component at this point */
|
2017-04-19 14:15:24 +02:00
|
|
|
vec->x = (m->m22 * vec2.x - m->m21 * vec2.y + m->m21 * m->dy - m->m22 * m->dx) / det;
|
2015-07-20 14:15:01 +02:00
|
|
|
vec->x /= ppdip;
|
|
|
|
|
2017-04-19 14:15:24 +02:00
|
|
|
vec->y = (-m->m12 * vec2.x + m->m11 * vec2.y - (m->m11 * m->dy - m->m12 * m->dx)) / det;
|
2015-07-20 14:15:01 +02:00
|
|
|
vec->y /= ppdip;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
vec->x = floorf(vec->x * ppdip + 0.5f) / ppdip;
|
|
|
|
vec->y = floorf(vec->y * ppdip + 0.5f) / ppdip;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-06 08:05:41 +02:00
|
|
|
static void layout_apply_leading_alignment(struct dwrite_textlayout *layout)
|
|
|
|
{
|
2015-07-09 11:26:23 +02:00
|
|
|
BOOL is_rtl = layout->format.readingdir == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT;
|
2015-07-06 08:05:41 +02:00
|
|
|
struct layout_effective_inline *inrun;
|
|
|
|
struct layout_effective_run *erun;
|
|
|
|
|
|
|
|
erun = layout_get_next_erun(layout, NULL);
|
|
|
|
inrun = layout_get_next_inline_run(layout, NULL);
|
|
|
|
|
|
|
|
while (erun) {
|
2016-01-11 14:15:53 +01:00
|
|
|
erun->align_dx = 0.0f;
|
2015-07-06 08:05:41 +02:00
|
|
|
erun = layout_get_next_erun(layout, erun);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (inrun) {
|
2016-01-11 14:15:53 +01:00
|
|
|
inrun->align_dx = 0.0f;
|
2015-07-06 08:05:41 +02:00
|
|
|
inrun = layout_get_next_inline_run(layout, inrun);
|
|
|
|
}
|
|
|
|
|
2016-01-11 14:15:53 +01:00
|
|
|
layout->metrics.left = is_rtl ? layout->metrics.layoutWidth - layout->metrics.width : 0.0f;
|
2015-07-06 08:05:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void layout_apply_trailing_alignment(struct dwrite_textlayout *layout)
|
|
|
|
{
|
2015-07-09 11:26:23 +02:00
|
|
|
BOOL is_rtl = layout->format.readingdir == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT;
|
2015-07-06 08:05:41 +02:00
|
|
|
struct layout_effective_inline *inrun;
|
|
|
|
struct layout_effective_run *erun;
|
|
|
|
UINT32 line;
|
|
|
|
|
|
|
|
erun = layout_get_next_erun(layout, NULL);
|
|
|
|
inrun = layout_get_next_inline_run(layout, NULL);
|
|
|
|
|
|
|
|
for (line = 0; line < layout->metrics.lineCount; line++) {
|
|
|
|
FLOAT width = layout_get_line_width(layout, erun, inrun, line);
|
|
|
|
FLOAT shift = layout->metrics.layoutWidth - width;
|
|
|
|
|
2015-07-09 11:26:23 +02:00
|
|
|
if (is_rtl)
|
2016-01-11 14:15:53 +01:00
|
|
|
shift *= -1.0f;
|
2015-07-09 11:26:23 +02:00
|
|
|
|
2015-07-06 08:05:41 +02:00
|
|
|
while (erun && erun->line == line) {
|
|
|
|
erun->align_dx = shift;
|
|
|
|
erun = layout_get_next_erun(layout, erun);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (inrun && inrun->line == line) {
|
2015-07-06 22:08:11 +02:00
|
|
|
inrun->align_dx = shift;
|
2015-07-06 08:05:41 +02:00
|
|
|
inrun = layout_get_next_inline_run(layout, inrun);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-11 14:15:53 +01:00
|
|
|
layout->metrics.left = is_rtl ? 0.0f : layout->metrics.layoutWidth - layout->metrics.width;
|
2015-07-06 08:05:41 +02:00
|
|
|
}
|
|
|
|
|
2015-07-20 14:15:01 +02:00
|
|
|
static inline FLOAT layout_get_centered_shift(struct dwrite_textlayout *layout, BOOL skiptransform,
|
|
|
|
FLOAT width, FLOAT det)
|
|
|
|
{
|
|
|
|
if (is_layout_gdi_compatible(layout)) {
|
2017-04-19 14:15:24 +02:00
|
|
|
D2D1_POINT_2F vec = { layout->metrics.layoutWidth - width, 0.0f};
|
2015-07-20 14:15:01 +02:00
|
|
|
layout_apply_snapping(&vec, skiptransform, layout->ppdip, &layout->transform, det);
|
|
|
|
return floorf(vec.x / 2.0f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return (layout->metrics.layoutWidth - width) / 2.0f;
|
|
|
|
}
|
|
|
|
|
2015-07-06 22:08:11 +02:00
|
|
|
static void layout_apply_centered_alignment(struct dwrite_textlayout *layout)
|
|
|
|
{
|
2015-07-09 11:26:23 +02:00
|
|
|
BOOL is_rtl = layout->format.readingdir == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT;
|
2015-07-06 22:08:11 +02:00
|
|
|
struct layout_effective_inline *inrun;
|
|
|
|
struct layout_effective_run *erun;
|
2015-07-20 14:15:01 +02:00
|
|
|
BOOL skiptransform;
|
2015-07-06 22:08:11 +02:00
|
|
|
UINT32 line;
|
2015-07-20 14:15:01 +02:00
|
|
|
FLOAT det;
|
2015-07-06 22:08:11 +02:00
|
|
|
|
|
|
|
erun = layout_get_next_erun(layout, NULL);
|
|
|
|
inrun = layout_get_next_inline_run(layout, NULL);
|
|
|
|
|
2015-07-20 14:15:01 +02:00
|
|
|
skiptransform = should_skip_transform(&layout->transform, &det);
|
|
|
|
|
2015-07-06 22:08:11 +02:00
|
|
|
for (line = 0; line < layout->metrics.lineCount; line++) {
|
|
|
|
FLOAT width = layout_get_line_width(layout, erun, inrun, line);
|
2015-07-20 14:15:01 +02:00
|
|
|
FLOAT shift = layout_get_centered_shift(layout, skiptransform, width, det);
|
2015-07-06 22:08:11 +02:00
|
|
|
|
2015-07-09 11:26:23 +02:00
|
|
|
if (is_rtl)
|
2016-01-11 14:15:53 +01:00
|
|
|
shift *= -1.0f;
|
2015-07-09 11:26:23 +02:00
|
|
|
|
2015-07-06 22:08:11 +02:00
|
|
|
while (erun && erun->line == line) {
|
|
|
|
erun->align_dx = shift;
|
|
|
|
erun = layout_get_next_erun(layout, erun);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (inrun && inrun->line == line) {
|
|
|
|
inrun->align_dx = shift;
|
|
|
|
inrun = layout_get_next_inline_run(layout, inrun);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-11 14:15:53 +01:00
|
|
|
layout->metrics.left = (layout->metrics.layoutWidth - layout->metrics.width) / 2.0f;
|
2015-07-06 22:08:11 +02:00
|
|
|
}
|
|
|
|
|
2015-07-06 08:05:41 +02:00
|
|
|
static void layout_apply_text_alignment(struct dwrite_textlayout *layout)
|
|
|
|
{
|
|
|
|
switch (layout->format.textalignment)
|
|
|
|
{
|
|
|
|
case DWRITE_TEXT_ALIGNMENT_LEADING:
|
|
|
|
layout_apply_leading_alignment(layout);
|
|
|
|
break;
|
|
|
|
case DWRITE_TEXT_ALIGNMENT_TRAILING:
|
|
|
|
layout_apply_trailing_alignment(layout);
|
|
|
|
break;
|
|
|
|
case DWRITE_TEXT_ALIGNMENT_CENTER:
|
2015-07-06 22:08:11 +02:00
|
|
|
layout_apply_centered_alignment(layout);
|
|
|
|
break;
|
|
|
|
case DWRITE_TEXT_ALIGNMENT_JUSTIFIED:
|
2015-07-06 08:05:41 +02:00
|
|
|
FIXME("alignment %d not implemented\n", layout->format.textalignment);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-06 08:06:08 +02:00
|
|
|
static void layout_apply_par_alignment(struct dwrite_textlayout *layout)
|
|
|
|
{
|
|
|
|
struct layout_effective_inline *inrun;
|
|
|
|
struct layout_effective_run *erun;
|
2016-01-11 14:15:53 +01:00
|
|
|
FLOAT origin_y = 0.0f;
|
2015-07-06 08:06:08 +02:00
|
|
|
UINT32 line;
|
|
|
|
|
|
|
|
/* alignment mode defines origin, after that all run origins are updated
|
|
|
|
the same way */
|
|
|
|
|
|
|
|
switch (layout->format.paralign)
|
|
|
|
{
|
|
|
|
case DWRITE_PARAGRAPH_ALIGNMENT_NEAR:
|
2016-01-11 14:15:53 +01:00
|
|
|
origin_y = 0.0f;
|
2015-07-06 08:06:08 +02:00
|
|
|
break;
|
|
|
|
case DWRITE_PARAGRAPH_ALIGNMENT_FAR:
|
|
|
|
origin_y = layout->metrics.layoutHeight - layout->metrics.height;
|
|
|
|
break;
|
|
|
|
case DWRITE_PARAGRAPH_ALIGNMENT_CENTER:
|
2016-01-11 14:15:53 +01:00
|
|
|
origin_y = (layout->metrics.layoutHeight - layout->metrics.height) / 2.0f;
|
2015-07-06 08:06:08 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
layout->metrics.top = origin_y;
|
|
|
|
|
|
|
|
erun = layout_get_next_erun(layout, NULL);
|
|
|
|
inrun = layout_get_next_inline_run(layout, NULL);
|
2019-05-14 12:27:28 +02:00
|
|
|
for (line = 0; line < layout->metrics.lineCount; line++)
|
|
|
|
{
|
|
|
|
float pos_y = origin_y + layout->lines[line].metrics.baseline;
|
2015-07-06 08:06:08 +02:00
|
|
|
|
|
|
|
while (erun && erun->line == line) {
|
2017-04-19 14:15:24 +02:00
|
|
|
erun->origin.y = pos_y;
|
2015-07-06 08:06:08 +02:00
|
|
|
erun = layout_get_next_erun(layout, erun);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (inrun && inrun->line == line) {
|
2017-04-19 14:15:24 +02:00
|
|
|
inrun->origin.y = pos_y - inrun->baseline;
|
2015-07-06 08:06:08 +02:00
|
|
|
inrun = layout_get_next_inline_run(layout, inrun);
|
|
|
|
}
|
2017-02-02 00:11:35 +01:00
|
|
|
|
2019-05-14 12:27:28 +02:00
|
|
|
origin_y += layout->lines[line].metrics.height;
|
2015-07-06 08:06:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-14 22:24:23 +01:00
|
|
|
struct layout_underline_splitting_params {
|
|
|
|
const WCHAR *locale; /* points to range data, no additional allocation */
|
|
|
|
IUnknown *effect; /* does not hold another reference */
|
|
|
|
};
|
|
|
|
|
|
|
|
static void init_u_splitting_params_from_erun(struct layout_effective_run *erun,
|
|
|
|
struct layout_underline_splitting_params *params)
|
|
|
|
{
|
|
|
|
params->locale = erun->run->u.regular.descr.localeName;
|
|
|
|
params->effect = erun->effect;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_same_u_splitting(struct layout_underline_splitting_params *left,
|
|
|
|
struct layout_underline_splitting_params *right)
|
|
|
|
{
|
|
|
|
return left->effect == right->effect && !strcmpiW(left->locale, right->locale);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT layout_add_underline(struct dwrite_textlayout *layout, struct layout_effective_run *first,
|
|
|
|
struct layout_effective_run *last)
|
|
|
|
{
|
2017-02-23 14:39:25 +01:00
|
|
|
FLOAT thickness, offset, runheight;
|
2016-01-14 22:24:23 +01:00
|
|
|
struct layout_effective_run *cur;
|
|
|
|
DWRITE_FONT_METRICS metrics;
|
|
|
|
|
|
|
|
if (first == layout_get_prev_erun(layout, last)) {
|
|
|
|
layout_get_erun_font_metrics(layout, first, &metrics);
|
|
|
|
thickness = SCALE_FONT_METRIC(metrics.underlineThickness, first->run->u.regular.run.fontEmSize, &metrics);
|
|
|
|
offset = SCALE_FONT_METRIC(metrics.underlinePosition, first->run->u.regular.run.fontEmSize, &metrics);
|
2017-02-23 14:39:25 +01:00
|
|
|
runheight = SCALE_FONT_METRIC(metrics.capHeight, first->run->u.regular.run.fontEmSize, &metrics);
|
2016-01-14 22:24:23 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
FLOAT width = 0.0f;
|
|
|
|
|
|
|
|
/* Single underline is added for consecutive underlined runs. In this case underline parameters are
|
|
|
|
calculated as weighted average, where run width acts as a weight. */
|
2017-02-23 14:39:25 +01:00
|
|
|
thickness = offset = runheight = 0.0f;
|
2016-01-14 22:24:23 +01:00
|
|
|
cur = first;
|
|
|
|
do {
|
|
|
|
layout_get_erun_font_metrics(layout, cur, &metrics);
|
|
|
|
|
|
|
|
thickness += SCALE_FONT_METRIC(metrics.underlineThickness, cur->run->u.regular.run.fontEmSize, &metrics) * cur->width;
|
|
|
|
offset += SCALE_FONT_METRIC(metrics.underlinePosition, cur->run->u.regular.run.fontEmSize, &metrics) * cur->width;
|
2017-02-23 14:39:25 +01:00
|
|
|
runheight = max(SCALE_FONT_METRIC(metrics.capHeight, cur->run->u.regular.run.fontEmSize, &metrics), runheight);
|
2016-01-14 22:24:23 +01:00
|
|
|
width += cur->width;
|
|
|
|
|
|
|
|
cur = layout_get_next_erun(layout, cur);
|
|
|
|
} while (cur != last);
|
|
|
|
|
|
|
|
thickness /= width;
|
|
|
|
offset /= width;
|
|
|
|
}
|
|
|
|
|
|
|
|
cur = first;
|
|
|
|
do {
|
2016-01-24 16:11:01 +01:00
|
|
|
struct layout_underline_splitting_params params, prev_params;
|
2016-01-14 22:24:23 +01:00
|
|
|
struct layout_effective_run *next, *w;
|
|
|
|
struct layout_underline *u;
|
|
|
|
|
|
|
|
init_u_splitting_params_from_erun(cur, &prev_params);
|
|
|
|
while ((next = layout_get_next_erun(layout, cur)) != last) {
|
|
|
|
init_u_splitting_params_from_erun(next, ¶ms);
|
|
|
|
if (!is_same_u_splitting(&prev_params, ¶ms))
|
|
|
|
break;
|
|
|
|
cur = next;
|
|
|
|
}
|
|
|
|
|
|
|
|
u = heap_alloc(sizeof(*u));
|
|
|
|
if (!u)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
w = cur;
|
|
|
|
u->u.width = 0.0f;
|
|
|
|
while (w != next) {
|
|
|
|
u->u.width += w->width;
|
|
|
|
w = layout_get_next_erun(layout, w);
|
|
|
|
}
|
|
|
|
|
|
|
|
u->u.thickness = thickness;
|
|
|
|
/* Font metrics convention is to have it negative when below baseline, for rendering
|
|
|
|
however Y grows from baseline down for horizontal baseline. */
|
|
|
|
u->u.offset = -offset;
|
2017-02-23 14:39:25 +01:00
|
|
|
u->u.runHeight = runheight;
|
2016-01-19 21:23:01 +01:00
|
|
|
u->u.readingDirection = is_run_rtl(cur) ? DWRITE_READING_DIRECTION_RIGHT_TO_LEFT :
|
|
|
|
DWRITE_READING_DIRECTION_LEFT_TO_RIGHT;
|
2016-01-14 22:24:23 +01:00
|
|
|
u->u.flowDirection = layout->format.flow;
|
|
|
|
u->u.localeName = cur->run->u.regular.descr.localeName;
|
|
|
|
u->u.measuringMode = layout->measuringmode;
|
|
|
|
u->run = cur;
|
|
|
|
list_add_tail(&layout->underlines, &u->entry);
|
|
|
|
|
|
|
|
cur = next;
|
|
|
|
} while (cur != last);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2016-01-12 21:12:05 +01:00
|
|
|
|
2016-02-02 21:14:37 +01:00
|
|
|
/* Adds zero width line, metrics are derived from font at specified text position. */
|
2017-01-26 05:41:49 +01:00
|
|
|
static HRESULT layout_set_dummy_line_metrics(struct dwrite_textlayout *layout, UINT32 pos)
|
2016-02-02 21:14:37 +01:00
|
|
|
{
|
2017-01-26 05:41:49 +01:00
|
|
|
DWRITE_LINE_METRICS1 metrics = { 0 };
|
2016-02-02 21:14:37 +01:00
|
|
|
DWRITE_FONT_METRICS fontmetrics;
|
|
|
|
struct layout_range *range;
|
|
|
|
IDWriteFontFace *fontface;
|
2016-02-14 17:05:10 +01:00
|
|
|
IDWriteFont *font;
|
2016-02-02 21:14:37 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
range = get_layout_range_by_pos(layout, pos);
|
2016-02-14 17:05:10 +01:00
|
|
|
hr = create_matching_font(range->collection,
|
|
|
|
range->fontfamily,
|
|
|
|
range->weight,
|
|
|
|
range->style,
|
|
|
|
range->stretch,
|
|
|
|
&font);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &fontface);
|
|
|
|
IDWriteFont_Release(font);
|
2016-02-02 21:14:37 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
layout_get_font_metrics(layout, fontface, range->fontsize, &fontmetrics);
|
|
|
|
layout_get_font_height(range->fontsize, &fontmetrics, &metrics.baseline, &metrics.height);
|
|
|
|
IDWriteFontFace_Release(fontface);
|
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
return layout_set_line_metrics(layout, &metrics);
|
2016-02-02 21:14:37 +01:00
|
|
|
}
|
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
static void layout_add_line(struct dwrite_textlayout *layout, UINT32 first_cluster, UINT32 last_cluster,
|
|
|
|
UINT32 *textpos)
|
2015-05-05 14:23:17 +02:00
|
|
|
{
|
2015-07-09 11:26:23 +02:00
|
|
|
BOOL is_rtl = layout->format.readingdir == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT;
|
2017-01-26 05:41:49 +01:00
|
|
|
struct layout_final_splitting_params params, prev_params;
|
2017-01-26 05:41:50 +01:00
|
|
|
DWRITE_INLINE_OBJECT_METRICS sign_metrics = { 0 };
|
2017-01-26 05:41:49 +01:00
|
|
|
UINT32 line = layout->metrics.lineCount, i;
|
|
|
|
DWRITE_LINE_METRICS1 metrics = { 0 };
|
2017-01-26 05:41:50 +01:00
|
|
|
UINT32 index, start, pos = *textpos;
|
2017-01-26 05:41:49 +01:00
|
|
|
FLOAT descent, trailingspacewidth;
|
2017-01-26 05:41:50 +01:00
|
|
|
BOOL append_trimming_run = FALSE;
|
2015-05-05 14:23:17 +02:00
|
|
|
const struct layout_run *run;
|
2019-05-13 13:21:45 +02:00
|
|
|
float width = 0.0f, origin_x;
|
2015-05-05 14:23:17 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
/* Take a look at clusters we got for this line in reverse order to set trailing properties for current line */
|
|
|
|
for (index = last_cluster, trailingspacewidth = 0.0f; index >= first_cluster; index--) {
|
|
|
|
DWRITE_CLUSTER_METRICS *cluster = &layout->clustermetrics[index];
|
|
|
|
struct layout_cluster *lc = &layout->clusters[index];
|
|
|
|
WCHAR ch;
|
2015-05-05 14:23:17 +02:00
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
/* This also filters out clusters added from inline objects, those are never
|
|
|
|
treated as a white space. */
|
|
|
|
if (!cluster->isWhitespace)
|
|
|
|
break;
|
2017-01-26 05:41:47 +01:00
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
/* Every isNewline cluster is also isWhitespace, but not every
|
|
|
|
newline character cluster has isNewline set, so go back to original string. */
|
|
|
|
ch = lc->run->u.regular.descr.string[lc->position];
|
|
|
|
if (cluster->length == 1 && lb_is_newline_char(ch))
|
|
|
|
metrics.newlineLength += cluster->length;
|
2015-05-05 14:23:17 +02:00
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
metrics.trailingWhitespaceLength += cluster->length;
|
|
|
|
trailingspacewidth += cluster->width;
|
2019-04-15 17:22:46 +02:00
|
|
|
|
|
|
|
if (index == 0)
|
|
|
|
break;
|
2017-01-26 05:41:49 +01:00
|
|
|
}
|
2016-01-12 21:12:05 +01:00
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
/* Line metrics length includes trailing whitespace length too */
|
|
|
|
for (i = first_cluster; i <= last_cluster; i++)
|
|
|
|
metrics.length += layout->clustermetrics[i].length;
|
2015-05-05 14:23:17 +02:00
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
/* Ignore trailing whitespaces */
|
|
|
|
while (last_cluster > first_cluster) {
|
|
|
|
if (!layout->clustermetrics[last_cluster].isWhitespace)
|
|
|
|
break;
|
2015-05-30 17:44:54 +02:00
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
last_cluster--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Does not include trailing space width */
|
2019-05-13 13:21:45 +02:00
|
|
|
if (!layout->clustermetrics[last_cluster].isWhitespace)
|
|
|
|
width = get_cluster_range_width(layout, first_cluster, last_cluster + 1);
|
2017-01-26 05:41:49 +01:00
|
|
|
|
2017-01-26 05:41:50 +01:00
|
|
|
/* Append trimming run if necessary */
|
|
|
|
if (width > layout->metrics.layoutWidth && layout->format.trimmingsign != NULL &&
|
|
|
|
layout->format.trimming.granularity != DWRITE_TRIMMING_GRANULARITY_NONE) {
|
|
|
|
FLOAT trimmed_width = width;
|
|
|
|
|
|
|
|
hr = IDWriteInlineObject_GetMetrics(layout->format.trimmingsign, &sign_metrics);
|
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
while (last_cluster > first_cluster) {
|
|
|
|
if (trimmed_width + sign_metrics.width <= layout->metrics.layoutWidth)
|
|
|
|
break;
|
2017-09-11 11:37:14 +02:00
|
|
|
if (layout->format.trimming.granularity == DWRITE_TRIMMING_GRANULARITY_CHARACTER)
|
|
|
|
trimmed_width -= layout->clustermetrics[last_cluster--].width;
|
|
|
|
else {
|
|
|
|
while (last_cluster > first_cluster) {
|
|
|
|
trimmed_width -= layout->clustermetrics[last_cluster].width;
|
|
|
|
if (layout->clustermetrics[last_cluster--].canWrapLineAfter)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-01-26 05:41:50 +01:00
|
|
|
}
|
|
|
|
append_trimming_run = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
WARN("Failed to get trimming sign metrics, lines won't be trimmed, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
width = trimmed_width + sign_metrics.width;
|
|
|
|
}
|
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
layout_splitting_params_from_pos(layout, pos, ¶ms);
|
|
|
|
prev_params = params;
|
|
|
|
run = layout->clusters[first_cluster].run;
|
|
|
|
|
|
|
|
/* Form runs from a range of clusters; this is what will be reported with DrawGlyphRun() */
|
|
|
|
origin_x = is_rtl ? layout->metrics.layoutWidth : 0.0f;
|
|
|
|
for (start = first_cluster, i = first_cluster; i <= last_cluster; i++) {
|
|
|
|
layout_splitting_params_from_pos(layout, pos, ¶ms);
|
2015-06-04 22:32:30 +02:00
|
|
|
|
2016-01-12 21:12:05 +01:00
|
|
|
if (run != layout->clusters[i].run || !is_same_splitting_params(&prev_params, ¶ms)) {
|
|
|
|
hr = layout_add_effective_run(layout, run, start, i - start, line, origin_x, &prev_params);
|
2015-05-05 14:23:17 +02:00
|
|
|
if (FAILED(hr))
|
2017-01-26 05:41:49 +01:00
|
|
|
return;
|
|
|
|
|
2015-07-09 11:29:09 +02:00
|
|
|
origin_x += is_rtl ? -get_cluster_range_width(layout, start, i) :
|
2017-01-26 05:41:49 +01:00
|
|
|
get_cluster_range_width(layout, start, i);
|
2015-06-04 22:32:30 +02:00
|
|
|
run = layout->clusters[i].run;
|
2015-05-05 14:23:17 +02:00
|
|
|
start = i;
|
|
|
|
}
|
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
prev_params = params;
|
|
|
|
pos += layout->clustermetrics[i].length;
|
|
|
|
}
|
2015-05-05 14:23:17 +02:00
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
/* Final run from what's left from cluster range */
|
|
|
|
hr = layout_add_effective_run(layout, run, start, i - start, line, origin_x, &prev_params);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return;
|
|
|
|
|
2018-09-21 15:54:19 +02:00
|
|
|
if (get_cluster_range_width(layout, start, i) + sign_metrics.width > layout->metrics.layoutWidth)
|
|
|
|
append_trimming_run = FALSE;
|
|
|
|
|
2017-01-26 05:41:50 +01:00
|
|
|
if (append_trimming_run) {
|
|
|
|
struct layout_effective_inline *trimming_sign;
|
|
|
|
|
|
|
|
trimming_sign = heap_alloc(sizeof(*trimming_sign));
|
|
|
|
if (!trimming_sign)
|
|
|
|
return;
|
|
|
|
|
|
|
|
trimming_sign->object = layout->format.trimmingsign;
|
|
|
|
trimming_sign->width = sign_metrics.width;
|
|
|
|
origin_x += is_rtl ? -get_cluster_range_width(layout, start, i) : get_cluster_range_width(layout, start, i);
|
2017-04-19 14:15:24 +02:00
|
|
|
trimming_sign->origin.x = is_rtl ? origin_x - trimming_sign->width : origin_x;
|
|
|
|
trimming_sign->origin.y = 0.0f; /* set after line is built */
|
2017-01-26 05:41:50 +01:00
|
|
|
trimming_sign->align_dx = 0.0f;
|
|
|
|
trimming_sign->baseline = sign_metrics.baseline;
|
|
|
|
|
|
|
|
trimming_sign->is_sideways = FALSE;
|
|
|
|
trimming_sign->is_rtl = FALSE;
|
|
|
|
trimming_sign->line = line;
|
|
|
|
|
2017-08-22 11:42:10 +02:00
|
|
|
trimming_sign->effect = layout_get_effect_from_pos(layout, layout->clusters[i].position +
|
|
|
|
layout->clusters[i].run->start_position);
|
2017-01-26 05:41:50 +01:00
|
|
|
|
|
|
|
list_add_tail(&layout->inlineobjects, &trimming_sign->entry);
|
|
|
|
}
|
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
/* Look for max baseline and descent for this line */
|
2017-01-26 05:41:50 +01:00
|
|
|
for (index = first_cluster, metrics.baseline = 0.0f, descent = 0.0f; index <= last_cluster; index++) {
|
2017-01-26 05:41:49 +01:00
|
|
|
const struct layout_run *cur = layout->clusters[index].run;
|
|
|
|
FLOAT cur_descent = cur->height - cur->baseline;
|
|
|
|
|
|
|
|
if (cur->baseline > metrics.baseline)
|
|
|
|
metrics.baseline = cur->baseline;
|
|
|
|
if (cur_descent > descent)
|
|
|
|
descent = cur_descent;
|
|
|
|
}
|
2015-05-05 14:23:17 +02:00
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
layout->metrics.width = max(width, layout->metrics.width);
|
|
|
|
layout->metrics.widthIncludingTrailingWhitespace = max(width + trailingspacewidth,
|
|
|
|
layout->metrics.widthIncludingTrailingWhitespace);
|
2015-05-05 14:23:17 +02:00
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
metrics.height = descent + metrics.baseline;
|
2017-01-26 05:41:50 +01:00
|
|
|
metrics.isTrimmed = append_trimming_run || width > layout->metrics.layoutWidth;
|
2017-01-26 05:41:49 +01:00
|
|
|
layout_set_line_metrics(layout, &metrics);
|
2015-06-21 14:34:02 +02:00
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
*textpos += metrics.length;
|
|
|
|
}
|
2015-06-21 14:34:02 +02:00
|
|
|
|
2017-02-02 00:11:35 +01:00
|
|
|
static void layout_set_line_positions(struct dwrite_textlayout *layout)
|
|
|
|
{
|
|
|
|
struct layout_effective_inline *inrun;
|
|
|
|
struct layout_effective_run *erun;
|
|
|
|
FLOAT origin_y;
|
|
|
|
UINT32 line;
|
|
|
|
|
|
|
|
/* Now all line info is here, update effective runs positions in flow direction */
|
|
|
|
erun = layout_get_next_erun(layout, NULL);
|
|
|
|
inrun = layout_get_next_inline_run(layout, NULL);
|
|
|
|
|
2019-05-14 12:27:28 +02:00
|
|
|
for (line = 0, origin_y = 0.0f; line < layout->metrics.lineCount; line++)
|
|
|
|
{
|
|
|
|
float pos_y = origin_y + layout->lines[line].metrics.baseline;
|
2017-02-02 00:11:35 +01:00
|
|
|
|
|
|
|
/* For all runs on this line */
|
|
|
|
while (erun && erun->line == line) {
|
2017-04-19 14:15:24 +02:00
|
|
|
erun->origin.y = pos_y;
|
2017-02-02 00:11:35 +01:00
|
|
|
erun = layout_get_next_erun(layout, erun);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Same for inline runs */
|
|
|
|
while (inrun && inrun->line == line) {
|
2017-04-19 14:15:24 +02:00
|
|
|
inrun->origin.y = pos_y - inrun->baseline;
|
2017-02-02 00:11:35 +01:00
|
|
|
inrun = layout_get_next_inline_run(layout, inrun);
|
|
|
|
}
|
|
|
|
|
2019-05-14 12:27:28 +02:00
|
|
|
origin_y += layout->lines[line].metrics.height;
|
2017-02-02 00:11:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
layout->metrics.height = origin_y;
|
|
|
|
|
|
|
|
/* Initial paragraph alignment is always near */
|
|
|
|
if (layout->format.paralign != DWRITE_PARAGRAPH_ALIGNMENT_NEAR)
|
|
|
|
layout_apply_par_alignment(layout);
|
|
|
|
}
|
|
|
|
|
2017-01-31 12:43:10 +01:00
|
|
|
static BOOL layout_can_wrap_after(const struct dwrite_textlayout *layout, UINT32 cluster)
|
|
|
|
{
|
|
|
|
if (layout->format.wrapping == DWRITE_WORD_WRAPPING_CHARACTER)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return layout->clustermetrics[cluster].canWrapLineAfter;
|
|
|
|
}
|
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
static HRESULT layout_compute_effective_runs(struct dwrite_textlayout *layout)
|
|
|
|
{
|
|
|
|
BOOL is_rtl = layout->format.readingdir == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT;
|
|
|
|
struct layout_effective_run *erun, *first_underlined;
|
2017-02-02 00:11:35 +01:00
|
|
|
UINT32 i, start, textpos, last_breaking_point;
|
2017-01-26 05:41:49 +01:00
|
|
|
DWRITE_LINE_METRICS1 metrics;
|
2017-02-02 00:11:35 +01:00
|
|
|
FLOAT width;
|
|
|
|
UINT32 line;
|
2017-01-26 05:41:49 +01:00
|
|
|
HRESULT hr;
|
2015-06-21 14:34:02 +02:00
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
if (!(layout->recompute & RECOMPUTE_LINES))
|
|
|
|
return S_OK;
|
2015-06-21 14:34:02 +02:00
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
free_layout_eruns(layout);
|
2015-07-01 19:43:30 +02:00
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
hr = layout_compute(layout);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2015-05-05 14:23:17 +02:00
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
layout->metrics.lineCount = 0;
|
|
|
|
memset(&metrics, 0, sizeof(metrics));
|
|
|
|
|
|
|
|
layout->metrics.height = 0.0f;
|
|
|
|
layout->metrics.width = 0.0f;
|
|
|
|
layout->metrics.widthIncludingTrailingWhitespace = 0.0f;
|
|
|
|
|
|
|
|
last_breaking_point = ~0u;
|
|
|
|
|
|
|
|
for (i = 0, start = 0, width = 0.0f, textpos = 0; i < layout->cluster_count; i++) {
|
|
|
|
BOOL overflow = FALSE;
|
|
|
|
|
|
|
|
while (i < layout->cluster_count && !layout->clustermetrics[i].isNewline) {
|
|
|
|
/* Check for overflow */
|
|
|
|
overflow = ((width + layout->clustermetrics[i].width > layout->metrics.layoutWidth) &&
|
|
|
|
(layout->format.wrapping != DWRITE_WORD_WRAPPING_NO_WRAP));
|
|
|
|
if (overflow)
|
|
|
|
break;
|
|
|
|
|
2017-01-31 12:43:10 +01:00
|
|
|
if (layout_can_wrap_after(layout, i))
|
2017-01-26 05:41:49 +01:00
|
|
|
last_breaking_point = i;
|
2015-05-05 14:23:17 +02:00
|
|
|
width += layout->clustermetrics[i].width;
|
2017-01-26 05:41:49 +01:00
|
|
|
i++;
|
2015-05-05 14:23:17 +02:00
|
|
|
}
|
2017-01-26 05:41:49 +01:00
|
|
|
i = min(i, layout->cluster_count - 1);
|
|
|
|
|
2017-02-03 13:20:27 +01:00
|
|
|
/* Ignore if overflown on whitespace */
|
|
|
|
if (overflow && !(layout->clustermetrics[i].isWhitespace && layout_can_wrap_after(layout, i))) {
|
2017-01-26 05:41:49 +01:00
|
|
|
/* Use most recently found breaking point */
|
2017-02-03 13:20:27 +01:00
|
|
|
if (last_breaking_point != ~0u) {
|
2017-01-26 05:41:49 +01:00
|
|
|
i = last_breaking_point;
|
|
|
|
last_breaking_point = ~0u;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Otherwise proceed forward to next newline or breaking point */
|
|
|
|
for (; i < layout->cluster_count; i++)
|
2017-01-31 12:43:10 +01:00
|
|
|
if (layout_can_wrap_after(layout, i) || layout->clustermetrics[i].isNewline)
|
2017-01-26 05:41:49 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i = min(i, layout->cluster_count - 1);
|
2015-05-05 14:23:17 +02:00
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
layout_add_line(layout, start, i, &textpos);
|
|
|
|
start = i + 1;
|
|
|
|
width = 0.0f;
|
2015-05-05 14:23:17 +02:00
|
|
|
}
|
|
|
|
|
2016-02-02 21:14:37 +01:00
|
|
|
/* Add dummy line if:
|
|
|
|
- there's no text, metrics come from first range in this case;
|
|
|
|
- last ended with a mandatory break, metrics come from last text position.
|
|
|
|
*/
|
|
|
|
if (layout->len == 0)
|
2017-01-26 05:41:49 +01:00
|
|
|
hr = layout_set_dummy_line_metrics(layout, 0);
|
2018-08-13 10:22:06 +02:00
|
|
|
else if (layout->cluster_count && layout->clustermetrics[layout->cluster_count - 1].isNewline)
|
2017-01-26 05:41:49 +01:00
|
|
|
hr = layout_set_dummy_line_metrics(layout, layout->len - 1);
|
2016-02-02 21:14:37 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2016-01-28 02:17:17 +01:00
|
|
|
|
|
|
|
layout->metrics.left = is_rtl ? layout->metrics.layoutWidth - layout->metrics.width : 0.0f;
|
2016-01-11 14:15:53 +01:00
|
|
|
layout->metrics.top = 0.0f;
|
2015-07-01 19:43:30 +02:00
|
|
|
layout->metrics.maxBidiReorderingDepth = 1; /* FIXME */
|
|
|
|
|
2017-02-02 00:11:35 +01:00
|
|
|
/* Add explicit underlined runs */
|
2015-06-22 10:56:25 +02:00
|
|
|
erun = layout_get_next_erun(layout, NULL);
|
2016-01-14 22:24:23 +01:00
|
|
|
first_underlined = erun && erun->underlined ? erun : NULL;
|
2015-07-06 08:04:43 +02:00
|
|
|
for (line = 0; line < layout->metrics.lineCount; line++) {
|
2015-06-22 10:56:25 +02:00
|
|
|
while (erun && erun->line == line) {
|
|
|
|
erun = layout_get_next_erun(layout, erun);
|
2016-01-14 22:24:23 +01:00
|
|
|
|
|
|
|
if (first_underlined && (!erun || !erun->underlined)) {
|
|
|
|
layout_add_underline(layout, first_underlined, erun);
|
|
|
|
first_underlined = NULL;
|
|
|
|
}
|
|
|
|
else if (!first_underlined && erun && erun->underlined)
|
|
|
|
first_underlined = erun;
|
2015-06-22 10:56:25 +02:00
|
|
|
}
|
|
|
|
}
|
2017-01-26 05:41:50 +01:00
|
|
|
|
2017-02-02 00:11:35 +01:00
|
|
|
/* Position runs in flow direction */
|
|
|
|
layout_set_line_positions(layout);
|
2015-06-22 10:56:25 +02:00
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
/* Initial alignment is always leading */
|
2015-07-06 08:05:41 +02:00
|
|
|
if (layout->format.textalignment != DWRITE_TEXT_ALIGNMENT_LEADING)
|
|
|
|
layout_apply_text_alignment(layout);
|
|
|
|
|
2016-07-18 12:03:44 +02:00
|
|
|
layout->recompute &= ~RECOMPUTE_LINES;
|
2015-05-05 14:23:17 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2017-01-26 05:41:49 +01:00
|
|
|
static BOOL is_same_layout_attrvalue(struct layout_range_header const *h, enum layout_range_attr_kind attr,
|
|
|
|
struct layout_range_attr_value *value)
|
2014-08-13 21:15:46 +02:00
|
|
|
{
|
2015-06-18 18:52:15 +02:00
|
|
|
struct layout_range_spacing const *range_spacing = (struct layout_range_spacing*)h;
|
2015-12-25 13:57:57 +01:00
|
|
|
struct layout_range_iface const *range_iface = (struct layout_range_iface*)h;
|
2015-06-04 16:55:26 +02:00
|
|
|
struct layout_range_bool const *range_bool = (struct layout_range_bool*)h;
|
|
|
|
struct layout_range const *range = (struct layout_range*)h;
|
|
|
|
|
2014-08-13 21:15:46 +02:00
|
|
|
switch (attr) {
|
|
|
|
case LAYOUT_RANGE_ATTR_WEIGHT:
|
|
|
|
return range->weight == value->u.weight;
|
2014-08-13 21:29:07 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_STYLE:
|
|
|
|
return range->style == value->u.style;
|
2014-08-24 17:24:18 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_STRETCH:
|
|
|
|
return range->stretch == value->u.stretch;
|
2014-08-24 18:46:16 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_FONTSIZE:
|
|
|
|
return range->fontsize == value->u.fontsize;
|
2014-08-13 21:15:46 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_INLINE:
|
|
|
|
return range->object == value->u.object;
|
2014-08-13 21:29:07 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_EFFECT:
|
2015-12-25 13:57:57 +01:00
|
|
|
return range_iface->iface == value->u.effect;
|
2014-08-13 21:29:07 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_UNDERLINE:
|
2016-01-12 21:12:06 +01:00
|
|
|
return range_bool->value == value->u.underline;
|
2014-08-13 21:29:07 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_STRIKETHROUGH:
|
2015-06-04 16:55:26 +02:00
|
|
|
return range_bool->value == value->u.strikethrough;
|
2015-03-13 09:25:18 +01:00
|
|
|
case LAYOUT_RANGE_ATTR_PAIR_KERNING:
|
|
|
|
return range->pair_kerning == value->u.pair_kerning;
|
2014-08-24 17:24:18 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_FONTCOLL:
|
|
|
|
return range->collection == value->u.collection;
|
2015-01-01 19:50:59 +01:00
|
|
|
case LAYOUT_RANGE_ATTR_LOCALE:
|
2015-12-25 13:58:01 +01:00
|
|
|
return strcmpiW(range->locale, value->u.locale) == 0;
|
2015-01-02 20:22:40 +01:00
|
|
|
case LAYOUT_RANGE_ATTR_FONTFAMILY:
|
|
|
|
return strcmpW(range->fontfamily, value->u.fontfamily) == 0;
|
2015-06-18 18:52:15 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_SPACING:
|
2017-08-22 11:42:09 +02:00
|
|
|
return range_spacing->leading == value->u.spacing.leading &&
|
|
|
|
range_spacing->trailing == value->u.spacing.trailing &&
|
|
|
|
range_spacing->min_advance == value->u.spacing.min_advance;
|
2015-12-25 13:57:57 +01:00
|
|
|
case LAYOUT_RANGE_ATTR_TYPOGRAPHY:
|
|
|
|
return range_iface->iface == (IUnknown*)value->u.typography;
|
2014-08-13 21:15:46 +02:00
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
static inline BOOL is_same_layout_attributes(struct layout_range_header const *hleft, struct layout_range_header const *hright)
|
2014-08-15 05:10:58 +02:00
|
|
|
{
|
2015-06-04 16:55:26 +02:00
|
|
|
switch (hleft->kind)
|
|
|
|
{
|
|
|
|
case LAYOUT_RANGE_REGULAR:
|
|
|
|
{
|
|
|
|
struct layout_range const *left = (struct layout_range const*)hleft;
|
|
|
|
struct layout_range const *right = (struct layout_range const*)hright;
|
|
|
|
return left->weight == right->weight &&
|
|
|
|
left->style == right->style &&
|
|
|
|
left->stretch == right->stretch &&
|
|
|
|
left->fontsize == right->fontsize &&
|
|
|
|
left->object == right->object &&
|
|
|
|
left->pair_kerning == right->pair_kerning &&
|
|
|
|
left->collection == right->collection &&
|
2015-12-25 13:58:01 +01:00
|
|
|
!strcmpiW(left->locale, right->locale) &&
|
2015-06-04 16:55:26 +02:00
|
|
|
!strcmpW(left->fontfamily, right->fontfamily);
|
|
|
|
}
|
2016-01-12 21:12:06 +01:00
|
|
|
case LAYOUT_RANGE_UNDERLINE:
|
2015-06-04 16:55:26 +02:00
|
|
|
case LAYOUT_RANGE_STRIKETHROUGH:
|
|
|
|
{
|
|
|
|
struct layout_range_bool const *left = (struct layout_range_bool const*)hleft;
|
|
|
|
struct layout_range_bool const *right = (struct layout_range_bool const*)hright;
|
|
|
|
return left->value == right->value;
|
|
|
|
}
|
2015-06-15 00:15:25 +02:00
|
|
|
case LAYOUT_RANGE_EFFECT:
|
2015-12-25 13:57:57 +01:00
|
|
|
case LAYOUT_RANGE_TYPOGRAPHY:
|
2015-06-15 00:15:25 +02:00
|
|
|
{
|
2015-12-25 13:57:57 +01:00
|
|
|
struct layout_range_iface const *left = (struct layout_range_iface const*)hleft;
|
|
|
|
struct layout_range_iface const *right = (struct layout_range_iface const*)hright;
|
|
|
|
return left->iface == right->iface;
|
2015-06-15 00:15:25 +02:00
|
|
|
}
|
2015-06-18 18:52:15 +02:00
|
|
|
case LAYOUT_RANGE_SPACING:
|
|
|
|
{
|
|
|
|
struct layout_range_spacing const *left = (struct layout_range_spacing const*)hleft;
|
|
|
|
struct layout_range_spacing const *right = (struct layout_range_spacing const*)hright;
|
|
|
|
return left->leading == right->leading &&
|
|
|
|
left->trailing == right->trailing &&
|
|
|
|
left->min_advance == right->min_advance;
|
|
|
|
}
|
2015-06-04 16:55:26 +02:00
|
|
|
default:
|
|
|
|
FIXME("unknown range kind %d\n", hleft->kind);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-08-15 05:10:58 +02:00
|
|
|
}
|
|
|
|
|
2014-08-13 21:15:46 +02:00
|
|
|
static inline BOOL is_same_text_range(const DWRITE_TEXT_RANGE *left, const DWRITE_TEXT_RANGE *right)
|
|
|
|
{
|
|
|
|
return left->startPosition == right->startPosition && left->length == right->length;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocates range and inits it with default values from text format. */
|
2015-06-04 16:55:26 +02:00
|
|
|
static struct layout_range_header *alloc_layout_range(struct dwrite_textlayout *layout, const DWRITE_TEXT_RANGE *r,
|
|
|
|
enum layout_range_kind kind)
|
2014-08-13 21:15:46 +02:00
|
|
|
{
|
2015-06-04 16:55:26 +02:00
|
|
|
struct layout_range_header *h;
|
2014-08-13 21:15:46 +02:00
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
switch (kind)
|
|
|
|
{
|
|
|
|
case LAYOUT_RANGE_REGULAR:
|
|
|
|
{
|
|
|
|
struct layout_range *range;
|
|
|
|
|
|
|
|
range = heap_alloc(sizeof(*range));
|
|
|
|
if (!range) return NULL;
|
|
|
|
|
|
|
|
range->weight = layout->format.weight;
|
|
|
|
range->style = layout->format.style;
|
|
|
|
range->stretch = layout->format.stretch;
|
|
|
|
range->fontsize = layout->format.fontsize;
|
|
|
|
range->object = NULL;
|
|
|
|
range->pair_kerning = FALSE;
|
|
|
|
|
|
|
|
range->fontfamily = heap_strdupW(layout->format.family_name);
|
|
|
|
if (!range->fontfamily) {
|
|
|
|
heap_free(range);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
range->collection = layout->format.collection;
|
|
|
|
if (range->collection)
|
|
|
|
IDWriteFontCollection_AddRef(range->collection);
|
|
|
|
strcpyW(range->locale, layout->format.locale);
|
|
|
|
|
|
|
|
h = &range->h;
|
|
|
|
break;
|
2015-01-02 20:22:40 +01:00
|
|
|
}
|
2016-01-12 21:12:06 +01:00
|
|
|
case LAYOUT_RANGE_UNDERLINE:
|
2015-06-04 16:55:26 +02:00
|
|
|
case LAYOUT_RANGE_STRIKETHROUGH:
|
|
|
|
{
|
|
|
|
struct layout_range_bool *range;
|
|
|
|
|
|
|
|
range = heap_alloc(sizeof(*range));
|
|
|
|
if (!range) return NULL;
|
2015-01-02 20:22:40 +01:00
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
range->value = FALSE;
|
|
|
|
h = &range->h;
|
|
|
|
break;
|
|
|
|
}
|
2015-06-15 00:15:25 +02:00
|
|
|
case LAYOUT_RANGE_EFFECT:
|
2015-12-25 13:57:57 +01:00
|
|
|
case LAYOUT_RANGE_TYPOGRAPHY:
|
2015-06-15 00:15:25 +02:00
|
|
|
{
|
2015-12-25 13:57:57 +01:00
|
|
|
struct layout_range_iface *range;
|
2015-06-15 00:15:25 +02:00
|
|
|
|
|
|
|
range = heap_alloc(sizeof(*range));
|
|
|
|
if (!range) return NULL;
|
|
|
|
|
2015-12-25 13:57:57 +01:00
|
|
|
range->iface = NULL;
|
2015-06-15 00:15:25 +02:00
|
|
|
h = &range->h;
|
|
|
|
break;
|
|
|
|
}
|
2015-06-18 18:52:15 +02:00
|
|
|
case LAYOUT_RANGE_SPACING:
|
|
|
|
{
|
|
|
|
struct layout_range_spacing *range;
|
|
|
|
|
|
|
|
range = heap_alloc(sizeof(*range));
|
|
|
|
if (!range) return NULL;
|
|
|
|
|
2016-01-11 14:15:53 +01:00
|
|
|
range->leading = 0.0f;
|
|
|
|
range->trailing = 0.0f;
|
|
|
|
range->min_advance = 0.0f;
|
2015-06-18 18:52:15 +02:00
|
|
|
h = &range->h;
|
|
|
|
break;
|
|
|
|
}
|
2015-06-04 16:55:26 +02:00
|
|
|
default:
|
|
|
|
FIXME("unknown range kind %d\n", kind);
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-08-13 21:15:46 +02:00
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
h->kind = kind;
|
|
|
|
h->range = *r;
|
|
|
|
return h;
|
2014-08-13 21:15:46 +02:00
|
|
|
}
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
static struct layout_range_header *alloc_layout_range_from(struct layout_range_header *h, const DWRITE_TEXT_RANGE *r)
|
2014-08-13 21:15:46 +02:00
|
|
|
{
|
2015-06-04 16:55:26 +02:00
|
|
|
struct layout_range_header *ret;
|
2014-08-13 21:15:46 +02:00
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
switch (h->kind)
|
|
|
|
{
|
|
|
|
case LAYOUT_RANGE_REGULAR:
|
|
|
|
{
|
|
|
|
struct layout_range *from = (struct layout_range*)h;
|
2014-08-13 21:15:46 +02:00
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
struct layout_range *range = heap_alloc(sizeof(*range));
|
|
|
|
if (!range) return NULL;
|
2014-08-13 21:15:46 +02:00
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
*range = *from;
|
|
|
|
range->fontfamily = heap_strdupW(from->fontfamily);
|
|
|
|
if (!range->fontfamily) {
|
|
|
|
heap_free(range);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* update refcounts */
|
|
|
|
if (range->object)
|
|
|
|
IDWriteInlineObject_AddRef(range->object);
|
|
|
|
if (range->collection)
|
|
|
|
IDWriteFontCollection_AddRef(range->collection);
|
|
|
|
ret = &range->h;
|
|
|
|
break;
|
2015-03-11 18:46:11 +01:00
|
|
|
}
|
2016-01-12 21:12:06 +01:00
|
|
|
case LAYOUT_RANGE_UNDERLINE:
|
2015-06-04 16:55:26 +02:00
|
|
|
case LAYOUT_RANGE_STRIKETHROUGH:
|
|
|
|
{
|
|
|
|
struct layout_range_bool *strike = heap_alloc(sizeof(*strike));
|
|
|
|
if (!strike) return NULL;
|
2015-03-11 18:46:11 +01:00
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
*strike = *(struct layout_range_bool*)h;
|
|
|
|
ret = &strike->h;
|
|
|
|
break;
|
|
|
|
}
|
2015-06-15 00:15:25 +02:00
|
|
|
case LAYOUT_RANGE_EFFECT:
|
2015-12-25 13:57:57 +01:00
|
|
|
case LAYOUT_RANGE_TYPOGRAPHY:
|
2015-06-15 00:15:25 +02:00
|
|
|
{
|
2015-12-25 13:57:57 +01:00
|
|
|
struct layout_range_iface *effect = heap_alloc(sizeof(*effect));
|
2015-06-15 00:15:25 +02:00
|
|
|
if (!effect) return NULL;
|
|
|
|
|
2015-12-25 13:57:57 +01:00
|
|
|
*effect = *(struct layout_range_iface*)h;
|
|
|
|
if (effect->iface)
|
|
|
|
IUnknown_AddRef(effect->iface);
|
2015-06-15 00:15:25 +02:00
|
|
|
ret = &effect->h;
|
|
|
|
break;
|
|
|
|
}
|
2015-06-18 18:52:15 +02:00
|
|
|
case LAYOUT_RANGE_SPACING:
|
|
|
|
{
|
|
|
|
struct layout_range_spacing *spacing = heap_alloc(sizeof(*spacing));
|
|
|
|
if (!spacing) return NULL;
|
|
|
|
|
|
|
|
*spacing = *(struct layout_range_spacing*)h;
|
|
|
|
ret = &spacing->h;
|
|
|
|
break;
|
|
|
|
}
|
2015-06-04 16:55:26 +02:00
|
|
|
default:
|
|
|
|
FIXME("unknown range kind %d\n", h->kind);
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-08-13 21:29:07 +02:00
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
ret->range = *r;
|
|
|
|
return ret;
|
2014-08-13 21:15:46 +02:00
|
|
|
}
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
static void free_layout_range(struct layout_range_header *h)
|
2014-08-13 21:15:46 +02:00
|
|
|
{
|
2015-06-04 16:55:26 +02:00
|
|
|
if (!h)
|
2014-09-21 14:26:13 +02:00
|
|
|
return;
|
2015-06-04 16:55:26 +02:00
|
|
|
|
2015-06-15 00:15:25 +02:00
|
|
|
switch (h->kind)
|
|
|
|
{
|
|
|
|
case LAYOUT_RANGE_REGULAR:
|
|
|
|
{
|
2015-06-04 16:55:26 +02:00
|
|
|
struct layout_range *range = (struct layout_range*)h;
|
|
|
|
|
|
|
|
if (range->object)
|
|
|
|
IDWriteInlineObject_Release(range->object);
|
|
|
|
if (range->collection)
|
|
|
|
IDWriteFontCollection_Release(range->collection);
|
|
|
|
heap_free(range->fontfamily);
|
2015-06-15 00:15:25 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LAYOUT_RANGE_EFFECT:
|
2015-12-25 13:57:57 +01:00
|
|
|
case LAYOUT_RANGE_TYPOGRAPHY:
|
2015-06-15 00:15:25 +02:00
|
|
|
{
|
2015-12-25 13:57:57 +01:00
|
|
|
struct layout_range_iface *range = (struct layout_range_iface*)h;
|
|
|
|
if (range->iface)
|
|
|
|
IUnknown_Release(range->iface);
|
2015-06-15 00:15:25 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
;
|
2015-06-04 16:55:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
heap_free(h);
|
2014-08-13 21:15:46 +02:00
|
|
|
}
|
|
|
|
|
2014-08-19 04:22:56 +02:00
|
|
|
static void free_layout_ranges_list(struct dwrite_textlayout *layout)
|
2014-08-13 21:15:46 +02:00
|
|
|
{
|
2015-06-04 16:55:26 +02:00
|
|
|
struct layout_range_header *cur, *cur2;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(cur, cur2, &layout->ranges, struct layout_range_header, entry) {
|
|
|
|
list_remove(&cur->entry);
|
|
|
|
free_layout_range(cur);
|
|
|
|
}
|
|
|
|
|
2016-01-12 21:12:06 +01:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(cur, cur2, &layout->underline_ranges, struct layout_range_header, entry) {
|
|
|
|
list_remove(&cur->entry);
|
|
|
|
free_layout_range(cur);
|
|
|
|
}
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(cur, cur2, &layout->strike_ranges, struct layout_range_header, entry) {
|
|
|
|
list_remove(&cur->entry);
|
2014-08-13 21:15:46 +02:00
|
|
|
free_layout_range(cur);
|
|
|
|
}
|
2015-06-15 00:15:25 +02:00
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(cur, cur2, &layout->effects, struct layout_range_header, entry) {
|
|
|
|
list_remove(&cur->entry);
|
|
|
|
free_layout_range(cur);
|
|
|
|
}
|
2015-06-18 18:52:15 +02:00
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(cur, cur2, &layout->spacing, struct layout_range_header, entry) {
|
|
|
|
list_remove(&cur->entry);
|
|
|
|
free_layout_range(cur);
|
|
|
|
}
|
2015-12-25 13:57:57 +01:00
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(cur, cur2, &layout->typographies, struct layout_range_header, entry) {
|
|
|
|
list_remove(&cur->entry);
|
|
|
|
free_layout_range(cur);
|
|
|
|
}
|
2014-08-13 21:15:46 +02:00
|
|
|
}
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
static struct layout_range_header *find_outer_range(struct list *ranges, const DWRITE_TEXT_RANGE *range)
|
2014-08-13 21:15:46 +02:00
|
|
|
{
|
2015-06-04 16:55:26 +02:00
|
|
|
struct layout_range_header *cur;
|
2014-08-13 21:15:46 +02:00
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(cur, ranges, struct layout_range_header, entry) {
|
2014-08-13 21:15:46 +02:00
|
|
|
|
|
|
|
if (cur->range.startPosition > range->startPosition)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if ((cur->range.startPosition + cur->range.length < range->startPosition + range->length) &&
|
|
|
|
(range->startPosition < cur->range.startPosition + cur->range.length))
|
|
|
|
return NULL;
|
|
|
|
if (cur->range.startPosition + cur->range.length >= range->startPosition + range->length)
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-08-19 04:22:56 +02:00
|
|
|
static struct layout_range *get_layout_range_by_pos(struct dwrite_textlayout *layout, UINT32 pos)
|
2014-08-13 21:15:46 +02:00
|
|
|
{
|
|
|
|
struct layout_range *cur;
|
|
|
|
|
2015-06-04 12:37:01 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(cur, &layout->ranges, struct layout_range, h.entry) {
|
2015-06-04 16:55:26 +02:00
|
|
|
DWRITE_TEXT_RANGE *r = &cur->h.range;
|
|
|
|
if (r->startPosition <= pos && pos < r->startPosition + r->length)
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-03-11 20:20:34 +01:00
|
|
|
static inline BOOL set_layout_range_iface_attr(IUnknown **dest, IUnknown *value)
|
|
|
|
{
|
|
|
|
if (*dest == value) return FALSE;
|
|
|
|
|
|
|
|
if (*dest)
|
|
|
|
IUnknown_Release(*dest);
|
|
|
|
*dest = value;
|
|
|
|
if (*dest)
|
|
|
|
IUnknown_AddRef(*dest);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
static BOOL set_layout_range_attrval(struct layout_range_header *h, enum layout_range_attr_kind attr, struct layout_range_attr_value *value)
|
2014-08-13 21:15:46 +02:00
|
|
|
{
|
2015-06-18 18:52:15 +02:00
|
|
|
struct layout_range_spacing *dest_spacing = (struct layout_range_spacing*)h;
|
2015-12-25 13:57:57 +01:00
|
|
|
struct layout_range_iface *dest_iface = (struct layout_range_iface*)h;
|
2015-06-04 16:55:26 +02:00
|
|
|
struct layout_range_bool *dest_bool = (struct layout_range_bool*)h;
|
|
|
|
struct layout_range *dest = (struct layout_range*)h;
|
|
|
|
|
2014-08-13 21:15:46 +02:00
|
|
|
BOOL changed = FALSE;
|
|
|
|
|
|
|
|
switch (attr) {
|
|
|
|
case LAYOUT_RANGE_ATTR_WEIGHT:
|
|
|
|
changed = dest->weight != value->u.weight;
|
|
|
|
dest->weight = value->u.weight;
|
|
|
|
break;
|
2014-08-13 21:29:07 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_STYLE:
|
|
|
|
changed = dest->style != value->u.style;
|
|
|
|
dest->style = value->u.style;
|
|
|
|
break;
|
2014-08-24 17:24:18 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_STRETCH:
|
|
|
|
changed = dest->stretch != value->u.stretch;
|
|
|
|
dest->stretch = value->u.stretch;
|
|
|
|
break;
|
2014-08-24 18:46:16 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_FONTSIZE:
|
|
|
|
changed = dest->fontsize != value->u.fontsize;
|
|
|
|
dest->fontsize = value->u.fontsize;
|
|
|
|
break;
|
2014-08-13 21:15:46 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_INLINE:
|
2015-03-11 20:20:34 +01:00
|
|
|
changed = set_layout_range_iface_attr((IUnknown**)&dest->object, (IUnknown*)value->u.object);
|
2014-08-13 21:15:46 +02:00
|
|
|
break;
|
2014-08-13 21:29:07 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_EFFECT:
|
2019-02-28 00:50:27 +01:00
|
|
|
changed = set_layout_range_iface_attr(&dest_iface->iface, value->u.effect);
|
2014-08-13 21:29:07 +02:00
|
|
|
break;
|
|
|
|
case LAYOUT_RANGE_ATTR_UNDERLINE:
|
2016-01-12 21:12:06 +01:00
|
|
|
changed = dest_bool->value != value->u.underline;
|
|
|
|
dest_bool->value = value->u.underline;
|
2014-08-13 21:29:07 +02:00
|
|
|
break;
|
|
|
|
case LAYOUT_RANGE_ATTR_STRIKETHROUGH:
|
2015-06-04 16:55:26 +02:00
|
|
|
changed = dest_bool->value != value->u.strikethrough;
|
|
|
|
dest_bool->value = value->u.strikethrough;
|
2014-08-13 21:29:07 +02:00
|
|
|
break;
|
2015-03-13 09:25:18 +01:00
|
|
|
case LAYOUT_RANGE_ATTR_PAIR_KERNING:
|
|
|
|
changed = dest->pair_kerning != value->u.pair_kerning;
|
|
|
|
dest->pair_kerning = value->u.pair_kerning;
|
|
|
|
break;
|
2014-08-24 17:24:18 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_FONTCOLL:
|
2015-03-11 20:20:34 +01:00
|
|
|
changed = set_layout_range_iface_attr((IUnknown**)&dest->collection, (IUnknown*)value->u.collection);
|
2014-08-24 17:24:18 +02:00
|
|
|
break;
|
2015-01-01 19:50:59 +01:00
|
|
|
case LAYOUT_RANGE_ATTR_LOCALE:
|
2015-12-25 13:58:01 +01:00
|
|
|
changed = strcmpiW(dest->locale, value->u.locale) != 0;
|
2016-01-14 22:24:24 +01:00
|
|
|
if (changed) {
|
2015-01-01 19:50:59 +01:00
|
|
|
strcpyW(dest->locale, value->u.locale);
|
2016-01-14 22:24:24 +01:00
|
|
|
strlwrW(dest->locale);
|
|
|
|
}
|
2015-01-01 19:50:59 +01:00
|
|
|
break;
|
2015-01-02 20:22:40 +01:00
|
|
|
case LAYOUT_RANGE_ATTR_FONTFAMILY:
|
|
|
|
changed = strcmpW(dest->fontfamily, value->u.fontfamily) != 0;
|
|
|
|
if (changed) {
|
|
|
|
heap_free(dest->fontfamily);
|
|
|
|
dest->fontfamily = heap_strdupW(value->u.fontfamily);
|
|
|
|
}
|
|
|
|
break;
|
2015-06-18 18:52:15 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_SPACING:
|
2017-08-22 11:42:09 +02:00
|
|
|
changed = dest_spacing->leading != value->u.spacing.leading ||
|
|
|
|
dest_spacing->trailing != value->u.spacing.trailing ||
|
|
|
|
dest_spacing->min_advance != value->u.spacing.min_advance;
|
|
|
|
dest_spacing->leading = value->u.spacing.leading;
|
|
|
|
dest_spacing->trailing = value->u.spacing.trailing;
|
|
|
|
dest_spacing->min_advance = value->u.spacing.min_advance;
|
2015-06-18 18:52:15 +02:00
|
|
|
break;
|
2015-12-25 13:57:57 +01:00
|
|
|
case LAYOUT_RANGE_ATTR_TYPOGRAPHY:
|
2019-02-28 00:50:27 +01:00
|
|
|
changed = set_layout_range_iface_attr(&dest_iface->iface, (IUnknown*)value->u.typography);
|
2015-12-25 13:57:57 +01:00
|
|
|
break;
|
2014-08-13 21:15:46 +02:00
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline BOOL is_in_layout_range(const DWRITE_TEXT_RANGE *outer, const DWRITE_TEXT_RANGE *inner)
|
|
|
|
{
|
|
|
|
return (inner->startPosition >= outer->startPosition) &&
|
|
|
|
(inner->startPosition + inner->length <= outer->startPosition + outer->length);
|
|
|
|
}
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
static inline HRESULT return_range(const struct layout_range_header *h, DWRITE_TEXT_RANGE *r)
|
2014-08-24 17:01:40 +02:00
|
|
|
{
|
2015-06-04 16:55:26 +02:00
|
|
|
if (r) *r = h->range;
|
2014-08-24 17:01:40 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2016-01-17 19:41:56 +01:00
|
|
|
/* Sets attribute value for given range, does all needed splitting/merging of existing ranges. */
|
2014-08-13 21:15:46 +02:00
|
|
|
static HRESULT set_layout_range_attr(struct dwrite_textlayout *layout, enum layout_range_attr_kind attr, struct layout_range_attr_value *value)
|
|
|
|
{
|
2015-06-04 16:55:26 +02:00
|
|
|
struct layout_range_header *cur, *right, *left, *outer;
|
2014-08-15 05:10:58 +02:00
|
|
|
BOOL changed = FALSE;
|
2015-06-04 16:55:26 +02:00
|
|
|
struct list *ranges;
|
2014-08-13 21:15:46 +02:00
|
|
|
DWRITE_TEXT_RANGE r;
|
|
|
|
|
2015-06-08 20:12:54 +02:00
|
|
|
/* ignore zero length ranges */
|
|
|
|
if (value->range.length == 0)
|
|
|
|
return S_OK;
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
/* select from ranges lists */
|
|
|
|
switch (attr)
|
|
|
|
{
|
|
|
|
case LAYOUT_RANGE_ATTR_WEIGHT:
|
|
|
|
case LAYOUT_RANGE_ATTR_STYLE:
|
|
|
|
case LAYOUT_RANGE_ATTR_STRETCH:
|
|
|
|
case LAYOUT_RANGE_ATTR_FONTSIZE:
|
|
|
|
case LAYOUT_RANGE_ATTR_INLINE:
|
|
|
|
case LAYOUT_RANGE_ATTR_PAIR_KERNING:
|
|
|
|
case LAYOUT_RANGE_ATTR_FONTCOLL:
|
|
|
|
case LAYOUT_RANGE_ATTR_LOCALE:
|
|
|
|
case LAYOUT_RANGE_ATTR_FONTFAMILY:
|
|
|
|
ranges = &layout->ranges;
|
|
|
|
break;
|
2016-01-12 21:12:06 +01:00
|
|
|
case LAYOUT_RANGE_ATTR_UNDERLINE:
|
|
|
|
ranges = &layout->underline_ranges;
|
|
|
|
break;
|
2015-06-04 16:55:26 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_STRIKETHROUGH:
|
|
|
|
ranges = &layout->strike_ranges;
|
|
|
|
break;
|
2015-06-15 00:15:25 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_EFFECT:
|
|
|
|
ranges = &layout->effects;
|
|
|
|
break;
|
2015-06-18 18:52:15 +02:00
|
|
|
case LAYOUT_RANGE_ATTR_SPACING:
|
|
|
|
ranges = &layout->spacing;
|
|
|
|
break;
|
2015-12-25 13:57:57 +01:00
|
|
|
case LAYOUT_RANGE_ATTR_TYPOGRAPHY:
|
|
|
|
ranges = &layout->typographies;
|
|
|
|
break;
|
2015-06-04 16:55:26 +02:00
|
|
|
default:
|
|
|
|
FIXME("unknown attr kind %d\n", attr);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2014-08-13 21:15:46 +02:00
|
|
|
/* If new range is completely within existing range, split existing range in two */
|
2015-06-04 16:55:26 +02:00
|
|
|
if ((outer = find_outer_range(ranges, &value->range))) {
|
2014-08-13 21:15:46 +02:00
|
|
|
|
|
|
|
/* no need to add same range */
|
2014-08-15 05:10:58 +02:00
|
|
|
if (is_same_layout_attrvalue(outer, attr, value))
|
2014-08-13 21:15:46 +02:00
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
/* for matching range bounds just replace data */
|
|
|
|
if (is_same_text_range(&outer->range, &value->range)) {
|
2014-08-15 05:10:58 +02:00
|
|
|
changed = set_layout_range_attrval(outer, attr, value);
|
|
|
|
goto done;
|
2014-08-13 21:15:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* add new range to the left */
|
|
|
|
if (value->range.startPosition == outer->range.startPosition) {
|
|
|
|
left = alloc_layout_range_from(outer, &value->range);
|
|
|
|
if (!left) return E_OUTOFMEMORY;
|
|
|
|
|
2014-08-15 05:10:58 +02:00
|
|
|
changed = set_layout_range_attrval(left, attr, value);
|
2015-06-04 16:55:26 +02:00
|
|
|
list_add_before(&outer->entry, &left->entry);
|
2014-08-13 21:15:46 +02:00
|
|
|
outer->range.startPosition += value->range.length;
|
|
|
|
outer->range.length -= value->range.length;
|
2014-08-15 05:10:58 +02:00
|
|
|
goto done;
|
2014-08-13 21:15:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* add new range to the right */
|
|
|
|
if (value->range.startPosition + value->range.length == outer->range.startPosition + outer->range.length) {
|
|
|
|
right = alloc_layout_range_from(outer, &value->range);
|
|
|
|
if (!right) return E_OUTOFMEMORY;
|
|
|
|
|
2014-08-15 05:10:58 +02:00
|
|
|
changed = set_layout_range_attrval(right, attr, value);
|
2015-06-04 16:55:26 +02:00
|
|
|
list_add_after(&outer->entry, &right->entry);
|
2014-08-13 21:15:46 +02:00
|
|
|
outer->range.length -= value->range.length;
|
2014-08-15 05:10:58 +02:00
|
|
|
goto done;
|
2014-08-13 21:15:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
r.startPosition = value->range.startPosition + value->range.length;
|
|
|
|
r.length = outer->range.length + outer->range.startPosition - r.startPosition;
|
|
|
|
|
|
|
|
/* right part */
|
|
|
|
right = alloc_layout_range_from(outer, &r);
|
|
|
|
/* new range in the middle */
|
|
|
|
cur = alloc_layout_range_from(outer, &value->range);
|
|
|
|
if (!right || !cur) {
|
|
|
|
free_layout_range(right);
|
|
|
|
free_layout_range(cur);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reuse container range as a left part */
|
|
|
|
outer->range.length = value->range.startPosition - outer->range.startPosition;
|
|
|
|
|
|
|
|
/* new part */
|
|
|
|
set_layout_range_attrval(cur, attr, value);
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
list_add_after(&outer->entry, &cur->entry);
|
|
|
|
list_add_after(&cur->entry, &right->entry);
|
2014-08-13 21:15:46 +02:00
|
|
|
|
2016-02-02 21:14:38 +01:00
|
|
|
layout->recompute = RECOMPUTE_EVERYTHING;
|
2014-08-13 21:15:46 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now it's only possible that given range contains some existing ranges, fully or partially.
|
|
|
|
Update all of them. */
|
2015-06-04 16:55:26 +02:00
|
|
|
left = get_layout_range_header_by_pos(ranges, value->range.startPosition);
|
2014-08-13 21:15:46 +02:00
|
|
|
if (left->range.startPosition == value->range.startPosition)
|
2014-08-15 05:10:58 +02:00
|
|
|
changed = set_layout_range_attrval(left, attr, value);
|
2014-08-13 21:15:46 +02:00
|
|
|
else /* need to split */ {
|
|
|
|
r.startPosition = value->range.startPosition;
|
|
|
|
r.length = left->range.length - value->range.startPosition + left->range.startPosition;
|
|
|
|
left->range.length -= r.length;
|
|
|
|
cur = alloc_layout_range_from(left, &r);
|
2014-08-15 05:10:58 +02:00
|
|
|
changed = set_layout_range_attrval(cur, attr, value);
|
2015-06-04 16:55:26 +02:00
|
|
|
list_add_after(&left->entry, &cur->entry);
|
2014-08-13 21:15:46 +02:00
|
|
|
}
|
2015-06-04 16:55:26 +02:00
|
|
|
cur = LIST_ENTRY(list_next(ranges, &left->entry), struct layout_range_header, entry);
|
2014-08-13 21:15:46 +02:00
|
|
|
|
|
|
|
/* for all existing ranges covered by new one update value */
|
2015-06-05 10:24:54 +02:00
|
|
|
while (cur && is_in_layout_range(&value->range, &cur->range)) {
|
2015-12-25 13:58:02 +01:00
|
|
|
changed |= set_layout_range_attrval(cur, attr, value);
|
2015-06-04 16:55:26 +02:00
|
|
|
cur = LIST_ENTRY(list_next(ranges, &cur->entry), struct layout_range_header, entry);
|
2014-08-13 21:15:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* it's possible rightmost range intersects */
|
|
|
|
if (cur && (cur->range.startPosition < value->range.startPosition + value->range.length)) {
|
|
|
|
r.startPosition = cur->range.startPosition;
|
|
|
|
r.length = value->range.startPosition + value->range.length - cur->range.startPosition;
|
|
|
|
left = alloc_layout_range_from(cur, &r);
|
2015-12-25 13:58:02 +01:00
|
|
|
changed |= set_layout_range_attrval(left, attr, value);
|
2014-08-13 21:15:46 +02:00
|
|
|
cur->range.startPosition += left->range.length;
|
|
|
|
cur->range.length -= left->range.length;
|
2015-06-04 16:55:26 +02:00
|
|
|
list_add_before(&cur->entry, &left->entry);
|
2014-08-13 21:15:46 +02:00
|
|
|
}
|
|
|
|
|
2014-08-15 05:10:58 +02:00
|
|
|
done:
|
|
|
|
if (changed) {
|
|
|
|
struct list *next, *i;
|
|
|
|
|
2015-03-30 09:15:48 +02:00
|
|
|
layout->recompute = RECOMPUTE_EVERYTHING;
|
2014-08-15 05:10:58 +02:00
|
|
|
i = list_head(ranges);
|
|
|
|
while ((next = list_next(ranges, i))) {
|
2015-06-04 16:55:26 +02:00
|
|
|
struct layout_range_header *next_range = LIST_ENTRY(next, struct layout_range_header, entry);
|
2014-08-15 05:10:58 +02:00
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
cur = LIST_ENTRY(i, struct layout_range_header, entry);
|
2014-08-15 05:10:58 +02:00
|
|
|
if (is_same_layout_attributes(cur, next_range)) {
|
|
|
|
/* remove similar range */
|
|
|
|
cur->range.length += next_range->range.length;
|
|
|
|
list_remove(next);
|
|
|
|
free_layout_range(next_range);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
i = list_next(ranges, i);
|
|
|
|
}
|
|
|
|
}
|
2014-08-13 21:15:46 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-01-02 20:22:40 +01:00
|
|
|
static inline const WCHAR *get_string_attribute_ptr(struct layout_range *range, enum layout_range_attr_kind kind)
|
|
|
|
{
|
|
|
|
const WCHAR *str;
|
|
|
|
|
|
|
|
switch (kind) {
|
|
|
|
case LAYOUT_RANGE_ATTR_LOCALE:
|
|
|
|
str = range->locale;
|
|
|
|
break;
|
|
|
|
case LAYOUT_RANGE_ATTR_FONTFAMILY:
|
|
|
|
str = range->fontfamily;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
str = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT get_string_attribute_length(struct dwrite_textlayout *layout, enum layout_range_attr_kind kind, UINT32 position,
|
|
|
|
UINT32 *length, DWRITE_TEXT_RANGE *r)
|
|
|
|
{
|
|
|
|
struct layout_range *range;
|
|
|
|
const WCHAR *str;
|
|
|
|
|
|
|
|
range = get_layout_range_by_pos(layout, position);
|
|
|
|
if (!range) {
|
|
|
|
*length = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
str = get_string_attribute_ptr(range, kind);
|
|
|
|
*length = strlenW(str);
|
2015-06-04 16:55:26 +02:00
|
|
|
return return_range(&range->h, r);
|
2015-01-02 20:22:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT get_string_attribute_value(struct dwrite_textlayout *layout, enum layout_range_attr_kind kind, UINT32 position,
|
|
|
|
WCHAR *ret, UINT32 length, DWRITE_TEXT_RANGE *r)
|
|
|
|
{
|
|
|
|
struct layout_range *range;
|
|
|
|
const WCHAR *str;
|
|
|
|
|
|
|
|
if (length == 0)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
ret[0] = 0;
|
|
|
|
range = get_layout_range_by_pos(layout, position);
|
|
|
|
if (!range)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
str = get_string_attribute_ptr(range, kind);
|
|
|
|
if (length < strlenW(str) + 1)
|
|
|
|
return E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
|
|
|
|
strcpyW(ret, str);
|
2015-06-04 16:55:26 +02:00
|
|
|
return return_range(&range->h, r);
|
2015-01-02 20:22:40 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_QueryInterface(IDWriteTextLayout4 *iface, REFIID riid, void **obj)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
|
2012-09-28 10:13:17 +02:00
|
|
|
|
2015-03-15 00:38:32 +01:00
|
|
|
*obj = NULL;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteTextLayout4) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteTextLayout3) ||
|
2016-02-16 22:19:38 +01:00
|
|
|
IsEqualIID(riid, &IID_IDWriteTextLayout2) ||
|
2014-11-07 07:25:33 +01:00
|
|
|
IsEqualIID(riid, &IID_IDWriteTextLayout1) ||
|
2014-10-10 11:38:54 +02:00
|
|
|
IsEqualIID(riid, &IID_IDWriteTextLayout) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
|
|
|
*obj = iface;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
2019-11-29 10:54:27 +01:00
|
|
|
else if (IsEqualIID(riid, &IID_IDWriteTextFormat3) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteTextFormat2) ||
|
2018-05-21 23:08:06 +02:00
|
|
|
IsEqualIID(riid, &IID_IDWriteTextFormat1) ||
|
2015-03-15 00:38:32 +01:00
|
|
|
IsEqualIID(riid, &IID_IDWriteTextFormat))
|
2019-11-29 10:54:27 +01:00
|
|
|
{
|
|
|
|
*obj = &layout->IDWriteTextFormat3_iface;
|
|
|
|
}
|
2015-03-15 00:38:32 +01:00
|
|
|
|
|
|
|
if (*obj) {
|
2019-11-29 10:54:26 +01:00
|
|
|
IDWriteTextLayout4_AddRef(iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2012-09-28 10:13:17 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static ULONG WINAPI dwritetextlayout_AddRef(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&layout->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static ULONG WINAPI dwritetextlayout_Release(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&layout->refcount);
|
2012-09-28 10:13:17 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
2012-09-28 10:13:17 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
IDWriteFactory5_Release(layout->factory);
|
|
|
|
free_layout_ranges_list(layout);
|
|
|
|
free_layout_eruns(layout);
|
|
|
|
free_layout_runs(layout);
|
|
|
|
release_format_data(&layout->format);
|
|
|
|
heap_free(layout->nominal_breakpoints);
|
|
|
|
heap_free(layout->actual_breakpoints);
|
|
|
|
heap_free(layout->clustermetrics);
|
|
|
|
heap_free(layout->clusters);
|
|
|
|
heap_free(layout->lines);
|
|
|
|
heap_free(layout->str);
|
|
|
|
heap_free(layout);
|
2012-10-20 23:02:25 +02:00
|
|
|
}
|
2012-09-28 10:13:17 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
return refcount;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetTextAlignment(IDWriteTextLayout4 *iface, DWRITE_TEXT_ALIGNMENT alignment)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_SetTextAlignment(&layout->IDWriteTextFormat3_iface, alignment);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetParagraphAlignment(IDWriteTextLayout4 *iface,
|
|
|
|
DWRITE_PARAGRAPH_ALIGNMENT alignment)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_SetParagraphAlignment(&layout->IDWriteTextFormat3_iface, alignment);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetWordWrapping(IDWriteTextLayout4 *iface, DWRITE_WORD_WRAPPING wrapping)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_SetWordWrapping(&layout->IDWriteTextFormat3_iface, wrapping);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetReadingDirection(IDWriteTextLayout4 *iface,
|
|
|
|
DWRITE_READING_DIRECTION direction)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_SetReadingDirection(&layout->IDWriteTextFormat3_iface, direction);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetFlowDirection(IDWriteTextLayout4 *iface, DWRITE_FLOW_DIRECTION direction)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_SetFlowDirection(&layout->IDWriteTextFormat3_iface, direction);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetIncrementalTabStop(IDWriteTextLayout4 *iface, FLOAT tabstop)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_SetIncrementalTabStop(&layout->IDWriteTextFormat3_iface, tabstop);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetTrimming(IDWriteTextLayout4 *iface, DWRITE_TRIMMING const *trimming,
|
2012-09-28 10:13:17 +02:00
|
|
|
IDWriteInlineObject *trimming_sign)
|
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_SetTrimming(&layout->IDWriteTextFormat3_iface, trimming, trimming_sign);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetLineSpacing(IDWriteTextLayout4 *iface, DWRITE_LINE_SPACING_METHOD spacing,
|
2012-09-28 10:13:17 +02:00
|
|
|
FLOAT line_spacing, FLOAT baseline)
|
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat1_SetLineSpacing((IDWriteTextFormat1 *)&layout->IDWriteTextFormat3_iface, spacing,
|
2018-05-21 23:08:06 +02:00
|
|
|
line_spacing, baseline);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static DWRITE_TEXT_ALIGNMENT WINAPI dwritetextlayout_GetTextAlignment(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetTextAlignment(&layout->IDWriteTextFormat3_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static DWRITE_PARAGRAPH_ALIGNMENT WINAPI dwritetextlayout_GetParagraphAlignment(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetParagraphAlignment(&layout->IDWriteTextFormat3_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static DWRITE_WORD_WRAPPING WINAPI dwritetextlayout_GetWordWrapping(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetWordWrapping(&layout->IDWriteTextFormat3_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static DWRITE_READING_DIRECTION WINAPI dwritetextlayout_GetReadingDirection(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetReadingDirection(&layout->IDWriteTextFormat3_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static DWRITE_FLOW_DIRECTION WINAPI dwritetextlayout_GetFlowDirection(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetFlowDirection(&layout->IDWriteTextFormat3_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static FLOAT WINAPI dwritetextlayout_GetIncrementalTabStop(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetIncrementalTabStop(&layout->IDWriteTextFormat3_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetTrimming(IDWriteTextLayout4 *iface, DWRITE_TRIMMING *options,
|
2012-09-28 10:13:17 +02:00
|
|
|
IDWriteInlineObject **trimming_sign)
|
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetTrimming(&layout->IDWriteTextFormat3_iface, options, trimming_sign);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetLineSpacing(IDWriteTextLayout4 *iface, DWRITE_LINE_SPACING_METHOD *method,
|
2012-09-28 10:13:17 +02:00
|
|
|
FLOAT *spacing, FLOAT *baseline)
|
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat_GetLineSpacing((IDWriteTextFormat *)&layout->IDWriteTextFormat3_iface, method,
|
2018-05-21 23:08:06 +02:00
|
|
|
spacing, baseline);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetFontCollection(IDWriteTextLayout4 *iface, IDWriteFontCollection **collection)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetFontCollection(&layout->IDWriteTextFormat3_iface, collection);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static UINT32 WINAPI dwritetextlayout_GetFontFamilyNameLength(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetFontFamilyNameLength(&layout->IDWriteTextFormat3_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetFontFamilyName(IDWriteTextLayout4 *iface, WCHAR *name, UINT32 size)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetFontFamilyName(&layout->IDWriteTextFormat3_iface, name, size);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static DWRITE_FONT_WEIGHT WINAPI dwritetextlayout_GetFontWeight(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetFontWeight(&layout->IDWriteTextFormat3_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static DWRITE_FONT_STYLE WINAPI dwritetextlayout_GetFontStyle(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetFontStyle(&layout->IDWriteTextFormat3_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static DWRITE_FONT_STRETCH WINAPI dwritetextlayout_GetFontStretch(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetFontStretch(&layout->IDWriteTextFormat3_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static FLOAT WINAPI dwritetextlayout_GetFontSize(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetFontSize(&layout->IDWriteTextFormat3_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static UINT32 WINAPI dwritetextlayout_GetLocaleNameLength(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetLocaleNameLength(&layout->IDWriteTextFormat3_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetLocaleName(IDWriteTextLayout4 *iface, WCHAR *name, UINT32 size)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetLocaleName(&layout->IDWriteTextFormat3_iface, name, size);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetMaxWidth(IDWriteTextLayout4 *iface, FLOAT maxWidth)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2017-01-26 05:41:48 +01:00
|
|
|
BOOL changed;
|
2015-07-03 10:00:45 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %.8e.\n", iface, maxWidth);
|
2014-10-14 08:03:28 +02:00
|
|
|
|
2016-01-11 14:15:53 +01:00
|
|
|
if (maxWidth < 0.0f)
|
2014-10-14 08:03:28 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
changed = layout->metrics.layoutWidth != maxWidth;
|
|
|
|
layout->metrics.layoutWidth = maxWidth;
|
2017-01-26 05:41:48 +01:00
|
|
|
|
|
|
|
if (changed)
|
2019-11-29 10:54:26 +01:00
|
|
|
layout->recompute |= RECOMPUTE_LINES_AND_OVERHANGS;
|
2014-07-30 17:59:07 +02:00
|
|
|
return S_OK;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetMaxHeight(IDWriteTextLayout4 *iface, FLOAT maxHeight)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2017-01-26 05:41:48 +01:00
|
|
|
BOOL changed;
|
2015-07-03 10:00:45 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %.8e.\n", iface, maxHeight);
|
2014-10-14 08:03:28 +02:00
|
|
|
|
2016-01-11 14:15:53 +01:00
|
|
|
if (maxHeight < 0.0f)
|
2014-10-14 08:03:28 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
changed = layout->metrics.layoutHeight != maxHeight;
|
|
|
|
layout->metrics.layoutHeight = maxHeight;
|
2017-01-26 05:41:48 +01:00
|
|
|
|
|
|
|
if (changed)
|
2019-11-29 10:54:26 +01:00
|
|
|
layout->recompute |= RECOMPUTE_LINES_AND_OVERHANGS;
|
2014-07-30 17:59:07 +02:00
|
|
|
return S_OK;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetFontCollection(IDWriteTextLayout4 *iface, IDWriteFontCollection *collection,
|
|
|
|
DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2014-08-24 17:24:18 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %p, %s.\n", iface, collection, debugstr_range(&range));
|
2014-08-24 17:24:18 +02:00
|
|
|
|
|
|
|
value.range = range;
|
|
|
|
value.u.collection = collection;
|
2019-11-29 10:54:26 +01:00
|
|
|
return set_layout_range_attr(layout, LAYOUT_RANGE_ATTR_FONTCOLL, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetFontFamilyName(IDWriteTextLayout4 *iface, WCHAR const *name,
|
|
|
|
DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2015-01-02 20:22:40 +01:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %s, %s.\n", iface, debugstr_w(name), debugstr_range(&range));
|
2015-01-02 20:22:40 +01:00
|
|
|
|
|
|
|
if (!name)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
value.range = range;
|
|
|
|
value.u.fontfamily = name;
|
2019-11-29 10:54:26 +01:00
|
|
|
return set_layout_range_attr(layout, LAYOUT_RANGE_ATTR_FONTFAMILY, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetFontWeight(IDWriteTextLayout4 *iface, DWRITE_FONT_WEIGHT weight,
|
|
|
|
DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2014-08-13 21:15:46 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %d, %s.\n", iface, weight, debugstr_range(&range));
|
2014-08-13 21:15:46 +02:00
|
|
|
|
2016-07-19 22:03:01 +02:00
|
|
|
if ((UINT32)weight > DWRITE_FONT_WEIGHT_ULTRA_BLACK)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2014-08-13 21:15:46 +02:00
|
|
|
value.range = range;
|
|
|
|
value.u.weight = weight;
|
2019-11-29 10:54:26 +01:00
|
|
|
return set_layout_range_attr(layout, LAYOUT_RANGE_ATTR_WEIGHT, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetFontStyle(IDWriteTextLayout4 *iface, DWRITE_FONT_STYLE style,
|
|
|
|
DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2014-08-13 21:29:07 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %d, %s.\n", iface, style, debugstr_range(&range));
|
2014-08-13 21:29:07 +02:00
|
|
|
|
2015-06-06 18:05:00 +02:00
|
|
|
if ((UINT32)style > DWRITE_FONT_STYLE_ITALIC)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2014-08-13 21:29:07 +02:00
|
|
|
value.range = range;
|
|
|
|
value.u.style = style;
|
2019-11-29 10:54:26 +01:00
|
|
|
return set_layout_range_attr(layout, LAYOUT_RANGE_ATTR_STYLE, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetFontStretch(IDWriteTextLayout4 *iface, DWRITE_FONT_STRETCH stretch,
|
|
|
|
DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2014-08-24 17:24:18 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %d, %s.\n", iface, stretch, debugstr_range(&range));
|
2014-08-24 17:24:18 +02:00
|
|
|
|
2015-06-06 18:05:00 +02:00
|
|
|
if (stretch == DWRITE_FONT_STRETCH_UNDEFINED || (UINT32)stretch > DWRITE_FONT_STRETCH_ULTRA_EXPANDED)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2014-08-24 17:24:18 +02:00
|
|
|
value.range = range;
|
|
|
|
value.u.stretch = stretch;
|
2019-11-29 10:54:26 +01:00
|
|
|
return set_layout_range_attr(layout, LAYOUT_RANGE_ATTR_STRETCH, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetFontSize(IDWriteTextLayout4 *iface, FLOAT size, DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2014-08-24 18:46:16 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %.8e, %s.\n", iface, size, debugstr_range(&range));
|
2014-08-24 18:46:16 +02:00
|
|
|
|
2016-01-11 14:15:53 +01:00
|
|
|
if (size <= 0.0f)
|
2015-06-06 18:05:00 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2014-08-24 18:46:16 +02:00
|
|
|
value.range = range;
|
|
|
|
value.u.fontsize = size;
|
2019-11-29 10:54:26 +01:00
|
|
|
return set_layout_range_attr(layout, LAYOUT_RANGE_ATTR_FONTSIZE, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetUnderline(IDWriteTextLayout4 *iface, BOOL underline, DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2014-08-13 21:29:07 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %d, %s.\n", iface, underline, debugstr_range(&range));
|
2014-08-13 21:29:07 +02:00
|
|
|
|
|
|
|
value.range = range;
|
|
|
|
value.u.underline = underline;
|
2019-11-29 10:54:26 +01:00
|
|
|
return set_layout_range_attr(layout, LAYOUT_RANGE_ATTR_UNDERLINE, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetStrikethrough(IDWriteTextLayout4 *iface, BOOL strikethrough,
|
|
|
|
DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2014-08-13 21:29:07 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %d, %s.\n", iface, strikethrough, debugstr_range(&range));
|
2014-08-13 21:29:07 +02:00
|
|
|
|
|
|
|
value.range = range;
|
2015-05-01 10:33:24 +02:00
|
|
|
value.u.strikethrough = strikethrough;
|
2019-11-29 10:54:26 +01:00
|
|
|
return set_layout_range_attr(layout, LAYOUT_RANGE_ATTR_STRIKETHROUGH, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetDrawingEffect(IDWriteTextLayout4 *iface, IUnknown* effect,
|
|
|
|
DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2014-08-13 21:29:07 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %p, %s.\n", iface, effect, debugstr_range(&range));
|
2014-08-13 21:29:07 +02:00
|
|
|
|
|
|
|
value.range = range;
|
|
|
|
value.u.effect = effect;
|
2019-11-29 10:54:26 +01:00
|
|
|
return set_layout_range_attr(layout, LAYOUT_RANGE_ATTR_EFFECT, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetInlineObject(IDWriteTextLayout4 *iface, IDWriteInlineObject *object,
|
|
|
|
DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2015-01-02 20:25:28 +01:00
|
|
|
struct layout_range_attr_value value;
|
2014-08-13 21:15:46 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %p, %s.\n", iface, object, debugstr_range(&range));
|
2014-08-13 21:15:46 +02:00
|
|
|
|
2015-01-02 20:25:28 +01:00
|
|
|
value.range = range;
|
|
|
|
value.u.object = object;
|
2019-11-29 10:54:26 +01:00
|
|
|
return set_layout_range_attr(layout, LAYOUT_RANGE_ATTR_INLINE, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetTypography(IDWriteTextLayout4 *iface, IDWriteTypography *typography,
|
|
|
|
DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2015-12-25 13:57:57 +01:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %p, %s.\n", iface, typography, debugstr_range(&range));
|
2015-12-25 13:57:57 +01:00
|
|
|
|
|
|
|
value.range = range;
|
|
|
|
value.u.typography = typography;
|
2019-11-29 10:54:26 +01:00
|
|
|
return set_layout_range_attr(layout, LAYOUT_RANGE_ATTR_TYPOGRAPHY, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetLocaleName(IDWriteTextLayout4 *iface, WCHAR const* locale,
|
|
|
|
DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2015-01-02 20:25:28 +01:00
|
|
|
struct layout_range_attr_value value;
|
2015-01-01 19:50:59 +01:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %s, %s.\n", iface, debugstr_w(locale), debugstr_range(&range));
|
2015-01-01 19:50:59 +01:00
|
|
|
|
|
|
|
if (!locale || strlenW(locale) > LOCALE_NAME_MAX_LENGTH-1)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2015-01-02 20:25:28 +01:00
|
|
|
value.range = range;
|
|
|
|
value.u.locale = locale;
|
2019-11-29 10:54:26 +01:00
|
|
|
return set_layout_range_attr(layout, LAYOUT_RANGE_ATTR_LOCALE, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static FLOAT WINAPI dwritetextlayout_GetMaxWidth(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->metrics.layoutWidth;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static FLOAT WINAPI dwritetextlayout_GetMaxHeight(IDWriteTextLayout4 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->metrics.layoutHeight;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetFontCollection(IDWriteTextLayout4 *iface, UINT32 position,
|
|
|
|
IDWriteFontCollection **collection, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2014-08-24 17:24:18 +02:00
|
|
|
struct layout_range *range;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, position, collection, r);
|
2014-08-24 17:24:18 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
if (position >= layout->len)
|
2015-06-03 17:57:54 +02:00
|
|
|
return S_OK;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
range = get_layout_range_by_pos(layout, position);
|
2015-06-03 17:57:54 +02:00
|
|
|
*collection = range->collection;
|
2014-08-24 17:24:18 +02:00
|
|
|
if (*collection)
|
|
|
|
IDWriteFontCollection_AddRef(*collection);
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
return return_range(&range->h, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetFontFamilyNameLength(IDWriteTextLayout4 *iface,
|
2015-01-02 20:22:40 +01:00
|
|
|
UINT32 position, UINT32 *length, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %d, %p, %p.\n", iface, position, length, r);
|
|
|
|
|
|
|
|
return get_string_attribute_length(layout, LAYOUT_RANGE_ATTR_FONTFAMILY, position, length, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetFontFamilyName(IDWriteTextLayout4 *iface,
|
2015-01-02 20:22:40 +01:00
|
|
|
UINT32 position, WCHAR *name, UINT32 length, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %u, %p, %u, %p.\n", iface, position, name, length, r);
|
|
|
|
|
|
|
|
return get_string_attribute_value(layout, LAYOUT_RANGE_ATTR_FONTFAMILY, position, name, length, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetFontWeight(IDWriteTextLayout4 *iface,
|
2014-08-13 21:15:46 +02:00
|
|
|
UINT32 position, DWRITE_FONT_WEIGHT *weight, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2014-08-13 21:15:46 +02:00
|
|
|
struct layout_range *range;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, position, weight, r);
|
2014-08-13 21:15:46 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
if (position >= layout->len)
|
2014-08-13 21:15:46 +02:00
|
|
|
return S_OK;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
range = get_layout_range_by_pos(layout, position);
|
2014-08-13 21:15:46 +02:00
|
|
|
*weight = range->weight;
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
return return_range(&range->h, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetFontStyle(IDWriteTextLayout4 *iface,
|
2014-08-13 21:29:07 +02:00
|
|
|
UINT32 position, DWRITE_FONT_STYLE *style, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2014-08-13 21:29:07 +02:00
|
|
|
struct layout_range *range;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, position, style, r);
|
2014-08-13 21:29:07 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
range = get_layout_range_by_pos(layout, position);
|
2014-08-13 21:29:07 +02:00
|
|
|
*style = range->style;
|
2015-06-04 16:55:26 +02:00
|
|
|
return return_range(&range->h, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetFontStretch(IDWriteTextLayout4 *iface,
|
2014-08-24 17:24:18 +02:00
|
|
|
UINT32 position, DWRITE_FONT_STRETCH *stretch, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2014-08-24 17:24:18 +02:00
|
|
|
struct layout_range *range;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, position, stretch, r);
|
2014-08-24 17:24:18 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
range = get_layout_range_by_pos(layout, position);
|
2014-08-24 17:24:18 +02:00
|
|
|
*stretch = range->stretch;
|
2015-06-04 16:55:26 +02:00
|
|
|
return return_range(&range->h, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetFontSize(IDWriteTextLayout4 *iface,
|
2014-08-24 18:46:16 +02:00
|
|
|
UINT32 position, FLOAT *size, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2014-08-24 18:46:16 +02:00
|
|
|
struct layout_range *range;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, position, size, r);
|
2014-08-24 18:46:16 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
range = get_layout_range_by_pos(layout, position);
|
2014-08-24 18:46:16 +02:00
|
|
|
*size = range->fontsize;
|
2015-06-04 16:55:26 +02:00
|
|
|
return return_range(&range->h, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetUnderline(IDWriteTextLayout4 *iface,
|
2014-08-13 21:29:07 +02:00
|
|
|
UINT32 position, BOOL *underline, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2016-01-12 21:12:06 +01:00
|
|
|
struct layout_range_bool *range;
|
2014-08-13 21:29:07 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, position, underline, r);
|
2014-08-13 21:29:07 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
range = (struct layout_range_bool *)get_layout_range_header_by_pos(&layout->underline_ranges, position);
|
2016-01-12 21:12:06 +01:00
|
|
|
*underline = range->value;
|
2014-08-13 21:29:07 +02:00
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
return return_range(&range->h, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetStrikethrough(IDWriteTextLayout4 *iface,
|
2014-08-13 21:29:07 +02:00
|
|
|
UINT32 position, BOOL *strikethrough, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2015-06-04 16:55:26 +02:00
|
|
|
struct layout_range_bool *range;
|
2014-08-13 21:29:07 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, position, strikethrough, r);
|
2014-08-13 21:29:07 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
range = (struct layout_range_bool *)get_layout_range_header_by_pos(&layout->strike_ranges, position);
|
2015-06-04 16:55:26 +02:00
|
|
|
*strikethrough = range->value;
|
2014-08-13 21:29:07 +02:00
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
return return_range(&range->h, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetDrawingEffect(IDWriteTextLayout4 *iface,
|
2014-08-13 21:29:07 +02:00
|
|
|
UINT32 position, IUnknown **effect, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2015-12-25 13:57:57 +01:00
|
|
|
struct layout_range_iface *range;
|
2014-08-13 21:29:07 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, position, effect, r);
|
2014-08-13 21:29:07 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
range = (struct layout_range_iface *)get_layout_range_header_by_pos(&layout->effects, position);
|
2015-12-25 13:57:57 +01:00
|
|
|
*effect = range->iface;
|
2014-08-13 21:29:07 +02:00
|
|
|
if (*effect)
|
|
|
|
IUnknown_AddRef(*effect);
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
return return_range(&range->h, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetInlineObject(IDWriteTextLayout4 *iface,
|
2014-08-13 21:15:46 +02:00
|
|
|
UINT32 position, IDWriteInlineObject **object, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2014-08-13 21:15:46 +02:00
|
|
|
struct layout_range *range;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, position, object, r);
|
2014-08-13 21:15:46 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
if (position >= layout->len)
|
2015-05-31 14:11:56 +02:00
|
|
|
return S_OK;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
range = get_layout_range_by_pos(layout, position);
|
2015-05-31 14:11:56 +02:00
|
|
|
*object = range->object;
|
2014-08-13 21:15:46 +02:00
|
|
|
if (*object)
|
|
|
|
IDWriteInlineObject_AddRef(*object);
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
return return_range(&range->h, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetTypography(IDWriteTextLayout4 *iface,
|
2015-12-25 13:57:57 +01:00
|
|
|
UINT32 position, IDWriteTypography** typography, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2015-12-25 13:57:57 +01:00
|
|
|
struct layout_range_iface *range;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, position, typography, r);
|
2015-12-25 13:57:57 +01:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
range = (struct layout_range_iface *)get_layout_range_header_by_pos(&layout->typographies, position);
|
|
|
|
*typography = (IDWriteTypography *)range->iface;
|
2015-12-25 13:57:57 +01:00
|
|
|
if (*typography)
|
|
|
|
IDWriteTypography_AddRef(*typography);
|
|
|
|
|
|
|
|
return return_range(&range->h, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetLocaleNameLength(IDWriteTextLayout4 *iface,
|
|
|
|
UINT32 position, UINT32 *length, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, position, length, r);
|
|
|
|
|
|
|
|
return get_string_attribute_length(layout, LAYOUT_RANGE_ATTR_LOCALE, position, length, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetLocaleName(IDWriteTextLayout4 *iface,
|
|
|
|
UINT32 position, WCHAR *locale, UINT32 length, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %u, %p, %u, %p.\n", iface, position, locale, length, r);
|
|
|
|
|
|
|
|
return get_string_attribute_value(layout, LAYOUT_RANGE_ATTR_LOCALE, position, locale, length, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2015-07-12 22:22:50 +02:00
|
|
|
static inline FLOAT renderer_apply_snapping(FLOAT coord, BOOL skiptransform, FLOAT ppdip, FLOAT det,
|
|
|
|
const DWRITE_MATRIX *m)
|
|
|
|
{
|
2017-04-19 14:15:24 +02:00
|
|
|
D2D1_POINT_2F vec, vec2;
|
2015-07-12 22:22:50 +02:00
|
|
|
|
|
|
|
if (!skiptransform) {
|
|
|
|
/* apply transform */
|
2017-04-19 14:15:24 +02:00
|
|
|
vec.x = 0.0f;
|
|
|
|
vec.y = coord * ppdip;
|
2015-07-12 22:22:50 +02:00
|
|
|
|
2017-04-19 14:15:24 +02:00
|
|
|
vec2.x = m->m11 * vec.x + m->m21 * vec.y + m->dx;
|
|
|
|
vec2.y = m->m12 * vec.x + m->m22 * vec.y + m->dy;
|
2015-07-12 22:22:50 +02:00
|
|
|
|
|
|
|
/* snap */
|
2017-04-19 14:15:24 +02:00
|
|
|
vec2.x = floorf(vec2.x + 0.5f);
|
|
|
|
vec2.y = floorf(vec2.y + 0.5f);
|
2015-07-12 22:22:50 +02:00
|
|
|
|
|
|
|
/* apply inverted transform, we don't care about X component at this point */
|
2017-04-19 14:15:24 +02:00
|
|
|
vec.y = (-m->m12 * vec2.x + m->m11 * vec2.y - (m->m11 * m->dy - m->m12 * m->dx)) / det;
|
|
|
|
vec.y /= ppdip;
|
2015-07-12 22:22:50 +02:00
|
|
|
}
|
|
|
|
else
|
2017-04-19 14:15:24 +02:00
|
|
|
vec.y = floorf(coord * ppdip + 0.5f) / ppdip;
|
2015-07-12 22:22:50 +02:00
|
|
|
|
2017-04-19 14:15:24 +02:00
|
|
|
return vec.y;
|
2015-07-12 22:22:50 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_Draw(IDWriteTextLayout4 *iface,
|
2015-05-05 14:23:17 +02:00
|
|
|
void *context, IDWriteTextRenderer* renderer, FLOAT origin_x, FLOAT origin_y)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2015-07-12 22:22:50 +02:00
|
|
|
BOOL disabled = FALSE, skiptransform = FALSE;
|
2015-05-30 17:44:54 +02:00
|
|
|
struct layout_effective_inline *inlineobject;
|
2015-05-05 14:23:17 +02:00
|
|
|
struct layout_effective_run *run;
|
2015-06-04 22:32:30 +02:00
|
|
|
struct layout_strikethrough *s;
|
2016-01-14 22:24:23 +01:00
|
|
|
struct layout_underline *u;
|
2016-01-11 14:15:53 +01:00
|
|
|
FLOAT det = 0.0f, ppdip = 0.0f;
|
2015-07-12 22:22:50 +02:00
|
|
|
DWRITE_MATRIX m = { 0 };
|
2015-05-05 14:23:17 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %p, %p, %.8e, %.8e.\n", iface, context, renderer, origin_x, origin_y);
|
2015-05-05 14:23:17 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
hr = layout_compute_effective_runs(layout);
|
2015-05-05 14:23:17 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2015-07-12 22:22:50 +02:00
|
|
|
hr = IDWriteTextRenderer_IsPixelSnappingDisabled(renderer, context, &disabled);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (!disabled) {
|
|
|
|
hr = IDWriteTextRenderer_GetPixelsPerDip(renderer, context, &ppdip);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = IDWriteTextRenderer_GetCurrentTransform(renderer, context, &m);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
/* it's only allowed to have a diagonal/antidiagonal transform matrix */
|
2016-01-11 14:15:53 +01:00
|
|
|
if (ppdip <= 0.0f ||
|
|
|
|
(m.m11 * m.m22 != 0.0f && (m.m12 != 0.0f || m.m21 != 0.0f)) ||
|
|
|
|
(m.m12 * m.m21 != 0.0f && (m.m11 != 0.0f || m.m22 != 0.0f)))
|
2015-07-12 22:22:50 +02:00
|
|
|
disabled = TRUE;
|
2015-07-20 14:15:01 +02:00
|
|
|
else
|
|
|
|
skiptransform = should_skip_transform(&m, &det);
|
2015-07-12 22:22:50 +02:00
|
|
|
}
|
|
|
|
|
2016-01-11 14:15:54 +01:00
|
|
|
#define SNAP_COORD(x) (disabled ? (x) : renderer_apply_snapping((x), skiptransform, ppdip, det, &m))
|
2015-05-05 14:23:17 +02:00
|
|
|
/* 1. Regular runs */
|
2019-11-29 10:54:26 +01:00
|
|
|
LIST_FOR_EACH_ENTRY(run, &layout->eruns, struct layout_effective_run, entry)
|
|
|
|
{
|
2015-05-05 14:23:17 +02:00
|
|
|
const struct regular_layout_run *regular = &run->run->u.regular;
|
|
|
|
UINT32 start_glyph = regular->clustermap[run->start];
|
|
|
|
DWRITE_GLYPH_RUN_DESCRIPTION descr;
|
|
|
|
DWRITE_GLYPH_RUN glyph_run;
|
|
|
|
|
|
|
|
/* Everything but cluster map will be reused from nominal run, as we only need
|
|
|
|
to adjust some pointers. Cluster map however is rebuilt when effective run is added,
|
|
|
|
it can't be reused because it has to start with 0 index for each reported run. */
|
|
|
|
glyph_run = regular->run;
|
|
|
|
glyph_run.glyphCount = run->glyphcount;
|
|
|
|
|
|
|
|
/* fixup glyph data arrays */
|
|
|
|
glyph_run.glyphIndices += start_glyph;
|
|
|
|
glyph_run.glyphAdvances += start_glyph;
|
|
|
|
glyph_run.glyphOffsets += start_glyph;
|
|
|
|
|
|
|
|
/* description */
|
|
|
|
descr = regular->descr;
|
|
|
|
descr.stringLength = run->length;
|
|
|
|
descr.string += run->start;
|
|
|
|
descr.clusterMap = run->clustermap;
|
|
|
|
descr.textPosition += run->start;
|
|
|
|
|
|
|
|
/* return value is ignored */
|
|
|
|
IDWriteTextRenderer_DrawGlyphRun(renderer,
|
|
|
|
context,
|
2017-04-19 14:15:24 +02:00
|
|
|
run->origin.x + run->align_dx + origin_x,
|
|
|
|
SNAP_COORD(run->origin.y + origin_y),
|
2019-11-29 10:54:26 +01:00
|
|
|
layout->measuringmode,
|
2015-05-05 14:23:17 +02:00
|
|
|
&glyph_run,
|
|
|
|
&descr,
|
2016-01-12 21:12:07 +01:00
|
|
|
run->effect);
|
2015-05-05 14:23:17 +02:00
|
|
|
}
|
|
|
|
|
2015-05-30 17:44:54 +02:00
|
|
|
/* 2. Inline objects */
|
2019-11-29 10:54:26 +01:00
|
|
|
LIST_FOR_EACH_ENTRY(inlineobject, &layout->inlineobjects, struct layout_effective_inline, entry)
|
|
|
|
{
|
2015-05-30 17:44:54 +02:00
|
|
|
IDWriteTextRenderer_DrawInlineObject(renderer,
|
|
|
|
context,
|
2017-04-19 14:15:24 +02:00
|
|
|
inlineobject->origin.x + inlineobject->align_dx + origin_x,
|
|
|
|
SNAP_COORD(inlineobject->origin.y + origin_y),
|
2017-01-26 05:41:50 +01:00
|
|
|
inlineobject->object,
|
2015-05-30 17:44:54 +02:00
|
|
|
inlineobject->is_sideways,
|
|
|
|
inlineobject->is_rtl,
|
2015-06-15 00:15:25 +02:00
|
|
|
inlineobject->effect);
|
2015-05-30 17:44:54 +02:00
|
|
|
}
|
|
|
|
|
2016-01-14 22:24:23 +01:00
|
|
|
/* 3. Underlines */
|
2019-11-29 10:54:26 +01:00
|
|
|
LIST_FOR_EACH_ENTRY(u, &layout->underlines, struct layout_underline, entry)
|
|
|
|
{
|
2016-01-14 22:24:23 +01:00
|
|
|
IDWriteTextRenderer_DrawUnderline(renderer,
|
|
|
|
context,
|
2016-01-19 21:23:00 +01:00
|
|
|
/* horizontal underline always grows from left to right, width is always added to origin regardless of run direction */
|
2017-04-19 14:15:24 +02:00
|
|
|
(is_run_rtl(u->run) ? u->run->origin.x - u->run->width : u->run->origin.x) + u->run->align_dx + origin_x,
|
|
|
|
SNAP_COORD(u->run->origin.y + origin_y),
|
2016-01-14 22:24:23 +01:00
|
|
|
&u->u,
|
|
|
|
u->run->effect);
|
|
|
|
}
|
2015-06-04 22:32:30 +02:00
|
|
|
|
|
|
|
/* 4. Strikethrough */
|
2019-11-29 10:54:26 +01:00
|
|
|
LIST_FOR_EACH_ENTRY(s, &layout->strikethrough, struct layout_strikethrough, entry)
|
|
|
|
{
|
2015-06-04 22:32:30 +02:00
|
|
|
IDWriteTextRenderer_DrawStrikethrough(renderer,
|
|
|
|
context,
|
2017-04-19 14:15:24 +02:00
|
|
|
s->run->origin.x + s->run->align_dx + origin_x,
|
|
|
|
SNAP_COORD(s->run->origin.y + origin_y),
|
2015-06-04 22:32:30 +02:00
|
|
|
&s->s,
|
2016-01-12 21:12:08 +01:00
|
|
|
s->run->effect);
|
2015-06-04 22:32:30 +02:00
|
|
|
}
|
2015-07-12 22:22:50 +02:00
|
|
|
#undef SNAP_COORD
|
2015-05-05 14:23:17 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetLineMetrics(IDWriteTextLayout4 *iface,
|
2015-05-05 14:23:17 +02:00
|
|
|
DWRITE_LINE_METRICS *metrics, UINT32 max_count, UINT32 *count)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-05-14 12:27:28 +02:00
|
|
|
unsigned int line_count;
|
2015-05-05 14:23:17 +02:00
|
|
|
HRESULT hr;
|
2019-05-14 12:27:28 +02:00
|
|
|
size_t i;
|
2015-05-05 14:23:17 +02:00
|
|
|
|
2019-05-14 12:27:28 +02:00
|
|
|
TRACE("%p, %p, %u, %p.\n", iface, metrics, max_count, count);
|
2015-05-05 14:23:17 +02:00
|
|
|
|
2019-05-14 12:27:28 +02:00
|
|
|
if (FAILED(hr = layout_compute_effective_runs(layout)))
|
2015-05-05 14:23:17 +02:00
|
|
|
return hr;
|
|
|
|
|
2019-05-14 12:27:28 +02:00
|
|
|
if (metrics)
|
|
|
|
{
|
|
|
|
line_count = min(max_count, layout->metrics.lineCount);
|
|
|
|
for (i = 0; i < line_count; ++i)
|
|
|
|
memcpy(&metrics[i], &layout->lines[i].metrics, sizeof(*metrics));
|
2016-07-25 10:42:56 +02:00
|
|
|
}
|
2015-05-05 14:23:17 +02:00
|
|
|
|
2019-05-14 12:27:28 +02:00
|
|
|
*count = layout->metrics.lineCount;
|
|
|
|
return max_count >= layout->metrics.lineCount ? S_OK : E_NOT_SUFFICIENT_BUFFER;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-05-13 13:21:42 +02:00
|
|
|
static HRESULT layout_update_metrics(struct dwrite_textlayout *layout)
|
|
|
|
{
|
|
|
|
return layout_compute_effective_runs(layout);
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetMetrics(IDWriteTextLayout4 *iface, DWRITE_TEXT_METRICS *metrics)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2015-03-21 17:27:21 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-05-13 13:21:42 +02:00
|
|
|
TRACE("%p, %p.\n", iface, metrics);
|
2015-03-21 17:27:21 +01:00
|
|
|
|
2019-05-13 13:21:42 +02:00
|
|
|
hr = layout_update_metrics(layout);
|
2015-03-21 17:27:21 +01:00
|
|
|
if (hr == S_OK)
|
2019-05-13 13:21:42 +02:00
|
|
|
memcpy(metrics, &layout->metrics, sizeof(*metrics));
|
2015-03-21 17:27:21 +01:00
|
|
|
|
|
|
|
return hr;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2017-04-19 14:15:24 +02:00
|
|
|
static void d2d_rect_offset(D2D1_RECT_F *rect, FLOAT x, FLOAT y)
|
2017-01-26 22:42:13 +01:00
|
|
|
{
|
|
|
|
rect->left += x;
|
|
|
|
rect->right += x;
|
|
|
|
rect->top += y;
|
|
|
|
rect->bottom += y;
|
|
|
|
}
|
|
|
|
|
2017-04-19 14:15:24 +02:00
|
|
|
static BOOL d2d_rect_is_empty(const D2D1_RECT_F *rect)
|
2017-01-26 22:42:13 +01:00
|
|
|
{
|
|
|
|
return ((rect->left >= rect->right) || (rect->top >= rect->bottom));
|
|
|
|
}
|
|
|
|
|
2017-04-19 14:15:24 +02:00
|
|
|
static void d2d_rect_union(D2D1_RECT_F *dst, const D2D1_RECT_F *src)
|
2017-01-26 22:42:13 +01:00
|
|
|
{
|
|
|
|
if (d2d_rect_is_empty(dst)) {
|
|
|
|
if (d2d_rect_is_empty(src)) {
|
|
|
|
dst->left = dst->right = dst->top = dst->bottom = 0.0f;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dst = *src;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!d2d_rect_is_empty(src)) {
|
|
|
|
dst->left = min(dst->left, src->left);
|
|
|
|
dst->right = max(dst->right, src->right);
|
|
|
|
dst->top = min(dst->top, src->top);
|
|
|
|
dst->bottom = max(dst->bottom, src->bottom);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-19 14:15:24 +02:00
|
|
|
static void layout_get_erun_bbox(struct dwrite_textlayout *layout, struct layout_effective_run *run, D2D1_RECT_F *bbox)
|
2017-01-26 22:42:13 +01:00
|
|
|
{
|
|
|
|
const struct regular_layout_run *regular = &run->run->u.regular;
|
|
|
|
UINT32 start_glyph = regular->clustermap[run->start];
|
|
|
|
const DWRITE_GLYPH_RUN *glyph_run = ®ular->run;
|
2017-04-19 14:15:24 +02:00
|
|
|
D2D1_POINT_2F origin = { 0 };
|
2019-01-25 12:56:40 +01:00
|
|
|
float rtl_factor;
|
2017-01-26 22:42:13 +01:00
|
|
|
UINT32 i;
|
|
|
|
|
2019-01-25 12:56:40 +01:00
|
|
|
if (run->bbox.top == run->bbox.bottom)
|
|
|
|
{
|
|
|
|
struct dwrite_glyphbitmap glyph_bitmap;
|
|
|
|
RECT *bbox;
|
|
|
|
|
|
|
|
memset(&glyph_bitmap, 0, sizeof(glyph_bitmap));
|
|
|
|
glyph_bitmap.fontface = (IDWriteFontFace4 *)glyph_run->fontFace;
|
|
|
|
glyph_bitmap.simulations = IDWriteFontFace_GetSimulations(glyph_run->fontFace);
|
|
|
|
glyph_bitmap.emsize = glyph_run->fontEmSize;
|
|
|
|
glyph_bitmap.nohint = layout->measuringmode == DWRITE_MEASURING_MODE_NATURAL;
|
|
|
|
|
|
|
|
bbox = &glyph_bitmap.bbox;
|
2017-01-26 22:42:13 +01:00
|
|
|
|
2019-01-25 12:56:40 +01:00
|
|
|
rtl_factor = glyph_run->bidiLevel & 1 ? -1.0f : 1.0f;
|
2017-04-25 07:54:43 +02:00
|
|
|
for (i = 0; i < run->glyphcount; i++) {
|
|
|
|
D2D1_RECT_F glyph_bbox;
|
2017-01-26 22:42:13 +01:00
|
|
|
|
2019-01-25 12:56:40 +01:00
|
|
|
/* FIXME: take care of vertical/rtl */
|
|
|
|
if (glyph_run->bidiLevel & 1)
|
|
|
|
origin.x -= glyph_run->glyphAdvances[i + start_glyph];
|
|
|
|
|
|
|
|
glyph_bitmap.glyph = glyph_run->glyphIndices[i + start_glyph];
|
|
|
|
freetype_get_glyph_bbox(&glyph_bitmap);
|
|
|
|
|
|
|
|
glyph_bbox.left = bbox->left;
|
|
|
|
glyph_bbox.top = bbox->top;
|
|
|
|
glyph_bbox.right = bbox->right;
|
|
|
|
glyph_bbox.bottom = bbox->bottom;
|
|
|
|
|
|
|
|
d2d_rect_offset(&glyph_bbox, origin.x + rtl_factor * glyph_run->glyphOffsets[i + start_glyph].advanceOffset,
|
|
|
|
origin.y - glyph_run->glyphOffsets[i + start_glyph].ascenderOffset);
|
2017-01-26 22:42:13 +01:00
|
|
|
|
2017-04-25 07:54:43 +02:00
|
|
|
d2d_rect_union(&run->bbox, &glyph_bbox);
|
2017-01-26 22:42:13 +01:00
|
|
|
|
2019-01-25 12:56:40 +01:00
|
|
|
if (!(glyph_run->bidiLevel & 1))
|
|
|
|
origin.x += glyph_run->glyphAdvances[i + start_glyph];
|
2017-04-25 07:54:43 +02:00
|
|
|
}
|
2017-01-26 22:42:13 +01:00
|
|
|
}
|
2017-04-25 07:54:43 +02:00
|
|
|
|
|
|
|
*bbox = run->bbox;
|
|
|
|
d2d_rect_offset(bbox, run->origin.x + run->align_dx, run->origin.y);
|
2017-01-26 22:42:13 +01:00
|
|
|
}
|
|
|
|
|
2017-10-02 06:50:58 +02:00
|
|
|
static void layout_get_inlineobj_bbox(struct dwrite_textlayout *layout, struct layout_effective_inline *run,
|
|
|
|
D2D1_RECT_F *bbox)
|
|
|
|
{
|
|
|
|
DWRITE_OVERHANG_METRICS overhang_metrics = { 0 };
|
|
|
|
DWRITE_INLINE_OBJECT_METRICS metrics = { 0 };
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (FAILED(hr = IDWriteInlineObject_GetMetrics(run->object, &metrics))) {
|
|
|
|
WARN("Failed to get inline object metrics, hr %#x.\n", hr);
|
|
|
|
memset(bbox, 0, sizeof(*bbox));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bbox->left = run->origin.x + run->align_dx;
|
|
|
|
bbox->right = bbox->left + metrics.width;
|
|
|
|
bbox->top = run->origin.y;
|
|
|
|
bbox->bottom = bbox->top + metrics.height;
|
|
|
|
|
|
|
|
IDWriteInlineObject_GetOverhangMetrics(run->object, &overhang_metrics);
|
|
|
|
|
|
|
|
bbox->left -= overhang_metrics.left;
|
|
|
|
bbox->right += overhang_metrics.right;
|
|
|
|
bbox->top -= overhang_metrics.top;
|
|
|
|
bbox->bottom += overhang_metrics.bottom;
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetOverhangMetrics(IDWriteTextLayout4 *iface,
|
2017-01-26 22:42:13 +01:00
|
|
|
DWRITE_OVERHANG_METRICS *overhangs)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2017-10-02 06:50:58 +02:00
|
|
|
struct layout_effective_inline *inline_run;
|
2017-01-26 22:42:13 +01:00
|
|
|
struct layout_effective_run *run;
|
2017-04-19 14:15:24 +02:00
|
|
|
D2D1_RECT_F bbox = { 0 };
|
2017-01-26 22:42:13 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %p.\n", iface, overhangs);
|
2017-01-26 22:42:13 +01:00
|
|
|
|
|
|
|
memset(overhangs, 0, sizeof(*overhangs));
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
if (!(layout->recompute & RECOMPUTE_OVERHANGS))
|
|
|
|
{
|
|
|
|
*overhangs = layout->overhangs;
|
2017-01-26 22:42:13 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
hr = layout_compute_effective_runs(layout);
|
2017-01-26 22:42:13 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
LIST_FOR_EACH_ENTRY(run, &layout->eruns, struct layout_effective_run, entry)
|
|
|
|
{
|
2017-04-19 14:15:24 +02:00
|
|
|
D2D1_RECT_F run_bbox;
|
2017-01-26 22:42:13 +01:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
layout_get_erun_bbox(layout, run, &run_bbox);
|
2017-01-26 22:42:13 +01:00
|
|
|
d2d_rect_union(&bbox, &run_bbox);
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
LIST_FOR_EACH_ENTRY(inline_run, &layout->inlineobjects, struct layout_effective_inline, entry)
|
|
|
|
{
|
2017-10-02 06:50:58 +02:00
|
|
|
D2D1_RECT_F object_bbox;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
layout_get_inlineobj_bbox(layout, inline_run, &object_bbox);
|
2017-10-02 06:50:58 +02:00
|
|
|
d2d_rect_union(&bbox, &object_bbox);
|
|
|
|
}
|
2017-01-26 22:42:13 +01:00
|
|
|
|
2017-10-02 06:50:58 +02:00
|
|
|
/* Deltas from layout box. */
|
2019-11-29 10:54:26 +01:00
|
|
|
layout->overhangs.left = -bbox.left;
|
|
|
|
layout->overhangs.top = -bbox.top;
|
|
|
|
layout->overhangs.right = bbox.right - layout->metrics.layoutWidth;
|
|
|
|
layout->overhangs.bottom = bbox.bottom - layout->metrics.layoutHeight;
|
|
|
|
layout->recompute &= ~RECOMPUTE_OVERHANGS;
|
2017-01-26 22:42:13 +01:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
*overhangs = layout->overhangs;
|
2017-01-26 22:42:13 +01:00
|
|
|
|
|
|
|
return S_OK;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetClusterMetrics(IDWriteTextLayout4 *iface,
|
2014-12-23 13:36:32 +01:00
|
|
|
DWRITE_CLUSTER_METRICS *metrics, UINT32 max_count, UINT32 *count)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2014-12-23 13:36:32 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %p, %u, %p.\n", iface, metrics, max_count, count);
|
2014-12-23 13:36:32 +01:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
hr = layout_compute(layout);
|
2014-12-23 13:36:32 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2015-01-12 11:56:27 +01:00
|
|
|
if (metrics)
|
2019-11-29 10:54:26 +01:00
|
|
|
memcpy(metrics, layout->clustermetrics, sizeof(DWRITE_CLUSTER_METRICS) * min(max_count, layout->cluster_count));
|
2015-01-12 11:56:27 +01:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
*count = layout->cluster_count;
|
|
|
|
return max_count >= layout->cluster_count ? S_OK : E_NOT_SUFFICIENT_BUFFER;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_DetermineMinWidth(IDWriteTextLayout4 *iface, FLOAT* min_width)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2016-01-26 13:44:48 +01:00
|
|
|
UINT32 start;
|
2015-03-30 09:15:48 +02:00
|
|
|
FLOAT width;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %p.\n", iface, min_width);
|
2015-03-30 09:15:48 +02:00
|
|
|
|
|
|
|
if (!min_width)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
if (!(layout->recompute & RECOMPUTE_MINIMAL_WIDTH))
|
2015-03-30 09:15:48 +02:00
|
|
|
goto width_done;
|
|
|
|
|
2016-01-11 14:15:53 +01:00
|
|
|
*min_width = 0.0f;
|
2019-11-29 10:54:26 +01:00
|
|
|
hr = layout_compute(layout);
|
2015-03-30 09:15:48 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2016-01-26 13:44:48 +01:00
|
|
|
/* Find widest word without emergency breaking between clusters, trailing whitespaces
|
|
|
|
preceding breaking point do not contribute to word width. */
|
2019-11-29 10:54:26 +01:00
|
|
|
for (start = 0; start < layout->cluster_count;)
|
|
|
|
{
|
2016-01-26 13:44:48 +01:00
|
|
|
UINT32 end = start, j, next;
|
|
|
|
|
|
|
|
/* Last cluster always could be wrapped after. */
|
2019-11-29 10:54:26 +01:00
|
|
|
while (!layout->clustermetrics[end].canWrapLineAfter)
|
2016-01-26 13:44:48 +01:00
|
|
|
end++;
|
|
|
|
/* make is so current cluster range that we can wrap after is [start,end) */
|
|
|
|
end++;
|
|
|
|
|
|
|
|
next = end;
|
|
|
|
|
|
|
|
/* Ignore trailing whitespace clusters, in case of single space range will
|
|
|
|
be reduced to empty range, or [start,start+1). */
|
2019-11-29 10:54:26 +01:00
|
|
|
while (end > start && layout->clustermetrics[end-1].isWhitespace)
|
2016-01-26 13:44:48 +01:00
|
|
|
end--;
|
|
|
|
|
|
|
|
/* check if cluster range exceeds last minimal width */
|
|
|
|
width = 0.0f;
|
|
|
|
for (j = start; j < end; j++)
|
2019-11-29 10:54:26 +01:00
|
|
|
width += layout->clustermetrics[j].width;
|
2016-01-26 13:44:48 +01:00
|
|
|
|
|
|
|
start = next;
|
2015-03-30 09:15:48 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
if (width > layout->minwidth)
|
|
|
|
layout->minwidth = width;
|
2015-03-30 09:15:48 +02:00
|
|
|
}
|
2019-11-29 10:54:26 +01:00
|
|
|
layout->recompute &= ~RECOMPUTE_MINIMAL_WIDTH;
|
2015-03-30 09:15:48 +02:00
|
|
|
|
|
|
|
width_done:
|
2019-11-29 10:54:26 +01:00
|
|
|
*min_width = layout->minwidth;
|
2015-03-30 09:15:48 +02:00
|
|
|
return S_OK;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_HitTestPoint(IDWriteTextLayout4 *iface,
|
2012-09-28 10:13:17 +02:00
|
|
|
FLOAT pointX, FLOAT pointY, BOOL* is_trailinghit, BOOL* is_inside, DWRITE_HIT_TEST_METRICS *metrics)
|
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
FIXME("%p, %.8e, %.8e, %p, %p, %p): stub\n", iface, pointX, pointY, is_trailinghit, is_inside, metrics);
|
|
|
|
|
2012-09-28 10:13:17 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_HitTestTextPosition(IDWriteTextLayout4 *iface,
|
|
|
|
UINT32 textPosition, BOOL is_trailinghit, FLOAT *pointX, FLOAT *pointY, DWRITE_HIT_TEST_METRICS *metrics)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
FIXME("%p, %u, %d, %p, %p, %p): stub\n", iface, textPosition, is_trailinghit, pointX, pointY, metrics);
|
|
|
|
|
2012-09-28 10:13:17 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_HitTestTextRange(IDWriteTextLayout4 *iface,
|
2012-09-28 10:13:17 +02:00
|
|
|
UINT32 textPosition, UINT32 textLength, FLOAT originX, FLOAT originY,
|
|
|
|
DWRITE_HIT_TEST_METRICS *metrics, UINT32 max_metricscount, UINT32* actual_metricscount)
|
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
FIXME("%p, %u, %u, %f, %f, %p, %u, %p): stub\n", iface, textPosition, textLength, originX, originY, metrics,
|
2012-09-28 10:13:17 +02:00
|
|
|
max_metricscount, actual_metricscount);
|
2019-11-29 10:54:26 +01:00
|
|
|
|
2012-09-28 10:13:17 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout1_SetPairKerning(IDWriteTextLayout4 *iface, BOOL is_pairkerning_enabled,
|
2014-10-10 11:38:54 +02:00
|
|
|
DWRITE_TEXT_RANGE range)
|
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2015-03-13 09:25:18 +01:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %d, %s.\n", iface, is_pairkerning_enabled, debugstr_range(&range));
|
2015-03-13 09:25:18 +01:00
|
|
|
|
|
|
|
value.range = range;
|
|
|
|
value.u.pair_kerning = !!is_pairkerning_enabled;
|
2019-11-29 10:54:26 +01:00
|
|
|
return set_layout_range_attr(layout, LAYOUT_RANGE_ATTR_PAIR_KERNING, &value);
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout1_GetPairKerning(IDWriteTextLayout4 *iface, UINT32 position,
|
|
|
|
BOOL *is_pairkerning_enabled, DWRITE_TEXT_RANGE *r)
|
2014-10-10 11:38:54 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2015-03-13 09:25:18 +01:00
|
|
|
struct layout_range *range;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, position, is_pairkerning_enabled, r);
|
2015-03-13 09:25:18 +01:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
if (position >= layout->len)
|
2015-03-13 09:25:18 +01:00
|
|
|
return S_OK;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
range = get_layout_range_by_pos(layout, position);
|
2015-03-13 09:25:18 +01:00
|
|
|
*is_pairkerning_enabled = range->pair_kerning;
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
return return_range(&range->h, r);
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout1_SetCharacterSpacing(IDWriteTextLayout4 *iface, FLOAT leading, FLOAT trailing,
|
2015-06-18 18:52:15 +02:00
|
|
|
FLOAT min_advance, DWRITE_TEXT_RANGE range)
|
2014-10-10 11:38:54 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2015-06-18 18:52:15 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %.8e, %.8e, %.8e, %s.\n", iface, leading, trailing, min_advance, debugstr_range(&range));
|
2015-06-18 18:52:15 +02:00
|
|
|
|
2016-01-11 14:15:53 +01:00
|
|
|
if (min_advance < 0.0f)
|
2015-06-18 18:52:15 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
value.range = range;
|
2017-08-22 11:42:09 +02:00
|
|
|
value.u.spacing.leading = leading;
|
|
|
|
value.u.spacing.trailing = trailing;
|
|
|
|
value.u.spacing.min_advance = min_advance;
|
2019-11-29 10:54:26 +01:00
|
|
|
return set_layout_range_attr(layout, LAYOUT_RANGE_ATTR_SPACING, &value);
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout1_GetCharacterSpacing(IDWriteTextLayout4 *iface, UINT32 position, FLOAT *leading,
|
2015-06-18 18:52:15 +02:00
|
|
|
FLOAT *trailing, FLOAT *min_advance, DWRITE_TEXT_RANGE *r)
|
2014-10-10 11:38:54 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2015-06-18 18:52:15 +02:00
|
|
|
struct layout_range_spacing *range;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %u, %p, %p, %p, %p.\n", iface, position, leading, trailing, min_advance, r);
|
2015-06-18 18:52:15 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
range = (struct layout_range_spacing *)get_layout_range_header_by_pos(&layout->spacing, position);
|
2015-06-18 18:52:15 +02:00
|
|
|
*leading = range->leading;
|
|
|
|
*trailing = range->trailing;
|
|
|
|
*min_advance = range->min_advance;
|
|
|
|
|
|
|
|
return return_range(&range->h, r);
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout2_GetMetrics(IDWriteTextLayout4 *iface, DWRITE_TEXT_METRICS1 *metrics)
|
2014-10-10 11:38:54 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2015-07-01 19:43:30 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-05-13 13:21:42 +02:00
|
|
|
TRACE("%p, %p.\n", iface, metrics);
|
2015-07-01 19:43:30 +02:00
|
|
|
|
2019-05-13 13:21:42 +02:00
|
|
|
if (SUCCEEDED(hr = layout_update_metrics(layout)))
|
|
|
|
*metrics = layout->metrics;
|
2015-07-01 19:43:30 +02:00
|
|
|
|
2019-05-13 13:21:42 +02:00
|
|
|
return hr;
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout2_SetVerticalGlyphOrientation(IDWriteTextLayout4 *iface,
|
|
|
|
DWRITE_VERTICAL_GLYPH_ORIENTATION orientation)
|
2014-10-10 11:38:54 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2015-03-13 09:58:32 +01:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %d.\n", iface, orientation);
|
2015-03-13 09:58:32 +01:00
|
|
|
|
|
|
|
if ((UINT32)orientation > DWRITE_VERTICAL_GLYPH_ORIENTATION_STACKED)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
layout->format.vertical_orientation = orientation;
|
2015-03-13 09:58:32 +01:00
|
|
|
return S_OK;
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static DWRITE_VERTICAL_GLYPH_ORIENTATION WINAPI dwritetextlayout2_GetVerticalGlyphOrientation(IDWriteTextLayout4 *iface)
|
2014-10-10 11:38:54 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->format.vertical_orientation;
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout2_SetLastLineWrapping(IDWriteTextLayout4 *iface, BOOL lastline_wrapping_enabled)
|
2014-10-10 11:38:54 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %d.\n", iface, lastline_wrapping_enabled);
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_SetLastLineWrapping(&layout->IDWriteTextFormat3_iface, lastline_wrapping_enabled);
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static BOOL WINAPI dwritetextlayout2_GetLastLineWrapping(IDWriteTextLayout4 *iface)
|
2014-10-10 11:38:54 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetLastLineWrapping(&layout->IDWriteTextFormat3_iface);
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout2_SetOpticalAlignment(IDWriteTextLayout4 *iface,
|
|
|
|
DWRITE_OPTICAL_ALIGNMENT alignment)
|
2014-10-10 11:38:54 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %d.\n", iface, alignment);
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_SetOpticalAlignment(&layout->IDWriteTextFormat3_iface, alignment);
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static DWRITE_OPTICAL_ALIGNMENT WINAPI dwritetextlayout2_GetOpticalAlignment(IDWriteTextLayout4 *iface)
|
2014-10-10 11:38:54 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
return IDWriteTextFormat3_GetOpticalAlignment(&layout->IDWriteTextFormat3_iface);
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout2_SetFontFallback(IDWriteTextLayout4 *iface, IDWriteFontFallback *fallback)
|
2014-10-10 11:38:54 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, fallback);
|
|
|
|
|
|
|
|
return set_fontfallback_for_format(&layout->format, fallback);
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout2_GetFontFallback(IDWriteTextLayout4 *iface, IDWriteFontFallback **fallback)
|
2014-10-10 11:38:54 +02:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, fallback);
|
|
|
|
|
|
|
|
return get_fontfallback_from_format(&layout->format, fallback);
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout3_InvalidateLayout(IDWriteTextLayout4 *iface)
|
2016-02-16 22:19:38 +01:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2016-02-16 22:19:39 +01:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p.\n", iface);
|
2016-02-16 22:19:39 +01:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
layout->recompute = RECOMPUTE_EVERYTHING;
|
2016-02-16 22:19:39 +01:00
|
|
|
return S_OK;
|
2016-02-16 22:19:38 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout3_SetLineSpacing(IDWriteTextLayout4 *iface, DWRITE_LINE_SPACING const *spacing)
|
2016-02-16 22:19:38 +01:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2016-07-25 10:42:54 +02:00
|
|
|
BOOL changed;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %p.\n", iface, spacing);
|
2016-07-25 10:42:54 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
hr = format_set_linespacing(&layout->format, spacing, &changed);
|
2016-07-25 10:42:54 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
if (changed)
|
|
|
|
{
|
|
|
|
if (!(layout->recompute & RECOMPUTE_LINES))
|
|
|
|
{
|
2017-02-02 00:11:35 +01:00
|
|
|
UINT32 line;
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
for (line = 0; line < layout->metrics.lineCount; line++)
|
|
|
|
layout_apply_line_spacing(layout, line);
|
2017-02-02 00:11:35 +01:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
layout_set_line_positions(layout);
|
2017-02-02 00:11:35 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
layout->recompute |= RECOMPUTE_OVERHANGS;
|
2017-02-02 00:11:35 +01:00
|
|
|
}
|
2016-07-25 10:42:54 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2016-02-16 22:19:38 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout3_GetLineSpacing(IDWriteTextLayout4 *iface, DWRITE_LINE_SPACING *spacing)
|
2016-02-16 22:19:38 +01:00
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2016-07-25 10:42:54 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %p.\n", iface, spacing);
|
2016-07-25 10:42:54 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
*spacing = layout->format.spacing;
|
2016-07-25 10:42:54 +02:00
|
|
|
return S_OK;
|
2016-02-16 22:19:38 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout3_GetLineMetrics(IDWriteTextLayout4 *iface, DWRITE_LINE_METRICS1 *metrics,
|
2016-02-16 22:19:38 +01:00
|
|
|
UINT32 max_count, UINT32 *count)
|
|
|
|
{
|
2019-11-29 10:54:26 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextLayout4(iface);
|
2019-05-14 12:27:28 +02:00
|
|
|
unsigned int line_count;
|
2016-07-25 10:42:56 +02:00
|
|
|
HRESULT hr;
|
2019-05-14 12:27:28 +02:00
|
|
|
size_t i;
|
2016-07-25 10:42:56 +02:00
|
|
|
|
2019-05-14 12:27:28 +02:00
|
|
|
TRACE("%p, %p, %u, %p.\n", iface, metrics, max_count, count);
|
2016-07-25 10:42:56 +02:00
|
|
|
|
2019-05-14 12:27:28 +02:00
|
|
|
if (FAILED(hr = layout_compute_effective_runs(layout)))
|
2016-07-25 10:42:56 +02:00
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (metrics)
|
2019-05-14 12:27:28 +02:00
|
|
|
{
|
|
|
|
line_count = min(max_count, layout->metrics.lineCount);
|
|
|
|
for (i = 0; i < line_count; ++i)
|
|
|
|
metrics[i] = layout->lines[i].metrics;
|
|
|
|
}
|
2016-07-25 10:42:56 +02:00
|
|
|
|
2019-05-14 12:27:28 +02:00
|
|
|
*count = layout->metrics.lineCount;
|
|
|
|
return max_count >= layout->metrics.lineCount ? S_OK : E_NOT_SUFFICIENT_BUFFER;
|
2016-02-16 22:19:38 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout4_SetFontAxisValues(IDWriteTextLayout4 *iface,
|
|
|
|
DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 num_values, DWRITE_TEXT_RANGE range)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p, %u, %s.\n", iface, axis_values, num_values, debugstr_range(&range));
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 WINAPI dwritetextlayout4_GetFontAxisValueCount(IDWriteTextLayout4 *iface, UINT32 pos)
|
|
|
|
{
|
|
|
|
FIXME("%p, %u.\n", iface, pos);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout4_GetFontAxisValues(IDWriteTextLayout4 *iface, UINT32 pos,
|
|
|
|
DWRITE_FONT_AXIS_VALUE *values, UINT32 num_values, DWRITE_TEXT_RANGE *range)
|
|
|
|
{
|
|
|
|
FIXME("%p, %u, %p, %u, %p.\n", iface, pos, values, num_values, range);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_AUTOMATIC_FONT_AXES WINAPI dwritetextlayout4_GetAutomaticFontAxes(IDWriteTextLayout4 *iface)
|
|
|
|
{
|
|
|
|
FIXME("%p.\n", iface);
|
|
|
|
|
|
|
|
return DWRITE_AUTOMATIC_FONT_AXES_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout4_SetAutomaticFontAxes(IDWriteTextLayout4 *iface,
|
|
|
|
DWRITE_AUTOMATIC_FONT_AXES axes)
|
|
|
|
{
|
|
|
|
FIXME("%p, %d.\n", iface, axes);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteTextLayout4Vtbl dwritetextlayoutvtbl =
|
|
|
|
{
|
2012-09-28 10:13:17 +02:00
|
|
|
dwritetextlayout_QueryInterface,
|
|
|
|
dwritetextlayout_AddRef,
|
|
|
|
dwritetextlayout_Release,
|
|
|
|
dwritetextlayout_SetTextAlignment,
|
|
|
|
dwritetextlayout_SetParagraphAlignment,
|
|
|
|
dwritetextlayout_SetWordWrapping,
|
|
|
|
dwritetextlayout_SetReadingDirection,
|
|
|
|
dwritetextlayout_SetFlowDirection,
|
|
|
|
dwritetextlayout_SetIncrementalTabStop,
|
|
|
|
dwritetextlayout_SetTrimming,
|
|
|
|
dwritetextlayout_SetLineSpacing,
|
|
|
|
dwritetextlayout_GetTextAlignment,
|
|
|
|
dwritetextlayout_GetParagraphAlignment,
|
|
|
|
dwritetextlayout_GetWordWrapping,
|
|
|
|
dwritetextlayout_GetReadingDirection,
|
|
|
|
dwritetextlayout_GetFlowDirection,
|
|
|
|
dwritetextlayout_GetIncrementalTabStop,
|
|
|
|
dwritetextlayout_GetTrimming,
|
|
|
|
dwritetextlayout_GetLineSpacing,
|
|
|
|
dwritetextlayout_GetFontCollection,
|
|
|
|
dwritetextlayout_GetFontFamilyNameLength,
|
|
|
|
dwritetextlayout_GetFontFamilyName,
|
|
|
|
dwritetextlayout_GetFontWeight,
|
|
|
|
dwritetextlayout_GetFontStyle,
|
|
|
|
dwritetextlayout_GetFontStretch,
|
|
|
|
dwritetextlayout_GetFontSize,
|
|
|
|
dwritetextlayout_GetLocaleNameLength,
|
|
|
|
dwritetextlayout_GetLocaleName,
|
|
|
|
dwritetextlayout_SetMaxWidth,
|
|
|
|
dwritetextlayout_SetMaxHeight,
|
|
|
|
dwritetextlayout_SetFontCollection,
|
|
|
|
dwritetextlayout_SetFontFamilyName,
|
|
|
|
dwritetextlayout_SetFontWeight,
|
|
|
|
dwritetextlayout_SetFontStyle,
|
|
|
|
dwritetextlayout_SetFontStretch,
|
|
|
|
dwritetextlayout_SetFontSize,
|
|
|
|
dwritetextlayout_SetUnderline,
|
|
|
|
dwritetextlayout_SetStrikethrough,
|
|
|
|
dwritetextlayout_SetDrawingEffect,
|
|
|
|
dwritetextlayout_SetInlineObject,
|
|
|
|
dwritetextlayout_SetTypography,
|
|
|
|
dwritetextlayout_SetLocaleName,
|
|
|
|
dwritetextlayout_GetMaxWidth,
|
|
|
|
dwritetextlayout_GetMaxHeight,
|
|
|
|
dwritetextlayout_layout_GetFontCollection,
|
|
|
|
dwritetextlayout_layout_GetFontFamilyNameLength,
|
|
|
|
dwritetextlayout_layout_GetFontFamilyName,
|
|
|
|
dwritetextlayout_layout_GetFontWeight,
|
|
|
|
dwritetextlayout_layout_GetFontStyle,
|
|
|
|
dwritetextlayout_layout_GetFontStretch,
|
|
|
|
dwritetextlayout_layout_GetFontSize,
|
|
|
|
dwritetextlayout_GetUnderline,
|
|
|
|
dwritetextlayout_GetStrikethrough,
|
|
|
|
dwritetextlayout_GetDrawingEffect,
|
|
|
|
dwritetextlayout_GetInlineObject,
|
|
|
|
dwritetextlayout_GetTypography,
|
|
|
|
dwritetextlayout_layout_GetLocaleNameLength,
|
|
|
|
dwritetextlayout_layout_GetLocaleName,
|
|
|
|
dwritetextlayout_Draw,
|
|
|
|
dwritetextlayout_GetLineMetrics,
|
|
|
|
dwritetextlayout_GetMetrics,
|
|
|
|
dwritetextlayout_GetOverhangMetrics,
|
|
|
|
dwritetextlayout_GetClusterMetrics,
|
|
|
|
dwritetextlayout_DetermineMinWidth,
|
|
|
|
dwritetextlayout_HitTestPoint,
|
|
|
|
dwritetextlayout_HitTestTextPosition,
|
2014-10-10 11:38:54 +02:00
|
|
|
dwritetextlayout_HitTestTextRange,
|
|
|
|
dwritetextlayout1_SetPairKerning,
|
|
|
|
dwritetextlayout1_GetPairKerning,
|
|
|
|
dwritetextlayout1_SetCharacterSpacing,
|
|
|
|
dwritetextlayout1_GetCharacterSpacing,
|
|
|
|
dwritetextlayout2_GetMetrics,
|
|
|
|
dwritetextlayout2_SetVerticalGlyphOrientation,
|
|
|
|
dwritetextlayout2_GetVerticalGlyphOrientation,
|
|
|
|
dwritetextlayout2_SetLastLineWrapping,
|
|
|
|
dwritetextlayout2_GetLastLineWrapping,
|
|
|
|
dwritetextlayout2_SetOpticalAlignment,
|
|
|
|
dwritetextlayout2_GetOpticalAlignment,
|
|
|
|
dwritetextlayout2_SetFontFallback,
|
2016-02-16 22:19:38 +01:00
|
|
|
dwritetextlayout2_GetFontFallback,
|
|
|
|
dwritetextlayout3_InvalidateLayout,
|
|
|
|
dwritetextlayout3_SetLineSpacing,
|
|
|
|
dwritetextlayout3_GetLineSpacing,
|
2019-11-29 10:54:26 +01:00
|
|
|
dwritetextlayout3_GetLineMetrics,
|
|
|
|
dwritetextlayout4_SetFontAxisValues,
|
|
|
|
dwritetextlayout4_GetFontAxisValueCount,
|
|
|
|
dwritetextlayout4_GetFontAxisValues,
|
|
|
|
dwritetextlayout4_GetAutomaticFontAxes,
|
|
|
|
dwritetextlayout4_SetAutomaticFontAxes,
|
2012-09-28 10:13:17 +02:00
|
|
|
};
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat_layout_QueryInterface(IDWriteTextFormat3 *iface, REFIID riid, void **obj)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2019-11-29 10:54:26 +01:00
|
|
|
|
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
return IDWriteTextLayout4_QueryInterface(&layout->IDWriteTextLayout4_iface, riid, obj);
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static ULONG WINAPI dwritetextformat_layout_AddRef(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2019-11-29 10:54:26 +01:00
|
|
|
return IDWriteTextLayout4_AddRef(&layout->IDWriteTextLayout4_iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static ULONG WINAPI dwritetextformat_layout_Release(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2019-11-29 10:54:26 +01:00
|
|
|
return IDWriteTextLayout4_Release(&layout->IDWriteTextLayout4_iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat_layout_SetTextAlignment(IDWriteTextFormat3 *iface,
|
2018-05-21 23:08:06 +02:00
|
|
|
DWRITE_TEXT_ALIGNMENT alignment)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2015-07-06 08:05:41 +02:00
|
|
|
BOOL changed;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
TRACE("%p, %d.\n", iface, alignment);
|
2015-07-06 08:05:41 +02:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
hr = format_set_textalignment(&layout->format, alignment, &changed);
|
2015-07-06 08:05:41 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
if (changed)
|
|
|
|
{
|
2017-04-25 07:54:43 +02:00
|
|
|
/* if layout is not ready there's nothing to align */
|
2019-11-29 10:54:27 +01:00
|
|
|
if (!(layout->recompute & RECOMPUTE_LINES))
|
|
|
|
layout_apply_text_alignment(layout);
|
|
|
|
layout->recompute |= RECOMPUTE_OVERHANGS;
|
2017-04-25 07:54:43 +02:00
|
|
|
}
|
2015-07-06 08:05:41 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat_layout_SetParagraphAlignment(IDWriteTextFormat3 *iface,
|
2018-05-21 23:08:06 +02:00
|
|
|
DWRITE_PARAGRAPH_ALIGNMENT alignment)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2015-07-06 08:06:08 +02:00
|
|
|
BOOL changed;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
TRACE("%p, %d.\n", iface, alignment);
|
2015-07-06 08:06:08 +02:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
hr = format_set_paralignment(&layout->format, alignment, &changed);
|
2015-07-06 08:06:08 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
if (changed)
|
|
|
|
{
|
2017-04-25 07:54:43 +02:00
|
|
|
/* if layout is not ready there's nothing to align */
|
2019-11-29 10:54:27 +01:00
|
|
|
if (!(layout->recompute & RECOMPUTE_LINES))
|
|
|
|
layout_apply_par_alignment(layout);
|
|
|
|
layout->recompute |= RECOMPUTE_OVERHANGS;
|
2017-04-25 07:54:43 +02:00
|
|
|
}
|
2015-07-06 08:06:08 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat_layout_SetWordWrapping(IDWriteTextFormat3 *iface, DWRITE_WORD_WRAPPING wrapping)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2015-07-12 22:35:32 +02:00
|
|
|
BOOL changed;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
TRACE("%p, %d.\n", iface, wrapping);
|
2015-07-12 22:35:32 +02:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
hr = format_set_wordwrapping(&layout->format, wrapping, &changed);
|
2015-07-12 22:35:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (changed)
|
2019-11-29 10:54:27 +01:00
|
|
|
layout->recompute |= RECOMPUTE_LINES_AND_OVERHANGS;
|
2015-07-12 22:35:32 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat_layout_SetReadingDirection(IDWriteTextFormat3 *iface,
|
2018-05-21 23:08:06 +02:00
|
|
|
DWRITE_READING_DIRECTION direction)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2015-07-09 11:25:54 +02:00
|
|
|
BOOL changed;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
TRACE("%p, %d.\n", iface, direction);
|
2015-07-09 11:25:54 +02:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
hr = format_set_readingdirection(&layout->format, direction, &changed);
|
2015-07-09 11:25:54 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (changed)
|
2019-11-29 10:54:27 +01:00
|
|
|
layout->recompute = RECOMPUTE_EVERYTHING;
|
2015-07-09 11:25:54 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat_layout_SetFlowDirection(IDWriteTextFormat3 *iface,
|
2018-05-21 23:08:06 +02:00
|
|
|
DWRITE_FLOW_DIRECTION direction)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2016-02-02 21:14:39 +01:00
|
|
|
BOOL changed;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
TRACE("%p, %d.\n", iface, direction);
|
2016-02-02 21:14:39 +01:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
hr = format_set_flowdirection(&layout->format, direction, &changed);
|
2016-02-02 21:14:39 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (changed)
|
2019-11-29 10:54:27 +01:00
|
|
|
layout->recompute = RECOMPUTE_EVERYTHING;
|
2016-02-02 21:14:39 +01:00
|
|
|
|
|
|
|
return S_OK;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat_layout_SetIncrementalTabStop(IDWriteTextFormat3 *iface, FLOAT tabstop)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2018-11-05 13:01:07 +01:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
TRACE("%p, %.8e.\n", iface, tabstop);
|
2018-11-05 13:01:07 +01:00
|
|
|
|
|
|
|
if (tabstop <= 0.0f)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
layout->format.tabstop = tabstop;
|
2017-11-23 18:31:02 +01:00
|
|
|
return S_OK;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat_layout_SetTrimming(IDWriteTextFormat3 *iface, DWRITE_TRIMMING const *trimming,
|
2015-03-15 00:38:32 +01:00
|
|
|
IDWriteInlineObject *trimming_sign)
|
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2016-07-18 23:10:36 +02:00
|
|
|
BOOL changed;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
TRACE("%p, %p, %p.\n", iface, trimming, trimming_sign);
|
2016-07-18 23:10:36 +02:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
hr = format_set_trimming(&layout->format, trimming, trimming_sign, &changed);
|
2016-07-18 23:10:36 +02:00
|
|
|
|
|
|
|
if (changed)
|
2019-11-29 10:54:27 +01:00
|
|
|
layout->recompute |= RECOMPUTE_LINES_AND_OVERHANGS;
|
2016-07-18 23:10:36 +02:00
|
|
|
|
|
|
|
return hr;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat_layout_SetLineSpacing(IDWriteTextFormat3 *iface,
|
2018-05-21 23:08:06 +02:00
|
|
|
DWRITE_LINE_SPACING_METHOD method, FLOAT height, FLOAT baseline)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2016-07-25 10:42:54 +02:00
|
|
|
DWRITE_LINE_SPACING spacing;
|
2016-02-02 21:14:40 +01:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
TRACE("%p, %d, %.8e, %.8e.\n", iface, method, height, baseline);
|
2016-02-02 21:14:40 +01:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
spacing = layout->format.spacing;
|
2016-07-25 10:42:54 +02:00
|
|
|
spacing.method = method;
|
|
|
|
spacing.height = height;
|
|
|
|
spacing.baseline = baseline;
|
2019-11-29 10:54:26 +01:00
|
|
|
return IDWriteTextLayout4_SetLineSpacing(&layout->IDWriteTextLayout4_iface, &spacing);
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static DWRITE_TEXT_ALIGNMENT WINAPI dwritetextformat_layout_GetTextAlignment(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->format.textalignment;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static DWRITE_PARAGRAPH_ALIGNMENT WINAPI dwritetextformat_layout_GetParagraphAlignment(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->format.paralign;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static DWRITE_WORD_WRAPPING WINAPI dwritetextformat_layout_GetWordWrapping(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->format.wrapping;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static DWRITE_READING_DIRECTION WINAPI dwritetextformat_layout_GetReadingDirection(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->format.readingdir;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static DWRITE_FLOW_DIRECTION WINAPI dwritetextformat_layout_GetFlowDirection(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->format.flow;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static FLOAT WINAPI dwritetextformat_layout_GetIncrementalTabStop(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->format.tabstop;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat_layout_GetTrimming(IDWriteTextFormat3 *iface, DWRITE_TRIMMING *options,
|
2015-03-15 00:38:32 +01:00
|
|
|
IDWriteInlineObject **trimming_sign)
|
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
TRACE("%p, %p, %p.\n", iface, options, trimming_sign);
|
2015-03-15 00:38:32 +01:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
*options = layout->format.trimming;
|
|
|
|
*trimming_sign = layout->format.trimmingsign;
|
2015-03-15 00:38:32 +01:00
|
|
|
if (*trimming_sign)
|
|
|
|
IDWriteInlineObject_AddRef(*trimming_sign);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat_layout_GetLineSpacing(IDWriteTextFormat3 *iface,
|
2018-05-21 23:08:06 +02:00
|
|
|
DWRITE_LINE_SPACING_METHOD *method, FLOAT *spacing, FLOAT *baseline)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
TRACE("%p, %p, %p, %p.\n", iface, method, spacing, baseline);
|
2015-03-15 00:38:32 +01:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
*method = layout->format.spacing.method;
|
|
|
|
*spacing = layout->format.spacing.height;
|
|
|
|
*baseline = layout->format.spacing.baseline;
|
2015-03-15 00:38:32 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat_layout_GetFontCollection(IDWriteTextFormat3 *iface,
|
2018-05-21 23:08:06 +02:00
|
|
|
IDWriteFontCollection **collection)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
TRACE("%p, %p.\n", iface, collection);
|
2015-03-15 00:38:32 +01:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
*collection = layout->format.collection;
|
2015-03-15 00:38:32 +01:00
|
|
|
if (*collection)
|
|
|
|
IDWriteFontCollection_AddRef(*collection);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static UINT32 WINAPI dwritetextformat_layout_GetFontFamilyNameLength(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->format.family_len;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat_layout_GetFontFamilyName(IDWriteTextFormat3 *iface, WCHAR *name, UINT32 size)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
TRACE("%p, %p, %u.\n", iface, name, size);
|
2015-03-15 00:38:32 +01:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
if (size <= layout->format.family_len) return E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
strcpyW(name, layout->format.family_name);
|
2015-03-15 00:38:32 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static DWRITE_FONT_WEIGHT WINAPI dwritetextformat_layout_GetFontWeight(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->format.weight;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static DWRITE_FONT_STYLE WINAPI dwritetextformat_layout_GetFontStyle(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->format.style;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static DWRITE_FONT_STRETCH WINAPI dwritetextformat_layout_GetFontStretch(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->format.stretch;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static FLOAT WINAPI dwritetextformat_layout_GetFontSize(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->format.fontsize;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static UINT32 WINAPI dwritetextformat_layout_GetLocaleNameLength(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->format.locale_len;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat_layout_GetLocaleName(IDWriteTextFormat3 *iface, WCHAR *name, UINT32 size)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
TRACE("%p, %p, %u.\n", iface, name, size);
|
2015-03-15 00:38:32 +01:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
if (size <= layout->format.locale_len) return E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
strcpyW(name, layout->format.locale);
|
2015-03-15 00:38:32 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_SetVerticalGlyphOrientation(IDWriteTextFormat3 *iface,
|
2018-05-21 23:08:06 +02:00
|
|
|
DWRITE_VERTICAL_GLYPH_ORIENTATION orientation)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
FIXME("%p, %d: stub\n", iface, orientation);
|
|
|
|
|
2015-03-15 00:38:32 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static DWRITE_VERTICAL_GLYPH_ORIENTATION WINAPI dwritetextformat1_layout_GetVerticalGlyphOrientation(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
FIXME("%p: stub\n", iface);
|
|
|
|
|
2015-03-15 00:38:32 +01:00
|
|
|
return DWRITE_VERTICAL_GLYPH_ORIENTATION_DEFAULT;
|
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_SetLastLineWrapping(IDWriteTextFormat3 *iface,
|
2018-05-21 23:08:06 +02:00
|
|
|
BOOL lastline_wrapping_enabled)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2015-12-25 13:57:59 +01:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
TRACE("%p, %d.\n", iface, lastline_wrapping_enabled);
|
2015-12-25 13:57:59 +01:00
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
layout->format.last_line_wrapping = !!lastline_wrapping_enabled;
|
2015-12-25 13:57:59 +01:00
|
|
|
return S_OK;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static BOOL WINAPI dwritetextformat1_layout_GetLastLineWrapping(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->format.last_line_wrapping;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_SetOpticalAlignment(IDWriteTextFormat3 *iface,
|
2018-05-21 23:08:06 +02:00
|
|
|
DWRITE_OPTICAL_ALIGNMENT alignment)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %d.\n", iface, alignment);
|
|
|
|
|
|
|
|
return format_set_optical_alignment(&layout->format, alignment);
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static DWRITE_OPTICAL_ALIGNMENT WINAPI dwritetextformat1_layout_GetOpticalAlignment(IDWriteTextFormat3 *iface)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return layout->format.optical_alignment;
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_SetFontFallback(IDWriteTextFormat3 *iface,
|
2018-05-21 23:08:06 +02:00
|
|
|
IDWriteFontFallback *fallback)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2019-11-29 10:54:26 +01:00
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, fallback);
|
|
|
|
|
|
|
|
return IDWriteTextLayout4_SetFontFallback(&layout->IDWriteTextLayout4_iface, fallback);
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_GetFontFallback(IDWriteTextFormat3 *iface,
|
2018-05-21 23:08:06 +02:00
|
|
|
IDWriteFontFallback **fallback)
|
2015-03-15 00:38:32 +01:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2019-11-29 10:54:26 +01:00
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, fallback);
|
|
|
|
|
|
|
|
return IDWriteTextLayout4_GetFontFallback(&layout->IDWriteTextLayout4_iface, fallback);
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat2_layout_SetLineSpacing(IDWriteTextFormat3 *iface,
|
2018-05-21 23:08:06 +02:00
|
|
|
DWRITE_LINE_SPACING const *spacing)
|
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2019-11-29 10:54:26 +01:00
|
|
|
return IDWriteTextLayout4_SetLineSpacing(&layout->IDWriteTextLayout4_iface, spacing);
|
2018-05-21 23:08:06 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat2_layout_GetLineSpacing(IDWriteTextFormat3 *iface, DWRITE_LINE_SPACING *spacing)
|
2018-05-21 23:08:06 +02:00
|
|
|
{
|
2019-11-29 10:54:27 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_layout_from_IDWriteTextFormat3(iface);
|
2019-11-29 10:54:26 +01:00
|
|
|
return IDWriteTextLayout4_GetLineSpacing(&layout->IDWriteTextLayout4_iface, spacing);
|
2018-05-21 23:08:06 +02:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:54:27 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat3_layout_SetFontAxisValues(IDWriteTextFormat3 *iface,
|
|
|
|
DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 num_values)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p, %u.\n", iface, axis_values, num_values);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 WINAPI dwritetextformat3_layout_GetFontAxisValueCount(IDWriteTextFormat3 *iface)
|
|
|
|
{
|
|
|
|
FIXME("%p.\n", iface);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat3_layout_GetFontAxisValues(IDWriteTextFormat3 *iface,
|
|
|
|
DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 num_values)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p, %u.\n", iface, axis_values, num_values);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_AUTOMATIC_FONT_AXES WINAPI dwritetextformat3_layout_GetAutomaticFontAxes(IDWriteTextFormat3 *iface)
|
|
|
|
{
|
|
|
|
FIXME("%p.\n", iface);
|
|
|
|
|
|
|
|
return DWRITE_AUTOMATIC_FONT_AXES_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat3_layout_SetAutomaticFontAxes(IDWriteTextFormat3 *iface,
|
|
|
|
DWRITE_AUTOMATIC_FONT_AXES axes)
|
|
|
|
{
|
|
|
|
FIXME("%p, %d.\n", iface, axes);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteTextFormat3Vtbl dwritetextformat3_layout_vtbl =
|
|
|
|
{
|
2016-02-16 22:19:40 +01:00
|
|
|
dwritetextformat_layout_QueryInterface,
|
|
|
|
dwritetextformat_layout_AddRef,
|
|
|
|
dwritetextformat_layout_Release,
|
|
|
|
dwritetextformat_layout_SetTextAlignment,
|
|
|
|
dwritetextformat_layout_SetParagraphAlignment,
|
|
|
|
dwritetextformat_layout_SetWordWrapping,
|
|
|
|
dwritetextformat_layout_SetReadingDirection,
|
|
|
|
dwritetextformat_layout_SetFlowDirection,
|
|
|
|
dwritetextformat_layout_SetIncrementalTabStop,
|
|
|
|
dwritetextformat_layout_SetTrimming,
|
|
|
|
dwritetextformat_layout_SetLineSpacing,
|
|
|
|
dwritetextformat_layout_GetTextAlignment,
|
|
|
|
dwritetextformat_layout_GetParagraphAlignment,
|
|
|
|
dwritetextformat_layout_GetWordWrapping,
|
|
|
|
dwritetextformat_layout_GetReadingDirection,
|
|
|
|
dwritetextformat_layout_GetFlowDirection,
|
|
|
|
dwritetextformat_layout_GetIncrementalTabStop,
|
|
|
|
dwritetextformat_layout_GetTrimming,
|
|
|
|
dwritetextformat_layout_GetLineSpacing,
|
|
|
|
dwritetextformat_layout_GetFontCollection,
|
|
|
|
dwritetextformat_layout_GetFontFamilyNameLength,
|
|
|
|
dwritetextformat_layout_GetFontFamilyName,
|
|
|
|
dwritetextformat_layout_GetFontWeight,
|
|
|
|
dwritetextformat_layout_GetFontStyle,
|
|
|
|
dwritetextformat_layout_GetFontStretch,
|
|
|
|
dwritetextformat_layout_GetFontSize,
|
|
|
|
dwritetextformat_layout_GetLocaleNameLength,
|
|
|
|
dwritetextformat_layout_GetLocaleName,
|
2015-03-15 00:38:32 +01:00
|
|
|
dwritetextformat1_layout_SetVerticalGlyphOrientation,
|
|
|
|
dwritetextformat1_layout_GetVerticalGlyphOrientation,
|
|
|
|
dwritetextformat1_layout_SetLastLineWrapping,
|
|
|
|
dwritetextformat1_layout_GetLastLineWrapping,
|
|
|
|
dwritetextformat1_layout_SetOpticalAlignment,
|
|
|
|
dwritetextformat1_layout_GetOpticalAlignment,
|
|
|
|
dwritetextformat1_layout_SetFontFallback,
|
2016-02-16 22:19:40 +01:00
|
|
|
dwritetextformat1_layout_GetFontFallback,
|
2018-05-21 23:08:06 +02:00
|
|
|
dwritetextformat2_layout_SetLineSpacing,
|
|
|
|
dwritetextformat2_layout_GetLineSpacing,
|
2019-11-29 10:54:27 +01:00
|
|
|
dwritetextformat3_layout_SetFontAxisValues,
|
|
|
|
dwritetextformat3_layout_GetFontAxisValueCount,
|
|
|
|
dwritetextformat3_layout_GetFontAxisValues,
|
|
|
|
dwritetextformat3_layout_GetAutomaticFontAxes,
|
|
|
|
dwritetextformat3_layout_SetAutomaticFontAxes,
|
2015-03-15 00:38:32 +01:00
|
|
|
};
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_sink_QueryInterface(IDWriteTextAnalysisSink1 *iface,
|
2014-12-23 13:36:32 +01:00
|
|
|
REFIID riid, void **obj)
|
|
|
|
{
|
2016-02-01 12:59:10 +01:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteTextAnalysisSink1) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteTextAnalysisSink) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
2014-12-23 13:36:32 +01:00
|
|
|
*obj = iface;
|
2016-02-01 12:59:10 +01:00
|
|
|
IDWriteTextAnalysisSink1_AddRef(iface);
|
2014-12-23 13:36:32 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2014-12-23 13:36:32 +01:00
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static ULONG WINAPI dwritetextlayout_sink_AddRef(IDWriteTextAnalysisSink1 *iface)
|
2014-12-23 13:36:32 +01:00
|
|
|
{
|
2016-02-01 12:59:11 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextAnalysisSink1(iface);
|
2019-11-29 10:54:26 +01:00
|
|
|
return IDWriteTextLayout4_AddRef(&layout->IDWriteTextLayout4_iface);
|
2014-12-23 13:36:32 +01:00
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static ULONG WINAPI dwritetextlayout_sink_Release(IDWriteTextAnalysisSink1 *iface)
|
2014-12-23 13:36:32 +01:00
|
|
|
{
|
2016-02-01 12:59:11 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextAnalysisSink1(iface);
|
2019-11-29 10:54:26 +01:00
|
|
|
return IDWriteTextLayout4_Release(&layout->IDWriteTextLayout4_iface);
|
2014-12-23 13:36:32 +01:00
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_sink_SetScriptAnalysis(IDWriteTextAnalysisSink1 *iface,
|
2014-12-23 13:36:32 +01:00
|
|
|
UINT32 position, UINT32 length, DWRITE_SCRIPT_ANALYSIS const* sa)
|
|
|
|
{
|
2016-02-01 12:59:10 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextAnalysisSink1(iface);
|
2014-12-23 13:36:32 +01:00
|
|
|
struct layout_run *run;
|
|
|
|
|
2016-02-01 23:41:11 +01:00
|
|
|
TRACE("[%u,%u) script=%u:%s\n", position, position + length, sa->script, debugstr_sa_script(sa->script));
|
2014-12-23 13:36:32 +01:00
|
|
|
|
2017-08-22 11:42:10 +02:00
|
|
|
run = alloc_layout_run(LAYOUT_RUN_REGULAR, position);
|
2014-12-23 13:36:32 +01:00
|
|
|
if (!run)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2015-04-04 13:05:52 +02:00
|
|
|
run->u.regular.descr.string = &layout->str[position];
|
|
|
|
run->u.regular.descr.stringLength = length;
|
|
|
|
run->u.regular.descr.textPosition = position;
|
|
|
|
run->u.regular.sa = *sa;
|
|
|
|
list_add_tail(&layout->runs, &run->entry);
|
2014-12-23 13:36:32 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_sink_SetLineBreakpoints(IDWriteTextAnalysisSink1 *iface,
|
2014-12-23 13:36:32 +01:00
|
|
|
UINT32 position, UINT32 length, DWRITE_LINE_BREAKPOINT const* breakpoints)
|
|
|
|
{
|
2016-02-01 12:59:10 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextAnalysisSink1(iface);
|
2014-12-25 12:03:19 +01:00
|
|
|
|
|
|
|
if (position + length > layout->len)
|
|
|
|
return E_FAIL;
|
|
|
|
|
2014-12-25 22:01:28 +01:00
|
|
|
memcpy(&layout->nominal_breakpoints[position], breakpoints, length*sizeof(DWRITE_LINE_BREAKPOINT));
|
2014-12-25 12:03:19 +01:00
|
|
|
return S_OK;
|
2014-12-23 13:36:32 +01:00
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_sink_SetBidiLevel(IDWriteTextAnalysisSink1 *iface, UINT32 position,
|
2014-12-23 13:36:32 +01:00
|
|
|
UINT32 length, UINT8 explicitLevel, UINT8 resolvedLevel)
|
|
|
|
{
|
2016-02-01 12:59:10 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextAnalysisSink1(iface);
|
2015-04-04 13:05:52 +02:00
|
|
|
struct layout_run *cur_run;
|
2014-12-25 11:34:35 +01:00
|
|
|
|
2016-02-01 23:41:11 +01:00
|
|
|
TRACE("[%u,%u) %u %u\n", position, position + length, explicitLevel, resolvedLevel);
|
2015-05-22 10:27:51 +02:00
|
|
|
|
2015-04-04 13:05:52 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(cur_run, &layout->runs, struct layout_run, entry) {
|
|
|
|
struct regular_layout_run *cur = &cur_run->u.regular;
|
2015-05-22 10:27:51 +02:00
|
|
|
struct layout_run *run;
|
2014-12-25 11:34:35 +01:00
|
|
|
|
2015-04-04 13:05:52 +02:00
|
|
|
if (cur_run->kind == LAYOUT_RUN_INLINE)
|
|
|
|
continue;
|
|
|
|
|
2014-12-25 11:34:35 +01:00
|
|
|
/* FIXME: levels are reported in a natural forward direction, so start loop from a run we ended on */
|
2015-05-22 10:27:51 +02:00
|
|
|
if (position < cur->descr.textPosition || position >= cur->descr.textPosition + cur->descr.stringLength)
|
2014-12-25 11:34:35 +01:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/* full hit - just set run level */
|
|
|
|
if (cur->descr.textPosition == position && cur->descr.stringLength == length) {
|
|
|
|
cur->run.bidiLevel = resolvedLevel;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* current run is fully covered, move to next one */
|
|
|
|
if (cur->descr.textPosition == position && cur->descr.stringLength < length) {
|
|
|
|
cur->run.bidiLevel = resolvedLevel;
|
|
|
|
position += cur->descr.stringLength;
|
|
|
|
length -= cur->descr.stringLength;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-05-22 10:27:51 +02:00
|
|
|
/* all fully covered runs are processed at this point, reuse existing run for remaining
|
|
|
|
reported bidi range and add another run for the rest of original one */
|
|
|
|
|
2017-08-22 11:42:10 +02:00
|
|
|
run = alloc_layout_run(LAYOUT_RUN_REGULAR, position + length);
|
2014-12-25 11:34:35 +01:00
|
|
|
if (!run)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2015-04-04 13:05:52 +02:00
|
|
|
*run = *cur_run;
|
2015-05-22 10:27:51 +02:00
|
|
|
run->u.regular.descr.textPosition = position + length;
|
|
|
|
run->u.regular.descr.stringLength = cur->descr.stringLength - length;
|
|
|
|
run->u.regular.descr.string = &layout->str[position + length];
|
2014-12-25 11:34:35 +01:00
|
|
|
|
2015-05-22 10:27:51 +02:00
|
|
|
/* reduce existing run */
|
|
|
|
cur->run.bidiLevel = resolvedLevel;
|
2015-06-14 23:36:43 +02:00
|
|
|
cur->descr.stringLength = length;
|
2014-12-25 11:34:35 +01:00
|
|
|
|
2015-05-22 10:27:51 +02:00
|
|
|
list_add_after(&cur_run->entry, &run->entry);
|
2014-12-25 11:34:35 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2014-12-23 13:36:32 +01:00
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_sink_SetNumberSubstitution(IDWriteTextAnalysisSink1 *iface,
|
2014-12-23 13:36:32 +01:00
|
|
|
UINT32 position, UINT32 length, IDWriteNumberSubstitution* substitution)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_sink_SetGlyphOrientation(IDWriteTextAnalysisSink1 *iface,
|
|
|
|
UINT32 position, UINT32 length, DWRITE_GLYPH_ORIENTATION_ANGLE angle, UINT8 adjusted_bidi_level,
|
|
|
|
BOOL is_sideways, BOOL is_rtl)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteTextAnalysisSink1Vtbl dwritetextlayoutsinkvtbl = {
|
2014-12-23 13:36:32 +01:00
|
|
|
dwritetextlayout_sink_QueryInterface,
|
|
|
|
dwritetextlayout_sink_AddRef,
|
|
|
|
dwritetextlayout_sink_Release,
|
|
|
|
dwritetextlayout_sink_SetScriptAnalysis,
|
|
|
|
dwritetextlayout_sink_SetLineBreakpoints,
|
|
|
|
dwritetextlayout_sink_SetBidiLevel,
|
2016-02-01 12:59:10 +01:00
|
|
|
dwritetextlayout_sink_SetNumberSubstitution,
|
|
|
|
dwritetextlayout_sink_SetGlyphOrientation
|
2014-12-23 13:36:32 +01:00
|
|
|
};
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_source_QueryInterface(IDWriteTextAnalysisSource1 *iface,
|
2014-12-23 13:36:32 +01:00
|
|
|
REFIID riid, void **obj)
|
|
|
|
{
|
2016-02-01 12:59:10 +01:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteTextAnalysisSource1) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteTextAnalysisSource) ||
|
2014-12-23 13:36:32 +01:00
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
2016-02-01 12:59:10 +01:00
|
|
|
IDWriteTextAnalysisSource1_AddRef(iface);
|
2014-12-23 13:36:32 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2014-12-23 13:36:32 +01:00
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static ULONG WINAPI dwritetextlayout_source_AddRef(IDWriteTextAnalysisSource1 *iface)
|
2014-12-23 13:36:32 +01:00
|
|
|
{
|
2016-02-01 12:59:11 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextAnalysisSource1(iface);
|
2019-11-29 10:54:26 +01:00
|
|
|
return IDWriteTextLayout4_AddRef(&layout->IDWriteTextLayout4_iface);
|
2014-12-23 13:36:32 +01:00
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static ULONG WINAPI dwritetextlayout_source_Release(IDWriteTextAnalysisSource1 *iface)
|
2014-12-23 13:36:32 +01:00
|
|
|
{
|
2016-02-01 12:59:11 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextAnalysisSource1(iface);
|
2019-11-29 10:54:26 +01:00
|
|
|
return IDWriteTextLayout4_Release(&layout->IDWriteTextLayout4_iface);
|
2014-12-23 13:36:32 +01:00
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_source_GetTextAtPosition(IDWriteTextAnalysisSource1 *iface,
|
2014-12-23 13:36:32 +01:00
|
|
|
UINT32 position, WCHAR const** text, UINT32* text_len)
|
|
|
|
{
|
2016-02-01 12:59:10 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextAnalysisSource1(iface);
|
2014-12-23 13:36:32 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p %p)\n", layout, position, text, text_len);
|
|
|
|
|
|
|
|
if (position < layout->len) {
|
|
|
|
*text = &layout->str[position];
|
|
|
|
*text_len = layout->len - position;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*text = NULL;
|
|
|
|
*text_len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_source_GetTextBeforePosition(IDWriteTextAnalysisSource1 *iface,
|
2014-12-23 13:36:32 +01:00
|
|
|
UINT32 position, WCHAR const** text, UINT32* text_len)
|
|
|
|
{
|
2016-02-01 12:59:13 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextAnalysisSource1(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p %p)\n", layout, position, text, text_len);
|
|
|
|
|
|
|
|
if (position > 0 && position < layout->len) {
|
|
|
|
*text = layout->str;
|
|
|
|
*text_len = position;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*text = NULL;
|
|
|
|
*text_len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2014-12-23 13:36:32 +01:00
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static DWRITE_READING_DIRECTION WINAPI dwritetextlayout_source_GetParagraphReadingDirection(IDWriteTextAnalysisSource1 *iface)
|
2014-12-23 13:36:32 +01:00
|
|
|
{
|
2016-02-01 12:59:10 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextAnalysisSource1(iface);
|
2019-11-29 10:54:26 +01:00
|
|
|
return IDWriteTextLayout4_GetReadingDirection(&layout->IDWriteTextLayout4_iface);
|
2014-12-23 13:36:32 +01:00
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_source_GetLocaleName(IDWriteTextAnalysisSource1 *iface,
|
2014-12-23 13:36:32 +01:00
|
|
|
UINT32 position, UINT32* text_len, WCHAR const** locale)
|
|
|
|
{
|
2016-02-01 12:59:12 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextAnalysisSource1(iface);
|
|
|
|
struct layout_range *range = get_layout_range_by_pos(layout, position);
|
|
|
|
|
|
|
|
if (position < layout->len) {
|
|
|
|
struct layout_range *next;
|
|
|
|
|
|
|
|
*locale = range->locale;
|
|
|
|
*text_len = range->h.range.length - position;
|
|
|
|
|
|
|
|
next = LIST_ENTRY(list_next(&layout->ranges, &range->h.entry), struct layout_range, h.entry);
|
|
|
|
while (next && next->h.range.startPosition < layout->len && !strcmpW(range->locale, next->locale)) {
|
|
|
|
*text_len += next->h.range.length;
|
|
|
|
next = LIST_ENTRY(list_next(&layout->ranges, &next->h.entry), struct layout_range, h.entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
*text_len = min(*text_len, layout->len - position);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*locale = NULL;
|
|
|
|
*text_len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2014-12-23 13:36:32 +01:00
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_source_GetNumberSubstitution(IDWriteTextAnalysisSource1 *iface,
|
2014-12-23 13:36:32 +01:00
|
|
|
UINT32 position, UINT32* text_len, IDWriteNumberSubstitution **substitution)
|
|
|
|
{
|
|
|
|
FIXME("%u %p %p: stub\n", position, text_len, substitution);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2016-02-01 12:59:10 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_source_GetVerticalGlyphOrientation(IDWriteTextAnalysisSource1 *iface,
|
|
|
|
UINT32 position, UINT32 *length, DWRITE_VERTICAL_GLYPH_ORIENTATION *orientation, UINT8 *bidi_level)
|
|
|
|
{
|
|
|
|
FIXME("%u %p %p %p: stub\n", position, length, orientation, bidi_level);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteTextAnalysisSource1Vtbl dwritetextlayoutsourcevtbl = {
|
2014-12-23 13:36:32 +01:00
|
|
|
dwritetextlayout_source_QueryInterface,
|
|
|
|
dwritetextlayout_source_AddRef,
|
|
|
|
dwritetextlayout_source_Release,
|
|
|
|
dwritetextlayout_source_GetTextAtPosition,
|
|
|
|
dwritetextlayout_source_GetTextBeforePosition,
|
|
|
|
dwritetextlayout_source_GetParagraphReadingDirection,
|
|
|
|
dwritetextlayout_source_GetLocaleName,
|
2016-02-01 12:59:10 +01:00
|
|
|
dwritetextlayout_source_GetNumberSubstitution,
|
|
|
|
dwritetextlayout_source_GetVerticalGlyphOrientation
|
2014-12-23 13:36:32 +01:00
|
|
|
};
|
|
|
|
|
2014-12-26 12:14:20 +01:00
|
|
|
static HRESULT layout_format_from_textformat(struct dwrite_textlayout *layout, IDWriteTextFormat *format)
|
2012-11-26 17:01:58 +01:00
|
|
|
{
|
2015-12-25 13:57:58 +01:00
|
|
|
struct dwrite_textformat *textformat;
|
2015-03-13 09:58:32 +01:00
|
|
|
IDWriteTextFormat1 *format1;
|
2014-12-26 12:14:20 +01:00
|
|
|
UINT32 len;
|
|
|
|
HRESULT hr;
|
2012-11-26 17:01:58 +01:00
|
|
|
|
2015-12-25 13:57:58 +01:00
|
|
|
if ((textformat = unsafe_impl_from_IDWriteTextFormat(format))) {
|
|
|
|
layout->format = textformat->format;
|
|
|
|
|
|
|
|
layout->format.locale = heap_strdupW(textformat->format.locale);
|
|
|
|
layout->format.family_name = heap_strdupW(textformat->format.family_name);
|
|
|
|
if (!layout->format.locale || !layout->format.family_name)
|
2016-01-08 10:55:37 +01:00
|
|
|
{
|
|
|
|
heap_free(layout->format.locale);
|
|
|
|
heap_free(layout->format.family_name);
|
2015-12-25 13:57:58 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2016-01-08 10:55:37 +01:00
|
|
|
}
|
2015-12-25 13:57:58 +01:00
|
|
|
|
|
|
|
if (layout->format.trimmingsign)
|
|
|
|
IDWriteInlineObject_AddRef(layout->format.trimmingsign);
|
|
|
|
if (layout->format.collection)
|
|
|
|
IDWriteFontCollection_AddRef(layout->format.collection);
|
|
|
|
if (layout->format.fallback)
|
|
|
|
IDWriteFontFallback_AddRef(layout->format.fallback);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-12-26 12:14:20 +01:00
|
|
|
layout->format.weight = IDWriteTextFormat_GetFontWeight(format);
|
|
|
|
layout->format.style = IDWriteTextFormat_GetFontStyle(format);
|
|
|
|
layout->format.stretch = IDWriteTextFormat_GetFontStretch(format);
|
|
|
|
layout->format.fontsize= IDWriteTextFormat_GetFontSize(format);
|
2018-11-05 13:01:07 +01:00
|
|
|
layout->format.tabstop = IDWriteTextFormat_GetIncrementalTabStop(format);
|
2014-12-26 12:14:20 +01:00
|
|
|
layout->format.textalignment = IDWriteTextFormat_GetTextAlignment(format);
|
|
|
|
layout->format.paralign = IDWriteTextFormat_GetParagraphAlignment(format);
|
|
|
|
layout->format.wrapping = IDWriteTextFormat_GetWordWrapping(format);
|
|
|
|
layout->format.readingdir = IDWriteTextFormat_GetReadingDirection(format);
|
|
|
|
layout->format.flow = IDWriteTextFormat_GetFlowDirection(format);
|
2015-03-14 22:43:20 +01:00
|
|
|
layout->format.fallback = NULL;
|
2016-07-25 10:42:54 +02:00
|
|
|
layout->format.spacing.leadingBefore = 0.0f;
|
|
|
|
layout->format.spacing.fontLineGapUsage = DWRITE_FONT_LINE_GAP_USAGE_DEFAULT;
|
|
|
|
hr = IDWriteTextFormat_GetLineSpacing(format, &layout->format.spacing.method,
|
|
|
|
&layout->format.spacing.height, &layout->format.spacing.baseline);
|
2014-12-26 12:14:20 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2012-11-26 17:01:58 +01:00
|
|
|
|
2014-12-26 12:14:20 +01:00
|
|
|
hr = IDWriteTextFormat_GetTrimming(format, &layout->format.trimming, &layout->format.trimmingsign);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
/* locale name and length */
|
|
|
|
len = IDWriteTextFormat_GetLocaleNameLength(format);
|
|
|
|
layout->format.locale = heap_alloc((len+1)*sizeof(WCHAR));
|
|
|
|
if (!layout->format.locale)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hr = IDWriteTextFormat_GetLocaleName(format, layout->format.locale, len+1);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
layout->format.locale_len = len;
|
2012-11-26 17:01:58 +01:00
|
|
|
|
2014-12-26 12:14:20 +01:00
|
|
|
/* font family name and length */
|
|
|
|
len = IDWriteTextFormat_GetFontFamilyNameLength(format);
|
|
|
|
layout->format.family_name = heap_alloc((len+1)*sizeof(WCHAR));
|
|
|
|
if (!layout->format.family_name)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hr = IDWriteTextFormat_GetFontFamilyName(format, layout->format.family_name, len+1);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
layout->format.family_len = len;
|
|
|
|
|
2015-03-13 09:58:32 +01:00
|
|
|
hr = IDWriteTextFormat_QueryInterface(format, &IID_IDWriteTextFormat1, (void**)&format1);
|
|
|
|
if (hr == S_OK) {
|
2016-07-25 10:42:54 +02:00
|
|
|
IDWriteTextFormat2 *format2;
|
|
|
|
|
2015-03-13 09:58:32 +01:00
|
|
|
layout->format.vertical_orientation = IDWriteTextFormat1_GetVerticalGlyphOrientation(format1);
|
2015-12-25 13:58:00 +01:00
|
|
|
layout->format.optical_alignment = IDWriteTextFormat1_GetOpticalAlignment(format1);
|
2015-03-14 22:43:20 +01:00
|
|
|
IDWriteTextFormat1_GetFontFallback(format1, &layout->format.fallback);
|
2016-07-25 10:42:54 +02:00
|
|
|
|
|
|
|
if (IDWriteTextFormat1_QueryInterface(format1, &IID_IDWriteTextFormat2, (void**)&format2) == S_OK) {
|
|
|
|
IDWriteTextFormat2_GetLineSpacing(format2, &layout->format.spacing);
|
|
|
|
IDWriteTextFormat2_Release(format2);
|
|
|
|
}
|
|
|
|
|
2015-03-13 09:58:32 +01:00
|
|
|
IDWriteTextFormat1_Release(format1);
|
|
|
|
}
|
2015-12-25 13:58:00 +01:00
|
|
|
else {
|
2015-03-13 09:58:32 +01:00
|
|
|
layout->format.vertical_orientation = DWRITE_VERTICAL_GLYPH_ORIENTATION_DEFAULT;
|
2015-12-25 13:58:00 +01:00
|
|
|
layout->format.optical_alignment = DWRITE_OPTICAL_ALIGNMENT_NONE;
|
|
|
|
}
|
2015-03-13 09:58:32 +01:00
|
|
|
|
2014-12-26 12:14:20 +01:00
|
|
|
return IDWriteTextFormat_GetFontCollection(format, &layout->format.collection);
|
2012-11-26 17:01:58 +01:00
|
|
|
}
|
|
|
|
|
2016-04-27 10:19:41 +02:00
|
|
|
static HRESULT init_textlayout(const struct textlayout_desc *desc, struct dwrite_textlayout *layout)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2016-01-12 21:12:06 +01:00
|
|
|
struct layout_range_header *range, *strike, *underline, *effect, *spacing, *typography;
|
2015-12-25 13:57:57 +01:00
|
|
|
static const DWRITE_TEXT_RANGE r = { 0, ~0u };
|
2014-12-26 12:14:20 +01:00
|
|
|
HRESULT hr;
|
2012-09-28 10:13:17 +02:00
|
|
|
|
2019-11-29 10:54:26 +01:00
|
|
|
layout->IDWriteTextLayout4_iface.lpVtbl = &dwritetextlayoutvtbl;
|
2019-11-29 10:54:27 +01:00
|
|
|
layout->IDWriteTextFormat3_iface.lpVtbl = &dwritetextformat3_layout_vtbl;
|
2016-02-01 12:59:10 +01:00
|
|
|
layout->IDWriteTextAnalysisSink1_iface.lpVtbl = &dwritetextlayoutsinkvtbl;
|
|
|
|
layout->IDWriteTextAnalysisSource1_iface.lpVtbl = &dwritetextlayoutsourcevtbl;
|
2019-11-29 10:54:26 +01:00
|
|
|
layout->refcount = 1;
|
2016-04-27 10:19:41 +02:00
|
|
|
layout->len = desc->length;
|
2015-03-30 09:15:48 +02:00
|
|
|
layout->recompute = RECOMPUTE_EVERYTHING;
|
2014-12-26 12:14:20 +01:00
|
|
|
layout->nominal_breakpoints = NULL;
|
|
|
|
layout->actual_breakpoints = NULL;
|
2015-05-05 14:23:17 +02:00
|
|
|
layout->cluster_count = 0;
|
2015-04-23 12:02:43 +02:00
|
|
|
layout->clustermetrics = NULL;
|
2015-01-11 22:03:31 +01:00
|
|
|
layout->clusters = NULL;
|
2015-05-05 14:23:17 +02:00
|
|
|
layout->lines = NULL;
|
2019-05-14 12:27:28 +02:00
|
|
|
layout->lines_size = 0;
|
2016-01-11 14:15:53 +01:00
|
|
|
layout->minwidth = 0.0f;
|
2015-05-05 14:23:17 +02:00
|
|
|
list_init(&layout->eruns);
|
2015-05-30 17:44:54 +02:00
|
|
|
list_init(&layout->inlineobjects);
|
2016-01-14 22:24:23 +01:00
|
|
|
list_init(&layout->underlines);
|
2015-06-04 22:32:30 +02:00
|
|
|
list_init(&layout->strikethrough);
|
2014-12-26 12:14:20 +01:00
|
|
|
list_init(&layout->runs);
|
|
|
|
list_init(&layout->ranges);
|
2015-06-04 16:55:26 +02:00
|
|
|
list_init(&layout->strike_ranges);
|
2016-01-12 21:12:06 +01:00
|
|
|
list_init(&layout->underline_ranges);
|
2015-06-15 00:15:25 +02:00
|
|
|
list_init(&layout->effects);
|
2015-06-18 18:52:15 +02:00
|
|
|
list_init(&layout->spacing);
|
2015-12-25 13:57:57 +01:00
|
|
|
list_init(&layout->typographies);
|
2014-12-26 12:14:20 +01:00
|
|
|
memset(&layout->format, 0, sizeof(layout->format));
|
2015-07-01 19:43:30 +02:00
|
|
|
memset(&layout->metrics, 0, sizeof(layout->metrics));
|
2016-04-27 10:19:41 +02:00
|
|
|
layout->metrics.layoutWidth = desc->max_width;
|
|
|
|
layout->metrics.layoutHeight = desc->max_height;
|
2015-07-16 12:10:54 +02:00
|
|
|
layout->measuringmode = DWRITE_MEASURING_MODE_NATURAL;
|
2014-12-26 12:14:20 +01:00
|
|
|
|
2016-01-11 14:15:53 +01:00
|
|
|
layout->ppdip = 0.0f;
|
2015-01-08 22:35:14 +01:00
|
|
|
memset(&layout->transform, 0, sizeof(layout->transform));
|
|
|
|
|
2016-04-27 10:19:41 +02:00
|
|
|
layout->str = heap_strdupnW(desc->string, desc->length);
|
|
|
|
if (desc->length && !layout->str) {
|
2014-12-26 12:14:20 +01:00
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto fail;
|
2014-08-13 21:15:46 +02:00
|
|
|
}
|
|
|
|
|
2016-04-27 10:19:41 +02:00
|
|
|
hr = layout_format_from_textformat(layout, desc->format);
|
2014-12-26 12:14:20 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto fail;
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
range = alloc_layout_range(layout, &r, LAYOUT_RANGE_REGULAR);
|
|
|
|
strike = alloc_layout_range(layout, &r, LAYOUT_RANGE_STRIKETHROUGH);
|
2016-01-12 21:12:06 +01:00
|
|
|
underline = alloc_layout_range(layout, &r, LAYOUT_RANGE_UNDERLINE);
|
2015-06-15 00:15:25 +02:00
|
|
|
effect = alloc_layout_range(layout, &r, LAYOUT_RANGE_EFFECT);
|
2015-06-18 18:52:15 +02:00
|
|
|
spacing = alloc_layout_range(layout, &r, LAYOUT_RANGE_SPACING);
|
2015-12-25 13:57:57 +01:00
|
|
|
typography = alloc_layout_range(layout, &r, LAYOUT_RANGE_TYPOGRAPHY);
|
2016-01-12 21:12:06 +01:00
|
|
|
if (!range || !strike || !effect || !spacing || !typography || !underline) {
|
2015-06-04 16:55:26 +02:00
|
|
|
free_layout_range(range);
|
|
|
|
free_layout_range(strike);
|
2016-01-12 21:12:06 +01:00
|
|
|
free_layout_range(underline);
|
2015-06-15 00:15:25 +02:00
|
|
|
free_layout_range(effect);
|
2015-06-18 18:52:15 +02:00
|
|
|
free_layout_range(spacing);
|
2016-01-11 14:15:55 +01:00
|
|
|
free_layout_range(typography);
|
2015-01-11 22:03:31 +01:00
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto fail;
|
|
|
|
}
|
2012-09-28 10:13:17 +02:00
|
|
|
|
2016-04-27 10:19:41 +02:00
|
|
|
if (desc->is_gdi_compatible)
|
|
|
|
layout->measuringmode = desc->use_gdi_natural ? DWRITE_MEASURING_MODE_GDI_NATURAL : DWRITE_MEASURING_MODE_GDI_CLASSIC;
|
|
|
|
else
|
|
|
|
layout->measuringmode = DWRITE_MEASURING_MODE_NATURAL;
|
|
|
|
layout->ppdip = desc->ppdip;
|
|
|
|
layout->transform = desc->transform ? *desc->transform : identity;
|
|
|
|
|
|
|
|
layout->factory = desc->factory;
|
2017-05-07 21:38:15 +02:00
|
|
|
IDWriteFactory5_AddRef(layout->factory);
|
2015-06-04 16:55:26 +02:00
|
|
|
list_add_head(&layout->ranges, &range->entry);
|
|
|
|
list_add_head(&layout->strike_ranges, &strike->entry);
|
2016-01-12 21:12:06 +01:00
|
|
|
list_add_head(&layout->underline_ranges, &underline->entry);
|
2015-06-15 00:15:25 +02:00
|
|
|
list_add_head(&layout->effects, &effect->entry);
|
2015-06-18 18:52:15 +02:00
|
|
|
list_add_head(&layout->spacing, &spacing->entry);
|
2015-12-25 13:57:57 +01:00
|
|
|
list_add_head(&layout->typographies, &typography->entry);
|
2012-09-28 10:13:17 +02:00
|
|
|
return S_OK;
|
2014-12-26 12:14:20 +01:00
|
|
|
|
|
|
|
fail:
|
2019-11-29 10:54:26 +01:00
|
|
|
IDWriteTextLayout4_Release(&layout->IDWriteTextLayout4_iface);
|
2014-12-26 12:14:20 +01:00
|
|
|
return hr;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
2012-10-10 20:58:20 +02:00
|
|
|
|
2016-04-27 10:19:41 +02:00
|
|
|
HRESULT create_textlayout(const struct textlayout_desc *desc, IDWriteTextLayout **ret)
|
2015-01-08 22:35:14 +01:00
|
|
|
{
|
|
|
|
struct dwrite_textlayout *layout;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
|
2016-04-27 10:19:41 +02:00
|
|
|
if (!desc->format || !desc->string)
|
2016-01-28 02:17:15 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2015-01-08 22:35:14 +01:00
|
|
|
layout = heap_alloc(sizeof(struct dwrite_textlayout));
|
|
|
|
if (!layout) return E_OUTOFMEMORY;
|
|
|
|
|
2016-04-27 10:19:41 +02:00
|
|
|
hr = init_textlayout(desc, layout);
|
2015-01-08 22:35:14 +01:00
|
|
|
if (hr == S_OK)
|
2019-11-29 10:54:26 +01:00
|
|
|
*ret = (IDWriteTextLayout *)&layout->IDWriteTextLayout4_iface;
|
2015-01-08 22:35:14 +01:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2014-04-08 05:42:24 +02:00
|
|
|
static HRESULT WINAPI dwritetrimmingsign_QueryInterface(IDWriteInlineObject *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteInlineObject)) {
|
|
|
|
*obj = iface;
|
|
|
|
IDWriteInlineObject_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2014-04-08 05:42:24 +02:00
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritetrimmingsign_AddRef(IDWriteInlineObject *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritetrimmingsign_Release(IDWriteInlineObject *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
|
2015-06-15 00:13:00 +02:00
|
|
|
if (!ref) {
|
|
|
|
IDWriteTextLayout_Release(This->layout);
|
2014-04-08 05:42:24 +02:00
|
|
|
heap_free(This);
|
2015-06-15 00:13:00 +02:00
|
|
|
}
|
2014-04-08 05:42:24 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetrimmingsign_Draw(IDWriteInlineObject *iface, void *context, IDWriteTextRenderer *renderer,
|
2015-06-15 00:13:00 +02:00
|
|
|
FLOAT originX, FLOAT originY, BOOL is_sideways, BOOL is_rtl, IUnknown *effect)
|
2014-04-08 05:42:24 +02:00
|
|
|
{
|
|
|
|
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
|
2017-01-26 05:41:50 +01:00
|
|
|
DWRITE_LINE_METRICS line;
|
|
|
|
UINT32 line_count;
|
2015-06-15 00:13:00 +02:00
|
|
|
|
2017-08-25 07:29:45 +02:00
|
|
|
TRACE("(%p)->(%p %p %.2f %.2f %d %d %p)\n", This, context, renderer, originX, originY,
|
|
|
|
is_sideways, is_rtl, effect);
|
2015-06-15 00:13:00 +02:00
|
|
|
|
2017-01-26 05:41:50 +01:00
|
|
|
IDWriteTextLayout_GetLineMetrics(This->layout, &line, 1, &line_count);
|
2017-08-24 13:25:06 +02:00
|
|
|
return IDWriteTextLayout_Draw(This->layout, context, renderer, originX, originY - line.baseline);
|
2014-04-08 05:42:24 +02:00
|
|
|
}
|
|
|
|
|
2015-07-12 22:36:15 +02:00
|
|
|
static HRESULT WINAPI dwritetrimmingsign_GetMetrics(IDWriteInlineObject *iface, DWRITE_INLINE_OBJECT_METRICS *ret)
|
2014-04-08 05:42:24 +02:00
|
|
|
{
|
|
|
|
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
|
2015-07-12 22:36:15 +02:00
|
|
|
DWRITE_TEXT_METRICS metrics;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, ret);
|
|
|
|
|
|
|
|
hr = IDWriteTextLayout_GetMetrics(This->layout, &metrics);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
memset(ret, 0, sizeof(*ret));
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->width = metrics.width;
|
2016-01-11 14:15:53 +01:00
|
|
|
ret->height = 0.0f;
|
|
|
|
ret->baseline = 0.0f;
|
2015-07-12 22:36:15 +02:00
|
|
|
ret->supportsSideways = FALSE;
|
2015-04-04 13:05:52 +02:00
|
|
|
return S_OK;
|
2014-04-08 05:42:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetrimmingsign_GetOverhangMetrics(IDWriteInlineObject *iface, DWRITE_OVERHANG_METRICS *overhangs)
|
|
|
|
{
|
|
|
|
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
|
2016-07-19 22:02:59 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, overhangs);
|
|
|
|
return IDWriteTextLayout_GetOverhangMetrics(This->layout, overhangs);
|
2014-04-08 05:42:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetrimmingsign_GetBreakConditions(IDWriteInlineObject *iface, DWRITE_BREAK_CONDITION *before,
|
|
|
|
DWRITE_BREAK_CONDITION *after)
|
|
|
|
{
|
|
|
|
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, before, after);
|
|
|
|
|
|
|
|
*before = *after = DWRITE_BREAK_CONDITION_NEUTRAL;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteInlineObjectVtbl dwritetrimmingsignvtbl = {
|
|
|
|
dwritetrimmingsign_QueryInterface,
|
|
|
|
dwritetrimmingsign_AddRef,
|
|
|
|
dwritetrimmingsign_Release,
|
|
|
|
dwritetrimmingsign_Draw,
|
|
|
|
dwritetrimmingsign_GetMetrics,
|
|
|
|
dwritetrimmingsign_GetOverhangMetrics,
|
|
|
|
dwritetrimmingsign_GetBreakConditions
|
|
|
|
};
|
|
|
|
|
2015-06-14 23:39:32 +02:00
|
|
|
static inline BOOL is_reading_direction_horz(DWRITE_READING_DIRECTION direction)
|
|
|
|
{
|
|
|
|
return (direction == DWRITE_READING_DIRECTION_LEFT_TO_RIGHT) ||
|
|
|
|
(direction == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline BOOL is_reading_direction_vert(DWRITE_READING_DIRECTION direction)
|
|
|
|
{
|
|
|
|
return (direction == DWRITE_READING_DIRECTION_TOP_TO_BOTTOM) ||
|
|
|
|
(direction == DWRITE_READING_DIRECTION_BOTTOM_TO_TOP);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline BOOL is_flow_direction_horz(DWRITE_FLOW_DIRECTION direction)
|
|
|
|
{
|
|
|
|
return (direction == DWRITE_FLOW_DIRECTION_LEFT_TO_RIGHT) ||
|
|
|
|
(direction == DWRITE_FLOW_DIRECTION_RIGHT_TO_LEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline BOOL is_flow_direction_vert(DWRITE_FLOW_DIRECTION direction)
|
|
|
|
{
|
|
|
|
return (direction == DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM) ||
|
|
|
|
(direction == DWRITE_FLOW_DIRECTION_BOTTOM_TO_TOP);
|
|
|
|
}
|
|
|
|
|
2017-05-07 21:38:15 +02:00
|
|
|
HRESULT create_trimmingsign(IDWriteFactory5 *factory, IDWriteTextFormat *format, IDWriteInlineObject **sign)
|
2014-04-08 05:42:24 +02:00
|
|
|
{
|
2015-06-15 00:13:00 +02:00
|
|
|
static const WCHAR ellipsisW = 0x2026;
|
2014-04-08 05:42:24 +02:00
|
|
|
struct dwrite_trimmingsign *This;
|
2015-06-14 23:39:32 +02:00
|
|
|
DWRITE_READING_DIRECTION reading;
|
|
|
|
DWRITE_FLOW_DIRECTION flow;
|
2015-06-15 00:13:00 +02:00
|
|
|
HRESULT hr;
|
2014-04-08 05:42:24 +02:00
|
|
|
|
|
|
|
*sign = NULL;
|
|
|
|
|
2015-06-14 23:39:32 +02:00
|
|
|
/* Validate reading/flow direction here, layout creation won't complain about
|
|
|
|
invalid combinations. */
|
|
|
|
reading = IDWriteTextFormat_GetReadingDirection(format);
|
|
|
|
flow = IDWriteTextFormat_GetFlowDirection(format);
|
|
|
|
|
|
|
|
if ((is_reading_direction_horz(reading) && is_flow_direction_horz(flow)) ||
|
|
|
|
(is_reading_direction_vert(reading) && is_flow_direction_vert(flow)))
|
|
|
|
return DWRITE_E_FLOWDIRECTIONCONFLICTS;
|
|
|
|
|
2015-06-15 00:13:00 +02:00
|
|
|
This = heap_alloc(sizeof(*This));
|
|
|
|
if (!This)
|
|
|
|
return E_OUTOFMEMORY;
|
2014-04-08 05:42:24 +02:00
|
|
|
|
|
|
|
This->IDWriteInlineObject_iface.lpVtbl = &dwritetrimmingsignvtbl;
|
|
|
|
This->ref = 1;
|
|
|
|
|
2017-05-07 21:38:15 +02:00
|
|
|
hr = IDWriteFactory5_CreateTextLayout(factory, &ellipsisW, 1, format, 0.0f, 0.0f, &This->layout);
|
2015-06-15 00:13:00 +02:00
|
|
|
if (FAILED(hr)) {
|
|
|
|
heap_free(This);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteTextLayout_SetWordWrapping(This->layout, DWRITE_WORD_WRAPPING_NO_WRAP);
|
2017-01-26 05:41:50 +01:00
|
|
|
IDWriteTextLayout_SetParagraphAlignment(This->layout, DWRITE_PARAGRAPH_ALIGNMENT_NEAR);
|
2017-08-24 13:25:07 +02:00
|
|
|
IDWriteTextLayout_SetTextAlignment(This->layout, DWRITE_TEXT_ALIGNMENT_LEADING);
|
|
|
|
|
2014-04-08 05:42:24 +02:00
|
|
|
*sign = &This->IDWriteInlineObject_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_QueryInterface(IDWriteTextFormat3 *iface, REFIID riid, void **obj)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-05-13 13:21:46 +02:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
|
2012-10-10 20:58:20 +02:00
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteTextFormat3) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteTextFormat2) ||
|
2016-02-16 22:19:40 +01:00
|
|
|
IsEqualIID(riid, &IID_IDWriteTextFormat1) ||
|
2014-10-10 11:57:28 +02:00
|
|
|
IsEqualIID(riid, &IID_IDWriteTextFormat) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
|
|
|
*obj = iface;
|
2019-10-08 12:04:33 +02:00
|
|
|
IDWriteTextFormat3_AddRef(iface);
|
2012-10-10 20:58:20 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2012-10-10 20:58:20 +02:00
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static ULONG WINAPI dwritetextformat_AddRef(IDWriteTextFormat3 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&format->refcount);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p, refcount %d.\n", iface, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static ULONG WINAPI dwritetextformat_Release(IDWriteTextFormat3 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&format->refcount);
|
2012-10-10 20:58:20 +02:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
TRACE("%p, refcount %d.\n", iface, refcount);
|
2012-10-10 20:58:20 +02:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
if (!refcount)
|
2012-10-12 15:12:57 +02:00
|
|
|
{
|
2019-05-13 13:21:46 +02:00
|
|
|
release_format_data(&format->format);
|
|
|
|
heap_free(format);
|
2012-10-12 15:12:57 +02:00
|
|
|
}
|
2012-10-10 20:58:20 +02:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
return refcount;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_SetTextAlignment(IDWriteTextFormat3 *iface, DWRITE_TEXT_ALIGNMENT alignment)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p, %d.\n", iface, alignment);
|
|
|
|
|
|
|
|
return format_set_textalignment(&format->format, alignment, NULL);
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_SetParagraphAlignment(IDWriteTextFormat3 *iface,
|
2019-05-13 13:21:46 +02:00
|
|
|
DWRITE_PARAGRAPH_ALIGNMENT alignment)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p, %d.\n", iface, alignment);
|
|
|
|
|
|
|
|
return format_set_paralignment(&format->format, alignment, NULL);
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_SetWordWrapping(IDWriteTextFormat3 *iface, DWRITE_WORD_WRAPPING wrapping)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p, %d.\n", iface, wrapping);
|
|
|
|
|
|
|
|
return format_set_wordwrapping(&format->format, wrapping, NULL);
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_SetReadingDirection(IDWriteTextFormat3 *iface, DWRITE_READING_DIRECTION direction)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p, %d.\n", iface, direction);
|
|
|
|
|
|
|
|
return format_set_readingdirection(&format->format, direction, NULL);
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_SetFlowDirection(IDWriteTextFormat3 *iface, DWRITE_FLOW_DIRECTION direction)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p, %d.\n", iface, direction);
|
|
|
|
|
|
|
|
return format_set_flowdirection(&format->format, direction, NULL);
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_SetIncrementalTabStop(IDWriteTextFormat3 *iface, FLOAT tabstop)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2018-11-05 13:01:07 +01:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
TRACE("%p, %f.\n", iface, tabstop);
|
2018-11-05 13:01:07 +01:00
|
|
|
|
|
|
|
if (tabstop <= 0.0f)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
format->format.tabstop = tabstop;
|
2017-11-23 18:31:02 +01:00
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_SetTrimming(IDWriteTextFormat3 *iface, DWRITE_TRIMMING const *trimming,
|
2012-10-10 20:58:20 +02:00
|
|
|
IDWriteInlineObject *trimming_sign)
|
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p, %p, %p.\n", iface, trimming, trimming_sign);
|
|
|
|
|
|
|
|
return format_set_trimming(&format->format, trimming, trimming_sign, NULL);
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_SetLineSpacing(IDWriteTextFormat3 *iface, DWRITE_LINE_SPACING_METHOD method,
|
2016-07-25 10:42:54 +02:00
|
|
|
FLOAT height, FLOAT baseline)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2016-07-25 10:42:54 +02:00
|
|
|
DWRITE_LINE_SPACING spacing;
|
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
TRACE("%p, %d, %f, %f.\n", iface, method, height, baseline);
|
2016-07-25 10:42:54 +02:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
spacing = format->format.spacing;
|
2016-07-25 10:42:54 +02:00
|
|
|
spacing.method = method;
|
|
|
|
spacing.height = height;
|
|
|
|
spacing.baseline = baseline;
|
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
return format_set_linespacing(&format->format, &spacing, NULL);
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static DWRITE_TEXT_ALIGNMENT WINAPI dwritetextformat_GetTextAlignment(IDWriteTextFormat3 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return format->format.textalignment;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static DWRITE_PARAGRAPH_ALIGNMENT WINAPI dwritetextformat_GetParagraphAlignment(IDWriteTextFormat3 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return format->format.paralign;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static DWRITE_WORD_WRAPPING WINAPI dwritetextformat_GetWordWrapping(IDWriteTextFormat3 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return format->format.wrapping;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static DWRITE_READING_DIRECTION WINAPI dwritetextformat_GetReadingDirection(IDWriteTextFormat3 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return format->format.readingdir;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static DWRITE_FLOW_DIRECTION WINAPI dwritetextformat_GetFlowDirection(IDWriteTextFormat3 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return format->format.flow;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static FLOAT WINAPI dwritetextformat_GetIncrementalTabStop(IDWriteTextFormat3 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return format->format.tabstop;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_GetTrimming(IDWriteTextFormat3 *iface, DWRITE_TRIMMING *options,
|
2012-10-10 20:58:20 +02:00
|
|
|
IDWriteInlineObject **trimming_sign)
|
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2014-04-08 05:42:06 +02:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
TRACE("%p, %p, %p.\n", iface, options, trimming_sign);
|
|
|
|
|
|
|
|
*options = format->format.trimming;
|
|
|
|
if ((*trimming_sign = format->format.trimmingsign))
|
2014-04-08 05:42:06 +02:00
|
|
|
IDWriteInlineObject_AddRef(*trimming_sign);
|
|
|
|
|
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_GetLineSpacing(IDWriteTextFormat3 *iface, DWRITE_LINE_SPACING_METHOD *method,
|
2012-10-10 20:58:20 +02:00
|
|
|
FLOAT *spacing, FLOAT *baseline)
|
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2014-04-07 07:18:30 +02:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
TRACE("%p, %p, %p, %p.\n", iface, method, spacing, baseline);
|
|
|
|
|
|
|
|
*method = format->format.spacing.method;
|
|
|
|
*spacing = format->format.spacing.height;
|
|
|
|
*baseline = format->format.spacing.baseline;
|
2014-04-07 07:18:30 +02:00
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_GetFontCollection(IDWriteTextFormat3 *iface, IDWriteFontCollection **collection)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2012-10-22 05:49:27 +02:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
TRACE("%p, %p.\n", iface, collection);
|
2012-10-22 05:49:27 +02:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
*collection = format->format.collection;
|
2012-10-22 05:49:27 +02:00
|
|
|
IDWriteFontCollection_AddRef(*collection);
|
|
|
|
|
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static UINT32 WINAPI dwritetextformat_GetFontFamilyNameLength(IDWriteTextFormat3 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return format->format.family_len;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_GetFontFamilyName(IDWriteTextFormat3 *iface, WCHAR *name, UINT32 size)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2012-11-26 16:43:49 +01:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
TRACE("%p, %p, %u.\n", iface, name, size);
|
2012-11-26 16:43:49 +01:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
if (size <= format->format.family_len)
|
|
|
|
return E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
strcpyW(name, format->format.family_name);
|
2012-11-26 16:43:49 +01:00
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static DWRITE_FONT_WEIGHT WINAPI dwritetextformat_GetFontWeight(IDWriteTextFormat3 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return format->format.weight;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static DWRITE_FONT_STYLE WINAPI dwritetextformat_GetFontStyle(IDWriteTextFormat3 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return format->format.style;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static DWRITE_FONT_STRETCH WINAPI dwritetextformat_GetFontStretch(IDWriteTextFormat3 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return format->format.stretch;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static FLOAT WINAPI dwritetextformat_GetFontSize(IDWriteTextFormat3 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return format->format.fontsize;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static UINT32 WINAPI dwritetextformat_GetLocaleNameLength(IDWriteTextFormat3 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return format->format.locale_len;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_GetLocaleName(IDWriteTextFormat3 *iface, WCHAR *name, UINT32 size)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2012-10-26 18:50:12 +02:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
TRACE("%p, %p %u.\n", iface, name, size);
|
2012-10-26 18:50:12 +02:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
if (size <= format->format.locale_len)
|
|
|
|
return E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
strcpyW(name, format->format.locale);
|
2012-10-26 18:50:12 +02:00
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat1_SetVerticalGlyphOrientation(IDWriteTextFormat3 *iface,
|
|
|
|
DWRITE_VERTICAL_GLYPH_ORIENTATION orientation)
|
2014-10-10 11:57:28 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2015-03-13 09:58:32 +01:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
TRACE("%p, %d.\n", iface, orientation);
|
2015-03-13 09:58:32 +01:00
|
|
|
|
|
|
|
if ((UINT32)orientation > DWRITE_VERTICAL_GLYPH_ORIENTATION_STACKED)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
format->format.vertical_orientation = orientation;
|
2015-03-13 09:58:32 +01:00
|
|
|
return S_OK;
|
2014-10-10 11:57:28 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static DWRITE_VERTICAL_GLYPH_ORIENTATION WINAPI dwritetextformat1_GetVerticalGlyphOrientation(IDWriteTextFormat3 *iface)
|
2014-10-10 11:57:28 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return format->format.vertical_orientation;
|
2014-10-10 11:57:28 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat1_SetLastLineWrapping(IDWriteTextFormat3 *iface, BOOL lastline_wrapping_enabled)
|
2014-10-10 11:57:28 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2015-12-25 13:57:59 +01:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
TRACE("%p, %d.\n", iface, lastline_wrapping_enabled);
|
2015-12-25 13:57:59 +01:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
format->format.last_line_wrapping = !!lastline_wrapping_enabled;
|
2015-12-25 13:57:59 +01:00
|
|
|
return S_OK;
|
2014-10-10 11:57:28 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static BOOL WINAPI dwritetextformat1_GetLastLineWrapping(IDWriteTextFormat3 *iface)
|
2014-10-10 11:57:28 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return format->format.last_line_wrapping;
|
2014-10-10 11:57:28 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat1_SetOpticalAlignment(IDWriteTextFormat3 *iface, DWRITE_OPTICAL_ALIGNMENT alignment)
|
2014-10-10 11:57:28 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p, %d.\n", iface, alignment);
|
|
|
|
|
|
|
|
return format_set_optical_alignment(&format->format, alignment);
|
2014-10-10 11:57:28 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static DWRITE_OPTICAL_ALIGNMENT WINAPI dwritetextformat1_GetOpticalAlignment(IDWriteTextFormat3 *iface)
|
2014-10-10 11:57:28 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return format->format.optical_alignment;
|
2014-10-10 11:57:28 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat1_SetFontFallback(IDWriteTextFormat3 *iface, IDWriteFontFallback *fallback)
|
2014-10-10 11:57:28 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, fallback);
|
|
|
|
|
|
|
|
return set_fontfallback_for_format(&format->format, fallback);
|
2014-10-10 11:57:28 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat1_GetFontFallback(IDWriteTextFormat3 *iface, IDWriteFontFallback **fallback)
|
2014-10-10 11:57:28 +02:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, fallback);
|
|
|
|
|
|
|
|
return get_fontfallback_from_format(&format->format, fallback);
|
2014-10-10 11:57:28 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat2_SetLineSpacing(IDWriteTextFormat3 *iface, DWRITE_LINE_SPACING const *spacing)
|
2016-02-16 22:19:40 +01:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2019-05-13 13:21:46 +02:00
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, spacing);
|
|
|
|
|
|
|
|
return format_set_linespacing(&format->format, spacing, NULL);
|
2016-02-16 22:19:40 +01:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat2_GetLineSpacing(IDWriteTextFormat3 *iface, DWRITE_LINE_SPACING *spacing)
|
2016-02-16 22:19:40 +01:00
|
|
|
{
|
2019-10-08 12:04:33 +02:00
|
|
|
struct dwrite_textformat *format = impl_from_IDWriteTextFormat3(iface);
|
2016-07-25 10:42:54 +02:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
TRACE("%p, %p.\n", iface, spacing);
|
2016-07-25 10:42:54 +02:00
|
|
|
|
2019-05-13 13:21:46 +02:00
|
|
|
*spacing = format->format.spacing;
|
2016-07-25 10:42:54 +02:00
|
|
|
return S_OK;
|
2016-02-16 22:19:40 +01:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat3_SetFontAxisValues(IDWriteTextFormat3 *iface,
|
|
|
|
DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 num_values)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p, %u.\n", iface, axis_values, num_values);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 WINAPI dwritetextformat3_GetFontAxisValueCount(IDWriteTextFormat3 *iface)
|
|
|
|
{
|
|
|
|
FIXME("%p.\n", iface);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat3_GetFontAxisValues(IDWriteTextFormat3 *iface,
|
|
|
|
DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 num_values)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p, %u.\n", iface, axis_values, num_values);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_AUTOMATIC_FONT_AXES WINAPI dwritetextformat3_GetAutomaticFontAxes(IDWriteTextFormat3 *iface)
|
|
|
|
{
|
|
|
|
FIXME("%p.\n", iface);
|
|
|
|
|
|
|
|
return DWRITE_AUTOMATIC_FONT_AXES_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat3_SetAutomaticFontAxes(IDWriteTextFormat3 *iface, DWRITE_AUTOMATIC_FONT_AXES axes)
|
|
|
|
{
|
|
|
|
FIXME("%p, %d.\n", iface, axes);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteTextFormat3Vtbl dwritetextformatvtbl =
|
|
|
|
{
|
2012-10-10 20:58:20 +02:00
|
|
|
dwritetextformat_QueryInterface,
|
|
|
|
dwritetextformat_AddRef,
|
|
|
|
dwritetextformat_Release,
|
|
|
|
dwritetextformat_SetTextAlignment,
|
|
|
|
dwritetextformat_SetParagraphAlignment,
|
|
|
|
dwritetextformat_SetWordWrapping,
|
|
|
|
dwritetextformat_SetReadingDirection,
|
|
|
|
dwritetextformat_SetFlowDirection,
|
|
|
|
dwritetextformat_SetIncrementalTabStop,
|
|
|
|
dwritetextformat_SetTrimming,
|
|
|
|
dwritetextformat_SetLineSpacing,
|
|
|
|
dwritetextformat_GetTextAlignment,
|
|
|
|
dwritetextformat_GetParagraphAlignment,
|
|
|
|
dwritetextformat_GetWordWrapping,
|
|
|
|
dwritetextformat_GetReadingDirection,
|
|
|
|
dwritetextformat_GetFlowDirection,
|
|
|
|
dwritetextformat_GetIncrementalTabStop,
|
|
|
|
dwritetextformat_GetTrimming,
|
|
|
|
dwritetextformat_GetLineSpacing,
|
|
|
|
dwritetextformat_GetFontCollection,
|
|
|
|
dwritetextformat_GetFontFamilyNameLength,
|
|
|
|
dwritetextformat_GetFontFamilyName,
|
|
|
|
dwritetextformat_GetFontWeight,
|
|
|
|
dwritetextformat_GetFontStyle,
|
|
|
|
dwritetextformat_GetFontStretch,
|
|
|
|
dwritetextformat_GetFontSize,
|
|
|
|
dwritetextformat_GetLocaleNameLength,
|
2014-10-10 11:57:28 +02:00
|
|
|
dwritetextformat_GetLocaleName,
|
|
|
|
dwritetextformat1_SetVerticalGlyphOrientation,
|
|
|
|
dwritetextformat1_GetVerticalGlyphOrientation,
|
|
|
|
dwritetextformat1_SetLastLineWrapping,
|
|
|
|
dwritetextformat1_GetLastLineWrapping,
|
|
|
|
dwritetextformat1_SetOpticalAlignment,
|
|
|
|
dwritetextformat1_GetOpticalAlignment,
|
|
|
|
dwritetextformat1_SetFontFallback,
|
2016-02-16 22:19:40 +01:00
|
|
|
dwritetextformat1_GetFontFallback,
|
|
|
|
dwritetextformat2_SetLineSpacing,
|
2019-10-08 12:04:33 +02:00
|
|
|
dwritetextformat2_GetLineSpacing,
|
|
|
|
dwritetextformat3_SetFontAxisValues,
|
|
|
|
dwritetextformat3_GetFontAxisValueCount,
|
|
|
|
dwritetextformat3_GetFontAxisValues,
|
|
|
|
dwritetextformat3_GetAutomaticFontAxes,
|
|
|
|
dwritetextformat3_SetAutomaticFontAxes,
|
2012-10-10 20:58:20 +02:00
|
|
|
};
|
|
|
|
|
2015-12-25 13:57:58 +01:00
|
|
|
static struct dwrite_textformat *unsafe_impl_from_IDWriteTextFormat(IDWriteTextFormat *iface)
|
|
|
|
{
|
|
|
|
return (iface->lpVtbl == (IDWriteTextFormatVtbl*)&dwritetextformatvtbl) ?
|
2019-10-08 12:04:33 +02:00
|
|
|
CONTAINING_RECORD(iface, struct dwrite_textformat, IDWriteTextFormat3_iface) : NULL;
|
2015-12-25 13:57:58 +01:00
|
|
|
}
|
|
|
|
|
2012-10-22 05:49:27 +02:00
|
|
|
HRESULT create_textformat(const WCHAR *family_name, IDWriteFontCollection *collection, DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STYLE style,
|
2012-10-12 15:12:57 +02:00
|
|
|
DWRITE_FONT_STRETCH stretch, FLOAT size, const WCHAR *locale, IDWriteTextFormat **format)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
|
|
|
struct dwrite_textformat *This;
|
|
|
|
|
2012-10-22 05:49:27 +02:00
|
|
|
*format = NULL;
|
|
|
|
|
2016-07-18 12:03:45 +02:00
|
|
|
if (size <= 0.0f)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (((UINT32)weight > DWRITE_FONT_WEIGHT_ULTRA_BLACK) ||
|
|
|
|
((UINT32)stretch > DWRITE_FONT_STRETCH_ULTRA_EXPANDED) ||
|
|
|
|
((UINT32)style > DWRITE_FONT_STYLE_ITALIC))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2012-10-10 20:58:20 +02:00
|
|
|
This = heap_alloc(sizeof(struct dwrite_textformat));
|
|
|
|
if (!This) return E_OUTOFMEMORY;
|
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
This->IDWriteTextFormat3_iface.lpVtbl = &dwritetextformatvtbl;
|
|
|
|
This->refcount = 1;
|
2012-10-23 14:32:34 +02:00
|
|
|
This->format.family_name = heap_strdupW(family_name);
|
2012-11-26 16:43:49 +01:00
|
|
|
This->format.family_len = strlenW(family_name);
|
2012-10-23 14:32:34 +02:00
|
|
|
This->format.locale = heap_strdupW(locale);
|
2012-10-26 18:50:12 +02:00
|
|
|
This->format.locale_len = strlenW(locale);
|
2016-01-08 10:55:37 +01:00
|
|
|
/* force locale name to lower case, layout will inherit this modified value */
|
|
|
|
strlwrW(This->format.locale);
|
2012-10-23 14:32:34 +02:00
|
|
|
This->format.weight = weight;
|
|
|
|
This->format.style = style;
|
2014-08-24 18:46:16 +02:00
|
|
|
This->format.fontsize = size;
|
2018-11-05 13:01:07 +01:00
|
|
|
This->format.tabstop = 4.0f * size;
|
2013-05-27 18:41:24 +02:00
|
|
|
This->format.stretch = stretch;
|
2014-04-07 07:18:30 +02:00
|
|
|
This->format.textalignment = DWRITE_TEXT_ALIGNMENT_LEADING;
|
2015-12-25 13:58:00 +01:00
|
|
|
This->format.optical_alignment = DWRITE_OPTICAL_ALIGNMENT_NONE;
|
2014-04-07 07:18:30 +02:00
|
|
|
This->format.paralign = DWRITE_PARAGRAPH_ALIGNMENT_NEAR;
|
|
|
|
This->format.wrapping = DWRITE_WORD_WRAPPING_WRAP;
|
2015-12-25 13:57:59 +01:00
|
|
|
This->format.last_line_wrapping = TRUE;
|
2014-04-07 07:18:30 +02:00
|
|
|
This->format.readingdir = DWRITE_READING_DIRECTION_LEFT_TO_RIGHT;
|
|
|
|
This->format.flow = DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM;
|
2016-07-25 10:42:54 +02:00
|
|
|
This->format.spacing.method = DWRITE_LINE_SPACING_METHOD_DEFAULT;
|
|
|
|
This->format.spacing.height = 0.0f;
|
|
|
|
This->format.spacing.baseline = 0.0f;
|
|
|
|
This->format.spacing.leadingBefore = 0.0f;
|
|
|
|
This->format.spacing.fontLineGapUsage = DWRITE_FONT_LINE_GAP_USAGE_DEFAULT;
|
2015-03-13 09:58:32 +01:00
|
|
|
This->format.vertical_orientation = DWRITE_VERTICAL_GLYPH_ORIENTATION_DEFAULT;
|
2014-04-08 05:42:06 +02:00
|
|
|
This->format.trimming.granularity = DWRITE_TRIMMING_GRANULARITY_NONE;
|
|
|
|
This->format.trimming.delimiter = 0;
|
|
|
|
This->format.trimming.delimiterCount = 0;
|
|
|
|
This->format.trimmingsign = NULL;
|
2014-12-16 15:48:15 +01:00
|
|
|
This->format.collection = collection;
|
2015-03-14 22:43:20 +01:00
|
|
|
This->format.fallback = NULL;
|
2014-12-16 15:48:15 +01:00
|
|
|
IDWriteFontCollection_AddRef(collection);
|
2012-10-22 05:49:27 +02:00
|
|
|
|
2019-10-08 12:04:33 +02:00
|
|
|
*format = (IDWriteTextFormat *)&This->IDWriteTextFormat3_iface;
|
2012-10-10 20:58:20 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2014-09-19 05:54:00 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetypography_QueryInterface(IDWriteTypography *iface, REFIID riid, void **obj)
|
|
|
|
{
|
2019-05-13 13:21:43 +02:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
|
2014-09-19 05:54:00 +02:00
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IDWriteTypography) || IsEqualIID(riid, &IID_IUnknown)) {
|
|
|
|
*obj = iface;
|
|
|
|
IDWriteTypography_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:34:51 +02:00
|
|
|
WARN("%s not implemented.\n", debugstr_guid(riid));
|
|
|
|
|
2014-09-19 05:54:00 +02:00
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritetypography_AddRef(IDWriteTypography *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_typography *typography = impl_from_IDWriteTypography(iface);
|
2019-05-13 13:21:43 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&typography->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %d.\n", iface, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
2014-09-19 05:54:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritetypography_Release(IDWriteTypography *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_typography *typography = impl_from_IDWriteTypography(iface);
|
2019-05-13 13:21:43 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&typography->refcount);
|
2014-09-19 05:54:00 +02:00
|
|
|
|
2019-05-13 13:21:43 +02:00
|
|
|
TRACE("%p, refcount %d.\n", iface, refcount);
|
2014-09-19 05:54:00 +02:00
|
|
|
|
2019-05-13 13:21:43 +02:00
|
|
|
if (!refcount)
|
|
|
|
{
|
2014-09-19 05:54:00 +02:00
|
|
|
heap_free(typography->features);
|
|
|
|
heap_free(typography);
|
|
|
|
}
|
|
|
|
|
2019-05-13 13:21:43 +02:00
|
|
|
return refcount;
|
2014-09-19 05:54:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetypography_AddFontFeature(IDWriteTypography *iface, DWRITE_FONT_FEATURE feature)
|
|
|
|
{
|
|
|
|
struct dwrite_typography *typography = impl_from_IDWriteTypography(iface);
|
|
|
|
|
2019-05-13 13:21:43 +02:00
|
|
|
TRACE("%p, %s, %u.\n", iface, debugstr_tag(feature.nameTag), feature.parameter);
|
2014-09-19 05:54:00 +02:00
|
|
|
|
2019-05-13 13:21:43 +02:00
|
|
|
if (!dwrite_array_reserve((void **)&typography->features, &typography->capacity, typography->count + 1,
|
|
|
|
sizeof(*typography->features)))
|
|
|
|
{
|
|
|
|
return E_OUTOFMEMORY;
|
2014-09-19 05:54:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
typography->features[typography->count++] = feature;
|
2019-05-13 13:21:43 +02:00
|
|
|
|
2014-09-19 05:54:00 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 WINAPI dwritetypography_GetFontFeatureCount(IDWriteTypography *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_typography *typography = impl_from_IDWriteTypography(iface);
|
2019-05-13 13:21:43 +02:00
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
2014-09-19 05:54:00 +02:00
|
|
|
return typography->count;
|
|
|
|
}
|
|
|
|
|
2019-05-13 13:21:43 +02:00
|
|
|
static HRESULT WINAPI dwritetypography_GetFontFeature(IDWriteTypography *iface, UINT32 index,
|
|
|
|
DWRITE_FONT_FEATURE *feature)
|
2014-09-19 05:54:00 +02:00
|
|
|
{
|
|
|
|
struct dwrite_typography *typography = impl_from_IDWriteTypography(iface);
|
|
|
|
|
2019-05-13 13:21:43 +02:00
|
|
|
TRACE("%p, %u, %p.\n", iface, index, feature);
|
2014-09-19 05:54:00 +02:00
|
|
|
|
|
|
|
if (index >= typography->count)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*feature = typography->features[index];
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteTypographyVtbl dwritetypographyvtbl = {
|
|
|
|
dwritetypography_QueryInterface,
|
|
|
|
dwritetypography_AddRef,
|
|
|
|
dwritetypography_Release,
|
|
|
|
dwritetypography_AddFontFeature,
|
|
|
|
dwritetypography_GetFontFeatureCount,
|
|
|
|
dwritetypography_GetFontFeature
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT create_typography(IDWriteTypography **ret)
|
|
|
|
{
|
|
|
|
struct dwrite_typography *typography;
|
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
|
2019-05-13 13:21:43 +02:00
|
|
|
typography = heap_alloc_zero(sizeof(*typography));
|
2014-09-19 05:54:00 +02:00
|
|
|
if (!typography)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
typography->IDWriteTypography_iface.lpVtbl = &dwritetypographyvtbl;
|
2019-05-13 13:21:43 +02:00
|
|
|
typography->refcount = 1;
|
2014-09-19 05:54:00 +02:00
|
|
|
|
|
|
|
*ret = &typography->IDWriteTypography_iface;
|
2019-05-13 13:21:43 +02:00
|
|
|
|
2014-09-19 05:54:00 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|