gdi32: Fix leak in GdiDeleteSpoolFileHandle.
[wine.git] / dlls / dwrite / dwrite_private.h
blobe87e747d295f2b3c6f710d794b85767c2e12ce6c
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 static inline const char *debugstr_tag(DWORD tag)
113 return debugstr_an((char *)&tag, 4);
116 const char *debugstr_sa_script(UINT16) DECLSPEC_HIDDEN;
118 static inline unsigned short get_table_entry_16(const unsigned short *table, WCHAR ch)
120 return table[table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0xf)];
123 static inline unsigned short get_table_entry_32(const unsigned short *table, UINT ch)
125 return table[table[table[table[ch >> 12] + ((ch >> 8) & 0x0f)] + ((ch >> 4) & 0x0f)] + (ch & 0xf)];
128 static inline BOOL is_simulation_valid(DWRITE_FONT_SIMULATIONS simulations)
130 return (simulations & ~(DWRITE_FONT_SIMULATIONS_NONE | DWRITE_FONT_SIMULATIONS_BOLD |
131 DWRITE_FONT_SIMULATIONS_OBLIQUE)) == 0;
134 struct textlayout_desc
136 IDWriteFactory7 *factory;
137 const WCHAR *string;
138 UINT32 length;
139 IDWriteTextFormat *format;
140 FLOAT max_width;
141 FLOAT max_height;
142 BOOL is_gdi_compatible;
143 /* fields below are only meaningful for gdi-compatible layout */
144 FLOAT ppdip;
145 const DWRITE_MATRIX *transform;
146 BOOL use_gdi_natural;
149 struct glyphrunanalysis_desc
151 const DWRITE_GLYPH_RUN *run;
152 const DWRITE_MATRIX *transform;
153 DWRITE_RENDERING_MODE1 rendering_mode;
154 DWRITE_MEASURING_MODE measuring_mode;
155 DWRITE_GRID_FIT_MODE gridfit_mode;
156 DWRITE_TEXT_ANTIALIAS_MODE aa_mode;
157 D2D_POINT_2F origin;
160 struct fontface_desc
162 IDWriteFactory7 *factory;
163 DWRITE_FONT_FACE_TYPE face_type;
164 IDWriteFontFile *file;
165 IDWriteFontFileStream *stream;
166 UINT32 index;
167 DWRITE_FONT_SIMULATIONS simulations;
168 struct dwrite_font_data *font_data; /* could be NULL when face is created directly with IDWriteFactory::CreateFontFace() */
171 struct dwrite_fonttable
173 const BYTE *data;
174 void *context;
175 UINT32 size;
176 BOOL exists;
179 struct fontfacecached
181 struct list entry;
182 IDWriteFontFace5 *fontface;
185 #define GLYPH_BLOCK_SHIFT 8
186 #define GLYPH_BLOCK_SIZE (1UL << GLYPH_BLOCK_SHIFT)
187 #define GLYPH_BLOCK_MASK (GLYPH_BLOCK_SIZE - 1)
188 #define GLYPH_MAX 65536
190 enum font_flags
192 FONT_IS_SYMBOL = 0x00000001,
193 FONT_IS_MONOSPACED = 0x00000002,
194 FONT_IS_COLORED = 0x00000004, /* CPAL/COLR support */
195 FONTFACE_KERNING_PAIRS = 0x00000008,
196 FONTFACE_NO_KERNING_PAIRS = 0x00000010,
197 FONTFACE_VERTICAL_VARIANTS = 0x00000020,
198 FONTFACE_NO_VERTICAL_VARIANTS = 0x00000040,
201 struct dwrite_cmap;
203 typedef UINT16 (*p_cmap_get_glyph_func)(const struct dwrite_cmap *cmap, unsigned int ch);
204 typedef unsigned int (*p_cmap_get_ranges_func)(const struct dwrite_cmap *cmap, unsigned int max_count,
205 DWRITE_UNICODE_RANGE *ranges);
207 struct dwrite_cmap
209 const void *data;
210 union
212 struct
214 unsigned int seg_count;
215 unsigned int glyph_id_array_len;
217 const UINT16 *ends;
218 const UINT16 *starts;
219 const UINT16 *id_delta;
220 const UINT16 *id_range_offset;
221 const UINT16 *glyph_id_array;
222 } format4;
223 struct
225 unsigned int first;
226 unsigned int last;
227 } format6_10;
228 struct
230 unsigned int group_count;
231 } format12_13;
232 } u;
233 p_cmap_get_glyph_func get_glyph;
234 p_cmap_get_ranges_func get_ranges;
235 unsigned short symbol : 1;
236 IDWriteFontFileStream *stream;
237 void *table_context;
240 extern void dwrite_cmap_init(struct dwrite_cmap *cmap, IDWriteFontFile *file, unsigned int face_index,
241 DWRITE_FONT_FACE_TYPE face_type) DECLSPEC_HIDDEN;
242 extern void dwrite_cmap_release(struct dwrite_cmap *cmap) DECLSPEC_HIDDEN;
243 extern UINT16 opentype_cmap_get_glyph(const struct dwrite_cmap *cmap, unsigned int ch) DECLSPEC_HIDDEN;
244 extern HRESULT opentype_cmap_get_unicode_ranges(const struct dwrite_cmap *cmap, unsigned int max_count,
245 DWRITE_UNICODE_RANGE *ranges, unsigned int *count) DECLSPEC_HIDDEN;
247 struct dwrite_fontface;
248 typedef UINT64 (*p_dwrite_fontface_get_font_object)(struct dwrite_fontface *fontface);
250 struct dwrite_fontface
252 IDWriteFontFace5 IDWriteFontFace5_iface;
253 IDWriteFontFaceReference IDWriteFontFaceReference_iface;
254 LONG refcount;
256 IDWriteFontFileStream *stream;
257 IDWriteFontFile *file;
258 UINT32 index;
260 IDWriteFactory7 *factory;
261 struct fontfacecached *cached;
262 UINT64 font_object;
263 void *data_context;
264 p_dwrite_fontface_get_font_object get_font_object;
265 struct
267 struct wine_rb_tree tree;
268 struct list mru;
269 size_t max_size;
270 size_t size;
271 } cache;
272 CRITICAL_SECTION cs;
274 USHORT simulations;
275 DWRITE_FONT_FACE_TYPE type;
276 DWRITE_FONT_METRICS1 metrics;
277 DWRITE_CARET_METRICS caret;
278 struct
280 unsigned int ascent;
281 unsigned int descent;
282 } typo_metrics;
283 unsigned int flags;
285 struct dwrite_cmap cmap;
287 struct dwrite_fonttable vdmx;
288 struct dwrite_fonttable gasp;
289 struct dwrite_fonttable cpal;
290 struct dwrite_fonttable colr;
291 struct dwrite_fonttable kern;
292 DWRITE_GLYPH_METRICS *glyphs[GLYPH_MAX/GLYPH_BLOCK_SIZE];
294 DWRITE_FONT_STYLE style;
295 DWRITE_FONT_STRETCH stretch;
296 DWRITE_FONT_WEIGHT weight;
297 DWRITE_PANOSE panose;
298 FONTSIGNATURE fontsig;
299 UINT32 glyph_image_formats;
301 IDWriteLocalizedStrings *info_strings[DWRITE_INFORMATIONAL_STRING_SUPPORTED_SCRIPT_LANGUAGE_TAG + 1];
302 IDWriteLocalizedStrings *family_names;
303 IDWriteLocalizedStrings *names;
305 struct scriptshaping_cache *shaping_cache;
307 LOGFONTW lf;
310 extern HRESULT create_numbersubstitution(DWRITE_NUMBER_SUBSTITUTION_METHOD,const WCHAR *locale,BOOL,IDWriteNumberSubstitution**) DECLSPEC_HIDDEN;
311 extern HRESULT create_text_format(const WCHAR *family_name, IDWriteFontCollection *collection, DWRITE_FONT_WEIGHT weight,
312 DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, float size, const WCHAR *locale, REFIID riid,
313 void **out) DECLSPEC_HIDDEN;
314 extern HRESULT create_textlayout(const struct textlayout_desc*,IDWriteTextLayout**) DECLSPEC_HIDDEN;
315 extern HRESULT create_trimmingsign(IDWriteFactory7 *factory, IDWriteTextFormat *format,
316 IDWriteInlineObject **sign) DECLSPEC_HIDDEN;
317 extern HRESULT create_typography(IDWriteTypography**) DECLSPEC_HIDDEN;
318 extern HRESULT create_localizedstrings(IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
319 extern HRESULT add_localizedstring(IDWriteLocalizedStrings*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN;
320 extern HRESULT clone_localizedstrings(IDWriteLocalizedStrings *iface, IDWriteLocalizedStrings **strings) DECLSPEC_HIDDEN;
321 extern void set_en_localizedstring(IDWriteLocalizedStrings*,const WCHAR*) DECLSPEC_HIDDEN;
322 extern void sort_localizedstrings(IDWriteLocalizedStrings*) DECLSPEC_HIDDEN;
323 extern unsigned int get_localizedstrings_count(IDWriteLocalizedStrings *strings) DECLSPEC_HIDDEN;
324 extern BOOL localizedstrings_contains(IDWriteLocalizedStrings *strings, const WCHAR *str) DECLSPEC_HIDDEN;
325 extern HRESULT get_system_fontcollection(IDWriteFactory7 *factory, DWRITE_FONT_FAMILY_MODEL family_model,
326 IDWriteFontCollection **collection) DECLSPEC_HIDDEN;
327 extern HRESULT get_eudc_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 **collection) DECLSPEC_HIDDEN;
328 extern IDWriteTextAnalyzer2 *get_text_analyzer(void) DECLSPEC_HIDDEN;
329 extern HRESULT create_font_file(IDWriteFontFileLoader *loader, const void *reference_key, UINT32 key_size, IDWriteFontFile **font_file) DECLSPEC_HIDDEN;
330 extern void init_local_fontfile_loader(void) DECLSPEC_HIDDEN;
331 extern IDWriteFontFileLoader *get_local_fontfile_loader(void) DECLSPEC_HIDDEN;
332 extern HRESULT create_fontface(const struct fontface_desc *desc, struct list *cached_list,
333 IDWriteFontFace5 **fontface) DECLSPEC_HIDDEN;
334 extern HRESULT create_font_collection(IDWriteFactory7 *factory, IDWriteFontFileEnumerator *enumerator, BOOL is_system,
335 IDWriteFontCollection3 **collection) DECLSPEC_HIDDEN;
336 extern HRESULT create_glyphrunanalysis(const struct glyphrunanalysis_desc*,IDWriteGlyphRunAnalysis**) DECLSPEC_HIDDEN;
337 extern BOOL is_system_collection(IDWriteFontCollection*) DECLSPEC_HIDDEN;
338 extern HRESULT get_local_refkey(const WCHAR*,const FILETIME*,void**,UINT32*) DECLSPEC_HIDDEN;
339 extern HRESULT get_filestream_from_file(IDWriteFontFile*,IDWriteFontFileStream**) DECLSPEC_HIDDEN;
340 extern BOOL is_face_type_supported(DWRITE_FONT_FACE_TYPE) DECLSPEC_HIDDEN;
341 extern HRESULT get_family_names_from_stream(IDWriteFontFileStream*,UINT32,DWRITE_FONT_FACE_TYPE,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
342 extern HRESULT create_colorglyphenum(D2D1_POINT_2F origin, const DWRITE_GLYPH_RUN *run, const DWRITE_GLYPH_RUN_DESCRIPTION *desc,
343 DWRITE_GLYPH_IMAGE_FORMATS formats, DWRITE_MEASURING_MODE mode, const DWRITE_MATRIX *transform, UINT32 palette,
344 IDWriteColorGlyphRunEnumerator1 **enumerator) DECLSPEC_HIDDEN;
345 extern BOOL lb_is_newline_char(WCHAR) DECLSPEC_HIDDEN;
346 extern HRESULT create_system_fontfallback(IDWriteFactory7 *factory, IDWriteFontFallback1 **fallback) DECLSPEC_HIDDEN;
347 extern void release_system_fontfallback(IDWriteFontFallback1 *fallback) DECLSPEC_HIDDEN;
348 extern void release_system_fallback_data(void) DECLSPEC_HIDDEN;
349 extern HRESULT create_fontfallback_builder(IDWriteFactory7 *factory, IDWriteFontFallbackBuilder **builder) DECLSPEC_HIDDEN;
350 extern HRESULT create_matching_font(IDWriteFontCollection *collection, const WCHAR *family, DWRITE_FONT_WEIGHT weight,
351 DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, REFIID riid, void **obj) DECLSPEC_HIDDEN;
352 extern HRESULT create_fontfacereference(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 face_index,
353 DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 axis_values_count,
354 IDWriteFontFaceReference1 **reference) DECLSPEC_HIDDEN;
355 extern HRESULT factory_get_cached_fontface(IDWriteFactory7 *factory, IDWriteFontFile * const *files, UINT32 num_files,
356 DWRITE_FONT_SIMULATIONS simulations, struct list **cache, REFIID riid, void **obj) DECLSPEC_HIDDEN;
357 extern void factory_detach_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 *collection) DECLSPEC_HIDDEN;
358 extern void factory_detach_gdiinterop(IDWriteFactory7 *factory, IDWriteGdiInterop1 *interop) DECLSPEC_HIDDEN;
359 extern struct fontfacecached *factory_cache_fontface(IDWriteFactory7 *factory, struct list *fontfaces,
360 IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN;
361 extern void get_logfont_from_font(IDWriteFont*,LOGFONTW*) DECLSPEC_HIDDEN;
362 extern void get_logfont_from_fontface(IDWriteFontFace*,LOGFONTW*) DECLSPEC_HIDDEN;
363 extern HRESULT get_fontsig_from_font(IDWriteFont*,FONTSIGNATURE*) DECLSPEC_HIDDEN;
364 extern HRESULT get_fontsig_from_fontface(IDWriteFontFace*,FONTSIGNATURE*) DECLSPEC_HIDDEN;
365 extern HRESULT create_gdiinterop(IDWriteFactory7 *factory, IDWriteGdiInterop1 **interop) DECLSPEC_HIDDEN;
366 extern void fontface_detach_from_cache(IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN;
367 extern void factory_lock(IDWriteFactory7 *factory) DECLSPEC_HIDDEN;
368 extern void factory_unlock(IDWriteFactory7 *factory) DECLSPEC_HIDDEN;
369 extern HRESULT create_inmemory_fileloader(IDWriteInMemoryFontFileLoader **loader) DECLSPEC_HIDDEN;
370 extern HRESULT create_font_resource(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 face_index,
371 IDWriteFontResource **resource) DECLSPEC_HIDDEN;
372 extern HRESULT create_fontset_builder(IDWriteFactory7 *factory, IDWriteFontSetBuilder2 **ret) DECLSPEC_HIDDEN;
373 extern HRESULT compute_glyph_origins(DWRITE_GLYPH_RUN const *run, DWRITE_MEASURING_MODE measuring_mode,
374 D2D1_POINT_2F baseline_origin, DWRITE_MATRIX const *transform, D2D1_POINT_2F *origins) DECLSPEC_HIDDEN;
375 extern HRESULT create_font_collection_from_set(IDWriteFactory7 *factory, IDWriteFontSet *set,
376 DWRITE_FONT_FAMILY_MODEL family_model, REFGUID riid, void **ret) DECLSPEC_HIDDEN;
377 extern HRESULT create_system_fontset(IDWriteFactory7 *factory, REFIID riid, void **obj) DECLSPEC_HIDDEN;
379 struct dwrite_fontface;
381 extern float fontface_get_scaled_design_advance(struct dwrite_fontface *fontface, DWRITE_MEASURING_MODE measuring_mode,
382 float emsize, float ppdip, const DWRITE_MATRIX *transform, UINT16 glyph, BOOL is_sideways) DECLSPEC_HIDDEN;
383 extern struct dwrite_fontface *unsafe_impl_from_IDWriteFontFace(IDWriteFontFace *iface) DECLSPEC_HIDDEN;
385 struct dwrite_textformat_data
387 WCHAR *family_name;
388 unsigned int family_len;
389 WCHAR *locale;
390 unsigned int locale_len;
392 DWRITE_FONT_WEIGHT weight;
393 DWRITE_FONT_STYLE style;
394 DWRITE_FONT_STRETCH stretch;
396 DWRITE_PARAGRAPH_ALIGNMENT paralign;
397 DWRITE_READING_DIRECTION readingdir;
398 DWRITE_WORD_WRAPPING wrapping;
399 BOOL last_line_wrapping;
400 DWRITE_TEXT_ALIGNMENT textalignment;
401 DWRITE_FLOW_DIRECTION flow;
402 DWRITE_VERTICAL_GLYPH_ORIENTATION vertical_orientation;
403 DWRITE_OPTICAL_ALIGNMENT optical_alignment;
404 DWRITE_LINE_SPACING spacing;
405 DWRITE_AUTOMATIC_FONT_AXES automatic_axes;
407 float fontsize;
408 float tabstop;
410 DWRITE_TRIMMING trimming;
411 IDWriteInlineObject *trimmingsign;
413 IDWriteFontCollection *collection;
414 IDWriteFontFallback *fallback;
416 DWRITE_FONT_AXIS_VALUE *axis_values;
417 unsigned int axis_values_count;
420 struct dwrite_textformat
422 IDWriteTextFormat3 IDWriteTextFormat3_iface;
423 LONG refcount;
424 struct dwrite_textformat_data format;
427 struct dwrite_textformat *unsafe_impl_from_IDWriteTextFormat(IDWriteTextFormat *iface) DECLSPEC_HIDDEN;
428 void release_format_data(struct dwrite_textformat_data *data) DECLSPEC_HIDDEN;
430 HRESULT format_set_vertical_orientation(struct dwrite_textformat_data *format,
431 DWRITE_VERTICAL_GLYPH_ORIENTATION orientation, BOOL *changed) DECLSPEC_HIDDEN;
432 HRESULT format_set_fontfallback(struct dwrite_textformat_data *format, IDWriteFontFallback *fallback) DECLSPEC_HIDDEN;
433 HRESULT format_get_fontfallback(const struct dwrite_textformat_data *format, IDWriteFontFallback **fallback) DECLSPEC_HIDDEN;
434 HRESULT format_set_font_axisvalues(struct dwrite_textformat_data *format,
435 DWRITE_FONT_AXIS_VALUE const *axis_values, unsigned int num_values) DECLSPEC_HIDDEN;
436 HRESULT format_get_font_axisvalues(struct dwrite_textformat_data *format,
437 DWRITE_FONT_AXIS_VALUE *axis_values, unsigned int num_values) DECLSPEC_HIDDEN;
438 HRESULT format_set_optical_alignment(struct dwrite_textformat_data *format,
439 DWRITE_OPTICAL_ALIGNMENT alignment) DECLSPEC_HIDDEN;
440 HRESULT format_set_trimming(struct dwrite_textformat_data *format, DWRITE_TRIMMING const *trimming,
441 IDWriteInlineObject *trimming_sign, BOOL *changed) DECLSPEC_HIDDEN;
442 HRESULT format_set_flowdirection(struct dwrite_textformat_data *format,
443 DWRITE_FLOW_DIRECTION direction, BOOL *changed) DECLSPEC_HIDDEN;
444 HRESULT format_set_readingdirection(struct dwrite_textformat_data *format,
445 DWRITE_READING_DIRECTION direction, BOOL *changed) DECLSPEC_HIDDEN;
446 HRESULT format_set_wordwrapping(struct dwrite_textformat_data *format, DWRITE_WORD_WRAPPING wrapping,
447 BOOL *changed) DECLSPEC_HIDDEN;
448 HRESULT format_set_paralignment(struct dwrite_textformat_data *format,
449 DWRITE_PARAGRAPH_ALIGNMENT alignment, BOOL *changed) DECLSPEC_HIDDEN;
450 HRESULT format_set_textalignment(struct dwrite_textformat_data *format, DWRITE_TEXT_ALIGNMENT alignment,
451 BOOL *changed) DECLSPEC_HIDDEN;
452 HRESULT format_set_linespacing(struct dwrite_textformat_data *format,
453 DWRITE_LINE_SPACING const *spacing, BOOL *changed) DECLSPEC_HIDDEN;
455 /* Opentype font table functions */
456 struct dwrite_font_props
458 DWRITE_FONT_STYLE style;
459 DWRITE_FONT_STRETCH stretch;
460 DWRITE_FONT_WEIGHT weight;
461 DWRITE_PANOSE panose;
462 FONTSIGNATURE fontsig;
463 LOGFONTW lf;
464 UINT32 flags;
465 float slant_angle;
468 struct file_stream_desc {
469 IDWriteFontFileStream *stream;
470 DWRITE_FONT_FACE_TYPE face_type;
471 UINT32 face_index;
474 extern const void* get_fontface_table(IDWriteFontFace5 *fontface, UINT32 tag,
475 struct dwrite_fonttable *table) DECLSPEC_HIDDEN;
477 struct tag_array
479 unsigned int *tags;
480 size_t capacity;
481 size_t count;
484 struct ot_gsubgpos_table
486 struct dwrite_fonttable table;
487 unsigned int script_list;
488 unsigned int feature_list;
489 unsigned int lookup_list;
492 struct dwrite_var_axis
494 DWRITE_FONT_AXIS_TAG tag;
495 float default_value;
496 float min_value;
497 float max_value;
498 unsigned int attributes;
501 extern HRESULT opentype_analyze_font(IDWriteFontFileStream*,BOOL*,DWRITE_FONT_FILE_TYPE*,DWRITE_FONT_FACE_TYPE*,UINT32*) DECLSPEC_HIDDEN;
502 extern HRESULT opentype_try_get_font_table(const struct file_stream_desc *stream_desc, UINT32 tag, const void **data,
503 void **context, UINT32 *size, BOOL *exists) DECLSPEC_HIDDEN;
504 extern void opentype_get_font_properties(const struct file_stream_desc *stream_desc,
505 struct dwrite_font_props *props) DECLSPEC_HIDDEN;
506 extern void opentype_get_font_metrics(struct file_stream_desc*,DWRITE_FONT_METRICS1*,DWRITE_CARET_METRICS*) DECLSPEC_HIDDEN;
507 extern void opentype_get_font_typo_metrics(struct file_stream_desc *stream_desc, unsigned int *ascent,
508 unsigned int *descent) DECLSPEC_HIDDEN;
509 extern HRESULT opentype_get_font_info_strings(const struct file_stream_desc *stream_desc,
510 DWRITE_INFORMATIONAL_STRING_ID id, IDWriteLocalizedStrings **strings) DECLSPEC_HIDDEN;
511 extern HRESULT opentype_get_font_familyname(const struct file_stream_desc *desc, DWRITE_FONT_FAMILY_MODEL family_model,
512 IDWriteLocalizedStrings **names) DECLSPEC_HIDDEN;
513 extern HRESULT opentype_get_font_facename(struct file_stream_desc*,WCHAR*,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
514 extern void opentype_get_typographic_features(struct ot_gsubgpos_table *table, unsigned int script_index,
515 unsigned int language_index, struct tag_array *tags) DECLSPEC_HIDDEN;
516 extern BOOL opentype_get_vdmx_size(const struct dwrite_fonttable *table, INT ppem, UINT16 *ascent,
517 UINT16 *descent) DECLSPEC_HIDDEN;
518 extern unsigned int opentype_get_cpal_palettecount(const struct dwrite_fonttable *table) DECLSPEC_HIDDEN;
519 extern unsigned int opentype_get_cpal_paletteentrycount(const struct dwrite_fonttable *table) DECLSPEC_HIDDEN;
520 extern HRESULT opentype_get_cpal_entries(const struct dwrite_fonttable *table, unsigned int palette,
521 unsigned int first_entry_index, unsigned int entry_count, DWRITE_COLOR_F *entries) DECLSPEC_HIDDEN;
522 extern UINT32 opentype_get_glyph_image_formats(IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN;
523 extern DWRITE_CONTAINER_TYPE opentype_analyze_container_type(void const *, UINT32) DECLSPEC_HIDDEN;
524 extern HRESULT opentype_get_kerning_pairs(struct dwrite_fontface *fontface, unsigned int count,
525 const UINT16 *glyphs, INT32 *values) DECLSPEC_HIDDEN;
526 extern BOOL opentype_has_kerning_pairs(struct dwrite_fontface *fontface) DECLSPEC_HIDDEN;
527 extern HRESULT opentype_get_font_var_axis(const struct file_stream_desc *stream_desc, struct dwrite_var_axis **axis,
528 unsigned int *axis_count) DECLSPEC_HIDDEN;
530 struct dwrite_colorglyph {
531 USHORT layer; /* [0, num_layers) index indicating current layer */
532 /* base glyph record data, set once on initialization */
533 USHORT first_layer;
534 USHORT num_layers;
535 /* current layer record data, updated every time glyph is switched to next layer */
536 UINT16 glyph;
537 UINT16 palette_index;
540 extern HRESULT opentype_get_colr_glyph(const struct dwrite_fonttable *table, UINT16 glyph,
541 struct dwrite_colorglyph *color_glyph) DECLSPEC_HIDDEN;
542 extern void opentype_colr_next_glyph(const struct dwrite_fonttable *table,
543 struct dwrite_colorglyph *color_glyph) DECLSPEC_HIDDEN;
545 enum gasp_flags {
546 GASP_GRIDFIT = 0x0001,
547 GASP_DOGRAY = 0x0002,
548 GASP_SYMMETRIC_GRIDFIT = 0x0004,
549 GASP_SYMMETRIC_SMOOTHING = 0x0008,
552 extern unsigned int opentype_get_gasp_flags(const struct dwrite_fonttable *gasp, float emsize) DECLSPEC_HIDDEN;
554 /* BiDi helpers */
555 struct bidi_char
557 unsigned int ch;
558 UINT8 explicit;
559 UINT8 resolved;
560 UINT8 nominal_bidi_class;
561 UINT8 bidi_class;
564 extern HRESULT bidi_computelevels(struct bidi_char *chars, unsigned int count, UINT8 baselevel) DECLSPEC_HIDDEN;
566 struct dwrite_glyphbitmap
568 DWORD simulations;
569 float emsize;
570 UINT16 glyph;
571 INT pitch;
572 RECT bbox;
573 BYTE *buf;
574 DWRITE_MATRIX *m;
577 enum dwrite_outline_tags
579 OUTLINE_BEGIN_FIGURE,
580 OUTLINE_END_FIGURE,
581 OUTLINE_LINE,
582 OUTLINE_BEZIER,
585 struct dwrite_outline
587 struct
589 unsigned char *values;
590 size_t count;
591 size_t size;
592 } tags;
594 struct
596 D2D1_POINT_2F *values;
597 size_t count;
598 size_t size;
599 } points;
602 /* Glyph shaping */
603 enum SCRIPT_JUSTIFY
605 SCRIPT_JUSTIFY_NONE,
606 SCRIPT_JUSTIFY_ARABIC_BLANK,
607 SCRIPT_JUSTIFY_CHARACTER,
608 SCRIPT_JUSTIFY_RESERVED1,
609 SCRIPT_JUSTIFY_BLANK,
610 SCRIPT_JUSTIFY_RESERVED2,
611 SCRIPT_JUSTIFY_RESERVED3,
612 SCRIPT_JUSTIFY_ARABIC_NORMAL,
613 SCRIPT_JUSTIFY_ARABIC_KASHIDA,
614 SCRIPT_JUSTIFY_ARABIC_ALEF,
615 SCRIPT_JUSTIFY_ARABIC_HA,
616 SCRIPT_JUSTIFY_ARABIC_RA,
617 SCRIPT_JUSTIFY_ARABIC_BA,
618 SCRIPT_JUSTIFY_ARABIC_BARA,
619 SCRIPT_JUSTIFY_ARABIC_SEEN,
620 SCRIPT_JUSTIFY_ARABIC_SEEN_M
623 struct scriptshaping_cache
625 const struct shaping_font_ops *font;
626 void *context;
627 UINT16 upem;
629 struct ot_gsubgpos_table gsub;
630 struct ot_gsubgpos_table gpos;
632 struct
634 struct dwrite_fonttable table;
635 unsigned int classdef;
636 unsigned int markattachclassdef;
637 unsigned int markglyphsetdef;
638 } gdef;
641 struct shaping_glyph_info
643 /* Combined features mask. */
644 unsigned int mask;
645 /* Derived from glyph class, supplied by GDEF. */
646 unsigned int props;
647 /* Used for GPOS mark and cursive attachments. */
648 int attach_chain;
649 /* Only relevant for isClusterStart glyphs. Indicates text position for this cluster. */
650 unsigned int start_text_idx;
651 unsigned int codepoint;
654 struct shaping_glyph_properties
656 UINT16 justification : 4;
657 UINT16 isClusterStart : 1;
658 UINT16 isDiacritic : 1;
659 UINT16 isZeroWidthSpace : 1;
660 UINT16 reserved : 1;
661 UINT16 components : 4;
662 UINT16 lig_component : 4;
665 struct scriptshaping_context;
667 typedef void (*p_apply_context_lookup)(struct scriptshaping_context *context, unsigned int lookup_index);
669 enum shaping_feature_flags
671 FEATURE_GLOBAL = 0x1,
672 FEATURE_GLOBAL_SEARCH = 0x2,
673 FEATURE_MANUAL_ZWNJ = 0x4,
674 FEATURE_MANUAL_ZWJ = 0x8,
675 FEATURE_MANUAL_JOINERS = FEATURE_MANUAL_ZWNJ | FEATURE_MANUAL_ZWJ,
676 FEATURE_HAS_FALLBACK = 0x10,
677 FEATURE_NEEDS_FALLBACK = 0x20,
680 struct shaping_feature
682 unsigned int tag;
683 unsigned int index;
684 unsigned int flags;
685 unsigned int max_value;
686 unsigned int default_value;
687 unsigned int mask;
688 unsigned int shift;
689 unsigned int stage;
692 #define MAX_SHAPING_STAGE 16
694 struct shaping_features;
696 typedef void (*stage_func)(struct scriptshaping_context *context,
697 const struct shaping_features *features);
699 struct shaping_stage
701 stage_func func;
702 unsigned int last_lookup;
705 struct shaping_features
707 struct shaping_feature *features;
708 size_t count;
709 size_t capacity;
710 unsigned int stage;
711 struct shaping_stage stages[MAX_SHAPING_STAGE];
714 struct shaper
716 void (*collect_features)(struct scriptshaping_context *context, struct shaping_features *features);
717 void (*setup_masks)(struct scriptshaping_context *context, const struct shaping_features *features);
720 extern const struct shaper arabic_shaper DECLSPEC_HIDDEN;
722 extern void shape_enable_feature(struct shaping_features *features, unsigned int tag,
723 unsigned int flags) DECLSPEC_HIDDEN;
724 extern void shape_add_feature_full(struct shaping_features *features, unsigned int tag,
725 unsigned int flags, unsigned int value) DECLSPEC_HIDDEN;
726 extern unsigned int shape_get_feature_1_mask(const struct shaping_features *features,
727 unsigned int tag) DECLSPEC_HIDDEN;
728 extern void shape_start_next_stage(struct shaping_features *features, stage_func func) DECLSPEC_HIDDEN;
730 struct scriptshaping_context
732 struct scriptshaping_cache *cache;
733 const struct shaper *shaper;
734 unsigned int script;
735 UINT32 language_tag;
737 const WCHAR *text;
738 unsigned int length;
739 BOOL is_rtl;
740 BOOL is_sideways;
742 union
744 struct
746 const UINT16 *glyphs;
747 const DWRITE_SHAPING_GLYPH_PROPERTIES *glyph_props;
748 DWRITE_SHAPING_TEXT_PROPERTIES *text_props;
749 const UINT16 *clustermap;
750 p_apply_context_lookup apply_context_lookup;
751 } pos;
752 struct
754 UINT16 *glyphs;
755 DWRITE_SHAPING_GLYPH_PROPERTIES *glyph_props;
756 DWRITE_SHAPING_TEXT_PROPERTIES *text_props;
757 UINT16 *clustermap;
758 p_apply_context_lookup apply_context_lookup;
759 unsigned int max_glyph_count;
760 unsigned int capacity;
761 const WCHAR *digits;
762 } subst;
763 struct
765 UINT16 *glyphs;
766 struct shaping_glyph_properties *glyph_props;
767 DWRITE_SHAPING_TEXT_PROPERTIES *text_props;
768 UINT16 *clustermap;
769 p_apply_context_lookup apply_context_lookup;
770 } buffer;
771 } u;
773 const struct ot_gsubgpos_table *table; /* Either GSUB or GPOS. */
774 struct
776 const DWRITE_TYPOGRAPHIC_FEATURES **features;
777 const unsigned int *range_lengths;
778 unsigned int range_count;
779 } user_features;
780 unsigned int global_mask;
781 unsigned int lookup_mask; /* Currently processed feature mask, set in main loop. */
782 unsigned int auto_zwj;
783 unsigned int auto_zwnj;
784 struct shaping_glyph_info *glyph_infos;
785 unsigned int has_gpos_attachment : 1;
787 unsigned int cur;
788 unsigned int glyph_count;
789 unsigned int nesting_level_left;
791 float emsize;
792 DWRITE_MEASURING_MODE measuring_mode;
793 float *advances;
794 DWRITE_GLYPH_OFFSET *offsets;
797 struct shaping_font_ops
799 void (*grab_font_table)(void *context, UINT32 table, const BYTE **data, UINT32 *size, void **data_context);
800 void (*release_font_table)(void *context, void *data_context);
801 UINT16 (*get_font_upem)(void *context);
802 BOOL (*has_glyph)(void *context, unsigned int codepoint);
803 UINT16 (*get_glyph)(void *context, unsigned int codepoint);
806 extern struct scriptshaping_cache *create_scriptshaping_cache(void *context,
807 const struct shaping_font_ops *font_ops) DECLSPEC_HIDDEN;
808 extern void release_scriptshaping_cache(struct scriptshaping_cache*) DECLSPEC_HIDDEN;
809 extern struct scriptshaping_cache *fontface_get_shaping_cache(struct dwrite_fontface *fontface) DECLSPEC_HIDDEN;
811 extern void opentype_layout_scriptshaping_cache_init(struct scriptshaping_cache *cache) DECLSPEC_HIDDEN;
812 extern unsigned int opentype_layout_find_script(const struct scriptshaping_cache *cache, unsigned int kind,
813 DWORD tag, unsigned int *script_index) DECLSPEC_HIDDEN;
814 extern unsigned int opentype_layout_find_language(const struct scriptshaping_cache *cache, unsigned int kind,
815 DWORD tag, unsigned int script_index, unsigned int *language_index) DECLSPEC_HIDDEN;
816 extern void opentype_layout_apply_gsub_features(struct scriptshaping_context *context, unsigned int script_index,
817 unsigned int language_index, struct shaping_features *features) DECLSPEC_HIDDEN;
818 extern void opentype_layout_apply_gpos_features(struct scriptshaping_context *context, unsigned int script_index,
819 unsigned int language_index, struct shaping_features *features) DECLSPEC_HIDDEN;
820 extern BOOL opentype_layout_check_feature(struct scriptshaping_context *context, unsigned int script_index,
821 unsigned int language_index, struct shaping_feature *feature, unsigned int glyph_count,
822 const UINT16 *glyphs, UINT8 *feature_applies) DECLSPEC_HIDDEN;
823 extern void opentype_layout_unsafe_to_break(struct scriptshaping_context *context, unsigned int start,
824 unsigned int end) DECLSPEC_HIDDEN;
825 extern BOOL opentype_has_vertical_variants(struct dwrite_fontface *fontface) DECLSPEC_HIDDEN;
826 extern HRESULT opentype_get_vertical_glyph_variants(struct dwrite_fontface *fontface, unsigned int glyph_count,
827 const UINT16 *nominal_glyphs, UINT16 *glyphs) DECLSPEC_HIDDEN;
829 extern HRESULT shape_get_glyphs(struct scriptshaping_context *context, const unsigned int *scripts) DECLSPEC_HIDDEN;
830 extern HRESULT shape_get_positions(struct scriptshaping_context *context, const unsigned int *scripts) DECLSPEC_HIDDEN;
831 extern HRESULT shape_get_typographic_features(struct scriptshaping_context *context, const unsigned int *scripts,
832 unsigned int max_tagcount, unsigned int *actual_tagcount, unsigned int *tags) DECLSPEC_HIDDEN;
833 extern HRESULT shape_check_typographic_feature(struct scriptshaping_context *context, const unsigned int *scripts,
834 unsigned int tag, unsigned int glyph_count, const UINT16 *glyphs, UINT8 *feature_applies) DECLSPEC_HIDDEN;
836 struct font_data_context;
837 extern HMODULE dwrite_module DECLSPEC_HIDDEN;
839 extern void dwrite_fontface_get_glyph_bbox(IDWriteFontFace *fontface, struct dwrite_glyphbitmap *bitmap) DECLSPEC_HIDDEN;
841 #endif /* __WINE_DWRITE_PRIVATE_H */