vcruntime140_1: Add __CxxFrameHandler4 stub.
[wine.git] / dlls / dwrite / dwrite_private.h
blob5755696875e7f7cd7b03918a701a79805fdda421
1 /*
2 * Copyright 2012 Nikolay Sivov for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "dwrite_3.h"
20 #include "d2d1.h"
22 #include "wine/debug.h"
23 #include "wine/heap.h"
24 #include "wine/list.h"
25 #include "wine/unicode.h"
27 static const DWRITE_MATRIX identity =
29 1.0f, 0.0f,
30 0.0f, 1.0f,
31 0.0f, 0.0f
34 static inline LPWSTR heap_strdupW(const WCHAR *str)
36 LPWSTR ret = NULL;
38 if(str) {
39 DWORD size;
41 size = (strlenW(str)+1)*sizeof(WCHAR);
42 ret = heap_alloc(size);
43 if(ret)
44 memcpy(ret, str, size);
47 return ret;
50 static inline LPWSTR heap_strdupnW(const WCHAR *str, UINT32 len)
52 WCHAR *ret = NULL;
54 if (len)
56 ret = heap_alloc((len+1)*sizeof(WCHAR));
57 if(ret)
59 memcpy(ret, str, len*sizeof(WCHAR));
60 ret[len] = 0;
64 return ret;
67 static inline const char *debugstr_range(const DWRITE_TEXT_RANGE *range)
69 return wine_dbg_sprintf("%u:%u", range->startPosition, range->length);
72 static inline const char *debugstr_matrix(const DWRITE_MATRIX *m)
74 if (!m) return "(null)";
75 return wine_dbg_sprintf("{%.2f,%.2f,%.2f,%.2f,%.2f,%.2f}", m->m11, m->m12, m->m21, m->m22,
76 m->dx, m->dy);
79 static inline BOOL dwrite_array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
81 size_t new_capacity, max_capacity;
82 void *new_elements;
84 if (count <= *capacity)
85 return TRUE;
87 max_capacity = ~(SIZE_T)0 / size;
88 if (count > max_capacity)
89 return FALSE;
91 new_capacity = max(4, *capacity);
92 while (new_capacity < count && new_capacity <= max_capacity / 2)
93 new_capacity *= 2;
94 if (new_capacity < count)
95 new_capacity = max_capacity;
97 if (!(new_elements = heap_realloc(*elements, new_capacity * size)))
98 return FALSE;
100 *elements = new_elements;
101 *capacity = new_capacity;
103 return TRUE;
106 static inline const char *debugstr_tag(DWORD tag)
108 return debugstr_an((char *)&tag, 4);
111 const char *debugstr_sa_script(UINT16) DECLSPEC_HIDDEN;
113 static inline unsigned short get_table_entry(const unsigned short *table, WCHAR ch)
115 return table[table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0xf)];
118 static inline FLOAT get_scaled_advance_width(INT32 advance, FLOAT emSize, const DWRITE_FONT_METRICS *metrics)
120 return (FLOAT)advance * emSize / (FLOAT)metrics->designUnitsPerEm;
123 static inline BOOL is_simulation_valid(DWRITE_FONT_SIMULATIONS simulations)
125 return (simulations & ~(DWRITE_FONT_SIMULATIONS_NONE | DWRITE_FONT_SIMULATIONS_BOLD |
126 DWRITE_FONT_SIMULATIONS_OBLIQUE)) == 0;
129 struct textlayout_desc
131 IDWriteFactory7 *factory;
132 const WCHAR *string;
133 UINT32 length;
134 IDWriteTextFormat *format;
135 FLOAT max_width;
136 FLOAT max_height;
137 BOOL is_gdi_compatible;
138 /* fields below are only meaningful for gdi-compatible layout */
139 FLOAT ppdip;
140 const DWRITE_MATRIX *transform;
141 BOOL use_gdi_natural;
144 struct glyphrunanalysis_desc
146 const DWRITE_GLYPH_RUN *run;
147 const DWRITE_MATRIX *transform;
148 DWRITE_RENDERING_MODE1 rendering_mode;
149 DWRITE_MEASURING_MODE measuring_mode;
150 DWRITE_GRID_FIT_MODE gridfit_mode;
151 DWRITE_TEXT_ANTIALIAS_MODE aa_mode;
152 D2D_POINT_2F origin;
155 struct fontface_desc
157 IDWriteFactory7 *factory;
158 DWRITE_FONT_FACE_TYPE face_type;
159 IDWriteFontFile * const *files;
160 IDWriteFontFileStream *stream;
161 UINT32 files_number;
162 UINT32 index;
163 DWRITE_FONT_SIMULATIONS simulations;
164 struct dwrite_font_data *font_data; /* could be NULL when face is created directly with IDWriteFactory::CreateFontFace() */
167 struct dwrite_fonttable
169 const BYTE *data;
170 void *context;
171 UINT32 size;
172 BOOL exists;
175 struct fontfacecached
177 struct list entry;
178 IDWriteFontFace5 *fontface;
181 #define GLYPH_BLOCK_SHIFT 8
182 #define GLYPH_BLOCK_SIZE (1UL << GLYPH_BLOCK_SHIFT)
183 #define GLYPH_BLOCK_MASK (GLYPH_BLOCK_SIZE - 1)
184 #define GLYPH_MAX 65536
186 enum font_flags
188 FONT_IS_SYMBOL = 1 << 0,
189 FONT_IS_MONOSPACED = 1 << 1,
190 FONT_IS_COLORED = 1 << 2, /* CPAL/COLR support */
191 FONTFACE_HAS_KERNING_PAIRS = 1 << 3,
192 FONTFACE_HAS_VERTICAL_VARIANTS = 1 << 4
195 struct dwrite_fontface
197 IDWriteFontFace5 IDWriteFontFace5_iface;
198 IDWriteFontFaceReference IDWriteFontFaceReference_iface;
199 LONG refcount;
201 IDWriteFontFileStream *stream;
202 IDWriteFontFile **files;
203 UINT32 file_count;
204 UINT32 index;
206 IDWriteFactory7 *factory;
207 struct fontfacecached *cached;
209 USHORT simulations;
210 DWRITE_FONT_FACE_TYPE type;
211 DWRITE_FONT_METRICS1 metrics;
212 DWRITE_CARET_METRICS caret;
213 struct
215 unsigned int ascent;
216 unsigned int descent;
217 } typo_metrics;
218 INT charmap;
219 UINT32 flags;
221 struct dwrite_fonttable cmap;
222 struct dwrite_fonttable vdmx;
223 struct dwrite_fonttable gasp;
224 struct dwrite_fonttable cpal;
225 struct dwrite_fonttable colr;
226 DWRITE_GLYPH_METRICS *glyphs[GLYPH_MAX/GLYPH_BLOCK_SIZE];
228 DWRITE_FONT_STYLE style;
229 DWRITE_FONT_STRETCH stretch;
230 DWRITE_FONT_WEIGHT weight;
231 DWRITE_PANOSE panose;
232 FONTSIGNATURE fontsig;
233 UINT32 glyph_image_formats;
235 IDWriteLocalizedStrings *info_strings[DWRITE_INFORMATIONAL_STRING_SUPPORTED_SCRIPT_LANGUAGE_TAG + 1];
236 IDWriteLocalizedStrings *family_names;
237 IDWriteLocalizedStrings *names;
239 struct scriptshaping_cache *shaping_cache;
241 LOGFONTW lf;
244 extern HRESULT create_numbersubstitution(DWRITE_NUMBER_SUBSTITUTION_METHOD,const WCHAR *locale,BOOL,IDWriteNumberSubstitution**) DECLSPEC_HIDDEN;
245 extern HRESULT create_textformat(const WCHAR*,IDWriteFontCollection*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH,
246 FLOAT,const WCHAR*,IDWriteTextFormat**) DECLSPEC_HIDDEN;
247 extern HRESULT create_textlayout(const struct textlayout_desc*,IDWriteTextLayout**) DECLSPEC_HIDDEN;
248 extern HRESULT create_trimmingsign(IDWriteFactory7 *factory, IDWriteTextFormat *format,
249 IDWriteInlineObject **sign) DECLSPEC_HIDDEN;
250 extern HRESULT create_typography(IDWriteTypography**) DECLSPEC_HIDDEN;
251 extern HRESULT create_localizedstrings(IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
252 extern HRESULT add_localizedstring(IDWriteLocalizedStrings*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN;
253 extern HRESULT clone_localizedstrings(IDWriteLocalizedStrings *iface, IDWriteLocalizedStrings **strings) DECLSPEC_HIDDEN;
254 extern void set_en_localizedstring(IDWriteLocalizedStrings*,const WCHAR*) DECLSPEC_HIDDEN;
255 extern void sort_localizedstrings(IDWriteLocalizedStrings*) DECLSPEC_HIDDEN;
256 extern HRESULT get_system_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection1 **collection) DECLSPEC_HIDDEN;
257 extern HRESULT get_eudc_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 **collection) DECLSPEC_HIDDEN;
258 extern IDWriteTextAnalyzer *get_text_analyzer(void) DECLSPEC_HIDDEN;
259 extern HRESULT create_font_file(IDWriteFontFileLoader *loader, const void *reference_key, UINT32 key_size, IDWriteFontFile **font_file) DECLSPEC_HIDDEN;
260 extern void init_local_fontfile_loader(void) DECLSPEC_HIDDEN;
261 extern IDWriteFontFileLoader *get_local_fontfile_loader(void) DECLSPEC_HIDDEN;
262 extern HRESULT create_fontface(const struct fontface_desc *desc, struct list *cached_list,
263 IDWriteFontFace5 **fontface) DECLSPEC_HIDDEN;
264 extern HRESULT create_font_collection(IDWriteFactory7 *factory, IDWriteFontFileEnumerator *enumerator, BOOL is_system,
265 IDWriteFontCollection3 **collection) DECLSPEC_HIDDEN;
266 extern HRESULT create_glyphrunanalysis(const struct glyphrunanalysis_desc*,IDWriteGlyphRunAnalysis**) DECLSPEC_HIDDEN;
267 extern BOOL is_system_collection(IDWriteFontCollection*) DECLSPEC_HIDDEN;
268 extern HRESULT get_local_refkey(const WCHAR*,const FILETIME*,void**,UINT32*) DECLSPEC_HIDDEN;
269 extern HRESULT get_filestream_from_file(IDWriteFontFile*,IDWriteFontFileStream**) DECLSPEC_HIDDEN;
270 extern BOOL is_face_type_supported(DWRITE_FONT_FACE_TYPE) DECLSPEC_HIDDEN;
271 extern HRESULT get_family_names_from_stream(IDWriteFontFileStream*,UINT32,DWRITE_FONT_FACE_TYPE,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
272 extern HRESULT create_colorglyphenum(FLOAT,FLOAT,const DWRITE_GLYPH_RUN*,const DWRITE_GLYPH_RUN_DESCRIPTION*,DWRITE_MEASURING_MODE,
273 const DWRITE_MATRIX*,UINT32,IDWriteColorGlyphRunEnumerator**) DECLSPEC_HIDDEN;
274 extern BOOL lb_is_newline_char(WCHAR) DECLSPEC_HIDDEN;
275 extern HRESULT create_system_fontfallback(IDWriteFactory7 *factory, IDWriteFontFallback1 **fallback) DECLSPEC_HIDDEN;
276 extern void release_system_fontfallback(IDWriteFontFallback1 *fallback) DECLSPEC_HIDDEN;
277 extern HRESULT create_fontfallback_builder(IDWriteFactory7 *factory, IDWriteFontFallbackBuilder **builder) DECLSPEC_HIDDEN;
278 extern HRESULT create_matching_font(IDWriteFontCollection*,const WCHAR*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH,
279 IDWriteFont**) DECLSPEC_HIDDEN;
280 extern HRESULT create_fontfacereference(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 face_index,
281 DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 axis_values_count,
282 IDWriteFontFaceReference1 **reference) DECLSPEC_HIDDEN;
283 extern HRESULT factory_get_cached_fontface(IDWriteFactory7 *factory, IDWriteFontFile * const *files, UINT32 num_files,
284 DWRITE_FONT_SIMULATIONS simulations, struct list **cache, REFIID riid, void **obj) DECLSPEC_HIDDEN;
285 extern void factory_detach_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 *collection) DECLSPEC_HIDDEN;
286 extern void factory_detach_gdiinterop(IDWriteFactory7 *factory, IDWriteGdiInterop1 *interop) DECLSPEC_HIDDEN;
287 extern struct fontfacecached *factory_cache_fontface(IDWriteFactory7 *factory, struct list *fontfaces,
288 IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN;
289 extern void get_logfont_from_font(IDWriteFont*,LOGFONTW*) DECLSPEC_HIDDEN;
290 extern void get_logfont_from_fontface(IDWriteFontFace*,LOGFONTW*) DECLSPEC_HIDDEN;
291 extern HRESULT get_fontsig_from_font(IDWriteFont*,FONTSIGNATURE*) DECLSPEC_HIDDEN;
292 extern HRESULT get_fontsig_from_fontface(IDWriteFontFace*,FONTSIGNATURE*) DECLSPEC_HIDDEN;
293 extern HRESULT create_gdiinterop(IDWriteFactory7 *factory, IDWriteGdiInterop1 **interop) DECLSPEC_HIDDEN;
294 extern void fontface_detach_from_cache(IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN;
295 extern void factory_lock(IDWriteFactory7 *factory) DECLSPEC_HIDDEN;
296 extern void factory_unlock(IDWriteFactory7 *factory) DECLSPEC_HIDDEN;
297 extern HRESULT create_inmemory_fileloader(IDWriteFontFileLoader**) DECLSPEC_HIDDEN;
298 extern HRESULT create_font_resource(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 face_index,
299 IDWriteFontResource **resource) DECLSPEC_HIDDEN;
301 struct dwrite_fontface;
303 extern float fontface_get_scaled_design_advance(struct dwrite_fontface *fontface, DWRITE_MEASURING_MODE measuring_mode,
304 float emsize, float ppdip, const DWRITE_MATRIX *transform, UINT16 glyph, BOOL is_sideways) DECLSPEC_HIDDEN;
305 extern struct dwrite_fontface *unsafe_impl_from_IDWriteFontFace(IDWriteFontFace *iface) DECLSPEC_HIDDEN;
307 /* Opentype font table functions */
308 struct dwrite_font_props
310 DWRITE_FONT_STYLE style;
311 DWRITE_FONT_STRETCH stretch;
312 DWRITE_FONT_WEIGHT weight;
313 DWRITE_PANOSE panose;
314 FONTSIGNATURE fontsig;
315 LOGFONTW lf;
316 UINT32 flags;
319 struct file_stream_desc {
320 IDWriteFontFileStream *stream;
321 DWRITE_FONT_FACE_TYPE face_type;
322 UINT32 face_index;
325 extern const void* get_fontface_table(IDWriteFontFace5 *fontface, UINT32 tag,
326 struct dwrite_fonttable *table) DECLSPEC_HIDDEN;
328 extern HRESULT opentype_analyze_font(IDWriteFontFileStream*,BOOL*,DWRITE_FONT_FILE_TYPE*,DWRITE_FONT_FACE_TYPE*,UINT32*) DECLSPEC_HIDDEN;
329 extern HRESULT opentype_try_get_font_table(const struct file_stream_desc *stream_desc, UINT32 tag, const void **data,
330 void **context, UINT32 *size, BOOL *exists) DECLSPEC_HIDDEN;
331 extern HRESULT opentype_cmap_get_unicode_ranges(const struct file_stream_desc *stream_desc, unsigned int max_count,
332 DWRITE_UNICODE_RANGE *ranges, unsigned int *count) DECLSPEC_HIDDEN;
333 extern void opentype_get_font_properties(struct file_stream_desc*,struct dwrite_font_props*) DECLSPEC_HIDDEN;
334 extern void opentype_get_font_metrics(struct file_stream_desc*,DWRITE_FONT_METRICS1*,DWRITE_CARET_METRICS*) DECLSPEC_HIDDEN;
335 extern void opentype_get_font_typo_metrics(struct file_stream_desc *stream_desc, unsigned int *ascent,
336 unsigned int *descent) DECLSPEC_HIDDEN;
337 extern HRESULT opentype_get_font_info_strings(const struct file_stream_desc *stream_desc,
338 DWRITE_INFORMATIONAL_STRING_ID id, IDWriteLocalizedStrings **strings) DECLSPEC_HIDDEN;
339 extern HRESULT opentype_get_font_familyname(struct file_stream_desc*,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
340 extern HRESULT opentype_get_font_facename(struct file_stream_desc*,WCHAR*,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
341 extern HRESULT opentype_get_typographic_features(IDWriteFontFace*,UINT32,UINT32,UINT32,UINT32*,DWRITE_FONT_FEATURE_TAG*) DECLSPEC_HIDDEN;
342 extern BOOL opentype_get_vdmx_size(const struct dwrite_fonttable *table, INT ppem, UINT16 *ascent,
343 UINT16 *descent) DECLSPEC_HIDDEN;
344 extern unsigned int opentype_get_cpal_palettecount(const struct dwrite_fonttable *table) DECLSPEC_HIDDEN;
345 extern unsigned int opentype_get_cpal_paletteentrycount(const struct dwrite_fonttable *table) DECLSPEC_HIDDEN;
346 extern HRESULT opentype_get_cpal_entries(const struct dwrite_fonttable *table, unsigned int palette,
347 unsigned int first_entry_index, unsigned int entry_count, DWRITE_COLOR_F *entries) DECLSPEC_HIDDEN;
348 extern BOOL opentype_has_vertical_variants(IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN;
349 extern UINT32 opentype_get_glyph_image_formats(IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN;
350 extern DWRITE_CONTAINER_TYPE opentype_analyze_container_type(void const *, UINT32) DECLSPEC_HIDDEN;
352 struct dwrite_colorglyph {
353 USHORT layer; /* [0, num_layers) index indicating current layer */
354 /* base glyph record data, set once on initialization */
355 USHORT first_layer;
356 USHORT num_layers;
357 /* current layer record data, updated every time glyph is switched to next layer */
358 UINT16 glyph;
359 UINT16 palette_index;
362 extern HRESULT opentype_get_colr_glyph(const struct dwrite_fonttable *table, UINT16 glyph,
363 struct dwrite_colorglyph *color_glyph) DECLSPEC_HIDDEN;
364 extern void opentype_colr_next_glyph(const struct dwrite_fonttable *table,
365 struct dwrite_colorglyph *color_glyph) DECLSPEC_HIDDEN;
367 enum gasp_flags {
368 GASP_GRIDFIT = 0x0001,
369 GASP_DOGRAY = 0x0002,
370 GASP_SYMMETRIC_GRIDFIT = 0x0004,
371 GASP_SYMMETRIC_SMOOTHING = 0x0008,
374 extern unsigned int opentype_get_gasp_flags(const struct dwrite_fonttable *gasp, float emsize) DECLSPEC_HIDDEN;
376 /* BiDi helpers */
377 extern HRESULT bidi_computelevels(const WCHAR*,UINT32,UINT8,UINT8*,UINT8*) DECLSPEC_HIDDEN;
378 extern WCHAR bidi_get_mirrored_char(WCHAR) DECLSPEC_HIDDEN;
380 /* FreeType integration */
381 struct dwrite_glyphbitmap
383 IDWriteFontFace4 *fontface;
384 DWORD simulations;
385 float emsize;
386 BOOL nohint;
387 BOOL aliased;
388 UINT16 glyph;
389 INT pitch;
390 RECT bbox;
391 BYTE *buf;
392 DWRITE_MATRIX *m;
395 extern BOOL init_freetype(void) DECLSPEC_HIDDEN;
396 extern void release_freetype(void) DECLSPEC_HIDDEN;
398 extern HRESULT freetype_get_design_glyph_metrics(struct dwrite_fontface *fontface, UINT16 glyph,
399 DWRITE_GLYPH_METRICS *metrics) DECLSPEC_HIDDEN;
400 extern void freetype_notify_cacheremove(IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN;
401 extern HRESULT freetype_get_glyphrun_outline(IDWriteFontFace5 *fontface, float emsize, UINT16 const *glyphs,
402 float const *advances, DWRITE_GLYPH_OFFSET const *offsets, unsigned int count, BOOL is_rtl,
403 IDWriteGeometrySink *sink) DECLSPEC_HIDDEN;
404 extern UINT16 freetype_get_glyphcount(IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN;
405 extern void freetype_get_glyphs(IDWriteFontFace5 *fontface, INT charmap, UINT32 const *codepoints, UINT32 count,
406 UINT16 *glyphs) DECLSPEC_HIDDEN;
407 extern BOOL freetype_has_kerning_pairs(IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN;
408 extern INT32 freetype_get_kerning_pair_adjustment(IDWriteFontFace5 *fontface, UINT16 left, UINT16 right) DECLSPEC_HIDDEN;
409 extern void freetype_get_glyph_bbox(struct dwrite_glyphbitmap *bitmap_desc) DECLSPEC_HIDDEN;
410 extern BOOL freetype_get_glyph_bitmap(struct dwrite_glyphbitmap*) DECLSPEC_HIDDEN;
411 extern INT freetype_get_charmap_index(IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN;
412 extern INT32 freetype_get_glyph_advance(IDWriteFontFace5 *fontface, FLOAT emsize, UINT16 index,
413 DWRITE_MEASURING_MODE measuring_mode, BOOL *has_contours) DECLSPEC_HIDDEN;
414 extern void freetype_get_design_glyph_bbox(IDWriteFontFace4*,UINT16,UINT16,RECT*) DECLSPEC_HIDDEN;
416 /* Glyph shaping */
417 enum SCRIPT_JUSTIFY
419 SCRIPT_JUSTIFY_NONE,
420 SCRIPT_JUSTIFY_ARABIC_BLANK,
421 SCRIPT_JUSTIFY_CHARACTER,
422 SCRIPT_JUSTIFY_RESERVED1,
423 SCRIPT_JUSTIFY_BLANK,
424 SCRIPT_JUSTIFY_RESERVED2,
425 SCRIPT_JUSTIFY_RESERVED3,
426 SCRIPT_JUSTIFY_ARABIC_NORMAL,
427 SCRIPT_JUSTIFY_ARABIC_KASHIDA,
428 SCRIPT_JUSTIFY_ARABIC_ALEF,
429 SCRIPT_JUSTIFY_ARABIC_HA,
430 SCRIPT_JUSTIFY_ARABIC_RA,
431 SCRIPT_JUSTIFY_ARABIC_BA,
432 SCRIPT_JUSTIFY_ARABIC_BARA,
433 SCRIPT_JUSTIFY_ARABIC_SEEN,
434 SCRIPT_JUSTIFY_ARABIC_SEEN_M
437 struct scriptshaping_cache
439 const struct shaping_font_ops *font;
440 void *context;
441 UINT16 upem;
443 struct
445 struct dwrite_fonttable table;
446 unsigned int script_list;
447 unsigned int feature_list;
448 unsigned int lookup_list;
449 } gpos;
451 struct
453 struct dwrite_fonttable table;
454 unsigned int classdef;
455 } gdef;
458 struct scriptshaping_context
460 struct scriptshaping_cache *cache;
461 UINT32 language_tag;
463 const WCHAR *text;
464 unsigned int length;
465 BOOL is_rtl;
467 union
469 struct
471 const UINT16 *glyphs;
472 const DWRITE_SHAPING_GLYPH_PROPERTIES *glyph_props;
473 } pos;
474 } u;
476 unsigned int glyph_count;
477 float emsize;
478 DWRITE_MEASURING_MODE measuring_mode;
479 float *advances;
480 DWRITE_GLYPH_OFFSET *offsets;
483 struct shaping_font_ops
485 void (*grab_font_table)(void *context, UINT32 table, const BYTE **data, UINT32 *size, void **data_context);
486 void (*release_font_table)(void *context, void *data_context);
487 UINT16 (*get_font_upem)(void *context);
490 extern struct scriptshaping_cache *create_scriptshaping_cache(void *context,
491 const struct shaping_font_ops *font_ops) DECLSPEC_HIDDEN;
492 extern void release_scriptshaping_cache(struct scriptshaping_cache*) DECLSPEC_HIDDEN;
493 extern struct scriptshaping_cache *fontface_get_shaping_cache(struct dwrite_fontface *fontface) DECLSPEC_HIDDEN;
495 struct shaping_features
497 const DWORD *tags;
498 unsigned int count;
501 extern void opentype_layout_scriptshaping_cache_init(struct scriptshaping_cache *cache) DECLSPEC_HIDDEN;
502 extern DWORD opentype_layout_find_script(const struct scriptshaping_cache *cache, DWORD kind, DWORD tag,
503 unsigned int *script_index) DECLSPEC_HIDDEN;
504 extern DWORD opentype_layout_find_language(const struct scriptshaping_cache *cache, DWORD kind, DWORD tag,
505 unsigned int script_index, unsigned int *language_index) DECLSPEC_HIDDEN;
506 extern void opentype_layout_apply_gpos_features(struct scriptshaping_context *context, unsigned int script_index,
507 unsigned int language_index, const struct shaping_features *features) DECLSPEC_HIDDEN;
509 struct scriptshaping_ops
511 HRESULT (*contextual_shaping)(struct scriptshaping_context *context, UINT16 *clustermap, UINT16 *glyph_indices, UINT32* actual_glyph_count);
512 HRESULT (*set_text_glyphs_props)(struct scriptshaping_context *context, UINT16 *clustermap, UINT16 *glyph_indices,
513 UINT32 glyphcount, DWRITE_SHAPING_TEXT_PROPERTIES *text_props, DWRITE_SHAPING_GLYPH_PROPERTIES *glyph_props);
514 const struct shaping_features *gpos_features;
517 extern const struct scriptshaping_ops default_shaping_ops DECLSPEC_HIDDEN;
518 extern const struct scriptshaping_ops latn_shaping_ops DECLSPEC_HIDDEN;
520 extern HRESULT shape_get_positions(struct scriptshaping_context *context, const DWORD *scripts,
521 const struct shaping_features *features) DECLSPEC_HIDDEN;