cmd: Use CRT's popen instead of rewriting it.
[wine.git] / dlls / dwrite / dwrite_private.h
blobf8d0b9add19fc70c5adea63e7d23b006e6f103ec
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 #ifndef __WINE_DWRITE_PRIVATE_H
20 #define __WINE_DWRITE_PRIVATE_H
22 #include "dwrite_3.h"
23 #include "d2d1.h"
24 #include "winternl.h"
26 #include "wine/debug.h"
27 #include "wine/list.h"
28 #include "wine/rbtree.h"
30 #define MS_GSUB_TAG DWRITE_MAKE_OPENTYPE_TAG('G','S','U','B')
31 #define MS_GPOS_TAG DWRITE_MAKE_OPENTYPE_TAG('G','P','O','S')
33 typedef struct MATRIX_2X2
35 float m11;
36 float m12;
37 float m21;
38 float m22;
39 } MATRIX_2X2;
41 static const DWRITE_MATRIX identity =
43 1.0f, 0.0f,
44 0.0f, 1.0f,
45 0.0f, 0.0f
48 static const MATRIX_2X2 identity_2x2 =
50 1.0f, 0.0f,
51 0.0f, 1.0f,
54 static inline LPWSTR heap_strdupnW(const WCHAR *str, UINT32 len)
56 WCHAR *ret = NULL;
58 if (len)
60 ret = malloc((len+1)*sizeof(WCHAR));
61 if(ret)
63 memcpy(ret, str, len*sizeof(WCHAR));
64 ret[len] = 0;
68 return ret;
71 static inline const char *debugstr_range(const DWRITE_TEXT_RANGE *range)
73 return wine_dbg_sprintf("%u:%u", range->startPosition, range->length);
76 static inline const char *debugstr_matrix(const DWRITE_MATRIX *m)
78 if (!m) return "(null)";
79 return wine_dbg_sprintf("{%.2f,%.2f,%.2f,%.2f,%.2f,%.2f}", m->m11, m->m12, m->m21, m->m22,
80 m->dx, m->dy);
83 static inline BOOL dwrite_array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
85 size_t new_capacity, max_capacity;
86 void *new_elements;
88 if (count <= *capacity)
89 return TRUE;
91 max_capacity = ~(SIZE_T)0 / size;
92 if (count > max_capacity)
93 return FALSE;
95 new_capacity = max(4, *capacity);
96 while (new_capacity < count && new_capacity <= max_capacity / 2)
97 new_capacity *= 2;
98 if (new_capacity < count)
99 new_capacity = max_capacity;
101 new_elements = realloc(*elements, new_capacity * size);
102 if (!new_elements)
103 return FALSE;
105 *elements = new_elements;
106 *capacity = new_capacity;
108 return TRUE;
111 const char *debugstr_sa_script(UINT16);
113 static inline unsigned short get_table_entry_16(const unsigned short *table, WCHAR ch)
115 return table[table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0xf)];
118 static inline unsigned short get_table_entry_32(const unsigned short *table, UINT ch)
120 return table[table[table[table[ch >> 12] + ((ch >> 8) & 0x0f)] + ((ch >> 4) & 0x0f)] + (ch & 0xf)];
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 *file;
160 IDWriteFontFileStream *stream;
161 UINT32 index;
162 DWRITE_FONT_SIMULATIONS simulations;
163 struct dwrite_font_data *font_data; /* could be NULL when face is created directly with IDWriteFactory::CreateFontFace() */
166 struct dwrite_fonttable
168 const BYTE *data;
169 void *context;
170 UINT32 size;
171 BOOL exists;
174 struct fontfacecached
176 struct list entry;
177 IDWriteFontFace5 *fontface;
180 #define GLYPH_BLOCK_SHIFT 8
181 #define GLYPH_BLOCK_SIZE (1UL << GLYPH_BLOCK_SHIFT)
182 #define GLYPH_BLOCK_MASK (GLYPH_BLOCK_SIZE - 1)
183 #define GLYPH_MAX 65536
185 enum font_flags
187 FONT_IS_SYMBOL = 0x00000001,
188 FONT_IS_MONOSPACED = 0x00000002,
189 FONT_IS_COLORED = 0x00000004, /* CPAL/COLR support */
190 FONTFACE_KERNING_PAIRS = 0x00000008,
191 FONTFACE_NO_KERNING_PAIRS = 0x00000010,
192 FONTFACE_VERTICAL_VARIANTS = 0x00000020,
193 FONTFACE_NO_VERTICAL_VARIANTS = 0x00000040,
196 struct dwrite_cmap;
198 typedef UINT16 (*p_cmap_get_glyph_func)(const struct dwrite_cmap *cmap, unsigned int ch);
199 typedef unsigned int (*p_cmap_get_ranges_func)(const struct dwrite_cmap *cmap, unsigned int max_count,
200 DWRITE_UNICODE_RANGE *ranges);
202 struct dwrite_cmap
204 const void *data;
205 union
207 struct
209 unsigned int seg_count;
210 unsigned int glyph_id_array_len;
212 const UINT16 *ends;
213 const UINT16 *starts;
214 const UINT16 *id_delta;
215 const UINT16 *id_range_offset;
216 const UINT16 *glyph_id_array;
217 } format4;
218 struct
220 unsigned int first;
221 unsigned int last;
222 } format6_10;
223 struct
225 unsigned int group_count;
226 } format12_13;
227 } u;
228 p_cmap_get_glyph_func get_glyph;
229 p_cmap_get_ranges_func get_ranges;
230 unsigned short symbol : 1;
231 IDWriteFontFileStream *stream;
232 void *table_context;
235 extern void dwrite_cmap_init(struct dwrite_cmap *cmap, IDWriteFontFile *file, unsigned int face_index,
236 DWRITE_FONT_FACE_TYPE face_type);
237 extern void dwrite_cmap_release(struct dwrite_cmap *cmap);
238 extern UINT16 opentype_cmap_get_glyph(const struct dwrite_cmap *cmap, unsigned int ch);
239 extern HRESULT opentype_cmap_get_unicode_ranges(const struct dwrite_cmap *cmap, unsigned int max_count,
240 DWRITE_UNICODE_RANGE *ranges, unsigned int *count);
242 struct dwrite_fontface;
243 typedef UINT64 (*p_dwrite_fontface_get_font_object)(struct dwrite_fontface *fontface);
245 struct dwrite_fontface
247 IDWriteFontFace5 IDWriteFontFace5_iface;
248 IDWriteFontFaceReference IDWriteFontFaceReference_iface;
249 LONG refcount;
251 IDWriteFontFileStream *stream;
252 IDWriteFontFile *file;
253 UINT32 index;
255 IDWriteFactory7 *factory;
256 struct fontfacecached *cached;
257 UINT64 font_object;
258 void *data_context;
259 p_dwrite_fontface_get_font_object get_font_object;
260 struct
262 struct wine_rb_tree tree;
263 struct list mru;
264 size_t max_size;
265 size_t size;
266 } cache;
267 CRITICAL_SECTION cs;
269 USHORT simulations;
270 DWRITE_FONT_FACE_TYPE type;
271 DWRITE_FONT_METRICS1 metrics;
272 DWRITE_CARET_METRICS caret;
273 struct
275 unsigned int ascent;
276 unsigned int descent;
277 } typo_metrics;
278 unsigned int flags;
280 struct dwrite_cmap cmap;
282 struct dwrite_fonttable vdmx;
283 struct dwrite_fonttable gasp;
284 struct dwrite_fonttable cpal;
285 struct dwrite_fonttable colr;
286 struct dwrite_fonttable kern;
287 DWRITE_GLYPH_METRICS *glyphs[GLYPH_MAX/GLYPH_BLOCK_SIZE];
289 DWRITE_FONT_STYLE style;
290 DWRITE_FONT_STRETCH stretch;
291 DWRITE_FONT_WEIGHT weight;
292 DWRITE_PANOSE panose;
293 FONTSIGNATURE fontsig;
294 UINT32 glyph_image_formats;
296 IDWriteLocalizedStrings *info_strings[DWRITE_INFORMATIONAL_STRING_SUPPORTED_SCRIPT_LANGUAGE_TAG + 1];
297 IDWriteLocalizedStrings *family_names;
298 IDWriteLocalizedStrings *names;
300 struct scriptshaping_cache *shaping_cache;
302 LOGFONTW lf;
305 extern HRESULT create_numbersubstitution(DWRITE_NUMBER_SUBSTITUTION_METHOD,const WCHAR *locale,BOOL,IDWriteNumberSubstitution**);
306 extern HRESULT create_text_format(const WCHAR *family_name, IDWriteFontCollection *collection, DWRITE_FONT_WEIGHT weight,
307 DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, float size, const WCHAR *locale, REFIID riid,
308 void **out);
309 extern HRESULT create_textlayout(const struct textlayout_desc*,IDWriteTextLayout**);
310 extern HRESULT create_trimmingsign(IDWriteFactory7 *factory, IDWriteTextFormat *format,
311 IDWriteInlineObject **sign);
312 extern HRESULT create_typography(IDWriteTypography**);
313 extern HRESULT create_localizedstrings(IDWriteLocalizedStrings**);
314 extern HRESULT add_localizedstring(IDWriteLocalizedStrings*,const WCHAR*,const WCHAR*);
315 extern HRESULT clone_localizedstrings(IDWriteLocalizedStrings *iface, IDWriteLocalizedStrings **strings);
316 extern void set_en_localizedstring(IDWriteLocalizedStrings*,const WCHAR*);
317 extern void sort_localizedstrings(IDWriteLocalizedStrings*);
318 extern unsigned int get_localizedstrings_count(IDWriteLocalizedStrings *strings);
319 extern BOOL localizedstrings_contains(IDWriteLocalizedStrings *strings, const WCHAR *str);
320 extern HRESULT get_system_fontcollection(IDWriteFactory7 *factory, DWRITE_FONT_FAMILY_MODEL family_model,
321 IDWriteFontCollection **collection);
322 extern HRESULT get_eudc_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 **collection);
323 extern IDWriteTextAnalyzer2 *get_text_analyzer(void);
324 extern HRESULT create_font_file(IDWriteFontFileLoader *loader, const void *reference_key, UINT32 key_size, IDWriteFontFile **font_file);
325 extern void init_local_fontfile_loader(void);
326 extern IDWriteFontFileLoader *get_local_fontfile_loader(void);
327 extern HRESULT create_fontface(const struct fontface_desc *desc, struct list *cached_list,
328 IDWriteFontFace5 **fontface);
329 extern HRESULT create_font_collection(IDWriteFactory7 *factory, IDWriteFontFileEnumerator *enumerator, BOOL is_system,
330 IDWriteFontCollection3 **collection);
331 extern HRESULT create_glyphrunanalysis(const struct glyphrunanalysis_desc*,IDWriteGlyphRunAnalysis**);
332 extern BOOL is_system_collection(IDWriteFontCollection*);
333 extern HRESULT get_local_refkey(const WCHAR*,const FILETIME*,void**,UINT32*);
334 extern HRESULT get_filestream_from_file(IDWriteFontFile*,IDWriteFontFileStream**);
335 extern BOOL is_face_type_supported(DWRITE_FONT_FACE_TYPE);
336 extern HRESULT get_family_names_from_stream(IDWriteFontFileStream*,UINT32,DWRITE_FONT_FACE_TYPE,IDWriteLocalizedStrings**);
337 extern HRESULT create_colorglyphenum(D2D1_POINT_2F origin, const DWRITE_GLYPH_RUN *run, const DWRITE_GLYPH_RUN_DESCRIPTION *desc,
338 DWRITE_GLYPH_IMAGE_FORMATS formats, DWRITE_MEASURING_MODE mode, const DWRITE_MATRIX *transform, UINT32 palette,
339 IDWriteColorGlyphRunEnumerator1 **enumerator);
340 extern BOOL lb_is_newline_char(WCHAR);
341 extern HRESULT create_system_fontfallback(IDWriteFactory7 *factory, IDWriteFontFallback1 **fallback);
342 extern void release_system_fontfallback(IDWriteFontFallback1 *fallback);
343 extern void release_system_fallback_data(void);
344 extern HRESULT create_fontfallback_builder(IDWriteFactory7 *factory, IDWriteFontFallbackBuilder **builder);
345 extern HRESULT create_matching_font(IDWriteFontCollection *collection, const WCHAR *family, DWRITE_FONT_WEIGHT weight,
346 DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, REFIID riid, void **obj);
347 extern HRESULT create_fontfacereference(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 face_index,
348 DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 axis_values_count,
349 IDWriteFontFaceReference1 **reference);
350 extern HRESULT factory_get_cached_fontface(IDWriteFactory7 *factory, IDWriteFontFile * const *files, UINT32 num_files,
351 DWRITE_FONT_SIMULATIONS simulations, struct list **cache, REFIID riid, void **obj);
352 extern void factory_detach_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 *collection);
353 extern void factory_detach_gdiinterop(IDWriteFactory7 *factory, IDWriteGdiInterop1 *interop);
354 extern struct fontfacecached *factory_cache_fontface(IDWriteFactory7 *factory, struct list *fontfaces,
355 IDWriteFontFace5 *fontface);
356 extern void get_logfont_from_font(IDWriteFont*,LOGFONTW*);
357 extern void get_logfont_from_fontface(IDWriteFontFace*,LOGFONTW*);
358 extern HRESULT get_fontsig_from_font(IDWriteFont*,FONTSIGNATURE*);
359 extern HRESULT get_fontsig_from_fontface(IDWriteFontFace*,FONTSIGNATURE*);
360 extern HRESULT create_gdiinterop(IDWriteFactory7 *factory, IDWriteGdiInterop1 **interop);
361 extern void fontface_detach_from_cache(IDWriteFontFace5 *fontface);
362 extern void factory_lock(IDWriteFactory7 *factory);
363 extern void factory_unlock(IDWriteFactory7 *factory);
364 extern HRESULT create_inmemory_fileloader(IDWriteInMemoryFontFileLoader **loader);
365 extern HRESULT create_font_resource(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 face_index,
366 IDWriteFontResource **resource);
367 extern HRESULT create_fontset_builder(IDWriteFactory7 *factory, IDWriteFontSetBuilder2 **ret);
368 extern HRESULT compute_glyph_origins(DWRITE_GLYPH_RUN const *run, DWRITE_MEASURING_MODE measuring_mode,
369 D2D1_POINT_2F baseline_origin, DWRITE_MATRIX const *transform, D2D1_POINT_2F *origins);
370 extern HRESULT create_font_collection_from_set(IDWriteFactory7 *factory, IDWriteFontSet *set,
371 DWRITE_FONT_FAMILY_MODEL family_model, REFGUID riid, void **ret);
372 extern HRESULT create_system_fontset(IDWriteFactory7 *factory, REFIID riid, void **obj);
374 struct dwrite_fontface;
376 extern float fontface_get_scaled_design_advance(struct dwrite_fontface *fontface, DWRITE_MEASURING_MODE measuring_mode,
377 float emsize, float ppdip, const DWRITE_MATRIX *transform, UINT16 glyph, BOOL is_sideways);
378 extern struct dwrite_fontface *unsafe_impl_from_IDWriteFontFace(IDWriteFontFace *iface);
380 struct dwrite_textformat_data
382 WCHAR *family_name;
383 unsigned int family_len;
384 WCHAR *locale;
385 unsigned int locale_len;
387 DWRITE_FONT_WEIGHT weight;
388 DWRITE_FONT_STYLE style;
389 DWRITE_FONT_STRETCH stretch;
391 DWRITE_PARAGRAPH_ALIGNMENT paralign;
392 DWRITE_READING_DIRECTION readingdir;
393 DWRITE_WORD_WRAPPING wrapping;
394 BOOL last_line_wrapping;
395 DWRITE_TEXT_ALIGNMENT textalignment;
396 DWRITE_FLOW_DIRECTION flow;
397 DWRITE_VERTICAL_GLYPH_ORIENTATION vertical_orientation;
398 DWRITE_OPTICAL_ALIGNMENT optical_alignment;
399 DWRITE_LINE_SPACING spacing;
400 DWRITE_AUTOMATIC_FONT_AXES automatic_axes;
402 float fontsize;
403 float tabstop;
405 DWRITE_TRIMMING trimming;
406 IDWriteInlineObject *trimmingsign;
408 IDWriteFontCollection *collection;
409 IDWriteFontFallback *fallback;
411 DWRITE_FONT_AXIS_VALUE *axis_values;
412 unsigned int axis_values_count;
415 struct dwrite_textformat
417 IDWriteTextFormat3 IDWriteTextFormat3_iface;
418 LONG refcount;
419 struct dwrite_textformat_data format;
422 struct dwrite_textformat *unsafe_impl_from_IDWriteTextFormat(IDWriteTextFormat *iface);
423 void release_format_data(struct dwrite_textformat_data *data);
425 HRESULT format_set_vertical_orientation(struct dwrite_textformat_data *format,
426 DWRITE_VERTICAL_GLYPH_ORIENTATION orientation, BOOL *changed);
427 HRESULT format_set_fontfallback(struct dwrite_textformat_data *format, IDWriteFontFallback *fallback);
428 HRESULT format_get_fontfallback(const struct dwrite_textformat_data *format, IDWriteFontFallback **fallback);
429 HRESULT format_set_font_axisvalues(struct dwrite_textformat_data *format,
430 DWRITE_FONT_AXIS_VALUE const *axis_values, unsigned int num_values);
431 HRESULT format_get_font_axisvalues(struct dwrite_textformat_data *format,
432 DWRITE_FONT_AXIS_VALUE *axis_values, unsigned int num_values);
433 HRESULT format_set_optical_alignment(struct dwrite_textformat_data *format,
434 DWRITE_OPTICAL_ALIGNMENT alignment);
435 HRESULT format_set_trimming(struct dwrite_textformat_data *format, DWRITE_TRIMMING const *trimming,
436 IDWriteInlineObject *trimming_sign, BOOL *changed);
437 HRESULT format_set_flowdirection(struct dwrite_textformat_data *format,
438 DWRITE_FLOW_DIRECTION direction, BOOL *changed);
439 HRESULT format_set_readingdirection(struct dwrite_textformat_data *format,
440 DWRITE_READING_DIRECTION direction, BOOL *changed);
441 HRESULT format_set_wordwrapping(struct dwrite_textformat_data *format, DWRITE_WORD_WRAPPING wrapping,
442 BOOL *changed);
443 HRESULT format_set_paralignment(struct dwrite_textformat_data *format,
444 DWRITE_PARAGRAPH_ALIGNMENT alignment, BOOL *changed);
445 HRESULT format_set_textalignment(struct dwrite_textformat_data *format, DWRITE_TEXT_ALIGNMENT alignment,
446 BOOL *changed);
447 HRESULT format_set_linespacing(struct dwrite_textformat_data *format,
448 DWRITE_LINE_SPACING const *spacing, BOOL *changed);
450 /* Opentype font table functions */
451 struct dwrite_font_props
453 DWRITE_FONT_STYLE style;
454 DWRITE_FONT_STRETCH stretch;
455 DWRITE_FONT_WEIGHT weight;
456 DWRITE_PANOSE panose;
457 FONTSIGNATURE fontsig;
458 LOGFONTW lf;
459 UINT32 flags;
460 float slant_angle;
463 struct file_stream_desc {
464 IDWriteFontFileStream *stream;
465 DWRITE_FONT_FACE_TYPE face_type;
466 UINT32 face_index;
469 extern const void* get_fontface_table(IDWriteFontFace5 *fontface, UINT32 tag,
470 struct dwrite_fonttable *table);
472 struct tag_array
474 unsigned int *tags;
475 size_t capacity;
476 size_t count;
479 struct ot_gsubgpos_table
481 struct dwrite_fonttable table;
482 unsigned int script_list;
483 unsigned int feature_list;
484 unsigned int lookup_list;
487 struct dwrite_var_axis
489 DWRITE_FONT_AXIS_TAG tag;
490 float default_value;
491 float min_value;
492 float max_value;
493 unsigned int attributes;
496 extern HRESULT opentype_analyze_font(IDWriteFontFileStream*,BOOL*,DWRITE_FONT_FILE_TYPE*,DWRITE_FONT_FACE_TYPE*,UINT32*);
497 extern HRESULT opentype_try_get_font_table(const struct file_stream_desc *stream_desc, UINT32 tag, const void **data,
498 void **context, UINT32 *size, BOOL *exists);
499 extern void opentype_get_font_properties(const struct file_stream_desc *stream_desc,
500 struct dwrite_font_props *props);
501 extern void opentype_get_font_metrics(struct file_stream_desc*,DWRITE_FONT_METRICS1*,DWRITE_CARET_METRICS*);
502 extern void opentype_get_font_typo_metrics(struct file_stream_desc *stream_desc, unsigned int *ascent,
503 unsigned int *descent);
504 extern HRESULT opentype_get_font_info_strings(const struct file_stream_desc *stream_desc,
505 DWRITE_INFORMATIONAL_STRING_ID id, IDWriteLocalizedStrings **strings);
506 extern HRESULT opentype_get_font_familyname(const struct file_stream_desc *desc, DWRITE_FONT_FAMILY_MODEL family_model,
507 IDWriteLocalizedStrings **names);
508 extern HRESULT opentype_get_font_facename(struct file_stream_desc*,WCHAR*,IDWriteLocalizedStrings**);
509 extern void opentype_get_typographic_features(struct ot_gsubgpos_table *table, unsigned int script_index,
510 unsigned int language_index, struct tag_array *tags);
511 extern BOOL opentype_get_vdmx_size(const struct dwrite_fonttable *table, INT ppem, UINT16 *ascent,
512 UINT16 *descent);
513 extern unsigned int opentype_get_cpal_palettecount(const struct dwrite_fonttable *table);
514 extern unsigned int opentype_get_cpal_paletteentrycount(const struct dwrite_fonttable *table);
515 extern HRESULT opentype_get_cpal_entries(const struct dwrite_fonttable *table, unsigned int palette,
516 unsigned int first_entry_index, unsigned int entry_count, DWRITE_COLOR_F *entries);
517 extern UINT32 opentype_get_glyph_image_formats(IDWriteFontFace5 *fontface);
518 extern DWRITE_CONTAINER_TYPE opentype_analyze_container_type(void const *, UINT32);
519 extern HRESULT opentype_get_kerning_pairs(struct dwrite_fontface *fontface, unsigned int count,
520 const UINT16 *glyphs, INT32 *values);
521 extern BOOL opentype_has_kerning_pairs(struct dwrite_fontface *fontface);
522 extern HRESULT opentype_get_font_var_axis(const struct file_stream_desc *stream_desc, struct dwrite_var_axis **axis,
523 unsigned int *axis_count);
525 struct dwrite_colorglyph {
526 USHORT layer; /* [0, num_layers) index indicating current layer */
527 /* base glyph record data, set once on initialization */
528 USHORT first_layer;
529 USHORT num_layers;
530 /* current layer record data, updated every time glyph is switched to next layer */
531 UINT16 glyph;
532 UINT16 palette_index;
535 extern HRESULT opentype_get_colr_glyph(const struct dwrite_fonttable *table, UINT16 glyph,
536 struct dwrite_colorglyph *color_glyph);
537 extern void opentype_colr_next_glyph(const struct dwrite_fonttable *table,
538 struct dwrite_colorglyph *color_glyph);
540 enum gasp_flags {
541 GASP_GRIDFIT = 0x0001,
542 GASP_DOGRAY = 0x0002,
543 GASP_SYMMETRIC_GRIDFIT = 0x0004,
544 GASP_SYMMETRIC_SMOOTHING = 0x0008,
547 extern unsigned int opentype_get_gasp_flags(const struct dwrite_fonttable *gasp, float emsize);
549 /* BiDi helpers */
550 struct bidi_char
552 unsigned int ch;
553 UINT8 explicit;
554 UINT8 resolved;
555 UINT8 nominal_bidi_class;
556 UINT8 bidi_class;
559 extern HRESULT bidi_computelevels(struct bidi_char *chars, unsigned int count, UINT8 baselevel);
561 struct dwrite_glyphbitmap
563 DWORD simulations;
564 float emsize;
565 UINT16 glyph;
566 INT pitch;
567 RECT bbox;
568 BYTE *buf;
569 DWRITE_MATRIX *m;
572 enum dwrite_outline_tags
574 OUTLINE_BEGIN_FIGURE,
575 OUTLINE_END_FIGURE,
576 OUTLINE_LINE,
577 OUTLINE_BEZIER,
580 struct dwrite_outline
582 struct
584 unsigned char *values;
585 size_t count;
586 size_t size;
587 } tags;
589 struct
591 D2D1_POINT_2F *values;
592 size_t count;
593 size_t size;
594 } points;
597 /* Glyph shaping */
598 enum SCRIPT_JUSTIFY
600 SCRIPT_JUSTIFY_NONE,
601 SCRIPT_JUSTIFY_ARABIC_BLANK,
602 SCRIPT_JUSTIFY_CHARACTER,
603 SCRIPT_JUSTIFY_RESERVED1,
604 SCRIPT_JUSTIFY_BLANK,
605 SCRIPT_JUSTIFY_RESERVED2,
606 SCRIPT_JUSTIFY_RESERVED3,
607 SCRIPT_JUSTIFY_ARABIC_NORMAL,
608 SCRIPT_JUSTIFY_ARABIC_KASHIDA,
609 SCRIPT_JUSTIFY_ARABIC_ALEF,
610 SCRIPT_JUSTIFY_ARABIC_HA,
611 SCRIPT_JUSTIFY_ARABIC_RA,
612 SCRIPT_JUSTIFY_ARABIC_BA,
613 SCRIPT_JUSTIFY_ARABIC_BARA,
614 SCRIPT_JUSTIFY_ARABIC_SEEN,
615 SCRIPT_JUSTIFY_ARABIC_SEEN_M
618 struct scriptshaping_cache
620 const struct shaping_font_ops *font;
621 void *context;
622 UINT16 upem;
624 struct ot_gsubgpos_table gsub;
625 struct ot_gsubgpos_table gpos;
627 struct
629 struct dwrite_fonttable table;
630 unsigned int classdef;
631 unsigned int markattachclassdef;
632 unsigned int markglyphsetdef;
633 } gdef;
636 struct shaping_glyph_info
638 /* Combined features mask. */
639 unsigned int mask;
640 /* Derived from glyph class, supplied by GDEF. */
641 unsigned int props;
642 /* Used for GPOS mark and cursive attachments. */
643 int attach_chain;
644 /* Only relevant for isClusterStart glyphs. Indicates text position for this cluster. */
645 unsigned int start_text_idx;
646 unsigned int codepoint;
649 struct shaping_glyph_properties
651 UINT16 justification : 4;
652 UINT16 isClusterStart : 1;
653 UINT16 isDiacritic : 1;
654 UINT16 isZeroWidthSpace : 1;
655 UINT16 reserved : 1;
656 UINT16 components : 4;
657 UINT16 lig_component : 4;
660 struct scriptshaping_context;
662 typedef void (*p_apply_context_lookup)(struct scriptshaping_context *context, unsigned int lookup_index);
664 enum shaping_feature_flags
666 FEATURE_GLOBAL = 0x1,
667 FEATURE_GLOBAL_SEARCH = 0x2,
668 FEATURE_MANUAL_ZWNJ = 0x4,
669 FEATURE_MANUAL_ZWJ = 0x8,
670 FEATURE_MANUAL_JOINERS = FEATURE_MANUAL_ZWNJ | FEATURE_MANUAL_ZWJ,
671 FEATURE_HAS_FALLBACK = 0x10,
672 FEATURE_NEEDS_FALLBACK = 0x20,
675 struct shaping_feature
677 unsigned int tag;
678 unsigned int index;
679 unsigned int flags;
680 unsigned int max_value;
681 unsigned int default_value;
682 unsigned int mask;
683 unsigned int shift;
684 unsigned int stage;
687 #define MAX_SHAPING_STAGE 16
689 struct shaping_features;
691 typedef void (*stage_func)(struct scriptshaping_context *context,
692 const struct shaping_features *features);
694 struct shaping_stage
696 stage_func func;
697 unsigned int last_lookup;
700 struct shaping_features
702 struct shaping_feature *features;
703 size_t count;
704 size_t capacity;
705 unsigned int stage;
706 struct shaping_stage stages[MAX_SHAPING_STAGE];
709 struct shaper
711 void (*collect_features)(struct scriptshaping_context *context, struct shaping_features *features);
712 void (*setup_masks)(struct scriptshaping_context *context, const struct shaping_features *features);
715 extern const struct shaper arabic_shaper;
717 extern void shape_enable_feature(struct shaping_features *features, unsigned int tag,
718 unsigned int flags);
719 extern void shape_add_feature_full(struct shaping_features *features, unsigned int tag,
720 unsigned int flags, unsigned int value);
721 extern unsigned int shape_get_feature_1_mask(const struct shaping_features *features,
722 unsigned int tag);
723 extern void shape_start_next_stage(struct shaping_features *features, stage_func func);
725 struct scriptshaping_context
727 struct scriptshaping_cache *cache;
728 const struct shaper *shaper;
729 unsigned int script;
730 UINT32 language_tag;
732 const WCHAR *text;
733 unsigned int length;
734 BOOL is_rtl;
735 BOOL is_sideways;
737 union
739 struct
741 const UINT16 *glyphs;
742 const DWRITE_SHAPING_GLYPH_PROPERTIES *glyph_props;
743 DWRITE_SHAPING_TEXT_PROPERTIES *text_props;
744 const UINT16 *clustermap;
745 p_apply_context_lookup apply_context_lookup;
746 } pos;
747 struct
749 UINT16 *glyphs;
750 DWRITE_SHAPING_GLYPH_PROPERTIES *glyph_props;
751 DWRITE_SHAPING_TEXT_PROPERTIES *text_props;
752 UINT16 *clustermap;
753 p_apply_context_lookup apply_context_lookup;
754 unsigned int max_glyph_count;
755 unsigned int capacity;
756 const WCHAR *digits;
757 } subst;
758 struct
760 UINT16 *glyphs;
761 struct shaping_glyph_properties *glyph_props;
762 DWRITE_SHAPING_TEXT_PROPERTIES *text_props;
763 UINT16 *clustermap;
764 p_apply_context_lookup apply_context_lookup;
765 } buffer;
766 } u;
768 const struct ot_gsubgpos_table *table; /* Either GSUB or GPOS. */
769 struct
771 const DWRITE_TYPOGRAPHIC_FEATURES **features;
772 const unsigned int *range_lengths;
773 unsigned int range_count;
774 } user_features;
775 unsigned int global_mask;
776 unsigned int lookup_mask; /* Currently processed feature mask, set in main loop. */
777 unsigned int auto_zwj;
778 unsigned int auto_zwnj;
779 struct shaping_glyph_info *glyph_infos;
780 unsigned int has_gpos_attachment : 1;
782 unsigned int cur;
783 unsigned int glyph_count;
784 unsigned int nesting_level_left;
786 float emsize;
787 DWRITE_MEASURING_MODE measuring_mode;
788 float *advances;
789 DWRITE_GLYPH_OFFSET *offsets;
792 struct shaping_font_ops
794 void (*grab_font_table)(void *context, UINT32 table, const BYTE **data, UINT32 *size, void **data_context);
795 void (*release_font_table)(void *context, void *data_context);
796 UINT16 (*get_font_upem)(void *context);
797 BOOL (*has_glyph)(void *context, unsigned int codepoint);
798 UINT16 (*get_glyph)(void *context, unsigned int codepoint);
801 extern struct scriptshaping_cache *create_scriptshaping_cache(void *context,
802 const struct shaping_font_ops *font_ops);
803 extern void release_scriptshaping_cache(struct scriptshaping_cache*);
804 extern struct scriptshaping_cache *fontface_get_shaping_cache(struct dwrite_fontface *fontface);
806 extern void opentype_layout_scriptshaping_cache_init(struct scriptshaping_cache *cache);
807 extern unsigned int opentype_layout_find_script(const struct scriptshaping_cache *cache, unsigned int kind,
808 DWORD tag, unsigned int *script_index);
809 extern unsigned int opentype_layout_find_language(const struct scriptshaping_cache *cache, unsigned int kind,
810 DWORD tag, unsigned int script_index, unsigned int *language_index);
811 extern void opentype_layout_apply_gsub_features(struct scriptshaping_context *context, unsigned int script_index,
812 unsigned int language_index, struct shaping_features *features);
813 extern void opentype_layout_apply_gpos_features(struct scriptshaping_context *context, unsigned int script_index,
814 unsigned int language_index, struct shaping_features *features);
815 extern BOOL opentype_layout_check_feature(struct scriptshaping_context *context, unsigned int script_index,
816 unsigned int language_index, struct shaping_feature *feature, unsigned int glyph_count,
817 const UINT16 *glyphs, UINT8 *feature_applies);
818 extern void opentype_layout_unsafe_to_break(struct scriptshaping_context *context, unsigned int start,
819 unsigned int end);
820 extern BOOL opentype_has_vertical_variants(struct dwrite_fontface *fontface);
821 extern HRESULT opentype_get_vertical_glyph_variants(struct dwrite_fontface *fontface, unsigned int glyph_count,
822 const UINT16 *nominal_glyphs, UINT16 *glyphs);
824 extern HRESULT shape_get_glyphs(struct scriptshaping_context *context, const unsigned int *scripts);
825 extern HRESULT shape_get_positions(struct scriptshaping_context *context, const unsigned int *scripts);
826 extern HRESULT shape_get_typographic_features(struct scriptshaping_context *context, const unsigned int *scripts,
827 unsigned int max_tagcount, unsigned int *actual_tagcount, DWRITE_FONT_FEATURE_TAG *tags);
828 extern HRESULT shape_check_typographic_feature(struct scriptshaping_context *context, const unsigned int *scripts,
829 unsigned int tag, unsigned int glyph_count, const UINT16 *glyphs, UINT8 *feature_applies);
831 struct font_data_context;
832 extern HMODULE dwrite_module;
834 extern void dwrite_fontface_get_glyph_bbox(IDWriteFontFace *fontface, struct dwrite_glyphbitmap *bitmap);
836 #endif /* __WINE_DWRITE_PRIVATE_H */