2012-09-28 10:13:17 +02:00
|
|
|
/*
|
|
|
|
* Text format and layout
|
|
|
|
*
|
2015-03-30 09:15:48 +02:00
|
|
|
* Copyright 2012, 2014-2015 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
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "dwrite_private.h"
|
2014-12-25 11:34:35 +01:00
|
|
|
#include "scripts.h"
|
2014-08-13 21:15:46 +02:00
|
|
|
#include "wine/list.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;
|
|
|
|
DWRITE_TEXT_ALIGNMENT textalignment;
|
|
|
|
DWRITE_FLOW_DIRECTION flow;
|
|
|
|
DWRITE_LINE_SPACING_METHOD spacingmethod;
|
2015-03-13 09:58:32 +01:00
|
|
|
DWRITE_VERTICAL_GLYPH_ORIENTATION vertical_orientation;
|
2014-04-07 07:18:30 +02:00
|
|
|
|
|
|
|
FLOAT spacing;
|
|
|
|
FLOAT baseline;
|
2014-08-24 18:46:16 +02:00
|
|
|
FLOAT fontsize;
|
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,
|
|
|
|
LAYOUT_RANGE_ATTR_FONTFAMILY
|
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;
|
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,
|
|
|
|
LAYOUT_RANGE_STRIKETHROUGH
|
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;
|
2014-08-13 21:29:07 +02:00
|
|
|
IUnknown *effect;
|
|
|
|
BOOL underline;
|
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-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;
|
2015-05-30 22:51:01 +02:00
|
|
|
/* this is actual glyph count after shaping, it's not necessary the same as reported to Draw() */
|
|
|
|
UINT32 glyphcount;
|
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-05-30 23:01:45 +02:00
|
|
|
IUnknown *effect;
|
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 */
|
|
|
|
FLOAT origin_x; /* baseline X position */
|
|
|
|
FLOAT origin_y; /* baseline Y position */
|
|
|
|
UINT16 *clustermap; /* effective clustermap, allocated separately, is not reused from nominal map */
|
|
|
|
};
|
|
|
|
|
2015-05-30 17:44:54 +02:00
|
|
|
struct layout_effective_inline {
|
|
|
|
struct list entry;
|
|
|
|
IDWriteInlineObject *object;
|
|
|
|
FLOAT origin_x;
|
|
|
|
FLOAT origin_y;
|
|
|
|
BOOL is_sideways;
|
|
|
|
BOOL is_rtl;
|
|
|
|
};
|
|
|
|
|
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 */
|
|
|
|
};
|
|
|
|
|
2015-03-30 09:15:48 +02:00
|
|
|
enum layout_recompute_mask {
|
2015-05-05 14:23:17 +02:00
|
|
|
RECOMPUTE_NOMINAL_RUNS = 1 << 0,
|
|
|
|
RECOMPUTE_MINIMAL_WIDTH = 1 << 1,
|
|
|
|
RECOMPUTE_EFFECTIVE_RUNS = 1 << 2,
|
|
|
|
RECOMPUTE_EVERYTHING = 0xffff
|
2015-03-30 09:15:48 +02:00
|
|
|
};
|
|
|
|
|
2012-10-23 14:32:34 +02:00
|
|
|
struct dwrite_textlayout {
|
2014-10-10 11:38:54 +02:00
|
|
|
IDWriteTextLayout2 IDWriteTextLayout2_iface;
|
2015-03-15 00:38:32 +01:00
|
|
|
IDWriteTextFormat1 IDWriteTextFormat1_iface;
|
2014-12-23 13:36:32 +01:00
|
|
|
IDWriteTextAnalysisSink IDWriteTextAnalysisSink_iface;
|
|
|
|
IDWriteTextAnalysisSource IDWriteTextAnalysisSource_iface;
|
2012-10-23 14:32:34 +02:00
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
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;
|
2014-07-30 17:59:07 +02:00
|
|
|
FLOAT maxwidth;
|
|
|
|
FLOAT maxheight;
|
2015-06-04 16:55:26 +02:00
|
|
|
struct list strike_ranges;
|
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;
|
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
|
|
|
|
2015-05-05 14:23:17 +02:00
|
|
|
DWRITE_LINE_METRICS *lines;
|
|
|
|
UINT32 line_count;
|
|
|
|
UINT32 line_alloc;
|
|
|
|
|
2015-01-08 22:35:14 +01:00
|
|
|
/* gdi-compatible layout specifics */
|
|
|
|
BOOL gdicompatible;
|
|
|
|
FLOAT pixels_per_dip;
|
|
|
|
BOOL use_gdi_natural;
|
|
|
|
DWRITE_MATRIX transform;
|
2012-10-23 14:32:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct dwrite_textformat {
|
2014-10-10 11:57:28 +02:00
|
|
|
IDWriteTextFormat1 IDWriteTextFormat1_iface;
|
2012-10-23 14:32:34 +02:00
|
|
|
LONG ref;
|
|
|
|
struct dwrite_textformat_data format;
|
|
|
|
};
|
|
|
|
|
2014-04-08 05:42:24 +02:00
|
|
|
struct dwrite_trimmingsign {
|
|
|
|
IDWriteInlineObject IDWriteInlineObject_iface;
|
|
|
|
LONG ref;
|
|
|
|
};
|
|
|
|
|
2014-09-19 05:54:00 +02:00
|
|
|
struct dwrite_typography {
|
|
|
|
IDWriteTypography IDWriteTypography_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
DWRITE_FONT_FEATURE *features;
|
|
|
|
UINT32 allocated;
|
|
|
|
UINT32 count;
|
|
|
|
};
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static const IDWriteTextFormat1Vtbl 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);
|
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static inline struct dwrite_textlayout *impl_from_IDWriteTextLayout2(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_textlayout, IDWriteTextLayout2_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2015-03-15 00:38:32 +01:00
|
|
|
static inline struct dwrite_textlayout *impl_layout_form_IDWriteTextFormat1(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_textlayout, IDWriteTextFormat1_iface);
|
|
|
|
}
|
|
|
|
|
2014-12-23 13:36:32 +01:00
|
|
|
static inline struct dwrite_textlayout *impl_from_IDWriteTextAnalysisSink(IDWriteTextAnalysisSink *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_textlayout, IDWriteTextAnalysisSink_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct dwrite_textlayout *impl_from_IDWriteTextAnalysisSource(IDWriteTextAnalysisSource *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_textlayout, IDWriteTextAnalysisSource_iface);
|
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static inline struct dwrite_textformat *impl_from_IDWriteTextFormat1(IDWriteTextFormat1 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct dwrite_textformat, IDWriteTextFormat1_iface);
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2015-04-04 13:05:52 +02:00
|
|
|
static inline const char *debugstr_run(const struct regular_layout_run *run)
|
2015-01-11 22:03:31 +01:00
|
|
|
{
|
2015-05-01 10:35:13 +02:00
|
|
|
return wine_dbg_sprintf("[%u,%u)", run->descr.textPosition, run->descr.textPosition +
|
2015-01-11 22:03:31 +01:00
|
|
|
run->descr.stringLength);
|
|
|
|
}
|
|
|
|
|
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-04-04 13:05:52 +02:00
|
|
|
static struct layout_run *alloc_layout_run(enum layout_run_kind kind)
|
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;
|
|
|
|
}
|
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;
|
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
|
|
|
|
|
|
|
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-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;
|
|
|
|
HRESULT hr;
|
|
|
|
UINT32 i;
|
|
|
|
|
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) {
|
|
|
|
layout->actual_breakpoints = heap_alloc(sizeof(DWRITE_LINE_BREAKPOINT)*layout->len);
|
|
|
|
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-04 16:55:26 +02:00
|
|
|
for (i = cur->h.range.startPosition; i < cur->h.range.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-04 16:55:26 +02:00
|
|
|
else if (i == cur->h.range.startPosition + cur->h.range.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;
|
|
|
|
}
|
|
|
|
|
|
|
|
layout->actual_breakpoints[i].isWhitespace = FALSE;
|
|
|
|
layout->actual_breakpoints[i].isSoftHyphen = FALSE;
|
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-04-03 10:38:23 +02:00
|
|
|
UINT16 start_glyph, UINT16 stop_glyph, UINT32 stop_position, DWRITE_CLUSTER_METRICS *metrics)
|
|
|
|
{
|
|
|
|
UINT8 breakcondition;
|
2015-04-23 12:01:18 +02:00
|
|
|
UINT32 position;
|
2015-04-03 10:38:23 +02:00
|
|
|
UINT16 j;
|
|
|
|
|
2015-01-11 22:03:31 +01:00
|
|
|
metrics->width = 0.0;
|
2015-05-30 22:51:01 +02:00
|
|
|
|
|
|
|
/* For clusters on control chars we report zero glyphs, and we need zero cluster
|
|
|
|
width as well; advances are already computed at this point and are not necessary zero. */
|
|
|
|
if (run->run.glyphCount) {
|
|
|
|
for (j = start_glyph; j < stop_glyph; j++)
|
|
|
|
metrics->width += run->run.glyphAdvances[j];
|
|
|
|
}
|
2015-04-03 10:38:23 +02:00
|
|
|
metrics->length = 0;
|
|
|
|
|
2015-04-23 12:01:18 +02:00
|
|
|
position = stop_position;
|
2015-05-30 22:51:01 +02:00
|
|
|
if (stop_glyph == run->glyphcount)
|
2015-04-03 10:38:23 +02:00
|
|
|
breakcondition = get_effective_breakpoint(layout, stop_position).breakConditionAfter;
|
2015-04-23 12:01:18 +02:00
|
|
|
else {
|
2015-04-03 10:38:23 +02:00
|
|
|
breakcondition = get_effective_breakpoint(layout, stop_position).breakConditionBefore;
|
2015-04-23 12:01:18 +02:00
|
|
|
if (stop_position) position = stop_position - 1;
|
|
|
|
}
|
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) {
|
|
|
|
WORD type;
|
|
|
|
|
|
|
|
GetStringTypeW(CT_CTYPE1, &layout->str[position], 1, &type);
|
|
|
|
metrics->isWhitespace = type == C1_SPACE;
|
|
|
|
metrics->isNewline = FALSE /* FIXME */;
|
|
|
|
metrics->isSoftHyphen = layout->str[position] == 0x00ad /* Unicode Soft Hyphen */;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
metrics->isWhitespace = FALSE;
|
|
|
|
metrics->isNewline = FALSE;
|
|
|
|
metrics->isSoftHyphen = FALSE;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
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]) {
|
|
|
|
init_cluster_metrics(layout, run, run->descr.clusterMap[start], run->descr.clusterMap[i], i, metrics);
|
|
|
|
metrics->length = i - start;
|
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-05-30 22:51:01 +02:00
|
|
|
init_cluster_metrics(layout, run, run->descr.clusterMap[start], run->glyphcount, i, metrics);
|
2015-04-03 10:38:23 +02:00
|
|
|
metrics->length = i - start + 1;
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-23 13:36:32 +01:00
|
|
|
static HRESULT layout_compute_runs(struct dwrite_textlayout *layout)
|
|
|
|
{
|
|
|
|
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;
|
2015-01-11 22:03:31 +01:00
|
|
|
UINT32 cluster = 0;
|
2015-01-06 21:57:15 +01:00
|
|
|
HRESULT hr;
|
2014-12-23 13:36:32 +01:00
|
|
|
|
2015-05-30 17:44:54 +02:00
|
|
|
free_layout_eruns(layout);
|
2014-12-23 13:36:32 +01:00
|
|
|
free_layout_runs(layout);
|
2015-04-23 12:02:43 +02:00
|
|
|
|
|
|
|
/* Cluster data arrays are allocated once, assuming one text position per cluster. */
|
|
|
|
if (!layout->clustermetrics) {
|
|
|
|
layout->clustermetrics = heap_alloc(layout->len*sizeof(*layout->clustermetrics));
|
|
|
|
layout->clusters = heap_alloc(layout->len*sizeof(*layout->clusters));
|
|
|
|
if (!layout->clustermetrics || !layout->clusters) {
|
|
|
|
heap_free(layout->clustermetrics);
|
|
|
|
heap_free(layout->clusters);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
2015-05-05 14:23:17 +02:00
|
|
|
layout->cluster_count = 0;
|
2014-12-23 13:36:32 +01:00
|
|
|
|
|
|
|
hr = get_textanalyzer(&analyzer);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2015-06-04 12:37:01 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(range, &layout->ranges, struct layout_range, h.entry) {
|
2014-12-23 13:36:32 +01:00
|
|
|
/* inline objects override actual text in a 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
|
|
|
|
|
|
|
r = alloc_layout_run(LAYOUT_RUN_INLINE);
|
|
|
|
if (!r)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
r->u.object.object = range->object;
|
2015-06-04 16:55:26 +02:00
|
|
|
r->u.object.length = range->h.range.length;
|
2015-05-30 23:01:45 +02:00
|
|
|
r->effect = range->effect;
|
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
|
|
|
|
2014-12-25 11:34:35 +01:00
|
|
|
/* initial splitting by script */
|
2014-12-23 13:36:32 +01:00
|
|
|
hr = IDWriteTextAnalyzer_AnalyzeScript(analyzer, &layout->IDWriteTextAnalysisSource_iface,
|
2015-06-04 16:55:26 +02:00
|
|
|
range->h.range.startPosition, range->h.range.length, &layout->IDWriteTextAnalysisSink_iface);
|
2014-12-23 13:36:32 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
break;
|
2014-12-25 11:34:35 +01:00
|
|
|
|
|
|
|
/* this splits it further */
|
|
|
|
hr = IDWriteTextAnalyzer_AnalyzeBidi(analyzer, &layout->IDWriteTextAnalysisSource_iface,
|
2015-06-04 16:55:26 +02:00
|
|
|
range->h.range.startPosition, range->h.range.length, &layout->IDWriteTextAnalysisSink_iface);
|
2014-12-25 11:34:35 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
break;
|
2014-12-23 13:36:32 +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) {
|
2015-01-08 10:33:17 +01:00
|
|
|
DWRITE_SHAPING_GLYPH_PROPERTIES *glyph_props = NULL;
|
|
|
|
DWRITE_SHAPING_TEXT_PROPERTIES *text_props = NULL;
|
2015-04-04 13:05:52 +02:00
|
|
|
struct regular_layout_run *run = &r->u.regular;
|
2015-01-06 21:57:15 +01:00
|
|
|
IDWriteFontFamily *family;
|
2015-01-08 10:33:17 +01:00
|
|
|
UINT32 index, max_count;
|
2015-01-06 21:57:15 +01:00
|
|
|
IDWriteFont *font;
|
|
|
|
BOOL exists = TRUE;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
metrics->width = 0.0;
|
|
|
|
metrics->length = r->u.object.length;
|
|
|
|
metrics->canWrapLineAfter = FALSE;
|
|
|
|
metrics->isWhitespace = FALSE;
|
|
|
|
metrics->isNewline = FALSE;
|
|
|
|
metrics->isSoftHyphen = FALSE;
|
|
|
|
metrics->isRightToLeft = FALSE;
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* FIXME: use resolved breakpoints in this case too */
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-01-06 21:57:15 +01:00
|
|
|
range = get_layout_range_by_pos(layout, run->descr.textPosition);
|
2015-05-30 23:01:45 +02:00
|
|
|
r->effect = range->effect;
|
2015-01-06 21:57:15 +01:00
|
|
|
|
|
|
|
hr = IDWriteFontCollection_FindFamilyName(range->collection, range->fontfamily, &index, &exists);
|
|
|
|
if (FAILED(hr) || !exists) {
|
2015-01-11 22:03:31 +01:00
|
|
|
WARN("%s: family %s not found in collection %p\n", debugstr_run(run), debugstr_w(range->fontfamily), range->collection);
|
2015-01-06 21:57:15 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDWriteFontCollection_GetFontFamily(range->collection, index, &family);
|
|
|
|
if (FAILED(hr))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
hr = IDWriteFontFamily_GetFirstMatchingFont(family, range->weight, range->stretch, range->style, &font);
|
|
|
|
IDWriteFontFamily_Release(family);
|
|
|
|
if (FAILED(hr)) {
|
2015-01-11 22:03:31 +01:00
|
|
|
WARN("%s: failed to get a matching font\n", debugstr_run(run));
|
2015-01-06 21:57:15 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDWriteFont_CreateFontFace(font, &run->run.fontFace);
|
|
|
|
IDWriteFont_Release(font);
|
|
|
|
if (FAILED(hr))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
run->run.fontEmSize = range->fontsize;
|
|
|
|
run->descr.localeName = range->locale;
|
2015-01-08 10:33:17 +01:00
|
|
|
run->clustermap = heap_alloc(run->descr.stringLength*sizeof(UINT16));
|
|
|
|
|
|
|
|
max_count = 3*run->descr.stringLength/2 + 16;
|
|
|
|
run->glyphs = heap_alloc(max_count*sizeof(UINT16));
|
|
|
|
if (!run->clustermap || !run->glyphs)
|
|
|
|
goto memerr;
|
|
|
|
|
|
|
|
text_props = heap_alloc(run->descr.stringLength*sizeof(DWRITE_SHAPING_TEXT_PROPERTIES));
|
|
|
|
glyph_props = heap_alloc(max_count*sizeof(DWRITE_SHAPING_GLYPH_PROPERTIES));
|
|
|
|
if (!text_props || !glyph_props)
|
|
|
|
goto memerr;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
hr = IDWriteTextAnalyzer_GetGlyphs(analyzer, run->descr.string, run->descr.stringLength,
|
2015-03-26 11:23:43 +01:00
|
|
|
run->run.fontFace, run->run.isSideways, run->run.bidiLevel & 1, &run->sa, run->descr.localeName,
|
2015-01-08 10:33:17 +01:00
|
|
|
NULL /* FIXME */, NULL, NULL, 0, max_count, run->clustermap, text_props, run->glyphs, glyph_props,
|
2015-05-30 22:51:01 +02:00
|
|
|
&run->glyphcount);
|
2015-01-08 10:33:17 +01:00
|
|
|
if (hr == E_NOT_SUFFICIENT_BUFFER) {
|
|
|
|
heap_free(run->glyphs);
|
|
|
|
heap_free(glyph_props);
|
|
|
|
|
2015-05-30 22:51:01 +02:00
|
|
|
max_count = run->glyphcount;
|
2015-01-08 10:33:17 +01:00
|
|
|
|
|
|
|
run->glyphs = heap_alloc(max_count*sizeof(UINT16));
|
|
|
|
glyph_props = heap_alloc(max_count*sizeof(DWRITE_SHAPING_GLYPH_PROPERTIES));
|
|
|
|
if (!run->glyphs || !glyph_props)
|
|
|
|
goto memerr;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
2015-01-08 11:25:35 +01:00
|
|
|
heap_free(text_props);
|
|
|
|
heap_free(glyph_props);
|
2015-01-11 22:03:31 +01:00
|
|
|
WARN("%s: shaping failed 0x%08x\n", debugstr_run(run), hr);
|
2015-01-08 10:33:17 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
run->run.glyphIndices = run->glyphs;
|
|
|
|
run->descr.clusterMap = run->clustermap;
|
|
|
|
|
2015-05-30 22:51:01 +02:00
|
|
|
run->advances = heap_alloc(run->glyphcount*sizeof(FLOAT));
|
|
|
|
run->offsets = heap_alloc(run->glyphcount*sizeof(DWRITE_GLYPH_OFFSET));
|
2015-01-08 11:25:35 +01:00
|
|
|
if (!run->advances || !run->offsets)
|
|
|
|
goto memerr;
|
|
|
|
|
|
|
|
/* now set advances and offsets */
|
2015-01-08 23:07:33 +01:00
|
|
|
if (layout->gdicompatible)
|
|
|
|
hr = IDWriteTextAnalyzer_GetGdiCompatibleGlyphPlacements(analyzer, run->descr.string, run->descr.clusterMap,
|
2015-05-30 22:51:01 +02:00
|
|
|
text_props, run->descr.stringLength, run->run.glyphIndices, glyph_props, run->glyphcount,
|
2015-01-08 23:07:33 +01:00
|
|
|
run->run.fontFace, run->run.fontEmSize, layout->pixels_per_dip, &layout->transform, layout->use_gdi_natural,
|
2015-03-26 11:23:43 +01:00
|
|
|
run->run.isSideways, run->run.bidiLevel & 1, &run->sa, run->descr.localeName, NULL, NULL, 0,
|
2015-01-08 23:07:33 +01:00
|
|
|
run->advances, run->offsets);
|
|
|
|
else
|
|
|
|
hr = IDWriteTextAnalyzer_GetGlyphPlacements(analyzer, run->descr.string, run->descr.clusterMap, text_props,
|
2015-05-30 22:51:01 +02:00
|
|
|
run->descr.stringLength, run->run.glyphIndices, glyph_props, run->glyphcount, run->run.fontFace,
|
2015-03-26 11:23:43 +01:00
|
|
|
run->run.fontEmSize, run->run.isSideways, run->run.bidiLevel & 1, &run->sa, run->descr.localeName,
|
2015-01-08 23:07:33 +01:00
|
|
|
NULL, NULL, 0, run->advances, run->offsets);
|
|
|
|
|
2015-01-08 11:25:35 +01:00
|
|
|
heap_free(text_props);
|
|
|
|
heap_free(glyph_props);
|
|
|
|
if (FAILED(hr))
|
2015-01-11 22:03:31 +01:00
|
|
|
WARN("%s: failed to get glyph placement info, 0x%08x\n", debugstr_run(run), hr);
|
2015-01-08 11:25:35 +01:00
|
|
|
|
|
|
|
run->run.glyphAdvances = run->advances;
|
|
|
|
run->run.glyphOffsets = run->offsets;
|
|
|
|
|
2015-05-30 22:51:01 +02:00
|
|
|
/* Special treatment of control script, shaping code adds normal glyphs for it,
|
|
|
|
with non-zero advances, and layout code exposes those as zero width clusters,
|
|
|
|
so we have to do it manually. */
|
|
|
|
if (run->sa.script == Script_Common)
|
|
|
|
run->run.glyphCount = 0;
|
|
|
|
else
|
|
|
|
run->run.glyphCount = run->glyphcount;
|
2015-04-23 12:02:43 +02:00
|
|
|
layout_set_cluster_metrics(layout, r, &cluster);
|
2015-01-11 22:03:31 +01:00
|
|
|
|
2015-01-08 10:33:17 +01:00
|
|
|
continue;
|
|
|
|
|
|
|
|
memerr:
|
|
|
|
heap_free(text_props);
|
|
|
|
heap_free(glyph_props);
|
|
|
|
heap_free(run->clustermap);
|
|
|
|
heap_free(run->glyphs);
|
2015-01-08 11:25:35 +01:00
|
|
|
heap_free(run->advances);
|
|
|
|
heap_free(run->offsets);
|
|
|
|
run->advances = NULL;
|
|
|
|
run->offsets = NULL;
|
2015-01-08 10:33:17 +01:00
|
|
|
run->clustermap = run->glyphs = NULL;
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
break;
|
2015-01-06 21:57:15 +01:00
|
|
|
}
|
|
|
|
|
2015-01-11 22:03:31 +01:00
|
|
|
if (hr == S_OK)
|
2015-05-05 14:23:17 +02:00
|
|
|
layout->cluster_count = cluster;
|
2015-01-11 22:03:31 +01:00
|
|
|
|
2014-12-23 13:36:32 +01:00
|
|
|
IDWriteTextAnalyzer_Release(analyzer);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT layout_compute(struct dwrite_textlayout *layout)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
2015-03-30 09:15:48 +02:00
|
|
|
if (!(layout->recompute & RECOMPUTE_NOMINAL_RUNS))
|
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;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2014-12-25 22:01:28 +01:00
|
|
|
layout->nominal_breakpoints = heap_alloc(sizeof(DWRITE_LINE_BREAKPOINT)*layout->len);
|
|
|
|
if (!layout->nominal_breakpoints)
|
2014-12-25 12:03:19 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hr = get_textanalyzer(&analyzer);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = IDWriteTextAnalyzer_AnalyzeLineBreakpoints(analyzer, &layout->IDWriteTextAnalysisSource_iface,
|
|
|
|
0, layout->len, &layout->IDWriteTextAnalysisSink_iface);
|
|
|
|
IDWriteTextAnalyzer_Release(analyzer);
|
|
|
|
}
|
2015-04-03 10:38:23 +02:00
|
|
|
if (layout->actual_breakpoints) {
|
|
|
|
heap_free(layout->actual_breakpoints);
|
|
|
|
layout->actual_breakpoints = NULL;
|
|
|
|
}
|
2014-12-25 12:03:19 +01:00
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-30 09:15:48 +02:00
|
|
|
layout->recompute &= ~RECOMPUTE_NOMINAL_RUNS;
|
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)
|
|
|
|
{
|
|
|
|
FLOAT width = 0.0;
|
|
|
|
for (; start < end; start++)
|
|
|
|
width += layout->clustermetrics[start].width;
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
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,
|
2015-06-04 22:32:30 +02:00
|
|
|
UINT32 cluster_count, FLOAT origin_x, BOOL strikethrough)
|
2015-05-05 14:23:17 +02:00
|
|
|
{
|
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;
|
|
|
|
|
|
|
|
inlineobject->object = r->u.object.object;
|
|
|
|
inlineobject->origin_x = origin_x;
|
|
|
|
inlineobject->origin_y = 0.0; /* FIXME */
|
|
|
|
/* 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;
|
|
|
|
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:
|
|
|
|
<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
|
|
|
|
2015-05-05 14:23:17 +02:00
|
|
|
run->clustermap = heap_alloc(sizeof(UINT16)*length);
|
|
|
|
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;
|
|
|
|
run->origin_x = origin_x;
|
|
|
|
run->origin_y = 0.0; /* FIXME: set after line is built */
|
|
|
|
|
2015-05-30 22:51:01 +02:00
|
|
|
if (r->u.regular.run.glyphCount) {
|
|
|
|
/* trim from the left */
|
|
|
|
run->glyphcount = r->u.regular.run.glyphCount - r->u.regular.clustermap[start];
|
|
|
|
/* trim from the right */
|
|
|
|
if (length < r->u.regular.descr.stringLength)
|
|
|
|
run->glyphcount -= r->u.regular.clustermap[start + length];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
run->glyphcount = 0;
|
2015-05-05 14:23:17 +02:00
|
|
|
|
|
|
|
/* cluster map needs to be shifted */
|
|
|
|
for (i = 0; i < length; i++)
|
|
|
|
run->clustermap[i] = r->u.regular.clustermap[start] - start;
|
|
|
|
|
|
|
|
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,
|
|
|
|
it's width equals to run width, thikness and offset are derived from
|
|
|
|
font metrics, rest of the values are from layout or run itself */
|
|
|
|
if (strikethrough) {
|
|
|
|
DWRITE_FONT_METRICS metrics = { 0 };
|
|
|
|
struct layout_strikethrough *s;
|
|
|
|
|
|
|
|
s = heap_alloc(sizeof(*s));
|
|
|
|
if (!s)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (layout->gdicompatible) {
|
|
|
|
HRESULT hr = IDWriteFontFace_GetGdiCompatibleMetrics(
|
|
|
|
r->u.regular.run.fontFace,
|
|
|
|
r->u.regular.run.fontEmSize,
|
|
|
|
layout->pixels_per_dip,
|
|
|
|
&layout->transform,
|
|
|
|
&metrics);
|
|
|
|
if (FAILED(hr))
|
|
|
|
WARN("failed to get font metrics, 0x%08x\n", hr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
IDWriteFontFace_GetMetrics(r->u.regular.run.fontFace, &metrics);
|
|
|
|
|
|
|
|
s->s.width = get_cluster_range_width(layout, first_cluster, first_cluster + cluster_count);
|
|
|
|
s->s.thickness = metrics.strikethroughThickness;
|
|
|
|
s->s.offset = metrics.strikethroughPosition;
|
|
|
|
s->s.readingDirection = layout->format.readingdir;
|
|
|
|
s->s.flowDirection = layout->format.flow;
|
|
|
|
s->s.localeName = r->u.regular.descr.localeName;
|
|
|
|
s->s.measuringMode = DWRITE_MEASURING_MODE_NATURAL; /* FIXME */
|
|
|
|
s->run = run;
|
|
|
|
|
|
|
|
list_add_tail(&layout->strikethrough, &s->entry);
|
|
|
|
}
|
|
|
|
|
2015-05-05 14:23:17 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT layout_set_line_metrics(struct dwrite_textlayout *layout, DWRITE_LINE_METRICS *metrics, UINT32 *line)
|
|
|
|
{
|
|
|
|
if (!layout->line_alloc) {
|
|
|
|
layout->line_alloc = 5;
|
|
|
|
layout->lines = heap_alloc(layout->line_alloc*sizeof(*layout->lines));
|
|
|
|
if (!layout->lines)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (layout->line_count == layout->line_alloc) {
|
|
|
|
DWRITE_LINE_METRICS *l = heap_realloc(layout->lines, layout->line_alloc*2*sizeof(*layout->lines));
|
|
|
|
if (!l)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
layout->lines = l;
|
|
|
|
layout->line_alloc *= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
layout->lines[*line] = *metrics;
|
|
|
|
*line += 1;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-06-04 22:32:30 +02:00
|
|
|
static struct layout_range_header *get_layout_range_header_by_pos(struct list *ranges, UINT32 pos)
|
2015-05-05 14:23:17 +02:00
|
|
|
{
|
2015-06-04 22:32:30 +02:00
|
|
|
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 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;
|
2015-05-05 14:23:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT layout_compute_effective_runs(struct dwrite_textlayout *layout)
|
|
|
|
{
|
|
|
|
DWRITE_LINE_METRICS metrics;
|
|
|
|
const struct layout_run *run;
|
|
|
|
FLOAT width, origin_x;
|
2015-06-04 22:32:30 +02:00
|
|
|
UINT32 i, start, line, textpos;
|
2015-05-05 14:23:17 +02:00
|
|
|
HRESULT hr;
|
2015-06-04 22:32:30 +02:00
|
|
|
BOOL s[2];
|
2015-05-05 14:23:17 +02:00
|
|
|
|
|
|
|
if (!(layout->recompute & RECOMPUTE_EFFECTIVE_RUNS))
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
hr = layout_compute(layout);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
layout->line_count = 0;
|
|
|
|
origin_x = 0.0;
|
|
|
|
line = 0;
|
|
|
|
run = layout->clusters[0].run;
|
|
|
|
memset(&metrics, 0, sizeof(metrics));
|
2015-06-04 22:32:30 +02:00
|
|
|
s[0] = s[1] = layout_get_strikethrough_from_pos(layout, 0);
|
2015-05-05 14:23:17 +02:00
|
|
|
|
2015-06-04 22:32:30 +02:00
|
|
|
for (i = 0, start = 0, textpos = 0, width = 0.0; i < layout->cluster_count; i++) {
|
2015-05-30 17:44:54 +02:00
|
|
|
BOOL can_wrap_after = layout->clustermetrics[i].canWrapLineAfter;
|
|
|
|
|
2015-06-04 22:32:30 +02:00
|
|
|
s[1] = layout_get_strikethrough_from_pos(layout, textpos);
|
|
|
|
|
2015-05-30 17:44:54 +02:00
|
|
|
/* switched to next nominal run, at this point all previous pending clusters are already
|
|
|
|
checked for layout line overflow, so new effective run will fit in current line */
|
2015-06-04 22:32:30 +02:00
|
|
|
if (run != layout->clusters[i].run || s[0] != s[1]) {
|
|
|
|
hr = layout_add_effective_run(layout, run, start, i - start, origin_x, s[0]);
|
2015-05-05 14:23:17 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
origin_x += 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if we got new line */
|
|
|
|
if (((can_wrap_after && (width + layout->clustermetrics[i].width > layout->maxwidth)) ||
|
|
|
|
layout->clustermetrics[i].isNewline || /* always wrap on new line */
|
|
|
|
i == layout->cluster_count - 1)) /* end of the text */ {
|
|
|
|
|
|
|
|
UINT32 strlength = metrics.length, index = i;
|
|
|
|
|
2015-05-30 22:51:01 +02:00
|
|
|
if (i >= start) {
|
2015-06-04 22:32:30 +02:00
|
|
|
hr = layout_add_effective_run(layout, run, start, i - start + 1, origin_x, s[0]);
|
2015-05-05 14:23:17 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
/* we don't need to update origin for next run as we're going to wrap */
|
|
|
|
}
|
|
|
|
|
2015-05-30 17:44:54 +02:00
|
|
|
/* take a look at clusters we got for this line in reverse order to set
|
|
|
|
trailing properties for current line */
|
2015-05-05 14:23:17 +02:00
|
|
|
while (strlength) {
|
|
|
|
DWRITE_CLUSTER_METRICS *cluster = &layout->clustermetrics[index];
|
|
|
|
|
|
|
|
if (!cluster->isNewline && !cluster->isWhitespace)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (cluster->isNewline) {
|
|
|
|
metrics.trailingWhitespaceLength += cluster->length;
|
|
|
|
metrics.newlineLength += cluster->length;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cluster->isWhitespace)
|
|
|
|
metrics.trailingWhitespaceLength += cluster->length;
|
|
|
|
|
|
|
|
strlength -= cluster->length;
|
|
|
|
index--;
|
|
|
|
}
|
|
|
|
|
|
|
|
metrics.height = 0.0; /* FIXME */
|
|
|
|
metrics.baseline = 0.0; /* FIXME */
|
|
|
|
metrics.isTrimmed = width > layout->maxwidth;
|
|
|
|
hr = layout_set_line_metrics(layout, &metrics, &line);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
width = layout->clustermetrics[i].width;
|
|
|
|
memset(&metrics, 0, sizeof(metrics));
|
|
|
|
origin_x = 0.0;
|
|
|
|
start = i;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
metrics.length += layout->clustermetrics[i].length;
|
|
|
|
width += layout->clustermetrics[i].width;
|
|
|
|
}
|
|
|
|
|
2015-06-04 22:32:30 +02:00
|
|
|
s[0] = s[1];
|
|
|
|
textpos += layout->clustermetrics[i].length;
|
2015-05-05 14:23:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
layout->line_count = line;
|
|
|
|
layout->recompute &= ~RECOMPUTE_EFFECTIVE_RUNS;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2014-08-13 21:15:46 +02:00
|
|
|
/* To be used in IDWriteTextLayout methods to validate and fix passed range */
|
|
|
|
static inline BOOL validate_text_range(struct dwrite_textlayout *layout, DWRITE_TEXT_RANGE *r)
|
|
|
|
{
|
|
|
|
if (r->startPosition >= layout->len)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (r->startPosition + r->length > layout->len)
|
|
|
|
r->length = layout->len - r->startPosition;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-06-04 16:55:26 +02: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-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:
|
|
|
|
return range->effect == value->u.effect;
|
|
|
|
case LAYOUT_RANGE_ATTR_UNDERLINE:
|
|
|
|
return range->underline == value->u.underline;
|
|
|
|
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:
|
|
|
|
return strcmpW(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;
|
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->effect == right->effect &&
|
|
|
|
left->underline == right->underline &&
|
|
|
|
left->pair_kerning == right->pair_kerning &&
|
|
|
|
left->collection == right->collection &&
|
|
|
|
!strcmpW(left->locale, right->locale) &&
|
|
|
|
!strcmpW(left->fontfamily, right->fontfamily);
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
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->effect = NULL;
|
|
|
|
range->underline = FALSE;
|
|
|
|
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
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
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->effect)
|
|
|
|
IUnknown_AddRef(range->effect);
|
|
|
|
if (range->collection)
|
|
|
|
IDWriteFontCollection_AddRef(range->collection);
|
|
|
|
ret = &range->h;
|
|
|
|
break;
|
2015-03-11 18:46:11 +01:00
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
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
|
|
|
|
|
|
|
if (h->kind == LAYOUT_RANGE_REGULAR) {
|
|
|
|
struct layout_range *range = (struct layout_range*)h;
|
|
|
|
|
|
|
|
if (range->object)
|
|
|
|
IDWriteInlineObject_Release(range->object);
|
|
|
|
if (range->effect)
|
|
|
|
IUnknown_Release(range->effect);
|
|
|
|
if (range->collection)
|
|
|
|
IDWriteFontCollection_Release(range->collection);
|
|
|
|
heap_free(range->fontfamily);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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-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-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:
|
2015-03-11 20:20:34 +01:00
|
|
|
changed = set_layout_range_iface_attr((IUnknown**)&dest->effect, (IUnknown*)value->u.effect);
|
2014-08-13 21:29:07 +02:00
|
|
|
break;
|
|
|
|
case LAYOUT_RANGE_ATTR_UNDERLINE:
|
|
|
|
changed = dest->underline != value->u.underline;
|
|
|
|
dest->underline = value->u.underline;
|
|
|
|
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:
|
|
|
|
changed = strcmpW(dest->locale, value->u.locale) != 0;
|
|
|
|
if (changed)
|
|
|
|
strcpyW(dest->locale, value->u.locale);
|
|
|
|
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;
|
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;
|
|
|
|
}
|
|
|
|
|
2014-08-13 21:15:46 +02:00
|
|
|
/* Set attribute value for given range, does all needed splitting/merging of existing ranges. */
|
|
|
|
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-01-02 22:35:04 +01:00
|
|
|
if (!validate_text_range(layout, &value->range))
|
|
|
|
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_EFFECT:
|
|
|
|
case LAYOUT_RANGE_ATTR_INLINE:
|
|
|
|
case LAYOUT_RANGE_ATTR_UNDERLINE:
|
|
|
|
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;
|
|
|
|
case LAYOUT_RANGE_ATTR_STRIKETHROUGH:
|
|
|
|
ranges = &layout->strike_ranges;
|
|
|
|
break;
|
|
|
|
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
|
|
|
|
|
|
|
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)) {
|
2014-08-15 05:10:58 +02: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);
|
2014-08-15 05:10:58 +02: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
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_QueryInterface(IDWriteTextLayout2 *iface, REFIID riid, void **obj)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
|
|
|
|
|
2015-03-15 00:38:32 +01:00
|
|
|
*obj = NULL;
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
if (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
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &IID_IDWriteTextFormat1) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteTextFormat))
|
|
|
|
*obj = &This->IDWriteTextFormat1_iface;
|
|
|
|
|
|
|
|
if (*obj) {
|
2014-10-10 11:38:54 +02:00
|
|
|
IDWriteTextLayout2_AddRef(iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static ULONG WINAPI dwritetextlayout_AddRef(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static ULONG WINAPI dwritetextlayout_Release(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
|
2014-08-13 21:15:46 +02:00
|
|
|
if (!ref) {
|
2014-08-19 04:22:56 +02:00
|
|
|
free_layout_ranges_list(This);
|
2015-05-05 14:23:17 +02:00
|
|
|
free_layout_eruns(This);
|
2014-12-23 13:36:32 +01:00
|
|
|
free_layout_runs(This);
|
2012-10-26 18:50:12 +02:00
|
|
|
release_format_data(&This->format);
|
2014-12-25 22:01:28 +01:00
|
|
|
heap_free(This->nominal_breakpoints);
|
|
|
|
heap_free(This->actual_breakpoints);
|
2015-04-23 12:02:43 +02:00
|
|
|
heap_free(This->clustermetrics);
|
2015-01-11 22:03:31 +01:00
|
|
|
heap_free(This->clusters);
|
2015-05-05 14:23:17 +02:00
|
|
|
heap_free(This->lines);
|
2012-10-20 23:02:25 +02:00
|
|
|
heap_free(This->str);
|
2012-09-28 10:13:17 +02:00
|
|
|
heap_free(This);
|
2012-10-20 23:02:25 +02:00
|
|
|
}
|
2012-09-28 10:13:17 +02:00
|
|
|
|
2012-10-21 03:47:22 +02:00
|
|
|
return ref;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetTextAlignment(IDWriteTextLayout2 *iface, DWRITE_TEXT_ALIGNMENT alignment)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, alignment);
|
|
|
|
return IDWriteTextFormat1_SetTextAlignment(&This->IDWriteTextFormat1_iface, alignment);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetParagraphAlignment(IDWriteTextLayout2 *iface, DWRITE_PARAGRAPH_ALIGNMENT alignment)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, alignment);
|
|
|
|
return IDWriteTextFormat1_SetParagraphAlignment(&This->IDWriteTextFormat1_iface, alignment);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetWordWrapping(IDWriteTextLayout2 *iface, DWRITE_WORD_WRAPPING wrapping)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, wrapping);
|
|
|
|
return IDWriteTextFormat1_SetWordWrapping(&This->IDWriteTextFormat1_iface, wrapping);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetReadingDirection(IDWriteTextLayout2 *iface, DWRITE_READING_DIRECTION direction)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, direction);
|
|
|
|
return IDWriteTextFormat1_SetReadingDirection(&This->IDWriteTextFormat1_iface, direction);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetFlowDirection(IDWriteTextLayout2 *iface, DWRITE_FLOW_DIRECTION direction)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, direction);
|
|
|
|
return IDWriteTextFormat1_SetFlowDirection(&This->IDWriteTextFormat1_iface, direction);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetIncrementalTabStop(IDWriteTextLayout2 *iface, FLOAT tabstop)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
TRACE("(%p)->(%.2f)\n", This, tabstop);
|
|
|
|
return IDWriteTextFormat1_SetIncrementalTabStop(&This->IDWriteTextFormat1_iface, tabstop);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetTrimming(IDWriteTextLayout2 *iface, DWRITE_TRIMMING const *trimming,
|
2012-09-28 10:13:17 +02:00
|
|
|
IDWriteInlineObject *trimming_sign)
|
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, trimming, trimming_sign);
|
|
|
|
return IDWriteTextFormat1_SetTrimming(&This->IDWriteTextFormat1_iface, trimming, trimming_sign);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetLineSpacing(IDWriteTextLayout2 *iface, DWRITE_LINE_SPACING_METHOD spacing,
|
2012-09-28 10:13:17 +02:00
|
|
|
FLOAT line_spacing, FLOAT baseline)
|
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
TRACE("(%p)->(%d %.2f %.2f)\n", This, spacing, line_spacing, baseline);
|
|
|
|
return IDWriteTextFormat1_SetLineSpacing(&This->IDWriteTextFormat1_iface, spacing, line_spacing, baseline);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static DWRITE_TEXT_ALIGNMENT WINAPI dwritetextlayout_GetTextAlignment(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-15 05:27:30 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2015-03-15 00:38:32 +01:00
|
|
|
return IDWriteTextFormat1_GetTextAlignment(&This->IDWriteTextFormat1_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static DWRITE_PARAGRAPH_ALIGNMENT WINAPI dwritetextlayout_GetParagraphAlignment(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-15 05:27:30 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2015-03-15 00:38:32 +01:00
|
|
|
return IDWriteTextFormat1_GetParagraphAlignment(&This->IDWriteTextFormat1_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static DWRITE_WORD_WRAPPING WINAPI dwritetextlayout_GetWordWrapping(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return IDWriteTextFormat1_GetWordWrapping(&This->IDWriteTextFormat1_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static DWRITE_READING_DIRECTION WINAPI dwritetextlayout_GetReadingDirection(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-15 05:27:30 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2015-03-15 00:38:32 +01:00
|
|
|
return IDWriteTextFormat1_GetReadingDirection(&This->IDWriteTextFormat1_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static DWRITE_FLOW_DIRECTION WINAPI dwritetextlayout_GetFlowDirection(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-15 05:27:30 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2015-03-15 00:38:32 +01:00
|
|
|
return IDWriteTextFormat1_GetFlowDirection(&This->IDWriteTextFormat1_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static FLOAT WINAPI dwritetextlayout_GetIncrementalTabStop(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-15 00:38:32 +01:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return IDWriteTextFormat1_GetIncrementalTabStop(&This->IDWriteTextFormat1_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetTrimming(IDWriteTextLayout2 *iface, DWRITE_TRIMMING *options,
|
2012-09-28 10:13:17 +02:00
|
|
|
IDWriteInlineObject **trimming_sign)
|
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-15 05:27:30 +02:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, options, trimming_sign);
|
2015-03-15 00:38:32 +01:00
|
|
|
return IDWriteTextFormat1_GetTrimming(&This->IDWriteTextFormat1_iface, options, trimming_sign);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetLineSpacing(IDWriteTextLayout2 *iface, DWRITE_LINE_SPACING_METHOD *method,
|
2012-09-28 10:13:17 +02:00
|
|
|
FLOAT *spacing, FLOAT *baseline)
|
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-15 05:27:30 +02:00
|
|
|
TRACE("(%p)->(%p %p %p)\n", This, method, spacing, baseline);
|
2015-03-15 00:38:32 +01:00
|
|
|
return IDWriteTextFormat1_GetLineSpacing(&This->IDWriteTextFormat1_iface, method, spacing, baseline);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetFontCollection(IDWriteTextLayout2 *iface, IDWriteFontCollection **collection)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-15 05:27:30 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, collection);
|
2015-03-15 00:38:32 +01:00
|
|
|
return IDWriteTextFormat1_GetFontCollection(&This->IDWriteTextFormat1_iface, collection);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static UINT32 WINAPI dwritetextlayout_GetFontFamilyNameLength(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-15 05:27:30 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2015-03-15 00:38:32 +01:00
|
|
|
return IDWriteTextFormat1_GetFontFamilyNameLength(&This->IDWriteTextFormat1_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetFontFamilyName(IDWriteTextLayout2 *iface, WCHAR *name, UINT32 size)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-15 05:27:30 +02:00
|
|
|
TRACE("(%p)->(%p %u)\n", This, name, size);
|
2015-03-15 00:38:32 +01:00
|
|
|
return IDWriteTextFormat1_GetFontFamilyName(&This->IDWriteTextFormat1_iface, name, size);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static DWRITE_FONT_WEIGHT WINAPI dwritetextlayout_GetFontWeight(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-15 05:27:30 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2015-03-15 00:38:32 +01:00
|
|
|
return IDWriteTextFormat1_GetFontWeight(&This->IDWriteTextFormat1_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static DWRITE_FONT_STYLE WINAPI dwritetextlayout_GetFontStyle(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-15 05:27:30 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2015-03-15 00:38:32 +01:00
|
|
|
return IDWriteTextFormat1_GetFontStyle(&This->IDWriteTextFormat1_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static DWRITE_FONT_STRETCH WINAPI dwritetextlayout_GetFontStretch(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-15 05:27:30 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2015-03-15 00:38:32 +01:00
|
|
|
return IDWriteTextFormat1_GetFontStretch(&This->IDWriteTextFormat1_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static FLOAT WINAPI dwritetextlayout_GetFontSize(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-15 05:27:30 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2015-03-15 00:38:32 +01:00
|
|
|
return IDWriteTextFormat1_GetFontSize(&This->IDWriteTextFormat1_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static UINT32 WINAPI dwritetextlayout_GetLocaleNameLength(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2012-10-26 18:50:12 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2015-03-15 00:38:32 +01:00
|
|
|
return IDWriteTextFormat1_GetLocaleNameLength(&This->IDWriteTextFormat1_iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetLocaleName(IDWriteTextLayout2 *iface, WCHAR *name, UINT32 size)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2012-10-26 18:50:12 +02:00
|
|
|
TRACE("(%p)->(%p %u)\n", This, name, size);
|
2015-03-15 00:38:32 +01:00
|
|
|
return IDWriteTextFormat1_GetLocaleName(&This->IDWriteTextFormat1_iface, name, size);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetMaxWidth(IDWriteTextLayout2 *iface, FLOAT maxWidth)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-07-30 17:59:07 +02:00
|
|
|
TRACE("(%p)->(%.1f)\n", This, maxWidth);
|
2014-10-14 08:03:28 +02:00
|
|
|
|
|
|
|
if (maxWidth < 0.0)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2014-07-30 17:59:07 +02:00
|
|
|
This->maxwidth = maxWidth;
|
|
|
|
return S_OK;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetMaxHeight(IDWriteTextLayout2 *iface, FLOAT maxHeight)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-07-30 17:59:07 +02:00
|
|
|
TRACE("(%p)->(%.1f)\n", This, maxHeight);
|
2014-10-14 08:03:28 +02:00
|
|
|
|
|
|
|
if (maxHeight < 0.0)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2014-07-30 17:59:07 +02:00
|
|
|
This->maxheight = maxHeight;
|
|
|
|
return S_OK;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetFontCollection(IDWriteTextLayout2 *iface, IDWriteFontCollection* collection, DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-24 17:24:18 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %s)\n", This, collection, debugstr_range(&range));
|
|
|
|
|
|
|
|
value.range = range;
|
|
|
|
value.u.collection = collection;
|
|
|
|
return set_layout_range_attr(This, LAYOUT_RANGE_ATTR_FONTCOLL, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetFontFamilyName(IDWriteTextLayout2 *iface, WCHAR const *name, DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-01-02 20:22:40 +01:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %s)\n", This, debugstr_w(name), debugstr_range(&range));
|
|
|
|
|
|
|
|
if (!name)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
value.range = range;
|
|
|
|
value.u.fontfamily = name;
|
|
|
|
return set_layout_range_attr(This, LAYOUT_RANGE_ATTR_FONTFAMILY, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetFontWeight(IDWriteTextLayout2 *iface, DWRITE_FONT_WEIGHT weight, DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-13 21:15:46 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s)\n", This, weight, debugstr_range(&range));
|
|
|
|
|
|
|
|
value.range = range;
|
|
|
|
value.u.weight = weight;
|
|
|
|
return set_layout_range_attr(This, LAYOUT_RANGE_ATTR_WEIGHT, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetFontStyle(IDWriteTextLayout2 *iface, DWRITE_FONT_STYLE style, DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-13 21:29:07 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s)\n", This, style, debugstr_range(&range));
|
|
|
|
|
|
|
|
value.range = range;
|
|
|
|
value.u.style = style;
|
|
|
|
return set_layout_range_attr(This, LAYOUT_RANGE_ATTR_STYLE, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetFontStretch(IDWriteTextLayout2 *iface, DWRITE_FONT_STRETCH stretch, DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-24 17:24:18 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s)\n", This, stretch, debugstr_range(&range));
|
|
|
|
|
|
|
|
value.range = range;
|
|
|
|
value.u.stretch = stretch;
|
|
|
|
return set_layout_range_attr(This, LAYOUT_RANGE_ATTR_STRETCH, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetFontSize(IDWriteTextLayout2 *iface, FLOAT size, DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-24 18:46:16 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%.2f %s)\n", This, size, debugstr_range(&range));
|
|
|
|
|
|
|
|
value.range = range;
|
|
|
|
value.u.fontsize = size;
|
|
|
|
return set_layout_range_attr(This, LAYOUT_RANGE_ATTR_FONTSIZE, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetUnderline(IDWriteTextLayout2 *iface, BOOL underline, DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-13 21:29:07 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s)\n", This, underline, debugstr_range(&range));
|
|
|
|
|
|
|
|
value.range = range;
|
|
|
|
value.u.underline = underline;
|
|
|
|
return set_layout_range_attr(This, LAYOUT_RANGE_ATTR_UNDERLINE, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetStrikethrough(IDWriteTextLayout2 *iface, BOOL strikethrough, DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-13 21:29:07 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s)\n", This, strikethrough, debugstr_range(&range));
|
|
|
|
|
|
|
|
value.range = range;
|
2015-05-01 10:33:24 +02:00
|
|
|
value.u.strikethrough = strikethrough;
|
2014-08-13 21:29:07 +02:00
|
|
|
return set_layout_range_attr(This, LAYOUT_RANGE_ATTR_STRIKETHROUGH, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetDrawingEffect(IDWriteTextLayout2 *iface, IUnknown* effect, DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-13 21:29:07 +02:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %s)\n", This, effect, debugstr_range(&range));
|
|
|
|
|
|
|
|
value.range = range;
|
|
|
|
value.u.effect = effect;
|
|
|
|
return set_layout_range_attr(This, LAYOUT_RANGE_ATTR_EFFECT, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2015-01-01 19:50:59 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetInlineObject(IDWriteTextLayout2 *iface, IDWriteInlineObject *object, DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-01-02 20:25:28 +01:00
|
|
|
struct layout_range_attr_value value;
|
2014-08-13 21:15:46 +02:00
|
|
|
|
2015-01-01 19:50:59 +01:00
|
|
|
TRACE("(%p)->(%p %s)\n", This, 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;
|
|
|
|
return set_layout_range_attr(This, LAYOUT_RANGE_ATTR_INLINE, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetTypography(IDWriteTextLayout2 *iface, IDWriteTypography* typography, DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-07-30 17:21:36 +02:00
|
|
|
FIXME("(%p)->(%p %s): stub\n", This, typography, debugstr_range(&range));
|
2012-09-28 10:13:17 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_SetLocaleName(IDWriteTextLayout2 *iface, WCHAR const* locale, DWRITE_TEXT_RANGE range)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-01-02 20:25:28 +01:00
|
|
|
struct layout_range_attr_value value;
|
2015-01-01 19:50:59 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %s)\n", This, debugstr_w(locale), debugstr_range(&range));
|
|
|
|
|
|
|
|
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;
|
|
|
|
return set_layout_range_attr(This, LAYOUT_RANGE_ATTR_LOCALE, &value);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static FLOAT WINAPI dwritetextlayout_GetMaxWidth(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-07-30 17:59:07 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->maxwidth;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static FLOAT WINAPI dwritetextlayout_GetMaxHeight(IDWriteTextLayout2 *iface)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-07-30 17:59:07 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->maxheight;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetFontCollection(IDWriteTextLayout2 *iface, UINT32 position,
|
2014-08-24 17:24:18 +02:00
|
|
|
IDWriteFontCollection** collection, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-24 17:24:18 +02:00
|
|
|
struct layout_range *range;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p %p)\n", This, position, collection, r);
|
|
|
|
|
2015-06-03 17:57:54 +02:00
|
|
|
if (position >= This->len)
|
|
|
|
return S_OK;
|
|
|
|
|
2014-08-24 17:24:18 +02:00
|
|
|
range = get_layout_range_by_pos(This, 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
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetFontFamilyNameLength(IDWriteTextLayout2 *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
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-01-02 20:22:40 +01:00
|
|
|
TRACE("(%p)->(%d %p %p)\n", This, position, length, r);
|
|
|
|
return get_string_attribute_length(This, LAYOUT_RANGE_ATTR_FONTFAMILY, position, length, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetFontFamilyName(IDWriteTextLayout2 *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
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-01-02 20:22:40 +01:00
|
|
|
TRACE("(%p)->(%u %p %u %p)\n", This, position, name, length, r);
|
|
|
|
return get_string_attribute_value(This, LAYOUT_RANGE_ATTR_FONTFAMILY, position, name, length, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetFontWeight(IDWriteTextLayout2 *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
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-13 21:15:46 +02:00
|
|
|
struct layout_range *range;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p %p)\n", This, position, weight, r);
|
|
|
|
|
|
|
|
if (position >= This->len)
|
|
|
|
return S_OK;
|
|
|
|
|
2014-08-19 04:22:56 +02:00
|
|
|
range = get_layout_range_by_pos(This, 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
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetFontStyle(IDWriteTextLayout2 *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
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-13 21:29:07 +02:00
|
|
|
struct layout_range *range;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p %p)\n", This, position, style, r);
|
|
|
|
|
|
|
|
if (position >= This->len)
|
|
|
|
return S_OK;
|
|
|
|
|
2014-08-19 04:22:56 +02:00
|
|
|
range = get_layout_range_by_pos(This, 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
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetFontStretch(IDWriteTextLayout2 *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
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-24 17:24:18 +02:00
|
|
|
struct layout_range *range;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p %p)\n", This, position, stretch, r);
|
|
|
|
|
|
|
|
if (position >= This->len)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
range = get_layout_range_by_pos(This, position);
|
|
|
|
*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
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetFontSize(IDWriteTextLayout2 *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
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-24 18:46:16 +02:00
|
|
|
struct layout_range *range;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p %p)\n", This, position, size, r);
|
|
|
|
|
|
|
|
if (position >= This->len)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
range = get_layout_range_by_pos(This, position);
|
|
|
|
*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
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetUnderline(IDWriteTextLayout2 *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
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-13 21:29:07 +02:00
|
|
|
struct layout_range *range;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p %p)\n", This, position, underline, r);
|
|
|
|
|
|
|
|
if (position >= This->len)
|
|
|
|
return S_OK;
|
|
|
|
|
2014-08-19 04:22:56 +02:00
|
|
|
range = get_layout_range_by_pos(This, position);
|
2014-08-13 21:29:07 +02:00
|
|
|
*underline = range->underline;
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
return return_range(&range->h, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetStrikethrough(IDWriteTextLayout2 *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
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-06-04 16:55:26 +02:00
|
|
|
struct layout_range_bool *range;
|
2014-08-13 21:29:07 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p %p)\n", This, position, strikethrough, r);
|
|
|
|
|
|
|
|
if (position >= This->len)
|
|
|
|
return S_OK;
|
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
range = (struct layout_range_bool*)get_layout_range_header_by_pos(&This->strike_ranges, position);
|
|
|
|
*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
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetDrawingEffect(IDWriteTextLayout2 *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
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-13 21:29:07 +02:00
|
|
|
struct layout_range *range;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p %p)\n", This, position, effect, r);
|
|
|
|
|
|
|
|
if (position >= This->len)
|
|
|
|
return S_OK;
|
|
|
|
|
2014-08-19 04:22:56 +02:00
|
|
|
range = get_layout_range_by_pos(This, position);
|
2014-08-13 21:29:07 +02:00
|
|
|
*effect = range->effect;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetInlineObject(IDWriteTextLayout2 *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
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-08-13 21:15:46 +02:00
|
|
|
struct layout_range *range;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p %p)\n", This, position, object, r);
|
|
|
|
|
2015-05-31 14:11:56 +02:00
|
|
|
if (position >= This->len)
|
|
|
|
return S_OK;
|
|
|
|
|
2014-08-19 04:22:56 +02:00
|
|
|
range = get_layout_range_by_pos(This, 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
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetTypography(IDWriteTextLayout2 *iface,
|
2012-09-28 10:13:17 +02:00
|
|
|
UINT32 position, IDWriteTypography** typography, DWRITE_TEXT_RANGE *range)
|
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
FIXME("(%p)->(%u %p %p): stub\n", This, position, typography, range);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetLocaleNameLength(IDWriteTextLayout2 *iface,
|
2015-01-01 19:50:59 +01:00
|
|
|
UINT32 position, UINT32* length, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-01-01 19:50:59 +01:00
|
|
|
TRACE("(%p)->(%u %p %p)\n", This, position, length, r);
|
2015-01-02 20:22:40 +01:00
|
|
|
return get_string_attribute_length(This, LAYOUT_RANGE_ATTR_LOCALE, position, length, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_layout_GetLocaleName(IDWriteTextLayout2 *iface,
|
2015-01-01 19:50:59 +01:00
|
|
|
UINT32 position, WCHAR* locale, UINT32 length, DWRITE_TEXT_RANGE *r)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-01-01 19:50:59 +01:00
|
|
|
TRACE("(%p)->(%u %p %u %p)\n", This, position, locale, length, r);
|
2015-01-02 20:22:40 +01:00
|
|
|
return get_string_attribute_value(This, LAYOUT_RANGE_ATTR_LOCALE, position, locale, length, r);
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_Draw(IDWriteTextLayout2 *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
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
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;
|
2015-05-05 14:23:17 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p %.2f %.2f)\n", This, context, renderer, origin_x, origin_y);
|
|
|
|
|
|
|
|
hr = layout_compute_effective_runs(This);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
/* 1. Regular runs */
|
|
|
|
LIST_FOR_EACH_ENTRY(run, &This->eruns, struct layout_effective_run, entry) {
|
|
|
|
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,
|
|
|
|
run->origin_x + origin_x,
|
|
|
|
run->origin_y + origin_y,
|
|
|
|
DWRITE_MEASURING_MODE_NATURAL,
|
|
|
|
&glyph_run,
|
|
|
|
&descr,
|
2015-05-30 23:01:45 +02:00
|
|
|
run->run->effect);
|
2015-05-05 14:23:17 +02:00
|
|
|
}
|
|
|
|
|
2015-05-30 17:44:54 +02:00
|
|
|
/* 2. Inline objects */
|
|
|
|
LIST_FOR_EACH_ENTRY(inlineobject, &This->inlineobjects, struct layout_effective_inline, entry) {
|
|
|
|
IDWriteTextRenderer_DrawInlineObject(renderer,
|
|
|
|
context,
|
|
|
|
inlineobject->origin_x,
|
|
|
|
inlineobject->origin_y,
|
|
|
|
inlineobject->object,
|
|
|
|
inlineobject->is_sideways,
|
|
|
|
inlineobject->is_rtl,
|
2015-05-30 23:01:45 +02:00
|
|
|
run->run->effect);
|
2015-05-30 17:44:54 +02:00
|
|
|
}
|
|
|
|
|
2015-05-05 14:23:17 +02:00
|
|
|
/* TODO: 3. Underlines */
|
2015-06-04 22:32:30 +02:00
|
|
|
|
|
|
|
/* 4. Strikethrough */
|
|
|
|
LIST_FOR_EACH_ENTRY(s, &This->strikethrough, struct layout_strikethrough, entry) {
|
|
|
|
IDWriteTextRenderer_DrawStrikethrough(renderer,
|
|
|
|
context,
|
|
|
|
s->run->origin_x,
|
|
|
|
s->run->origin_y,
|
|
|
|
&s->s,
|
|
|
|
s->run->run->effect);
|
|
|
|
}
|
2015-05-05 14:23:17 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetLineMetrics(IDWriteTextLayout2 *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
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-05-05 14:23:17 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %u %p)\n", This, metrics, max_count, count);
|
|
|
|
|
|
|
|
hr = layout_compute_effective_runs(This);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (metrics)
|
|
|
|
memcpy(metrics, This->lines, sizeof(DWRITE_LINE_METRICS)*min(max_count, This->line_count));
|
|
|
|
|
|
|
|
*count = This->line_count;
|
|
|
|
return max_count >= This->line_count ? S_OK : E_NOT_SUFFICIENT_BUFFER;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetMetrics(IDWriteTextLayout2 *iface, DWRITE_TEXT_METRICS *metrics)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-21 17:27:21 +01:00
|
|
|
DWRITE_TEXT_METRICS1 metrics1;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, metrics);
|
|
|
|
|
|
|
|
hr = IDWriteTextLayout2_GetMetrics(iface, &metrics1);
|
|
|
|
if (hr == S_OK)
|
|
|
|
memcpy(metrics, &metrics1, sizeof(*metrics));
|
|
|
|
|
|
|
|
return hr;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetOverhangMetrics(IDWriteTextLayout2 *iface, DWRITE_OVERHANG_METRICS *overhangs)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
FIXME("(%p)->(%p): stub\n", This, overhangs);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_GetClusterMetrics(IDWriteTextLayout2 *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
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2014-12-23 13:36:32 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2015-01-12 11:56:27 +01:00
|
|
|
TRACE("(%p)->(%p %u %p)\n", This, metrics, max_count, count);
|
2014-12-23 13:36:32 +01:00
|
|
|
|
|
|
|
hr = layout_compute(This);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2015-01-12 11:56:27 +01:00
|
|
|
if (metrics)
|
2015-05-05 14:23:17 +02:00
|
|
|
memcpy(metrics, This->clustermetrics, sizeof(DWRITE_CLUSTER_METRICS)*min(max_count, This->cluster_count));
|
2015-01-12 11:56:27 +01:00
|
|
|
|
2015-05-05 14:23:17 +02:00
|
|
|
*count = This->cluster_count;
|
|
|
|
return max_count >= This->cluster_count ? S_OK : E_NOT_SUFFICIENT_BUFFER;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2015-03-30 09:15:48 +02:00
|
|
|
/* Only to be used with DetermineMinWidth() to find the longest cluster sequence that we don't want to try
|
|
|
|
too hard to break. */
|
|
|
|
static inline BOOL is_terminal_cluster(struct dwrite_textlayout *layout, UINT32 index)
|
|
|
|
{
|
2015-04-23 12:02:43 +02:00
|
|
|
if (layout->clustermetrics[index].isWhitespace || layout->clustermetrics[index].isNewline ||
|
2015-05-05 14:23:17 +02:00
|
|
|
(index == layout->cluster_count - 1))
|
2015-03-30 09:15:48 +02:00
|
|
|
return TRUE;
|
|
|
|
/* check next one */
|
2015-05-05 14:23:17 +02:00
|
|
|
return (index < layout->cluster_count - 1) && layout->clustermetrics[index+1].isWhitespace;
|
2015-03-30 09:15:48 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_DetermineMinWidth(IDWriteTextLayout2 *iface, FLOAT* min_width)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-30 09:15:48 +02:00
|
|
|
FLOAT width;
|
|
|
|
HRESULT hr;
|
|
|
|
UINT32 i;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, min_width);
|
|
|
|
|
|
|
|
if (!min_width)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (!(This->recompute & RECOMPUTE_MINIMAL_WIDTH))
|
|
|
|
goto width_done;
|
|
|
|
|
|
|
|
*min_width = 0.0;
|
|
|
|
hr = layout_compute(This);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2015-05-05 14:23:17 +02:00
|
|
|
for (i = 0; i < This->cluster_count;) {
|
2015-03-30 09:15:48 +02:00
|
|
|
if (is_terminal_cluster(This, i)) {
|
2015-04-23 12:02:43 +02:00
|
|
|
width = This->clustermetrics[i].width;
|
2015-03-30 09:15:48 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
width = 0.0;
|
|
|
|
while (!is_terminal_cluster(This, i)) {
|
2015-04-23 12:02:43 +02:00
|
|
|
width += This->clustermetrics[i].width;
|
2015-03-30 09:15:48 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
/* count last one too */
|
2015-04-23 12:02:43 +02:00
|
|
|
width += This->clustermetrics[i].width;
|
2015-03-30 09:15:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (width > This->minwidth)
|
|
|
|
This->minwidth = width;
|
|
|
|
}
|
|
|
|
This->recompute &= ~RECOMPUTE_MINIMAL_WIDTH;
|
|
|
|
|
|
|
|
width_done:
|
|
|
|
*min_width = This->minwidth;
|
|
|
|
return S_OK;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_HitTestPoint(IDWriteTextLayout2 *iface,
|
2012-09-28 10:13:17 +02:00
|
|
|
FLOAT pointX, FLOAT pointY, BOOL* is_trailinghit, BOOL* is_inside, DWRITE_HIT_TEST_METRICS *metrics)
|
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
FIXME("(%p)->(%f %f %p %p %p): stub\n", This, pointX, pointY, is_trailinghit, is_inside, metrics);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_HitTestTextPosition(IDWriteTextLayout2 *iface,
|
2012-09-28 10:13:17 +02:00
|
|
|
UINT32 textPosition, BOOL is_trailinghit, FLOAT* pointX, FLOAT* pointY, DWRITE_HIT_TEST_METRICS *metrics)
|
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
FIXME("(%p)->(%u %d %p %p %p): stub\n", This, textPosition, is_trailinghit, pointX, pointY, metrics);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout_HitTestTextRange(IDWriteTextLayout2 *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)
|
|
|
|
{
|
2014-10-10 11:38:54 +02:00
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2012-09-28 10:13:17 +02:00
|
|
|
FIXME("(%p)->(%u %u %f %f %p %u %p): stub\n", This, textPosition, textLength, originX, originY, metrics,
|
|
|
|
max_metricscount, actual_metricscount);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2014-10-10 11:38:54 +02:00
|
|
|
static HRESULT WINAPI dwritetextlayout1_SetPairKerning(IDWriteTextLayout2 *iface, BOOL is_pairkerning_enabled,
|
|
|
|
DWRITE_TEXT_RANGE range)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-13 09:25:18 +01:00
|
|
|
struct layout_range_attr_value value;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s)\n", This, is_pairkerning_enabled, debugstr_range(&range));
|
|
|
|
|
|
|
|
value.range = range;
|
|
|
|
value.u.pair_kerning = !!is_pairkerning_enabled;
|
|
|
|
return set_layout_range_attr(This, LAYOUT_RANGE_ATTR_PAIR_KERNING, &value);
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout1_GetPairKerning(IDWriteTextLayout2 *iface, UINT32 position, BOOL *is_pairkerning_enabled,
|
2015-03-13 09:25:18 +01:00
|
|
|
DWRITE_TEXT_RANGE *r)
|
2014-10-10 11:38:54 +02:00
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-13 09:25:18 +01:00
|
|
|
struct layout_range *range;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p %p)\n", This, position, is_pairkerning_enabled, r);
|
|
|
|
|
|
|
|
if (position >= This->len)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
range = get_layout_range_by_pos(This, position);
|
|
|
|
*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
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout1_SetCharacterSpacing(IDWriteTextLayout2 *iface, FLOAT leading_spacing, FLOAT trailing_spacing,
|
|
|
|
FLOAT minimum_advance_width, DWRITE_TEXT_RANGE range)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
|
|
|
FIXME("(%p)->(%f %f %f %s): stub\n", This, leading_spacing, trailing_spacing, minimum_advance_width, debugstr_range(&range));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout1_GetCharacterSpacing(IDWriteTextLayout2 *iface, UINT32 position, FLOAT* leading_spacing,
|
|
|
|
FLOAT* trailing_spacing, FLOAT* minimum_advance_width, DWRITE_TEXT_RANGE *range)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
|
|
|
FIXME("(%p)->(%u %p %p %p %p): stub\n", This, position, leading_spacing, trailing_spacing, minimum_advance_width, range);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout2_GetMetrics(IDWriteTextLayout2 *iface, DWRITE_TEXT_METRICS1 *metrics)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
|
|
|
FIXME("(%p)->(%p): stub\n", This, metrics);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout2_SetVerticalGlyphOrientation(IDWriteTextLayout2 *iface, DWRITE_VERTICAL_GLYPH_ORIENTATION orientation)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-13 09:58:32 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, orientation);
|
|
|
|
|
|
|
|
if ((UINT32)orientation > DWRITE_VERTICAL_GLYPH_ORIENTATION_STACKED)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
This->format.vertical_orientation = orientation;
|
|
|
|
return S_OK;
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_VERTICAL_GLYPH_ORIENTATION WINAPI dwritetextlayout2_GetVerticalGlyphOrientation(IDWriteTextLayout2 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-13 09:58:32 +01:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.vertical_orientation;
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout2_SetLastLineWrapping(IDWriteTextLayout2 *iface, BOOL lastline_wrapping_enabled)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
|
|
|
FIXME("(%p)->(%d): stub\n", This, lastline_wrapping_enabled);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL WINAPI dwritetextlayout2_GetLastLineWrapping(IDWriteTextLayout2 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout2_SetOpticalAlignment(IDWriteTextLayout2 *iface, DWRITE_OPTICAL_ALIGNMENT alignment)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
|
|
|
FIXME("(%p)->(%d): stub\n", This, alignment);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_OPTICAL_ALIGNMENT WINAPI dwritetextlayout2_GetOpticalAlignment(IDWriteTextLayout2 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return DWRITE_OPTICAL_ALIGNMENT_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout2_SetFontFallback(IDWriteTextLayout2 *iface, IDWriteFontFallback *fallback)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-15 01:52:35 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, fallback);
|
|
|
|
return set_fontfallback_for_format(&This->format, fallback);
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout2_GetFontFallback(IDWriteTextLayout2 *iface, IDWriteFontFallback **fallback)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
2015-03-14 22:43:20 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, fallback);
|
|
|
|
return get_fontfallback_from_format(&This->format, fallback);
|
2014-10-10 11:38:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteTextLayout2Vtbl 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,
|
|
|
|
dwritetextlayout2_GetFontFallback
|
2012-09-28 10:13:17 +02:00
|
|
|
};
|
|
|
|
|
2015-03-15 00:38:32 +01:00
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_QueryInterface(IDWriteTextFormat1 *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
|
|
|
|
return IDWriteTextLayout2_QueryInterface(&This->IDWriteTextLayout2_iface, riid, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritetextformat1_layout_AddRef(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
return IDWriteTextLayout2_AddRef(&This->IDWriteTextLayout2_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritetextformat1_layout_Release(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
return IDWriteTextLayout2_Release(&This->IDWriteTextLayout2_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_SetTextAlignment(IDWriteTextFormat1 *iface, DWRITE_TEXT_ALIGNMENT alignment)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p)->(%d): stub\n", This, alignment);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_SetParagraphAlignment(IDWriteTextFormat1 *iface, DWRITE_PARAGRAPH_ALIGNMENT alignment)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p)->(%d): stub\n", This, alignment);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_SetWordWrapping(IDWriteTextFormat1 *iface, DWRITE_WORD_WRAPPING wrapping)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p)->(%d): stub\n", This, wrapping);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_SetReadingDirection(IDWriteTextFormat1 *iface, DWRITE_READING_DIRECTION direction)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p)->(%d): stub\n", This, direction);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_SetFlowDirection(IDWriteTextFormat1 *iface, DWRITE_FLOW_DIRECTION direction)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p)->(%d): stub\n", This, direction);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_SetIncrementalTabStop(IDWriteTextFormat1 *iface, FLOAT tabstop)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p)->(%f): stub\n", This, tabstop);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_SetTrimming(IDWriteTextFormat1 *iface, DWRITE_TRIMMING const *trimming,
|
|
|
|
IDWriteInlineObject *trimming_sign)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p)->(%p %p): stub\n", This, trimming, trimming_sign);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_SetLineSpacing(IDWriteTextFormat1 *iface, DWRITE_LINE_SPACING_METHOD spacing,
|
|
|
|
FLOAT line_spacing, FLOAT baseline)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p)->(%d %f %f): stub\n", This, spacing, line_spacing, baseline);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_TEXT_ALIGNMENT WINAPI dwritetextformat1_layout_GetTextAlignment(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.textalignment;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_PARAGRAPH_ALIGNMENT WINAPI dwritetextformat1_layout_GetParagraphAlignment(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.paralign;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_WORD_WRAPPING WINAPI dwritetextformat1_layout_GetWordWrapping(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return This->format.wrapping;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_READING_DIRECTION WINAPI dwritetextformat1_layout_GetReadingDirection(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.readingdir;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_FLOW_DIRECTION WINAPI dwritetextformat1_layout_GetFlowDirection(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.flow;
|
|
|
|
}
|
|
|
|
|
|
|
|
static FLOAT WINAPI dwritetextformat1_layout_GetIncrementalTabStop(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_GetTrimming(IDWriteTextFormat1 *iface, DWRITE_TRIMMING *options,
|
|
|
|
IDWriteInlineObject **trimming_sign)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, options, trimming_sign);
|
|
|
|
|
|
|
|
*options = This->format.trimming;
|
|
|
|
*trimming_sign = This->format.trimmingsign;
|
|
|
|
if (*trimming_sign)
|
|
|
|
IDWriteInlineObject_AddRef(*trimming_sign);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_GetLineSpacing(IDWriteTextFormat1 *iface, DWRITE_LINE_SPACING_METHOD *method,
|
|
|
|
FLOAT *spacing, FLOAT *baseline)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p %p)\n", This, method, spacing, baseline);
|
|
|
|
|
|
|
|
*method = This->format.spacingmethod;
|
|
|
|
*spacing = This->format.spacing;
|
|
|
|
*baseline = This->format.baseline;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_GetFontCollection(IDWriteTextFormat1 *iface, IDWriteFontCollection **collection)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, collection);
|
|
|
|
|
|
|
|
*collection = This->format.collection;
|
|
|
|
if (*collection)
|
|
|
|
IDWriteFontCollection_AddRef(*collection);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 WINAPI dwritetextformat1_layout_GetFontFamilyNameLength(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.family_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_GetFontFamilyName(IDWriteTextFormat1 *iface, WCHAR *name, UINT32 size)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %u)\n", This, name, size);
|
|
|
|
|
|
|
|
if (size <= This->format.family_len) return E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
strcpyW(name, This->format.family_name);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_FONT_WEIGHT WINAPI dwritetextformat1_layout_GetFontWeight(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.weight;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_FONT_STYLE WINAPI dwritetextformat1_layout_GetFontStyle(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.style;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_FONT_STRETCH WINAPI dwritetextformat1_layout_GetFontStretch(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.stretch;
|
|
|
|
}
|
|
|
|
|
|
|
|
static FLOAT WINAPI dwritetextformat1_layout_GetFontSize(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.fontsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 WINAPI dwritetextformat1_layout_GetLocaleNameLength(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.locale_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_GetLocaleName(IDWriteTextFormat1 *iface, WCHAR *name, UINT32 size)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %u)\n", This, name, size);
|
|
|
|
|
|
|
|
if (size <= This->format.locale_len) return E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
strcpyW(name, This->format.locale);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_SetVerticalGlyphOrientation(IDWriteTextFormat1 *iface, DWRITE_VERTICAL_GLYPH_ORIENTATION orientation)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p)->(%d): stub\n", This, orientation);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_VERTICAL_GLYPH_ORIENTATION WINAPI dwritetextformat1_layout_GetVerticalGlyphOrientation(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return DWRITE_VERTICAL_GLYPH_ORIENTATION_DEFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_SetLastLineWrapping(IDWriteTextFormat1 *iface, BOOL lastline_wrapping_enabled)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p)->(%d): stub\n", This, lastline_wrapping_enabled);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL WINAPI dwritetextformat1_layout_GetLastLineWrapping(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_SetOpticalAlignment(IDWriteTextFormat1 *iface, DWRITE_OPTICAL_ALIGNMENT alignment)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p)->(%d): stub\n", This, alignment);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_OPTICAL_ALIGNMENT WINAPI dwritetextformat1_layout_GetOpticalAlignment(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return DWRITE_OPTICAL_ALIGNMENT_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_SetFontFallback(IDWriteTextFormat1 *iface, IDWriteFontFallback *fallback)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
2015-03-15 01:52:35 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, fallback);
|
|
|
|
return IDWriteTextLayout2_SetFontFallback(&This->IDWriteTextLayout2_iface, fallback);
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_layout_GetFontFallback(IDWriteTextFormat1 *iface, IDWriteFontFallback **fallback)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
2015-03-15 01:52:35 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, fallback);
|
|
|
|
return IDWriteTextLayout2_GetFontFallback(&This->IDWriteTextLayout2_iface, fallback);
|
2015-03-15 00:38:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteTextFormat1Vtbl dwritetextformat1_layout_vtbl = {
|
|
|
|
dwritetextformat1_layout_QueryInterface,
|
|
|
|
dwritetextformat1_layout_AddRef,
|
|
|
|
dwritetextformat1_layout_Release,
|
|
|
|
dwritetextformat1_layout_SetTextAlignment,
|
|
|
|
dwritetextformat1_layout_SetParagraphAlignment,
|
|
|
|
dwritetextformat1_layout_SetWordWrapping,
|
|
|
|
dwritetextformat1_layout_SetReadingDirection,
|
|
|
|
dwritetextformat1_layout_SetFlowDirection,
|
|
|
|
dwritetextformat1_layout_SetIncrementalTabStop,
|
|
|
|
dwritetextformat1_layout_SetTrimming,
|
|
|
|
dwritetextformat1_layout_SetLineSpacing,
|
|
|
|
dwritetextformat1_layout_GetTextAlignment,
|
|
|
|
dwritetextformat1_layout_GetParagraphAlignment,
|
|
|
|
dwritetextformat1_layout_GetWordWrapping,
|
|
|
|
dwritetextformat1_layout_GetReadingDirection,
|
|
|
|
dwritetextformat1_layout_GetFlowDirection,
|
|
|
|
dwritetextformat1_layout_GetIncrementalTabStop,
|
|
|
|
dwritetextformat1_layout_GetTrimming,
|
|
|
|
dwritetextformat1_layout_GetLineSpacing,
|
|
|
|
dwritetextformat1_layout_GetFontCollection,
|
|
|
|
dwritetextformat1_layout_GetFontFamilyNameLength,
|
|
|
|
dwritetextformat1_layout_GetFontFamilyName,
|
|
|
|
dwritetextformat1_layout_GetFontWeight,
|
|
|
|
dwritetextformat1_layout_GetFontStyle,
|
|
|
|
dwritetextformat1_layout_GetFontStretch,
|
|
|
|
dwritetextformat1_layout_GetFontSize,
|
|
|
|
dwritetextformat1_layout_GetLocaleNameLength,
|
|
|
|
dwritetextformat1_layout_GetLocaleName,
|
|
|
|
dwritetextformat1_layout_SetVerticalGlyphOrientation,
|
|
|
|
dwritetextformat1_layout_GetVerticalGlyphOrientation,
|
|
|
|
dwritetextformat1_layout_SetLastLineWrapping,
|
|
|
|
dwritetextformat1_layout_GetLastLineWrapping,
|
|
|
|
dwritetextformat1_layout_SetOpticalAlignment,
|
|
|
|
dwritetextformat1_layout_GetOpticalAlignment,
|
|
|
|
dwritetextformat1_layout_SetFontFallback,
|
|
|
|
dwritetextformat1_layout_GetFontFallback
|
|
|
|
};
|
|
|
|
|
2014-12-23 13:36:32 +01:00
|
|
|
static HRESULT WINAPI dwritetextlayout_sink_QueryInterface(IDWriteTextAnalysisSink *iface,
|
|
|
|
REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_IDWriteTextAnalysisSink) || IsEqualIID(riid, &IID_IUnknown)) {
|
|
|
|
*obj = iface;
|
|
|
|
IDWriteTextAnalysisSink_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritetextlayout_sink_AddRef(IDWriteTextAnalysisSink *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritetextlayout_sink_Release(IDWriteTextAnalysisSink *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout_sink_SetScriptAnalysis(IDWriteTextAnalysisSink *iface,
|
|
|
|
UINT32 position, UINT32 length, DWRITE_SCRIPT_ANALYSIS const* sa)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextAnalysisSink(iface);
|
|
|
|
struct layout_run *run;
|
|
|
|
|
|
|
|
TRACE("%u %u script=%d\n", position, length, sa->script);
|
|
|
|
|
2015-04-04 13:05:52 +02:00
|
|
|
run = alloc_layout_run(LAYOUT_RUN_REGULAR);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout_sink_SetLineBreakpoints(IDWriteTextAnalysisSink *iface,
|
|
|
|
UINT32 position, UINT32 length, DWRITE_LINE_BREAKPOINT const* breakpoints)
|
|
|
|
{
|
2014-12-25 12:03:19 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextAnalysisSink(iface);
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout_sink_SetBidiLevel(IDWriteTextAnalysisSink *iface, UINT32 position,
|
|
|
|
UINT32 length, UINT8 explicitLevel, UINT8 resolvedLevel)
|
|
|
|
{
|
2014-12-25 11:34:35 +01:00
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextAnalysisSink(iface);
|
2015-04-04 13:05:52 +02:00
|
|
|
struct layout_run *cur_run;
|
2014-12-25 11:34:35 +01:00
|
|
|
|
2015-05-22 10:27:51 +02:00
|
|
|
TRACE("%u %u %u %u\n", position, length, explicitLevel, resolvedLevel);
|
|
|
|
|
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 */
|
|
|
|
|
2015-04-04 13:05:52 +02:00
|
|
|
run = alloc_layout_run(LAYOUT_RUN_REGULAR);
|
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;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout_sink_SetNumberSubstitution(IDWriteTextAnalysisSink *iface,
|
|
|
|
UINT32 position, UINT32 length, IDWriteNumberSubstitution* substitution)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteTextAnalysisSinkVtbl dwritetextlayoutsinkvtbl = {
|
|
|
|
dwritetextlayout_sink_QueryInterface,
|
|
|
|
dwritetextlayout_sink_AddRef,
|
|
|
|
dwritetextlayout_sink_Release,
|
|
|
|
dwritetextlayout_sink_SetScriptAnalysis,
|
|
|
|
dwritetextlayout_sink_SetLineBreakpoints,
|
|
|
|
dwritetextlayout_sink_SetBidiLevel,
|
|
|
|
dwritetextlayout_sink_SetNumberSubstitution
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout_source_QueryInterface(IDWriteTextAnalysisSource *iface,
|
|
|
|
REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_IDWriteTextAnalysisSource) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
IDWriteTextAnalysisSource_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritetextlayout_source_AddRef(IDWriteTextAnalysisSource *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritetextlayout_source_Release(IDWriteTextAnalysisSource *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout_source_GetTextAtPosition(IDWriteTextAnalysisSource *iface,
|
|
|
|
UINT32 position, WCHAR const** text, UINT32* text_len)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextAnalysisSource(iface);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout_source_GetTextBeforePosition(IDWriteTextAnalysisSource *iface,
|
|
|
|
UINT32 position, WCHAR const** text, UINT32* text_len)
|
|
|
|
{
|
|
|
|
FIXME("%u %p %p: stub\n", position, text, text_len);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_READING_DIRECTION WINAPI dwritetextlayout_source_GetParagraphReadingDirection(IDWriteTextAnalysisSource *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *layout = impl_from_IDWriteTextAnalysisSource(iface);
|
|
|
|
return IDWriteTextLayout2_GetReadingDirection(&layout->IDWriteTextLayout2_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout_source_GetLocaleName(IDWriteTextAnalysisSource *iface,
|
|
|
|
UINT32 position, UINT32* text_len, WCHAR const** locale)
|
|
|
|
{
|
|
|
|
FIXME("%u %p %p: stub\n", position, text_len, locale);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextlayout_source_GetNumberSubstitution(IDWriteTextAnalysisSource *iface,
|
|
|
|
UINT32 position, UINT32* text_len, IDWriteNumberSubstitution **substitution)
|
|
|
|
{
|
|
|
|
FIXME("%u %p %p: stub\n", position, text_len, substitution);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteTextAnalysisSourceVtbl dwritetextlayoutsourcevtbl = {
|
|
|
|
dwritetextlayout_source_QueryInterface,
|
|
|
|
dwritetextlayout_source_AddRef,
|
|
|
|
dwritetextlayout_source_Release,
|
|
|
|
dwritetextlayout_source_GetTextAtPosition,
|
|
|
|
dwritetextlayout_source_GetTextBeforePosition,
|
|
|
|
dwritetextlayout_source_GetParagraphReadingDirection,
|
|
|
|
dwritetextlayout_source_GetLocaleName,
|
|
|
|
dwritetextlayout_source_GetNumberSubstitution
|
|
|
|
};
|
|
|
|
|
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-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
|
|
|
|
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);
|
|
|
|
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;
|
2014-12-26 12:14:20 +01:00
|
|
|
hr = IDWriteTextFormat_GetLineSpacing(format, &layout->format.spacingmethod,
|
|
|
|
&layout->format.spacing, &layout->format.baseline);
|
|
|
|
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) {
|
|
|
|
layout->format.vertical_orientation = IDWriteTextFormat1_GetVerticalGlyphOrientation(format1);
|
2015-03-14 22:43:20 +01:00
|
|
|
IDWriteTextFormat1_GetFontFallback(format1, &layout->format.fallback);
|
2015-03-13 09:58:32 +01:00
|
|
|
IDWriteTextFormat1_Release(format1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
layout->format.vertical_orientation = DWRITE_VERTICAL_GLYPH_ORIENTATION_DEFAULT;
|
|
|
|
|
2014-12-26 12:14:20 +01:00
|
|
|
return IDWriteTextFormat_GetFontCollection(format, &layout->format.collection);
|
2012-11-26 17:01:58 +01:00
|
|
|
}
|
|
|
|
|
2015-01-08 22:35:14 +01:00
|
|
|
static HRESULT init_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *format, FLOAT maxwidth, FLOAT maxheight, struct dwrite_textlayout *layout)
|
2012-09-28 10:13:17 +02:00
|
|
|
{
|
2015-06-04 16:55:26 +02:00
|
|
|
struct layout_range_header *range, *strike;
|
2014-08-13 21:15:46 +02:00
|
|
|
DWRITE_TEXT_RANGE r = { 0, len };
|
2014-12-26 12:14:20 +01:00
|
|
|
HRESULT hr;
|
2012-09-28 10:13:17 +02:00
|
|
|
|
2014-12-26 12:14:20 +01:00
|
|
|
layout->IDWriteTextLayout2_iface.lpVtbl = &dwritetextlayoutvtbl;
|
2015-03-15 00:38:32 +01:00
|
|
|
layout->IDWriteTextFormat1_iface.lpVtbl = &dwritetextformat1_layout_vtbl;
|
2014-12-26 12:14:20 +01:00
|
|
|
layout->IDWriteTextAnalysisSink_iface.lpVtbl = &dwritetextlayoutsinkvtbl;
|
|
|
|
layout->IDWriteTextAnalysisSource_iface.lpVtbl = &dwritetextlayoutsourcevtbl;
|
|
|
|
layout->ref = 1;
|
|
|
|
layout->len = len;
|
|
|
|
layout->maxwidth = maxwidth;
|
|
|
|
layout->maxheight = maxheight;
|
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;
|
|
|
|
layout->line_count = 0;
|
|
|
|
layout->line_alloc = 0;
|
2015-03-30 09:15:48 +02:00
|
|
|
layout->minwidth = 0.0;
|
2015-05-05 14:23:17 +02:00
|
|
|
list_init(&layout->eruns);
|
2015-05-30 17:44:54 +02:00
|
|
|
list_init(&layout->inlineobjects);
|
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);
|
2014-12-26 12:14:20 +01:00
|
|
|
memset(&layout->format, 0, sizeof(layout->format));
|
|
|
|
|
2015-01-08 22:35:14 +01:00
|
|
|
layout->gdicompatible = FALSE;
|
|
|
|
layout->pixels_per_dip = 0.0;
|
|
|
|
layout->use_gdi_natural = FALSE;
|
|
|
|
memset(&layout->transform, 0, sizeof(layout->transform));
|
|
|
|
|
2014-12-26 12:14:20 +01:00
|
|
|
layout->str = heap_strdupnW(str, len);
|
|
|
|
if (len && !layout->str) {
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto fail;
|
2014-08-13 21:15:46 +02:00
|
|
|
}
|
|
|
|
|
2014-12-26 12:14:20 +01:00
|
|
|
hr = layout_format_from_textformat(layout, format);
|
|
|
|
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);
|
|
|
|
if (!range || !strike) {
|
|
|
|
free_layout_range(range);
|
|
|
|
free_layout_range(strike);
|
2015-01-11 22:03:31 +01:00
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto fail;
|
|
|
|
}
|
2012-09-28 10:13:17 +02:00
|
|
|
|
2015-06-04 16:55:26 +02:00
|
|
|
list_add_head(&layout->ranges, &range->entry);
|
|
|
|
list_add_head(&layout->strike_ranges, &strike->entry);
|
2012-09-28 10:13:17 +02:00
|
|
|
return S_OK;
|
2014-12-26 12:14:20 +01:00
|
|
|
|
|
|
|
fail:
|
|
|
|
IDWriteTextLayout2_Release(&layout->IDWriteTextLayout2_iface);
|
|
|
|
return hr;
|
2012-09-28 10:13:17 +02:00
|
|
|
}
|
2012-10-10 20:58:20 +02:00
|
|
|
|
2015-01-08 22:35:14 +01:00
|
|
|
HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *format, FLOAT maxwidth, FLOAT maxheight, IDWriteTextLayout **ret)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *layout;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
|
|
|
|
layout = heap_alloc(sizeof(struct dwrite_textlayout));
|
|
|
|
if (!layout) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hr = init_textlayout(str, len, format, maxwidth, maxheight, layout);
|
|
|
|
if (hr == S_OK)
|
|
|
|
*ret = (IDWriteTextLayout*)&layout->IDWriteTextLayout2_iface;
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT create_gdicompat_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *format, FLOAT maxwidth, FLOAT maxheight,
|
|
|
|
FLOAT pixels_per_dip, const DWRITE_MATRIX *transform, BOOL use_gdi_natural, IDWriteTextLayout **ret)
|
|
|
|
{
|
|
|
|
struct dwrite_textlayout *layout;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
|
|
|
|
layout = heap_alloc(sizeof(struct dwrite_textlayout));
|
|
|
|
if (!layout) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hr = init_textlayout(str, len, format, maxwidth, maxheight, layout);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
/* set gdi-specific properties */
|
|
|
|
layout->gdicompatible = TRUE;
|
|
|
|
layout->pixels_per_dip = pixels_per_dip;
|
|
|
|
layout->use_gdi_natural = use_gdi_natural;
|
|
|
|
layout->transform = transform ? *transform : identity;
|
|
|
|
|
|
|
|
*ret = (IDWriteTextLayout*)&layout->IDWriteTextLayout2_iface;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
*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);
|
|
|
|
|
|
|
|
if (!ref)
|
|
|
|
heap_free(This);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetrimmingsign_Draw(IDWriteInlineObject *iface, void *context, IDWriteTextRenderer *renderer,
|
|
|
|
FLOAT originX, FLOAT originY, BOOL is_sideways, BOOL is_rtl, IUnknown *drawing_effect)
|
|
|
|
{
|
|
|
|
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
|
|
|
|
FIXME("(%p)->(%p %p %f %f %d %d %p): stub\n", This, context, renderer, originX, originY, is_sideways, is_rtl, drawing_effect);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetrimmingsign_GetMetrics(IDWriteInlineObject *iface, DWRITE_INLINE_OBJECT_METRICS *metrics)
|
|
|
|
{
|
|
|
|
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
|
|
|
|
FIXME("(%p)->(%p): stub\n", This, metrics);
|
2015-04-04 13:05:52 +02:00
|
|
|
memset(metrics, 0, sizeof(*metrics));
|
|
|
|
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);
|
|
|
|
FIXME("(%p)->(%p): stub\n", This, overhangs);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT create_trimmingsign(IDWriteInlineObject **sign)
|
|
|
|
{
|
|
|
|
struct dwrite_trimmingsign *This;
|
|
|
|
|
|
|
|
*sign = NULL;
|
|
|
|
|
|
|
|
This = heap_alloc(sizeof(struct dwrite_trimmingsign));
|
|
|
|
if (!This) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->IDWriteInlineObject_iface.lpVtbl = &dwritetrimmingsignvtbl;
|
|
|
|
This->ref = 1;
|
|
|
|
|
|
|
|
*sign = &This->IDWriteInlineObject_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_QueryInterface(IDWriteTextFormat1 *iface, REFIID riid, void **obj)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2012-10-10 20:58:20 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteTextFormat1) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteTextFormat) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
|
|
|
*obj = iface;
|
2014-10-10 11:57:28 +02:00
|
|
|
IDWriteTextFormat1_AddRef(iface);
|
2012-10-10 20:58:20 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static ULONG WINAPI dwritetextformat_AddRef(IDWriteTextFormat1 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2012-10-10 20:58:20 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static ULONG WINAPI dwritetextformat_Release(IDWriteTextFormat1 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2012-10-10 20:58:20 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
|
|
|
|
if (!ref)
|
2012-10-12 15:12:57 +02:00
|
|
|
{
|
2012-10-23 14:32:34 +02:00
|
|
|
release_format_data(&This->format);
|
2012-10-10 20:58:20 +02:00
|
|
|
heap_free(This);
|
2012-10-12 15:12:57 +02:00
|
|
|
}
|
2012-10-10 20:58:20 +02:00
|
|
|
|
2012-10-21 03:47:22 +02:00
|
|
|
return ref;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_SetTextAlignment(IDWriteTextFormat1 *iface, DWRITE_TEXT_ALIGNMENT alignment)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2014-04-07 07:18:49 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, alignment);
|
|
|
|
This->format.textalignment = alignment;
|
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_SetParagraphAlignment(IDWriteTextFormat1 *iface, DWRITE_PARAGRAPH_ALIGNMENT alignment)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2014-04-07 07:18:49 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, alignment);
|
|
|
|
This->format.paralign = alignment;
|
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_SetWordWrapping(IDWriteTextFormat1 *iface, DWRITE_WORD_WRAPPING wrapping)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2014-04-07 07:18:49 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, wrapping);
|
|
|
|
This->format.wrapping = wrapping;
|
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_SetReadingDirection(IDWriteTextFormat1 *iface, DWRITE_READING_DIRECTION direction)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2014-04-07 07:18:49 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, direction);
|
|
|
|
This->format.readingdir = direction;
|
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_SetFlowDirection(IDWriteTextFormat1 *iface, DWRITE_FLOW_DIRECTION direction)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2014-04-07 07:18:49 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, direction);
|
|
|
|
This->format.flow = direction;
|
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_SetIncrementalTabStop(IDWriteTextFormat1 *iface, FLOAT tabstop)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2012-10-10 20:58:20 +02:00
|
|
|
FIXME("(%p)->(%f): stub\n", This, tabstop);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_SetTrimming(IDWriteTextFormat1 *iface, DWRITE_TRIMMING const *trimming,
|
2012-10-10 20:58:20 +02:00
|
|
|
IDWriteInlineObject *trimming_sign)
|
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2014-04-08 05:42:06 +02:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, trimming, trimming_sign);
|
|
|
|
|
|
|
|
This->format.trimming = *trimming;
|
|
|
|
if (This->format.trimmingsign)
|
|
|
|
IDWriteInlineObject_Release(This->format.trimmingsign);
|
|
|
|
This->format.trimmingsign = trimming_sign;
|
|
|
|
if (This->format.trimmingsign)
|
|
|
|
IDWriteInlineObject_AddRef(This->format.trimmingsign);
|
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_SetLineSpacing(IDWriteTextFormat1 *iface, DWRITE_LINE_SPACING_METHOD method,
|
2014-04-07 07:18:49 +02:00
|
|
|
FLOAT spacing, FLOAT baseline)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2014-04-07 07:18:49 +02:00
|
|
|
TRACE("(%p)->(%d %f %f)\n", This, method, spacing, baseline);
|
|
|
|
This->format.spacingmethod = method;
|
|
|
|
This->format.spacing = spacing;
|
|
|
|
This->format.baseline = baseline;
|
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static DWRITE_TEXT_ALIGNMENT WINAPI dwritetextformat_GetTextAlignment(IDWriteTextFormat1 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2014-04-07 07:18:30 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.textalignment;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static DWRITE_PARAGRAPH_ALIGNMENT WINAPI dwritetextformat_GetParagraphAlignment(IDWriteTextFormat1 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2014-04-07 07:18:30 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.paralign;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static DWRITE_WORD_WRAPPING WINAPI dwritetextformat_GetWordWrapping(IDWriteTextFormat1 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2014-04-07 07:18:30 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.wrapping;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static DWRITE_READING_DIRECTION WINAPI dwritetextformat_GetReadingDirection(IDWriteTextFormat1 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2014-04-07 07:18:30 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.readingdir;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static DWRITE_FLOW_DIRECTION WINAPI dwritetextformat_GetFlowDirection(IDWriteTextFormat1 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2014-04-07 07:18:30 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.flow;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static FLOAT WINAPI dwritetextformat_GetIncrementalTabStop(IDWriteTextFormat1 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2012-10-10 20:58:20 +02:00
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_GetTrimming(IDWriteTextFormat1 *iface, DWRITE_TRIMMING *options,
|
2012-10-10 20:58:20 +02:00
|
|
|
IDWriteInlineObject **trimming_sign)
|
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2014-04-08 05:42:06 +02:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, options, trimming_sign);
|
|
|
|
|
|
|
|
*options = This->format.trimming;
|
|
|
|
if ((*trimming_sign = This->format.trimmingsign))
|
|
|
|
IDWriteInlineObject_AddRef(*trimming_sign);
|
|
|
|
|
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_GetLineSpacing(IDWriteTextFormat1 *iface, DWRITE_LINE_SPACING_METHOD *method,
|
2012-10-10 20:58:20 +02:00
|
|
|
FLOAT *spacing, FLOAT *baseline)
|
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2014-04-07 07:18:30 +02:00
|
|
|
TRACE("(%p)->(%p %p %p)\n", This, method, spacing, baseline);
|
|
|
|
|
|
|
|
*method = This->format.spacingmethod;
|
|
|
|
*spacing = This->format.spacing;
|
|
|
|
*baseline = This->format.baseline;
|
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_GetFontCollection(IDWriteTextFormat1 *iface, IDWriteFontCollection **collection)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2012-10-22 05:49:27 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, collection);
|
|
|
|
|
2012-10-23 14:32:34 +02:00
|
|
|
*collection = This->format.collection;
|
2012-10-22 05:49:27 +02:00
|
|
|
IDWriteFontCollection_AddRef(*collection);
|
|
|
|
|
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static UINT32 WINAPI dwritetextformat_GetFontFamilyNameLength(IDWriteTextFormat1 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2012-11-26 16:43:49 +01:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.family_len;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_GetFontFamilyName(IDWriteTextFormat1 *iface, WCHAR *name, UINT32 size)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2012-11-26 16:43:49 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %u)\n", This, name, size);
|
|
|
|
|
|
|
|
if (size <= This->format.family_len) return E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
strcpyW(name, This->format.family_name);
|
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static DWRITE_FONT_WEIGHT WINAPI dwritetextformat_GetFontWeight(IDWriteTextFormat1 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2012-10-23 14:37:48 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.weight;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static DWRITE_FONT_STYLE WINAPI dwritetextformat_GetFontStyle(IDWriteTextFormat1 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2012-10-23 14:37:48 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.style;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static DWRITE_FONT_STRETCH WINAPI dwritetextformat_GetFontStretch(IDWriteTextFormat1 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2012-10-23 14:37:48 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.stretch;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static FLOAT WINAPI dwritetextformat_GetFontSize(IDWriteTextFormat1 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2012-10-23 14:37:48 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2014-08-24 18:46:16 +02:00
|
|
|
return This->format.fontsize;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static UINT32 WINAPI dwritetextformat_GetLocaleNameLength(IDWriteTextFormat1 *iface)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2012-10-26 18:50:12 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.locale_len;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat_GetLocaleName(IDWriteTextFormat1 *iface, WCHAR *name, UINT32 size)
|
2012-10-10 20:58:20 +02:00
|
|
|
{
|
2014-10-10 11:57:28 +02:00
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2012-10-26 18:50:12 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %u)\n", This, name, size);
|
|
|
|
|
|
|
|
if (size <= This->format.locale_len) return E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
strcpyW(name, This->format.locale);
|
|
|
|
return S_OK;
|
2012-10-10 20:58:20 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
static HRESULT WINAPI dwritetextformat1_SetVerticalGlyphOrientation(IDWriteTextFormat1 *iface, DWRITE_VERTICAL_GLYPH_ORIENTATION orientation)
|
|
|
|
{
|
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2015-03-13 09:58:32 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, orientation);
|
|
|
|
|
|
|
|
if ((UINT32)orientation > DWRITE_VERTICAL_GLYPH_ORIENTATION_STACKED)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
This->format.vertical_orientation = orientation;
|
|
|
|
return S_OK;
|
2014-10-10 11:57:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_VERTICAL_GLYPH_ORIENTATION WINAPI dwritetextformat1_GetVerticalGlyphOrientation(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2015-03-13 09:58:32 +01:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->format.vertical_orientation;
|
2014-10-10 11:57:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_SetLastLineWrapping(IDWriteTextFormat1 *iface, BOOL lastline_wrapping_enabled)
|
|
|
|
{
|
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p)->(%d): stub\n", This, lastline_wrapping_enabled);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL WINAPI dwritetextformat1_GetLastLineWrapping(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_SetOpticalAlignment(IDWriteTextFormat1 *iface, DWRITE_OPTICAL_ALIGNMENT alignment)
|
|
|
|
{
|
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p)->(%d): stub\n", This, alignment);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWRITE_OPTICAL_ALIGNMENT WINAPI dwritetextformat1_GetOpticalAlignment(IDWriteTextFormat1 *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return DWRITE_OPTICAL_ALIGNMENT_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_SetFontFallback(IDWriteTextFormat1 *iface, IDWriteFontFallback *fallback)
|
|
|
|
{
|
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2015-03-15 01:52:35 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, fallback);
|
|
|
|
return set_fontfallback_for_format(&This->format, fallback);
|
2014-10-10 11:57:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetextformat1_GetFontFallback(IDWriteTextFormat1 *iface, IDWriteFontFallback **fallback)
|
|
|
|
{
|
|
|
|
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
2015-03-14 22:43:20 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, fallback);
|
|
|
|
return get_fontfallback_from_format(&This->format, fallback);
|
2014-10-10 11:57:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteTextFormat1Vtbl 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,
|
|
|
|
dwritetextformat1_GetFontFallback
|
2012-10-10 20:58:20 +02: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;
|
|
|
|
|
2012-10-10 20:58:20 +02:00
|
|
|
This = heap_alloc(sizeof(struct dwrite_textformat));
|
|
|
|
if (!This) return E_OUTOFMEMORY;
|
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
This->IDWriteTextFormat1_iface.lpVtbl = &dwritetextformatvtbl;
|
2012-10-10 20:58:20 +02:00
|
|
|
This->ref = 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);
|
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;
|
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;
|
|
|
|
This->format.paralign = DWRITE_PARAGRAPH_ALIGNMENT_NEAR;
|
|
|
|
This->format.wrapping = DWRITE_WORD_WRAPPING_WRAP;
|
|
|
|
This->format.readingdir = DWRITE_READING_DIRECTION_LEFT_TO_RIGHT;
|
|
|
|
This->format.flow = DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM;
|
|
|
|
This->format.spacingmethod = DWRITE_LINE_SPACING_METHOD_DEFAULT;
|
2015-03-13 09:58:32 +01:00
|
|
|
This->format.vertical_orientation = DWRITE_VERTICAL_GLYPH_ORIENTATION_DEFAULT;
|
2014-04-07 07:18:30 +02:00
|
|
|
This->format.spacing = 0.0;
|
|
|
|
This->format.baseline = 0.0;
|
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
|
|
|
|
2014-10-10 11:57:28 +02:00
|
|
|
*format = (IDWriteTextFormat*)&This->IDWriteTextFormat1_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)
|
|
|
|
{
|
|
|
|
struct dwrite_typography *typography = impl_from_IDWriteTypography(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", typography, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IDWriteTypography) || IsEqualIID(riid, &IID_IUnknown)) {
|
|
|
|
*obj = iface;
|
|
|
|
IDWriteTypography_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritetypography_AddRef(IDWriteTypography *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_typography *typography = impl_from_IDWriteTypography(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&typography->ref);
|
|
|
|
TRACE("(%p)->(%d)\n", typography, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dwritetypography_Release(IDWriteTypography *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_typography *typography = impl_from_IDWriteTypography(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&typography->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", typography, ref);
|
|
|
|
|
|
|
|
if (!ref) {
|
|
|
|
heap_free(typography->features);
|
|
|
|
heap_free(typography);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetypography_AddFontFeature(IDWriteTypography *iface, DWRITE_FONT_FEATURE feature)
|
|
|
|
{
|
|
|
|
struct dwrite_typography *typography = impl_from_IDWriteTypography(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%x %u)\n", typography, feature.nameTag, feature.parameter);
|
|
|
|
|
|
|
|
if (typography->count == typography->allocated) {
|
|
|
|
DWRITE_FONT_FEATURE *ptr = heap_realloc(typography->features, 2*typography->allocated*sizeof(DWRITE_FONT_FEATURE));
|
|
|
|
if (!ptr)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
typography->features = ptr;
|
|
|
|
typography->allocated *= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
typography->features[typography->count++] = feature;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 WINAPI dwritetypography_GetFontFeatureCount(IDWriteTypography *iface)
|
|
|
|
{
|
|
|
|
struct dwrite_typography *typography = impl_from_IDWriteTypography(iface);
|
|
|
|
TRACE("(%p)\n", typography);
|
|
|
|
return typography->count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritetypography_GetFontFeature(IDWriteTypography *iface, UINT32 index, DWRITE_FONT_FEATURE *feature)
|
|
|
|
{
|
|
|
|
struct dwrite_typography *typography = impl_from_IDWriteTypography(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p)\n", typography, index, feature);
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
typography = heap_alloc(sizeof(*typography));
|
|
|
|
if (!typography)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
typography->IDWriteTypography_iface.lpVtbl = &dwritetypographyvtbl;
|
|
|
|
typography->ref = 1;
|
|
|
|
typography->allocated = 2;
|
|
|
|
typography->count = 0;
|
|
|
|
|
|
|
|
typography->features = heap_alloc(typography->allocated*sizeof(DWRITE_FONT_FEATURE));
|
|
|
|
if (!typography->features) {
|
|
|
|
heap_free(typography);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ret = &typography->IDWriteTypography_iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|