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
23 #include "wine/debug.h"
24 #include "wine/list.h"
25 #include "wine/rbtree.h"
27 #define MS_GSUB_TAG DWRITE_MAKE_OPENTYPE_TAG('G','S','U','B')
28 #define MS_GPOS_TAG DWRITE_MAKE_OPENTYPE_TAG('G','P','O','S')
30 static const DWRITE_MATRIX identity
=
37 static inline LPWSTR
heap_strdupnW(const WCHAR
*str
, UINT32 len
)
43 ret
= malloc((len
+1)*sizeof(WCHAR
));
46 memcpy(ret
, str
, len
*sizeof(WCHAR
));
54 static inline const char *debugstr_range(const DWRITE_TEXT_RANGE
*range
)
56 return wine_dbg_sprintf("%u:%u", range
->startPosition
, range
->length
);
59 static inline const char *debugstr_matrix(const DWRITE_MATRIX
*m
)
61 if (!m
) return "(null)";
62 return wine_dbg_sprintf("{%.2f,%.2f,%.2f,%.2f,%.2f,%.2f}", m
->m11
, m
->m12
, m
->m21
, m
->m22
,
66 static inline BOOL
dwrite_array_reserve(void **elements
, size_t *capacity
, size_t count
, size_t size
)
68 size_t new_capacity
, max_capacity
;
71 if (count
<= *capacity
)
74 max_capacity
= ~(SIZE_T
)0 / size
;
75 if (count
> max_capacity
)
78 new_capacity
= max(4, *capacity
);
79 while (new_capacity
< count
&& new_capacity
<= max_capacity
/ 2)
81 if (new_capacity
< count
)
82 new_capacity
= max_capacity
;
84 new_elements
= realloc(*elements
, new_capacity
* size
);
88 *elements
= new_elements
;
89 *capacity
= new_capacity
;
94 static inline const char *debugstr_tag(DWORD tag
)
96 return debugstr_an((char *)&tag
, 4);
99 const char *debugstr_sa_script(UINT16
) DECLSPEC_HIDDEN
;
101 static inline unsigned short get_table_entry(const unsigned short *table
, WCHAR ch
)
103 return table
[table
[table
[ch
>> 8] + ((ch
>> 4) & 0x0f)] + (ch
& 0xf)];
106 static inline BOOL
is_simulation_valid(DWRITE_FONT_SIMULATIONS simulations
)
108 return (simulations
& ~(DWRITE_FONT_SIMULATIONS_NONE
| DWRITE_FONT_SIMULATIONS_BOLD
|
109 DWRITE_FONT_SIMULATIONS_OBLIQUE
)) == 0;
112 struct textlayout_desc
114 IDWriteFactory7
*factory
;
117 IDWriteTextFormat
*format
;
120 BOOL is_gdi_compatible
;
121 /* fields below are only meaningful for gdi-compatible layout */
123 const DWRITE_MATRIX
*transform
;
124 BOOL use_gdi_natural
;
127 struct glyphrunanalysis_desc
129 const DWRITE_GLYPH_RUN
*run
;
130 const DWRITE_MATRIX
*transform
;
131 DWRITE_RENDERING_MODE1 rendering_mode
;
132 DWRITE_MEASURING_MODE measuring_mode
;
133 DWRITE_GRID_FIT_MODE gridfit_mode
;
134 DWRITE_TEXT_ANTIALIAS_MODE aa_mode
;
140 IDWriteFactory7
*factory
;
141 DWRITE_FONT_FACE_TYPE face_type
;
142 IDWriteFontFile
*file
;
143 IDWriteFontFileStream
*stream
;
145 DWRITE_FONT_SIMULATIONS simulations
;
146 struct dwrite_font_data
*font_data
; /* could be NULL when face is created directly with IDWriteFactory::CreateFontFace() */
149 struct dwrite_fonttable
157 struct fontfacecached
160 IDWriteFontFace5
*fontface
;
163 #define GLYPH_BLOCK_SHIFT 8
164 #define GLYPH_BLOCK_SIZE (1UL << GLYPH_BLOCK_SHIFT)
165 #define GLYPH_BLOCK_MASK (GLYPH_BLOCK_SIZE - 1)
166 #define GLYPH_MAX 65536
170 FONT_IS_SYMBOL
= 0x00000001,
171 FONT_IS_MONOSPACED
= 0x00000002,
172 FONT_IS_COLORED
= 0x00000004, /* CPAL/COLR support */
173 FONTFACE_KERNING_PAIRS
= 0x00000008,
174 FONTFACE_NO_KERNING_PAIRS
= 0x00000010,
175 FONTFACE_VERTICAL_VARIANTS
= 0x00000020,
176 FONTFACE_NO_VERTICAL_VARIANTS
= 0x00000040,
181 typedef UINT16 (*p_cmap_get_glyph_func
)(const struct dwrite_cmap
*cmap
, unsigned int ch
);
182 typedef unsigned int (*p_cmap_get_ranges_func
)(const struct dwrite_cmap
*cmap
, unsigned int max_count
,
183 DWRITE_UNICODE_RANGE
*ranges
);
192 unsigned int seg_count
;
193 unsigned int glyph_id_array_len
;
196 const UINT16
*starts
;
197 const UINT16
*id_delta
;
198 const UINT16
*id_range_offset
;
199 const UINT16
*glyph_id_array
;
208 unsigned int group_count
;
211 p_cmap_get_glyph_func get_glyph
;
212 p_cmap_get_ranges_func get_ranges
;
213 unsigned short symbol
: 1;
214 IDWriteFontFileStream
*stream
;
218 extern void dwrite_cmap_init(struct dwrite_cmap
*cmap
, IDWriteFontFile
*file
, unsigned int face_index
,
219 DWRITE_FONT_FACE_TYPE face_type
) DECLSPEC_HIDDEN
;
220 extern void dwrite_cmap_release(struct dwrite_cmap
*cmap
) DECLSPEC_HIDDEN
;
221 extern UINT16
opentype_cmap_get_glyph(const struct dwrite_cmap
*cmap
, unsigned int ch
) DECLSPEC_HIDDEN
;
222 extern HRESULT
opentype_cmap_get_unicode_ranges(const struct dwrite_cmap
*cmap
, unsigned int max_count
,
223 DWRITE_UNICODE_RANGE
*ranges
, unsigned int *count
) DECLSPEC_HIDDEN
;
225 struct dwrite_fontface
;
226 typedef UINT64 (*p_dwrite_fontface_get_font_object
)(struct dwrite_fontface
*fontface
);
228 struct dwrite_fontface
230 IDWriteFontFace5 IDWriteFontFace5_iface
;
231 IDWriteFontFaceReference IDWriteFontFaceReference_iface
;
234 IDWriteFontFileStream
*stream
;
235 IDWriteFontFile
*file
;
238 IDWriteFactory7
*factory
;
239 struct fontfacecached
*cached
;
242 p_dwrite_fontface_get_font_object get_font_object
;
245 struct wine_rb_tree tree
;
253 DWRITE_FONT_FACE_TYPE type
;
254 DWRITE_FONT_METRICS1 metrics
;
255 DWRITE_CARET_METRICS caret
;
259 unsigned int descent
;
263 struct dwrite_cmap cmap
;
265 struct dwrite_fonttable vdmx
;
266 struct dwrite_fonttable gasp
;
267 struct dwrite_fonttable cpal
;
268 struct dwrite_fonttable colr
;
269 struct dwrite_fonttable kern
;
270 DWRITE_GLYPH_METRICS
*glyphs
[GLYPH_MAX
/GLYPH_BLOCK_SIZE
];
272 DWRITE_FONT_STYLE style
;
273 DWRITE_FONT_STRETCH stretch
;
274 DWRITE_FONT_WEIGHT weight
;
275 DWRITE_PANOSE panose
;
276 FONTSIGNATURE fontsig
;
277 UINT32 glyph_image_formats
;
279 IDWriteLocalizedStrings
*info_strings
[DWRITE_INFORMATIONAL_STRING_SUPPORTED_SCRIPT_LANGUAGE_TAG
+ 1];
280 IDWriteLocalizedStrings
*family_names
;
281 IDWriteLocalizedStrings
*names
;
283 struct scriptshaping_cache
*shaping_cache
;
288 extern HRESULT
create_numbersubstitution(DWRITE_NUMBER_SUBSTITUTION_METHOD
,const WCHAR
*locale
,BOOL
,IDWriteNumberSubstitution
**) DECLSPEC_HIDDEN
;
289 extern HRESULT
create_text_format(const WCHAR
*family_name
, IDWriteFontCollection
*collection
, DWRITE_FONT_WEIGHT weight
,
290 DWRITE_FONT_STYLE style
, DWRITE_FONT_STRETCH stretch
, float size
, const WCHAR
*locale
, REFIID riid
,
291 void **out
) DECLSPEC_HIDDEN
;
292 extern HRESULT
create_textlayout(const struct textlayout_desc
*,IDWriteTextLayout
**) DECLSPEC_HIDDEN
;
293 extern HRESULT
create_trimmingsign(IDWriteFactory7
*factory
, IDWriteTextFormat
*format
,
294 IDWriteInlineObject
**sign
) DECLSPEC_HIDDEN
;
295 extern HRESULT
create_typography(IDWriteTypography
**) DECLSPEC_HIDDEN
;
296 extern HRESULT
create_localizedstrings(IDWriteLocalizedStrings
**) DECLSPEC_HIDDEN
;
297 extern HRESULT
add_localizedstring(IDWriteLocalizedStrings
*,const WCHAR
*,const WCHAR
*) DECLSPEC_HIDDEN
;
298 extern HRESULT
clone_localizedstrings(IDWriteLocalizedStrings
*iface
, IDWriteLocalizedStrings
**strings
) DECLSPEC_HIDDEN
;
299 extern void set_en_localizedstring(IDWriteLocalizedStrings
*,const WCHAR
*) DECLSPEC_HIDDEN
;
300 extern void sort_localizedstrings(IDWriteLocalizedStrings
*) DECLSPEC_HIDDEN
;
301 extern unsigned int get_localizedstrings_count(IDWriteLocalizedStrings
*strings
) DECLSPEC_HIDDEN
;
302 extern BOOL
localizedstrings_contains(IDWriteLocalizedStrings
*strings
, const WCHAR
*str
) DECLSPEC_HIDDEN
;
303 extern HRESULT
get_system_fontcollection(IDWriteFactory7
*factory
, DWRITE_FONT_FAMILY_MODEL family_model
,
304 IDWriteFontCollection
**collection
) DECLSPEC_HIDDEN
;
305 extern HRESULT
get_eudc_fontcollection(IDWriteFactory7
*factory
, IDWriteFontCollection3
**collection
) DECLSPEC_HIDDEN
;
306 extern IDWriteTextAnalyzer2
*get_text_analyzer(void) DECLSPEC_HIDDEN
;
307 extern HRESULT
create_font_file(IDWriteFontFileLoader
*loader
, const void *reference_key
, UINT32 key_size
, IDWriteFontFile
**font_file
) DECLSPEC_HIDDEN
;
308 extern void init_local_fontfile_loader(void) DECLSPEC_HIDDEN
;
309 extern IDWriteFontFileLoader
*get_local_fontfile_loader(void) DECLSPEC_HIDDEN
;
310 extern HRESULT
create_fontface(const struct fontface_desc
*desc
, struct list
*cached_list
,
311 IDWriteFontFace5
**fontface
) DECLSPEC_HIDDEN
;
312 extern HRESULT
create_font_collection(IDWriteFactory7
*factory
, IDWriteFontFileEnumerator
*enumerator
, BOOL is_system
,
313 IDWriteFontCollection3
**collection
) DECLSPEC_HIDDEN
;
314 extern HRESULT
create_glyphrunanalysis(const struct glyphrunanalysis_desc
*,IDWriteGlyphRunAnalysis
**) DECLSPEC_HIDDEN
;
315 extern BOOL
is_system_collection(IDWriteFontCollection
*) DECLSPEC_HIDDEN
;
316 extern HRESULT
get_local_refkey(const WCHAR
*,const FILETIME
*,void**,UINT32
*) DECLSPEC_HIDDEN
;
317 extern HRESULT
get_filestream_from_file(IDWriteFontFile
*,IDWriteFontFileStream
**) DECLSPEC_HIDDEN
;
318 extern BOOL
is_face_type_supported(DWRITE_FONT_FACE_TYPE
) DECLSPEC_HIDDEN
;
319 extern HRESULT
get_family_names_from_stream(IDWriteFontFileStream
*,UINT32
,DWRITE_FONT_FACE_TYPE
,IDWriteLocalizedStrings
**) DECLSPEC_HIDDEN
;
320 extern HRESULT
create_colorglyphenum(D2D1_POINT_2F origin
, const DWRITE_GLYPH_RUN
*run
, const DWRITE_GLYPH_RUN_DESCRIPTION
*desc
,
321 DWRITE_GLYPH_IMAGE_FORMATS formats
, DWRITE_MEASURING_MODE mode
, const DWRITE_MATRIX
*transform
, UINT32 palette
,
322 IDWriteColorGlyphRunEnumerator1
**enumerator
) DECLSPEC_HIDDEN
;
323 extern BOOL
lb_is_newline_char(WCHAR
) DECLSPEC_HIDDEN
;
324 extern HRESULT
create_system_fontfallback(IDWriteFactory7
*factory
, IDWriteFontFallback1
**fallback
) DECLSPEC_HIDDEN
;
325 extern void release_system_fontfallback(IDWriteFontFallback1
*fallback
) DECLSPEC_HIDDEN
;
326 extern HRESULT
create_fontfallback_builder(IDWriteFactory7
*factory
, IDWriteFontFallbackBuilder
**builder
) DECLSPEC_HIDDEN
;
327 extern HRESULT
create_matching_font(IDWriteFontCollection
*,const WCHAR
*,DWRITE_FONT_WEIGHT
,DWRITE_FONT_STYLE
,DWRITE_FONT_STRETCH
,
328 IDWriteFont
**) DECLSPEC_HIDDEN
;
329 extern HRESULT
create_fontfacereference(IDWriteFactory7
*factory
, IDWriteFontFile
*file
, UINT32 face_index
,
330 DWRITE_FONT_SIMULATIONS simulations
, DWRITE_FONT_AXIS_VALUE
const *axis_values
, UINT32 axis_values_count
,
331 IDWriteFontFaceReference1
**reference
) DECLSPEC_HIDDEN
;
332 extern HRESULT
factory_get_cached_fontface(IDWriteFactory7
*factory
, IDWriteFontFile
* const *files
, UINT32 num_files
,
333 DWRITE_FONT_SIMULATIONS simulations
, struct list
**cache
, REFIID riid
, void **obj
) DECLSPEC_HIDDEN
;
334 extern void factory_detach_fontcollection(IDWriteFactory7
*factory
, IDWriteFontCollection3
*collection
) DECLSPEC_HIDDEN
;
335 extern void factory_detach_gdiinterop(IDWriteFactory7
*factory
, IDWriteGdiInterop1
*interop
) DECLSPEC_HIDDEN
;
336 extern struct fontfacecached
*factory_cache_fontface(IDWriteFactory7
*factory
, struct list
*fontfaces
,
337 IDWriteFontFace5
*fontface
) DECLSPEC_HIDDEN
;
338 extern void get_logfont_from_font(IDWriteFont
*,LOGFONTW
*) DECLSPEC_HIDDEN
;
339 extern void get_logfont_from_fontface(IDWriteFontFace
*,LOGFONTW
*) DECLSPEC_HIDDEN
;
340 extern HRESULT
get_fontsig_from_font(IDWriteFont
*,FONTSIGNATURE
*) DECLSPEC_HIDDEN
;
341 extern HRESULT
get_fontsig_from_fontface(IDWriteFontFace
*,FONTSIGNATURE
*) DECLSPEC_HIDDEN
;
342 extern HRESULT
create_gdiinterop(IDWriteFactory7
*factory
, IDWriteGdiInterop1
**interop
) DECLSPEC_HIDDEN
;
343 extern void fontface_detach_from_cache(IDWriteFontFace5
*fontface
) DECLSPEC_HIDDEN
;
344 extern void factory_lock(IDWriteFactory7
*factory
) DECLSPEC_HIDDEN
;
345 extern void factory_unlock(IDWriteFactory7
*factory
) DECLSPEC_HIDDEN
;
346 extern HRESULT
create_inmemory_fileloader(IDWriteInMemoryFontFileLoader
**loader
) DECLSPEC_HIDDEN
;
347 extern HRESULT
create_font_resource(IDWriteFactory7
*factory
, IDWriteFontFile
*file
, UINT32 face_index
,
348 IDWriteFontResource
**resource
) DECLSPEC_HIDDEN
;
349 extern HRESULT
create_fontset_builder(IDWriteFactory7
*factory
, IDWriteFontSetBuilder2
**ret
) DECLSPEC_HIDDEN
;
350 extern HRESULT
compute_glyph_origins(DWRITE_GLYPH_RUN
const *run
, DWRITE_MEASURING_MODE measuring_mode
,
351 D2D1_POINT_2F baseline_origin
, DWRITE_MATRIX
const *transform
, D2D1_POINT_2F
*origins
) DECLSPEC_HIDDEN
;
352 extern HRESULT
create_font_collection_from_set(IDWriteFactory7
*factory
, IDWriteFontSet
*set
,
353 DWRITE_FONT_FAMILY_MODEL family_model
, REFGUID riid
, void **ret
) DECLSPEC_HIDDEN
;
354 extern HRESULT
create_system_fontset(IDWriteFactory7
*factory
, REFIID riid
, void **obj
) DECLSPEC_HIDDEN
;
356 struct dwrite_fontface
;
358 extern float fontface_get_scaled_design_advance(struct dwrite_fontface
*fontface
, DWRITE_MEASURING_MODE measuring_mode
,
359 float emsize
, float ppdip
, const DWRITE_MATRIX
*transform
, UINT16 glyph
, BOOL is_sideways
) DECLSPEC_HIDDEN
;
360 extern struct dwrite_fontface
*unsafe_impl_from_IDWriteFontFace(IDWriteFontFace
*iface
) DECLSPEC_HIDDEN
;
362 struct dwrite_textformat_data
365 unsigned int family_len
;
367 unsigned int locale_len
;
369 DWRITE_FONT_WEIGHT weight
;
370 DWRITE_FONT_STYLE style
;
371 DWRITE_FONT_STRETCH stretch
;
373 DWRITE_PARAGRAPH_ALIGNMENT paralign
;
374 DWRITE_READING_DIRECTION readingdir
;
375 DWRITE_WORD_WRAPPING wrapping
;
376 BOOL last_line_wrapping
;
377 DWRITE_TEXT_ALIGNMENT textalignment
;
378 DWRITE_FLOW_DIRECTION flow
;
379 DWRITE_VERTICAL_GLYPH_ORIENTATION vertical_orientation
;
380 DWRITE_OPTICAL_ALIGNMENT optical_alignment
;
381 DWRITE_LINE_SPACING spacing
;
382 DWRITE_AUTOMATIC_FONT_AXES automatic_axes
;
387 DWRITE_TRIMMING trimming
;
388 IDWriteInlineObject
*trimmingsign
;
390 IDWriteFontCollection
*collection
;
391 IDWriteFontFallback
*fallback
;
393 DWRITE_FONT_AXIS_VALUE
*axis_values
;
394 unsigned int axis_values_count
;
397 struct dwrite_textformat
399 IDWriteTextFormat3 IDWriteTextFormat3_iface
;
401 struct dwrite_textformat_data format
;
404 struct dwrite_textformat
*unsafe_impl_from_IDWriteTextFormat(IDWriteTextFormat
*iface
) DECLSPEC_HIDDEN
;
405 void release_format_data(struct dwrite_textformat_data
*data
) DECLSPEC_HIDDEN
;
407 HRESULT
format_set_vertical_orientation(struct dwrite_textformat_data
*format
,
408 DWRITE_VERTICAL_GLYPH_ORIENTATION orientation
, BOOL
*changed
) DECLSPEC_HIDDEN
;
409 HRESULT
format_set_fontfallback(struct dwrite_textformat_data
*format
, IDWriteFontFallback
*fallback
) DECLSPEC_HIDDEN
;
410 HRESULT
format_get_fontfallback(const struct dwrite_textformat_data
*format
, IDWriteFontFallback
**fallback
) DECLSPEC_HIDDEN
;
411 HRESULT
format_set_font_axisvalues(struct dwrite_textformat_data
*format
,
412 DWRITE_FONT_AXIS_VALUE
const *axis_values
, unsigned int num_values
) DECLSPEC_HIDDEN
;
413 HRESULT
format_get_font_axisvalues(struct dwrite_textformat_data
*format
,
414 DWRITE_FONT_AXIS_VALUE
*axis_values
, unsigned int num_values
) DECLSPEC_HIDDEN
;
415 HRESULT
format_set_optical_alignment(struct dwrite_textformat_data
*format
,
416 DWRITE_OPTICAL_ALIGNMENT alignment
) DECLSPEC_HIDDEN
;
417 HRESULT
format_set_trimming(struct dwrite_textformat_data
*format
, DWRITE_TRIMMING
const *trimming
,
418 IDWriteInlineObject
*trimming_sign
, BOOL
*changed
) DECLSPEC_HIDDEN
;
419 HRESULT
format_set_flowdirection(struct dwrite_textformat_data
*format
,
420 DWRITE_FLOW_DIRECTION direction
, BOOL
*changed
) DECLSPEC_HIDDEN
;
421 HRESULT
format_set_readingdirection(struct dwrite_textformat_data
*format
,
422 DWRITE_READING_DIRECTION direction
, BOOL
*changed
) DECLSPEC_HIDDEN
;
423 HRESULT
format_set_wordwrapping(struct dwrite_textformat_data
*format
, DWRITE_WORD_WRAPPING wrapping
,
424 BOOL
*changed
) DECLSPEC_HIDDEN
;
425 HRESULT
format_set_paralignment(struct dwrite_textformat_data
*format
,
426 DWRITE_PARAGRAPH_ALIGNMENT alignment
, BOOL
*changed
) DECLSPEC_HIDDEN
;
427 HRESULT
format_set_textalignment(struct dwrite_textformat_data
*format
, DWRITE_TEXT_ALIGNMENT alignment
,
428 BOOL
*changed
) DECLSPEC_HIDDEN
;
429 HRESULT
format_set_linespacing(struct dwrite_textformat_data
*format
,
430 DWRITE_LINE_SPACING
const *spacing
, BOOL
*changed
) DECLSPEC_HIDDEN
;
432 /* Opentype font table functions */
433 struct dwrite_font_props
435 DWRITE_FONT_STYLE style
;
436 DWRITE_FONT_STRETCH stretch
;
437 DWRITE_FONT_WEIGHT weight
;
438 DWRITE_PANOSE panose
;
439 FONTSIGNATURE fontsig
;
445 struct file_stream_desc
{
446 IDWriteFontFileStream
*stream
;
447 DWRITE_FONT_FACE_TYPE face_type
;
451 extern const void* get_fontface_table(IDWriteFontFace5
*fontface
, UINT32 tag
,
452 struct dwrite_fonttable
*table
) DECLSPEC_HIDDEN
;
461 struct ot_gsubgpos_table
463 struct dwrite_fonttable table
;
464 unsigned int script_list
;
465 unsigned int feature_list
;
466 unsigned int lookup_list
;
469 struct dwrite_var_axis
471 DWRITE_FONT_AXIS_TAG tag
;
475 unsigned int attributes
;
478 extern HRESULT
opentype_analyze_font(IDWriteFontFileStream
*,BOOL
*,DWRITE_FONT_FILE_TYPE
*,DWRITE_FONT_FACE_TYPE
*,UINT32
*) DECLSPEC_HIDDEN
;
479 extern HRESULT
opentype_try_get_font_table(const struct file_stream_desc
*stream_desc
, UINT32 tag
, const void **data
,
480 void **context
, UINT32
*size
, BOOL
*exists
) DECLSPEC_HIDDEN
;
481 extern void opentype_get_font_properties(const struct file_stream_desc
*stream_desc
,
482 struct dwrite_font_props
*props
) DECLSPEC_HIDDEN
;
483 extern void opentype_get_font_metrics(struct file_stream_desc
*,DWRITE_FONT_METRICS1
*,DWRITE_CARET_METRICS
*) DECLSPEC_HIDDEN
;
484 extern void opentype_get_font_typo_metrics(struct file_stream_desc
*stream_desc
, unsigned int *ascent
,
485 unsigned int *descent
) DECLSPEC_HIDDEN
;
486 extern HRESULT
opentype_get_font_info_strings(const struct file_stream_desc
*stream_desc
,
487 DWRITE_INFORMATIONAL_STRING_ID id
, IDWriteLocalizedStrings
**strings
) DECLSPEC_HIDDEN
;
488 extern HRESULT
opentype_get_font_familyname(const struct file_stream_desc
*desc
, DWRITE_FONT_FAMILY_MODEL family_model
,
489 IDWriteLocalizedStrings
**names
) DECLSPEC_HIDDEN
;
490 extern HRESULT
opentype_get_font_facename(struct file_stream_desc
*,WCHAR
*,IDWriteLocalizedStrings
**) DECLSPEC_HIDDEN
;
491 extern void opentype_get_typographic_features(struct ot_gsubgpos_table
*table
, unsigned int script_index
,
492 unsigned int language_index
, struct tag_array
*tags
) DECLSPEC_HIDDEN
;
493 extern BOOL
opentype_get_vdmx_size(const struct dwrite_fonttable
*table
, INT ppem
, UINT16
*ascent
,
494 UINT16
*descent
) DECLSPEC_HIDDEN
;
495 extern unsigned int opentype_get_cpal_palettecount(const struct dwrite_fonttable
*table
) DECLSPEC_HIDDEN
;
496 extern unsigned int opentype_get_cpal_paletteentrycount(const struct dwrite_fonttable
*table
) DECLSPEC_HIDDEN
;
497 extern HRESULT
opentype_get_cpal_entries(const struct dwrite_fonttable
*table
, unsigned int palette
,
498 unsigned int first_entry_index
, unsigned int entry_count
, DWRITE_COLOR_F
*entries
) DECLSPEC_HIDDEN
;
499 extern UINT32
opentype_get_glyph_image_formats(IDWriteFontFace5
*fontface
) DECLSPEC_HIDDEN
;
500 extern DWRITE_CONTAINER_TYPE
opentype_analyze_container_type(void const *, UINT32
) DECLSPEC_HIDDEN
;
501 extern HRESULT
opentype_get_kerning_pairs(struct dwrite_fontface
*fontface
, unsigned int count
,
502 const UINT16
*glyphs
, INT32
*values
) DECLSPEC_HIDDEN
;
503 extern BOOL
opentype_has_kerning_pairs(struct dwrite_fontface
*fontface
) DECLSPEC_HIDDEN
;
504 extern HRESULT
opentype_get_font_var_axis(const struct file_stream_desc
*stream_desc
, struct dwrite_var_axis
**axis
,
505 unsigned int *axis_count
) DECLSPEC_HIDDEN
;
507 struct dwrite_colorglyph
{
508 USHORT layer
; /* [0, num_layers) index indicating current layer */
509 /* base glyph record data, set once on initialization */
512 /* current layer record data, updated every time glyph is switched to next layer */
514 UINT16 palette_index
;
517 extern HRESULT
opentype_get_colr_glyph(const struct dwrite_fonttable
*table
, UINT16 glyph
,
518 struct dwrite_colorglyph
*color_glyph
) DECLSPEC_HIDDEN
;
519 extern void opentype_colr_next_glyph(const struct dwrite_fonttable
*table
,
520 struct dwrite_colorglyph
*color_glyph
) DECLSPEC_HIDDEN
;
523 GASP_GRIDFIT
= 0x0001,
524 GASP_DOGRAY
= 0x0002,
525 GASP_SYMMETRIC_GRIDFIT
= 0x0004,
526 GASP_SYMMETRIC_SMOOTHING
= 0x0008,
529 extern unsigned int opentype_get_gasp_flags(const struct dwrite_fonttable
*gasp
, float emsize
) DECLSPEC_HIDDEN
;
532 extern HRESULT
bidi_computelevels(const WCHAR
*,UINT32
,UINT8
,UINT8
*,UINT8
*) DECLSPEC_HIDDEN
;
534 struct dwrite_glyphbitmap
545 enum dwrite_outline_tags
547 OUTLINE_BEGIN_FIGURE
,
553 struct dwrite_outline
557 unsigned char *values
;
564 D2D1_POINT_2F
*values
;
574 SCRIPT_JUSTIFY_ARABIC_BLANK
,
575 SCRIPT_JUSTIFY_CHARACTER
,
576 SCRIPT_JUSTIFY_RESERVED1
,
577 SCRIPT_JUSTIFY_BLANK
,
578 SCRIPT_JUSTIFY_RESERVED2
,
579 SCRIPT_JUSTIFY_RESERVED3
,
580 SCRIPT_JUSTIFY_ARABIC_NORMAL
,
581 SCRIPT_JUSTIFY_ARABIC_KASHIDA
,
582 SCRIPT_JUSTIFY_ARABIC_ALEF
,
583 SCRIPT_JUSTIFY_ARABIC_HA
,
584 SCRIPT_JUSTIFY_ARABIC_RA
,
585 SCRIPT_JUSTIFY_ARABIC_BA
,
586 SCRIPT_JUSTIFY_ARABIC_BARA
,
587 SCRIPT_JUSTIFY_ARABIC_SEEN
,
588 SCRIPT_JUSTIFY_ARABIC_SEEN_M
591 struct scriptshaping_cache
593 const struct shaping_font_ops
*font
;
597 struct ot_gsubgpos_table gsub
;
598 struct ot_gsubgpos_table gpos
;
602 struct dwrite_fonttable table
;
603 unsigned int classdef
;
604 unsigned int markattachclassdef
;
605 unsigned int markglyphsetdef
;
609 struct shaping_glyph_info
611 /* Combined features mask. */
613 /* Derived from glyph class, supplied by GDEF. */
615 /* Used for GPOS mark and cursive attachments. */
617 /* Only relevant for isClusterStart glyphs. Indicates text position for this cluster. */
618 unsigned int start_text_idx
;
619 unsigned int codepoint
;
622 struct shaping_glyph_properties
624 UINT16 justification
: 4;
625 UINT16 isClusterStart
: 1;
626 UINT16 isDiacritic
: 1;
627 UINT16 isZeroWidthSpace
: 1;
629 UINT16 components
: 4;
630 UINT16 lig_component
: 4;
633 struct scriptshaping_context
;
635 typedef void (*p_apply_context_lookup
)(struct scriptshaping_context
*context
, unsigned int lookup_index
);
637 enum shaping_feature_flags
639 FEATURE_GLOBAL
= 0x1,
640 FEATURE_GLOBAL_SEARCH
= 0x2,
641 FEATURE_MANUAL_ZWNJ
= 0x4,
642 FEATURE_MANUAL_ZWJ
= 0x8,
643 FEATURE_MANUAL_JOINERS
= FEATURE_MANUAL_ZWNJ
| FEATURE_MANUAL_ZWJ
,
644 FEATURE_HAS_FALLBACK
= 0x10,
645 FEATURE_NEEDS_FALLBACK
= 0x20,
648 struct shaping_feature
653 unsigned int max_value
;
654 unsigned int default_value
;
660 #define MAX_SHAPING_STAGE 16
662 struct shaping_features
;
664 typedef void (*stage_func
)(struct scriptshaping_context
*context
,
665 const struct shaping_features
*features
);
670 unsigned int last_lookup
;
673 struct shaping_features
675 struct shaping_feature
*features
;
679 struct shaping_stage stages
[MAX_SHAPING_STAGE
];
684 void (*collect_features
)(struct scriptshaping_context
*context
, struct shaping_features
*features
);
685 void (*setup_masks
)(struct scriptshaping_context
*context
, const struct shaping_features
*features
);
688 extern const struct shaper arabic_shaper DECLSPEC_HIDDEN
;
690 extern void shape_enable_feature(struct shaping_features
*features
, unsigned int tag
,
691 unsigned int flags
) DECLSPEC_HIDDEN
;
692 extern void shape_add_feature_full(struct shaping_features
*features
, unsigned int tag
,
693 unsigned int flags
, unsigned int value
) DECLSPEC_HIDDEN
;
694 extern unsigned int shape_get_feature_1_mask(const struct shaping_features
*features
,
695 unsigned int tag
) DECLSPEC_HIDDEN
;
696 extern void shape_start_next_stage(struct shaping_features
*features
, stage_func func
) DECLSPEC_HIDDEN
;
698 struct scriptshaping_context
700 struct scriptshaping_cache
*cache
;
701 const struct shaper
*shaper
;
714 const UINT16
*glyphs
;
715 const DWRITE_SHAPING_GLYPH_PROPERTIES
*glyph_props
;
716 DWRITE_SHAPING_TEXT_PROPERTIES
*text_props
;
717 const UINT16
*clustermap
;
718 p_apply_context_lookup apply_context_lookup
;
723 DWRITE_SHAPING_GLYPH_PROPERTIES
*glyph_props
;
724 DWRITE_SHAPING_TEXT_PROPERTIES
*text_props
;
726 p_apply_context_lookup apply_context_lookup
;
727 unsigned int max_glyph_count
;
728 unsigned int capacity
;
734 struct shaping_glyph_properties
*glyph_props
;
735 DWRITE_SHAPING_TEXT_PROPERTIES
*text_props
;
737 p_apply_context_lookup apply_context_lookup
;
741 const struct ot_gsubgpos_table
*table
; /* Either GSUB or GPOS. */
744 const DWRITE_TYPOGRAPHIC_FEATURES
**features
;
745 const unsigned int *range_lengths
;
746 unsigned int range_count
;
748 unsigned int global_mask
;
749 unsigned int lookup_mask
; /* Currently processed feature mask, set in main loop. */
750 unsigned int auto_zwj
;
751 unsigned int auto_zwnj
;
752 struct shaping_glyph_info
*glyph_infos
;
753 unsigned int has_gpos_attachment
: 1;
756 unsigned int glyph_count
;
757 unsigned int nesting_level_left
;
760 DWRITE_MEASURING_MODE measuring_mode
;
762 DWRITE_GLYPH_OFFSET
*offsets
;
765 struct shaping_font_ops
767 void (*grab_font_table
)(void *context
, UINT32 table
, const BYTE
**data
, UINT32
*size
, void **data_context
);
768 void (*release_font_table
)(void *context
, void *data_context
);
769 UINT16 (*get_font_upem
)(void *context
);
770 BOOL (*has_glyph
)(void *context
, unsigned int codepoint
);
771 UINT16 (*get_glyph
)(void *context
, unsigned int codepoint
);
774 extern struct scriptshaping_cache
*create_scriptshaping_cache(void *context
,
775 const struct shaping_font_ops
*font_ops
) DECLSPEC_HIDDEN
;
776 extern void release_scriptshaping_cache(struct scriptshaping_cache
*) DECLSPEC_HIDDEN
;
777 extern struct scriptshaping_cache
*fontface_get_shaping_cache(struct dwrite_fontface
*fontface
) DECLSPEC_HIDDEN
;
779 extern void opentype_layout_scriptshaping_cache_init(struct scriptshaping_cache
*cache
) DECLSPEC_HIDDEN
;
780 extern unsigned int opentype_layout_find_script(const struct scriptshaping_cache
*cache
, unsigned int kind
,
781 DWORD tag
, unsigned int *script_index
) DECLSPEC_HIDDEN
;
782 extern unsigned int opentype_layout_find_language(const struct scriptshaping_cache
*cache
, unsigned int kind
,
783 DWORD tag
, unsigned int script_index
, unsigned int *language_index
) DECLSPEC_HIDDEN
;
784 extern void opentype_layout_apply_gsub_features(struct scriptshaping_context
*context
, unsigned int script_index
,
785 unsigned int language_index
, struct shaping_features
*features
) DECLSPEC_HIDDEN
;
786 extern void opentype_layout_apply_gpos_features(struct scriptshaping_context
*context
, unsigned int script_index
,
787 unsigned int language_index
, struct shaping_features
*features
) DECLSPEC_HIDDEN
;
788 extern BOOL
opentype_layout_check_feature(struct scriptshaping_context
*context
, unsigned int script_index
,
789 unsigned int language_index
, struct shaping_feature
*feature
, unsigned int glyph_count
,
790 const UINT16
*glyphs
, UINT8
*feature_applies
) DECLSPEC_HIDDEN
;
791 extern void opentype_layout_unsafe_to_break(struct scriptshaping_context
*context
, unsigned int start
,
792 unsigned int end
) DECLSPEC_HIDDEN
;
793 extern BOOL
opentype_has_vertical_variants(struct dwrite_fontface
*fontface
) DECLSPEC_HIDDEN
;
794 extern HRESULT
opentype_get_vertical_glyph_variants(struct dwrite_fontface
*fontface
, unsigned int glyph_count
,
795 const UINT16
*nominal_glyphs
, UINT16
*glyphs
) DECLSPEC_HIDDEN
;
797 extern HRESULT
shape_get_glyphs(struct scriptshaping_context
*context
, const unsigned int *scripts
) DECLSPEC_HIDDEN
;
798 extern HRESULT
shape_get_positions(struct scriptshaping_context
*context
, const unsigned int *scripts
) DECLSPEC_HIDDEN
;
799 extern HRESULT
shape_get_typographic_features(struct scriptshaping_context
*context
, const unsigned int *scripts
,
800 unsigned int max_tagcount
, unsigned int *actual_tagcount
, unsigned int *tags
) DECLSPEC_HIDDEN
;
801 extern HRESULT
shape_check_typographic_feature(struct scriptshaping_context
*context
, const unsigned int *scripts
,
802 unsigned int tag
, unsigned int glyph_count
, const UINT16
*glyphs
, UINT8
*feature_applies
) DECLSPEC_HIDDEN
;
804 struct font_data_context
;
805 extern HMODULE dwrite_module DECLSPEC_HIDDEN
;
807 extern void dwrite_fontface_get_glyph_bbox(IDWriteFontFace
*fontface
, struct dwrite_glyphbitmap
*bitmap
) DECLSPEC_HIDDEN
;