1 module directx.dwrite_2;
2 //+--------------------------------------------------------------------------
3 //
4 //  Copyright (c) Microsoft Corporation.  All rights reserved.
5 //
6 //  Abstract:
7 //     DirectX Typography Services public API definitions.
8 //
9 //----------------------------------------------------------------------------
10 
11 public import directx.dwrite_1;
12 
13 /// <summary>
14 /// How to align glyphs to the margin.
15 /// </summary>
16 alias DWRITE_OPTICAL_ALIGNMENT = int;
17 enum : DWRITE_OPTICAL_ALIGNMENT
18 {
19     /// <summary>
20     /// Align to the default metrics of the glyph.
21     /// </summary>
22     DWRITE_OPTICAL_ALIGNMENT_NONE,
23 
24     /// <summary>
25     /// Align glyphs to the margins. Without this, some small whitespace
26     /// may be present between the text and the margin from the glyph's side
27     /// bearing values. Note that glyphs may still overhang outside the
28     /// margin, such as flourishes or italic slants.
29     /// </summary>
30     DWRITE_OPTICAL_ALIGNMENT_NO_SIDE_BEARINGS,
31 }
32 
33 
34 /// <summary>
35 /// Whether to enable grid-fitting of glyph outlines (a.k.a. hinting).
36 /// </summary>
37 alias DWRITE_GRID_FIT_MODE = int;
38 enum : DWRITE_GRID_FIT_MODE
39 {
40     /// <summary>
41     /// Choose grid fitting base on the font's gasp table information.
42     /// </summary>
43     DWRITE_GRID_FIT_MODE_DEFAULT,
44 
45     /// <summary>
46     /// Always disable grid fitting, using the ideal glyph outlines.
47     /// </summary>
48     DWRITE_GRID_FIT_MODE_DISABLED,
49 
50     /// <summary>
51     /// Enable grid fitting, adjusting glyph outlines for device pixel display.
52     /// </summary>
53     DWRITE_GRID_FIT_MODE_ENABLED
54 }
55 
56 
57 /// <summary>
58 /// Overall metrics associated with text after layout.
59 /// All coordinates are in device independent pixels (DIPs).
60 /// </summary>
61 struct DWRITE_TEXT_METRICS1 // : DWRITE_TEXT_METRICS
62 {
63 	alias dtm this;
64 	DWRITE_TEXT_METRICS dtm;
65 	
66     /// <summary>
67     /// The height of the formatted text taking into account the
68     /// trailing whitespace at the end of each line, which will
69     /// matter for vertical reading directions.
70     /// </summary>
71     FLOAT heightIncludingTrailingWhitespace;
72 }
73 
74 
75 /// <summary>
76 /// The text renderer interface represents a set of application-defined
77 /// callbacks that perform rendering of text, inline objects, and decorations
78 /// such as underlines.
79 /// </summary>
80 mixin( uuid!(IDWriteTextRenderer1, "D3E0E934-22A0-427E-AAE4-7D9574B59DB1") );
81 interface IDWriteTextRenderer1 : IDWriteTextRenderer
82 {
83     /// <summary>
84     /// IDWriteTextLayout::Draw calls this function to instruct the client to
85     /// render a run of glyphs.
86     /// </summary>
87     /// <param name="clientDrawingContext">The context passed to 
88     ///     IDWriteTextLayout::Draw.</param>
89     /// <param name="baselineOriginX">X-coordinate of the baseline.</param>
90     /// <param name="baselineOriginY">Y-coordinate of the baseline.</param>
91     /// <param name="orientationAngle">Orientation of the glyph run.</param>
92     /// <param name="measuringMode">Specifies measuring method for glyphs in
93     ///     the run. Renderer implementations may choose different rendering
94     ///     modes for given measuring methods, but best results are seen when
95     ///     the rendering mode matches the corresponding measuring mode:
96     ///     DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL for DWRITE_MEASURING_MODE_NATURAL
97     ///     DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC for DWRITE_MEASURING_MODE_GDI_CLASSIC
98     ///     DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL for DWRITE_MEASURING_MODE_GDI_NATURAL
99     /// </param>
100     /// <param name="glyphRun">The glyph run to draw.</param>
101     /// <param name="glyphRunDescription">Properties of the characters 
102     ///     associated with this run.</param>
103     /// <param name="clientDrawingEffect">The drawing effect set in
104     ///     IDWriteTextLayout::SetDrawingEffect.</param>
105     /// <returns>
106     /// Standard HRESULT error code.
107     /// </returns>
108     /// <remarks>
109     /// If a non-identity orientation is passed, the glyph run should be
110     /// rotated around the given baseline x and y coordinates. The function
111     /// IDWriteAnalyzer2::GetGlyphOrientationTransform will return the
112     /// necessary transform for you, which can be combined with any existing
113     /// world transform on the drawing context.
114     /// </remarks>
115     HRESULT DrawGlyphRun(
116         void* clientDrawingContext,
117         FLOAT baselineOriginX,
118         FLOAT baselineOriginY,
119         DWRITE_GLYPH_ORIENTATION_ANGLE orientationAngle,
120         DWRITE_MEASURING_MODE measuringMode,
121         const(DWRITE_GLYPH_RUN)* glyphRun,
122         const(DWRITE_GLYPH_RUN_DESCRIPTION)* glyphRunDescription,
123         IUnknown clientDrawingEffect
124         );
125 
126     /// <summary>
127     /// IDWriteTextLayout::Draw calls this function to instruct the client to draw
128     /// an underline.
129     /// </summary>
130     /// <param name="clientDrawingContext">The context passed to 
131     /// IDWriteTextLayout::Draw.</param>
132     /// <param name="baselineOriginX">X-coordinate of the baseline.</param>
133     /// <param name="baselineOriginY">Y-coordinate of the baseline.</param>
134     /// <param name="orientationAngle">Orientation of the underline.</param>
135     /// <param name="underline">Underline logical information.</param>
136     /// <param name="clientDrawingEffect">The drawing effect set in
137     ///     IDWriteTextLayout::SetDrawingEffect.</param>
138     /// <returns>
139     /// Standard HRESULT error code.
140     /// </returns>
141     /// <remarks>
142     /// A single underline can be broken into multiple calls, depending on
143     /// how the formatting changes attributes. If font sizes/styles change
144     /// within an underline, the thickness and offset will be averaged
145     /// weighted according to characters.
146     ///
147     /// To get the correct top coordinate of the underline rect, add
148     /// underline::offset to the baseline's Y. Otherwise the underline will
149     /// be immediately under the text. The x coordinate will always be passed
150     /// as the left side, regardless of text directionality. This simplifies
151     /// drawing and reduces the problem of round-off that could potentially
152     /// cause gaps or a double stamped alpha blend. To avoid alpha overlap,
153     /// round the end points to the nearest device pixel.
154     /// </remarks>
155     HRESULT DrawUnderline(
156         void* clientDrawingContext,
157         FLOAT baselineOriginX,
158         FLOAT baselineOriginY,
159         DWRITE_GLYPH_ORIENTATION_ANGLE orientationAngle,
160         const(DWRITE_UNDERLINE)* underline,
161         IUnknown clientDrawingEffect
162         );
163 
164     /// <summary>
165     /// IDWriteTextLayout::Draw calls this function to instruct the client to draw
166     /// a strikethrough.
167     /// </summary>
168     /// <param name="clientDrawingContext">The context passed to 
169     /// IDWriteTextLayout::Draw.</param>
170     /// <param name="baselineOriginX">X-coordinate of the baseline.</param>
171     /// <param name="baselineOriginY">Y-coordinate of the baseline.</param>
172     /// <param name="orientationAngle">Orientation of the strikethrough.</param>
173     /// <param name="strikethrough">Strikethrough logical information.</param>
174     /// <param name="clientDrawingEffect">The drawing effect set in
175     ///     IDWriteTextLayout::SetDrawingEffect.</param>
176     /// <returns>
177     /// Standard HRESULT error code.
178     /// </returns>
179     /// <remarks>
180     /// A single strikethrough can be broken into multiple calls, depending on
181     /// how the formatting changes attributes. Strikethrough is not averaged
182     /// across font sizes/styles changes.
183     /// To get the correct top coordinate of the strikethrough rect,
184     /// add strikethrough::offset to the baseline's Y.
185     /// Like underlines, the x coordinate will always be passed as the left side,
186     /// regardless of text directionality.
187     /// </remarks>
188     HRESULT DrawStrikethrough(
189         void* clientDrawingContext,
190         FLOAT baselineOriginX,
191         FLOAT baselineOriginY,
192         DWRITE_GLYPH_ORIENTATION_ANGLE orientationAngle,
193         const(DWRITE_STRIKETHROUGH)* strikethrough,
194         IUnknown clientDrawingEffect
195         );
196 
197     /// <summary>
198     /// IDWriteTextLayout::Draw calls this application callback when it needs to
199     /// draw an inline object.
200     /// </summary>
201     /// <param name="clientDrawingContext">The context passed to
202     ///     IDWriteTextLayout::Draw.</param>
203     /// <param name="originX">X-coordinate at the top-left corner of the
204     ///     inline object.</param>
205     /// <param name="originY">Y-coordinate at the top-left corner of the
206     ///     inline object.</param>
207     /// <param name="orientationAngle">Orientation of the inline object.</param>
208     /// <param name="inlineObject">The object set using IDWriteTextLayout::SetInlineObject.</param>
209     /// <param name="isSideways">The object should be drawn on its side.</param>
210     /// <param name="isRightToLeft">The object is in an right-to-left context
211     ///     and should be drawn flipped.</param>
212     /// <param name="clientDrawingEffect">The drawing effect set in
213     ///     IDWriteTextLayout::SetDrawingEffect.</param>
214     /// <returns>
215     /// Standard HRESULT error code.
216     /// </returns>
217     /// <remarks>
218     /// The right-to-left flag is a hint to draw the appropriate visual for
219     /// that reading direction. For example, it would look strange to draw an
220     /// arrow pointing to the right to indicate a submenu. The sideways flag
221     /// similarly hints that the object is drawn in a different orientation.
222     /// If a non-identity orientation is passed, the top left of the inline
223     /// object should be rotated around the given x and y coordinates.
224     /// IDWriteAnalyzer2::GetGlyphOrientationTransform returns the necessary
225     /// transform for this.
226     /// </remarks>
227     HRESULT DrawInlineObject(
228         void* clientDrawingContext,
229         FLOAT originX,
230         FLOAT originY,
231         DWRITE_GLYPH_ORIENTATION_ANGLE orientationAngle,
232         IDWriteInlineObject inlineObject,
233         BOOL isSideways,
234         BOOL isRightToLeft,
235         IUnknown clientDrawingEffect
236         );
237 }
238 
239 
240 /// <summary>
241 /// The format of text used for text layout.
242 /// </summary>
243 /// <remarks>
244 /// This object may not be thread-safe and it may carry the state of text format change.
245 /// </remarks>
246 mixin( uuid!(IDWriteTextFormat1, "5F174B49-0D8B-4CFB-8BCA-F1CCE9D06C67") );
247 interface IDWriteTextFormat1 : IDWriteTextFormat
248 {
249     /// <summary>
250     /// Set the preferred orientation of glyphs when using a vertical reading direction.
251     /// </summary>
252     /// <param name="glyphOrientation">Preferred glyph orientation.</param>
253     /// <returns>
254     /// Standard HRESULT error code.
255     /// </returns>
256     HRESULT SetVerticalGlyphOrientation(
257         DWRITE_VERTICAL_GLYPH_ORIENTATION glyphOrientation
258         );
259 
260     /// <summary>
261     /// Get the preferred orientation of glyphs when using a vertical reading
262     /// direction.
263     /// </summary>
264     DWRITE_VERTICAL_GLYPH_ORIENTATION GetVerticalGlyphOrientation();
265 
266     /// <summary>
267     /// Set whether or not the last word on the last line is wrapped.
268     /// </summary>
269     /// <param name="isLastLineWrappingEnabled">Line wrapping option.</param>
270     /// <returns>
271     /// Standard HRESULT error code.
272     /// </returns>
273     HRESULT SetLastLineWrapping(
274         BOOL isLastLineWrappingEnabled
275         );
276 
277     /// <summary>
278     /// Get whether or not the last word on the last line is wrapped.
279     /// </summary>
280     BOOL GetLastLineWrapping();
281 
282     /// <summary>
283     /// Set how the glyphs align to the edges the margin. Default behavior is
284     /// to align glyphs using their default glyphs metrics which include side
285     /// bearings.
286     /// </summary>
287     /// <param name="opticalAlignment">Optical alignment option.</param>
288     /// <returns>
289     /// Standard HRESULT error code.
290     /// </returns>
291     HRESULT SetOpticalAlignment(
292         DWRITE_OPTICAL_ALIGNMENT opticalAlignment
293         );
294 
295     /// <summary>
296     /// Get how the glyphs align to the edges the margin.
297     /// </summary>
298     DWRITE_OPTICAL_ALIGNMENT GetOpticalAlignment();
299 
300     /// <summary>
301     /// Apply a custom font fallback onto layout. If none is specified,
302     /// layout uses the system fallback list.
303     /// </summary>
304     /// <param name="fontFallback">Custom font fallback created from
305     ///     IDWriteFontFallbackBuilder::CreateFontFallback or from
306     ///     IDWriteFactory2::GetSystemFontFallback.</param>
307     /// <returns>
308     /// Standard HRESULT error code.
309     /// </returns>
310     HRESULT SetFontFallback(
311         IDWriteFontFallback fontFallback
312         );
313 
314     /// <summary>
315     /// Get the current font fallback object.
316     /// </summary>
317     HRESULT GetFontFallback(
318         /*out*/ IDWriteFontFallback* fontFallback
319         );
320 }
321 
322 
323 /// <summary>
324 /// The text layout interface represents a block of text after it has
325 /// been fully analyzed and formatted.
326 ///
327 /// All coordinates are in device independent pixels (DIPs).
328 /// </summary>
329 mixin( uuid!(IDWriteTextLayout2, "1093C18F-8D5E-43F0-B064-0917311B525E") );
330 interface IDWriteTextLayout2 : IDWriteTextLayout1
331 {
332     /// <summary>
333     /// GetMetrics retrieves overall metrics for the formatted string.
334     /// </summary>
335     /// <param name="textMetrics">The returned metrics.</param>
336     /// <returns>
337     /// Standard HRESULT error code.
338     /// </returns>
339     /// <remarks>
340     /// Drawing effects like underline and strikethrough do not contribute
341     /// to the text size, which is essentially the sum of advance widths and
342     /// line heights. Additionally, visible swashes and other graphic
343     /// adornments may extend outside the returned width and height.
344     /// </remarks>
345     HRESULT GetMetrics(
346         /*out*/ DWRITE_TEXT_METRICS1* textMetrics
347         );
348 
349     //using IDWriteTextLayout::GetMetrics;
350 
351     /// <summary>
352     /// Set the preferred orientation of glyphs when using a vertical reading direction.
353     /// </summary>
354     /// <param name="glyphOrientation">Preferred glyph orientation.</param>
355     /// <returns>
356     /// Standard HRESULT error code.
357     /// </returns>
358     HRESULT SetVerticalGlyphOrientation(
359         DWRITE_VERTICAL_GLYPH_ORIENTATION glyphOrientation
360         );
361 
362     /// <summary>
363     /// Get the preferred orientation of glyphs when using a vertical reading
364     /// direction.
365     /// </summary>
366     DWRITE_VERTICAL_GLYPH_ORIENTATION GetVerticalGlyphOrientation();
367 
368     /// <summary>
369     /// Set whether or not the last word on the last line is wrapped.
370     /// </summary>
371     /// <param name="isLastLineWrappingEnabled">Line wrapping option.</param>
372     /// <returns>
373     /// Standard HRESULT error code.
374     /// </returns>
375     HRESULT SetLastLineWrapping(
376         BOOL isLastLineWrappingEnabled
377         );
378 
379     /// <summary>
380     /// Get whether or not the last word on the last line is wrapped.
381     /// </summary>
382     BOOL GetLastLineWrapping();
383 
384     /// <summary>
385     /// Set how the glyphs align to the edges the margin. Default behavior is
386     /// to align glyphs using their default glyphs metrics which include side
387     /// bearings.
388     /// </summary>
389     /// <param name="opticalAlignment">Optical alignment option.</param>
390     /// <returns>
391     /// Standard HRESULT error code.
392     /// </returns>
393     HRESULT SetOpticalAlignment(
394         DWRITE_OPTICAL_ALIGNMENT opticalAlignment
395         );
396 
397     /// <summary>
398     /// Get how the glyphs align to the edges the margin.
399     /// </summary>
400     DWRITE_OPTICAL_ALIGNMENT GetOpticalAlignment();
401 
402     /// <summary>
403     /// Apply a custom font fallback onto layout. If none is specified,
404     /// layout uses the system fallback list.
405     /// </summary>
406     /// <param name="fontFallback">Custom font fallback created from
407     ///     IDWriteFontFallbackBuilder::CreateFontFallback or
408     ///     IDWriteFactory2::GetSystemFontFallback.</param>
409     /// <returns>
410     /// Standard HRESULT error code.
411     /// </returns>
412     HRESULT SetFontFallback(
413         IDWriteFontFallback fontFallback
414         );
415 
416     /// <summary>
417     /// Get the current font fallback object.
418     /// </summary>
419     HRESULT GetFontFallback(
420         /*out*/ IDWriteFontFallback* fontFallback
421         );
422 }
423 
424 
425 /// <summary>
426 /// The text analyzer interface represents a set of application-defined
427 /// callbacks that perform rendering of text, inline objects, and decorations
428 /// such as underlines.
429 /// </summary>
430 mixin( uuid!(IDWriteTextAnalyzer2, "553A9FF3-5693-4DF7-B52B-74806F7F2EB9") );
431 interface IDWriteTextAnalyzer2 : IDWriteTextAnalyzer1
432 {
433     /// <summary>
434     /// Returns 2x3 transform matrix for the respective angle to draw the
435     /// glyph run or other object.
436     /// </summary>
437     /// <param name="glyphOrientationAngle">The angle reported to one of the application callbacks,
438     ///     including IDWriteTextAnalysisSink1::SetGlyphOrientation and IDWriteTextRenderer1::Draw*.</param>
439     /// <param name="isSideways">Whether the run's glyphs are sideways or not.</param>
440     /// <param name="originX">X origin of the element, be it a glyph run or underline or other.</param>
441     /// <param name="originY">Y origin of the element, be it a glyph run or underline or other.</param>
442     /// <param name="transform">Returned transform.</param>
443     /// <returns>
444     /// Standard HRESULT error code.
445     /// </returns>
446     /// <remarks>
447     /// This rotates around the given origin x and y, returning a translation component
448     /// such that the glyph run, text decoration, or inline object is drawn with the
449     /// right orientation at the expected coordinate.
450     /// </remarks>
451     HRESULT GetGlyphOrientationTransform(
452         DWRITE_GLYPH_ORIENTATION_ANGLE glyphOrientationAngle,
453         BOOL isSideways,
454         FLOAT originX,
455         FLOAT originY,
456         /*out*/ DWRITE_MATRIX* transform
457         );
458 
459     /// <summary>
460     /// Returns a list of typographic feature tags for the given script and language.
461     /// </summary>
462     /// <param name="fontFace">The font face to get features from.</param>
463     /// <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param>
464     /// <param name="localeName">The locale to use when selecting the feature,
465     ///     such en-us or ja-jp.</param>
466     /// <param name="maxTagCount">Maximum tag count.</param>
467     /// <param name="actualTagCount">Actual tag count. If greater than
468     ///     maxTagCount, E_NOT_SUFFICIENT_BUFFER is returned, and the call
469     ///     should be retried with a larger buffer.</param>
470     /// <param name="tags">Feature tag list.</param>
471     /// <returns>
472     /// Standard HRESULT error code.
473     /// </returns>
474     HRESULT GetTypographicFeatures(
475         IDWriteFontFace fontFace,
476         DWRITE_SCRIPT_ANALYSIS scriptAnalysis,
477         const(WCHAR)* localeName,
478         UINT32 maxTagCount,
479         /*out*/ UINT32* actualTagCount,
480         /*out*/ DWRITE_FONT_FEATURE_TAG* tags
481         );
482 
483     /// <summary>
484     /// Returns an array of which glyphs are affected by a given feature.
485     /// </summary>
486     /// <param name="fontFace">The font face to read glyph information from.</param>
487     /// <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param>
488     /// <param name="localeName">The locale to use when selecting the feature,
489     ///     such en-us or ja-jp.</param>
490     /// <param name="featureTag">OpenType feature name to use, which may be one
491     ///     of the DWRITE_FONT_FEATURE_TAG values or a custom feature using
492     ///     DWRITE_MAKE_OPENTYPE_TAG.</param>
493     /// <param name="glyphCount">Number of glyph indices to check.</param>
494     /// <param name="glyphIndices">Glyph indices to check for feature application.</param>
495     /// <param name="featureApplies">Output of which glyphs are affected by the
496     ///     feature, where for each glyph affected, the respective array index
497     ///     will be 1. The result is returned per-glyph without regard to
498     ///     neighboring context of adjacent glyphs.</param>
499     /// </remarks>
500     /// <returns>
501     /// Standard HRESULT error code.
502     /// </returns>
503     HRESULT CheckTypographicFeature(
504         IDWriteFontFace fontFace,
505         DWRITE_SCRIPT_ANALYSIS scriptAnalysis,
506         const(WCHAR)* localeName,
507         DWRITE_FONT_FEATURE_TAG featureTag,
508         UINT32 glyphCount,
509         const(UINT16)* glyphIndices,
510         /*out*/ UINT8* featureApplies
511         );
512 }
513 
514 
515 /// <summary>
516 /// A font fallback definition used for mapping characters to fonts capable of
517 /// supporting them.
518 /// </summary>
519 mixin( uuid!(IDWriteFontFallback, "EFA008F9-F7A1-48BF-B05C-F224713CC0FF") );
520 interface IDWriteFontFallback : IUnknown
521 {
522     /// <summary>
523     /// Determines an appropriate font to use to render the range of text.
524     /// </summary>
525     /// <param name="source">The text source implementation holds the text and
526     ///     locale.</param>
527     /// <param name="textLength">Length of the text to analyze.</param>
528     /// <param name="baseFontCollection">Default font collection to use.</param>
529     /// <param name="baseFont">Base font to check (optional).</param>
530     /// <param name="baseFamilyName">Family name of the base font. If you pass
531     ///     null, no matching will be done against the family.</param>
532     /// <param name="baseWeight">Desired weight.</param>
533     /// <param name="baseStyle">Desired style.</param>
534     /// <param name="baseStretch">Desired stretch.</param>
535     /// <param name="mappedLength">Length of text mapped to the mapped font.
536     ///     This will always be less or equal to the input text length and
537     ///     greater than zero (if the text length is non-zero) so that the
538     ///     caller advances at least one character each call.</param>
539     /// <param name="mappedFont">The font that should be used to render the
540     ///     first mappedLength characters of the text. If it returns NULL,
541     ///     then no known font can render the text, and mappedLength is the
542     ///     number of unsupported characters to skip.</param>
543     /// <param name="scale">Scale factor to multiply the em size of the
544     ///     returned font by.</param>
545     /// <returns>
546     /// Standard HRESULT error code.
547     /// </returns>
548     HRESULT MapCharacters(
549         IDWriteTextAnalysisSource analysisSource,
550         UINT32 textPosition,
551         UINT32 textLength,
552         IDWriteFontCollection baseFontCollection,
553         const(WCHAR)* baseFamilyName,
554         DWRITE_FONT_WEIGHT baseWeight,
555         DWRITE_FONT_STYLE baseStyle,
556         DWRITE_FONT_STRETCH baseStretch,
557         UINT32* mappedLength,
558         /*out*/ IDWriteFont* mappedFont,
559         /*out*/ FLOAT* scale
560         );
561 }
562 
563 
564 /// <summary>
565 /// Builder used to create a font fallback definition by appending a series of
566 /// fallback mappings, followed by a creation call.
567 /// </summary>
568 /// <remarks>
569 /// This object may not be thread-safe.
570 /// </remarks>
571 mixin( uuid!(IDWriteFontFallbackBuilder, "FD882D06-8ABA-4FB8-B849-8BE8B73E14DE") );
572 interface IDWriteFontFallbackBuilder : IUnknown
573 {
574     /// <summary>
575     /// Appends a single mapping to the list. Call this once for each additional mapping.
576     /// </summary>
577     /// <param name="ranges">Unicode ranges that apply to this mapping.</param>
578     /// <param name="rangesCount">Number of Unicode ranges.</param>
579     /// <param name="localeName">Locale of the context (e.g. document locale).</param>
580     /// <param name="baseFamilyName">Base family name to match against, if applicable.</param>
581     /// <param name="fontCollection">Explicit font collection for this mapping (optional).</param>
582     /// <param name="targetFamilyNames">List of target family name strings.</param>
583     /// <param name="targetFamilyNamesCount">Number of target family names.</param>
584     /// <param name="scale">Scale factor to multiply the result target font by.</param>
585     /// <returns>
586     /// Standard HRESULT error code.
587     /// </returns>
588     HRESULT AddMapping(
589         const(DWRITE_UNICODE_RANGE)* ranges,
590         UINT32 rangesCount,
591         const(WCHAR*)* targetFamilyNames,
592         UINT32 targetFamilyNamesCount,
593         IDWriteFontCollection fontCollection = null,
594         const(WCHAR)* localeName = null,
595         const(WCHAR)* baseFamilyName = null,
596         FLOAT scale = 1.0f
597         );
598 
599     /// <summary>
600     /// Appends all the mappings from an existing font fallback object.
601     /// </summary>
602     /// <param name="fontFallback">Font fallback to read mappings from.</param>
603     /// <returns>
604     /// Standard HRESULT error code.
605     /// </returns>
606     HRESULT AddMappings(
607         IDWriteFontFallback fontFallback
608         );
609 
610     /// <summary>
611     /// Creates the finalized fallback object from the mappings added.
612     /// </summary>
613     /// <param name="fontFallback">Created fallback list.</param>
614     /// <returns>
615     /// Standard HRESULT error code.
616     /// </returns>
617    HRESULT CreateFontFallback(
618         /*out*/ IDWriteFontFallback* fontFallback
619         );
620 }
621 
622 /// <summary>
623 /// DWRITE_COLOR_F
624 /// </summary>
625 static if ( !__traits(compiles,D3DCOLORVALUE.sizeof) )
626 {
627 
628 	struct D3DCOLORVALUE 
629 	{
630 		union {
631 		FLOAT r;
632 		FLOAT dvR;
633 		}
634 		union {
635 		FLOAT g;
636 		FLOAT dvG;
637 		}
638 		union {
639 		FLOAT b;
640 		FLOAT dvB;
641 		}
642 		union {
643 		FLOAT a;
644 		FLOAT dvA;
645 		}
646 	}
647 }
648 
649 alias DWRITE_COLOR_F = D3DCOLORVALUE;
650 
651 /// <summary>
652 /// The IDWriteFont interface represents a physical font in a font collection.
653 /// </summary>
654 mixin( uuid!(IDWriteFont2, "29748ed6-8c9c-4a6a-be0b-d912e8538944") );
655 interface IDWriteFont2 : IDWriteFont1
656 {
657     /// <summary>
658     /// Returns TRUE if the font contains color information (COLR and CPAL tables), 
659     /// or FALSE if not.
660     /// </summary>
661     BOOL IsColorFont();
662 }
663 
664 /// <summary>
665 /// The interface that represents an absolute reference to a font face.
666 /// It contains font face type, appropriate file references and face identification data.
667 /// Various font data such as metrics, names and glyph outlines is obtained from IDWriteFontFace.
668 /// </summary>
669 mixin( uuid!(IDWriteFontFace2, "d8b768ff-64bc-4e66-982b-ec8e87f693f7") );
670 interface IDWriteFontFace2 : IDWriteFontFace1
671 {
672     /// <summary>
673     /// Returns TRUE if the font contains color information (COLR and CPAL tables), 
674     /// or FALSE if not.
675     /// </summary>
676     BOOL IsColorFont();
677 
678     /// <summary>
679     /// Returns the number of color palettes defined by the font. The return
680     /// value is zero if the font has no color information. Color fonts must
681     /// have at least one palette, with palette index zero being the default.
682     /// </summary>
683     UINT32 GetColorPaletteCount();
684 
685     /// <summary>
686     /// Returns the number of entries in each color palette. All color palettes
687     /// in a font have the same number of palette entries. The return value is 
688     /// zero if the font has no color information.
689     /// </summary>
690     UINT32 GetPaletteEntryCount();
691 
692     /// <summary>
693     /// Reads color values from the font's color palette.
694     /// </summary>
695     /// <param name="colorPaletteIndex">Zero-based index of the color palette. If the
696     /// font does not have a palette with the specified index, the method returns 
697     /// DWRITE_E_NOCOLOR.<param>
698     /// <param name="firstEntryIndex">Zero-based index of the first palette entry
699     /// to read.</param>
700     /// <param name="entryCount">Number of palette entries to read.</param>
701     /// <param name="paletteEntries">Array that receives the color values.<param>
702     /// <returns>
703     /// Standard HRESULT error code.
704     /// The return value is E_INVALIDARG if firstEntryIndex + entryCount is greater
705     /// than the actual number of palette entries as returned by GetPaletteEntryCount.
706     /// The return value is DWRITE_E_NOCOLOR if the font does not have a palette
707     /// with the specified palette index.
708     /// </returns>
709     HRESULT GetPaletteEntries(
710         UINT32 colorPaletteIndex,
711         UINT32 firstEntryIndex,
712         UINT32 entryCount,
713         /*out*/ DWRITE_COLOR_F* paletteEntries
714         );
715 
716     /// <summary>
717     /// Determines the recommended text rendering and grid-fit mode to be used based on the
718     /// font, size, world transform, and measuring mode.
719     /// </summary>
720     /// <param name="fontEmSize">Logical font size in DIPs.</param>
721     /// <param name="dpiX">Number of pixels per logical inch in the horizontal direction.</param>
722     /// <param name="dpiY">Number of pixels per logical inch in the vertical direction.</param>
723     /// <param name="transform">Specifies the world transform.</param>
724     /// <param name="outlineThreshold">Specifies the quality of the graphics system's outline rendering,
725     /// affects the size threshold above which outline rendering is used.</param>
726     /// <param name="measuringMode">Specifies the method used to measure during text layout. For proper
727     /// glyph spacing, the function returns a rendering mode that is compatible with the specified 
728     /// measuring mode.</param>
729     /// <param name="renderingParams">Rendering parameters object. This parameter is necessary in case the rendering parameters 
730     /// object overrides the rendering mode.</param>
731     /// <param name="renderingMode">Receives the recommended rendering mode.</param>
732     /// <param name="gridFitMode">Receives the recommended grid-fit mode.</param>
733     /// <remarks>
734     /// This method should be used to determine the actual rendering mode in cases where the rendering 
735     /// mode of the rendering params object is DWRITE_RENDERING_MODE_DEFAULT, and the actual grid-fit
736     /// mode when the rendering params object is DWRITE_GRID_FIT_MODE_DEFAULT.
737     /// </remarks>
738     /// <returns>
739     /// Standard HRESULT error code.
740     /// </returns>
741     HRESULT GetRecommendedRenderingMode(
742         FLOAT fontEmSize,
743         FLOAT dpiX,
744         FLOAT dpiY,
745         const(DWRITE_MATRIX)* transform,
746         BOOL isSideways,
747         DWRITE_OUTLINE_THRESHOLD outlineThreshold,
748         DWRITE_MEASURING_MODE measuringMode,
749         IDWriteRenderingParams renderingParams,
750         /*out*/ DWRITE_RENDERING_MODE* renderingMode,
751         /*out*/ DWRITE_GRID_FIT_MODE* gridFitMode
752         );
753 }
754 
755 /// <summary>
756 /// Represents a color glyph run. The IDWriteFactory2::TranslateColorGlyphRun
757 /// method returns an ordered collection of color glyph runs, which can be
758 /// layered on top of each other to produce a color representation of the
759 /// given base glyph run.
760 /// </summary>
761 struct DWRITE_COLOR_GLYPH_RUN
762 {
763     /// <summary>
764     /// Glyph run to render.
765     /// </summary>
766     DWRITE_GLYPH_RUN glyphRun;
767 
768     /// <summary>
769     /// Optional glyph run description.
770     /// </summary>
771     DWRITE_GLYPH_RUN_DESCRIPTION* glyphRunDescription;
772 
773     /// <summary>
774     /// Location at which to draw this glyph run.
775     /// </summary>
776     FLOAT baselineOriginX;
777     FLOAT baselineOriginY;
778 
779     /// <summary>
780     /// Color to use for this layer, if any. This is the same color that
781     /// IDWriteFontFace2::GetPaletteEntries would return for the current
782     /// palette index if the paletteIndex member is less than 0xFFFF. If
783     /// the paletteIndex member is 0xFFFF then there is no associated
784     /// palette entry, this member is set to { 0, 0, 0, 0 }, and the client
785     /// should use the current foreground brush.
786     /// </summary>
787     DWRITE_COLOR_F runColor;
788 
789     /// <summary>
790     /// Zero-based index of this layer's color entry in the current color
791     /// palette, or 0xFFFF if this layer is to be rendered using 
792     /// the current foreground brush.
793     /// </summary>
794     UINT16 paletteIndex;
795 }
796 
797 /// <summary>
798 /// Enumerator for an ordered collection of color glyph runs.
799 /// </summary>
800 mixin( uuid!(IDWriteColorGlyphRunEnumerator, "d31fbe17-f157-41a2-8d24-cb779e0560e8") );
801 interface IDWriteColorGlyphRunEnumerator : IUnknown
802 {
803     /// <summary>
804     /// Advances to the first or next color run. The runs are enumerated
805     /// in order from back to front.
806     /// </summary>
807     /// <param name="hasRun">Receives TRUE if there is a current run or
808     /// FALSE if the end of the sequence has been reached.</param>
809     /// <returns>
810     /// Standard HRESULT error code.
811     /// </returns>
812     HRESULT MoveNext(
813         /*out*/ BOOL* hasRun
814         );
815 
816     /// <summary>
817     /// Gets the current color glyph run.
818     /// </summary>
819     /// <param name="colorGlyphRun">Receives a pointer to the color
820     /// glyph run. The pointer remains valid until the next call to
821     /// MoveNext or until the interface is released.</param>
822     /// <returns>
823     /// Standard HRESULT error code. An error is returned if there is
824     /// no current glyph run, i.e., if MoveNext has not yet been called
825     /// or if the end of the sequence has been reached.
826     /// </returns>
827     HRESULT GetCurrentRun(
828         /*out*/ const(DWRITE_COLOR_GLYPH_RUN*)* colorGlyphRun
829         );
830 }
831 
832 /// <summary>
833 /// The interface that represents text rendering settings for glyph rasterization and filtering.
834 /// </summary>
835 mixin( uuid!(IDWriteRenderingParams2, "F9D711C3-9777-40AE-87E8-3E5AF9BF0948") );
836 interface IDWriteRenderingParams2 : IDWriteRenderingParams1
837 {
838     /// <summary>
839     /// Gets the grid fitting mode.
840     /// </summary>
841     DWRITE_GRID_FIT_MODE GetGridFitMode();
842 }
843 
844 /// <summary>
845 /// The root factory interface for all DWrite objects.
846 /// </summary>
847 mixin( uuid!(IDWriteFactory2, "0439fc60-ca44-4994-8dee-3a9af7b732ec") );
848 interface IDWriteFactory2 : IDWriteFactory1
849 {
850     /// <summary>
851     /// Get the system-appropriate font fallback mapping list.
852     /// </summary>
853     /// <param name="fontFallback">The system fallback list.</param>
854     /// <returns>
855     /// Standard HRESULT error code.
856     /// </returns>
857     HRESULT GetSystemFontFallback(
858         /*out*/ IDWriteFontFallback* fontFallback
859         );
860 
861     /// <summary>
862     /// Create a custom font fallback builder.
863     /// </summary>
864     /// <param name="fontFallbackBuilder">Empty font fallback builder.</param>
865     /// <returns>
866     /// Standard HRESULT error code.
867     /// </returns>
868     HRESULT CreateFontFallbackBuilder(
869         /*out*/ IDWriteFontFallbackBuilder* fontFallbackBuilder
870         );
871 
872     /// <summary>
873     /// Translates a glyph run to a sequence of color glyph runs, which can be
874     /// rendered to produce a color representation of the original "base" run.
875     /// </summary>
876     /// <param name="baselineOriginX">Horizontal origin of the base glyph run in
877     /// pre-transform coordinates.</param>
878     /// <param name="baselineOriginY">Vertical origin of the base glyph run in
879     /// pre-transform coordinates.</param>
880     /// <param name="glyphRun">Pointer to the original "base" glyph run.</param>
881     /// <param name="glyphRunDescription">Optional glyph run description.</param>
882     /// <param name="measuringMode">Measuring mode, needed to compute the origins
883     /// of each glyph.</param>
884     /// <param name="worldToDeviceTransform">Matrix converting from the client's
885     /// coordinate space to device coordinates (pixels), i.e., the world transform
886     /// multiplied by any DPI scaling.</param>
887     /// <param name="colorPaletteIndex">Zero-based index of the color palette to use.
888     /// Valid indices are less than the number of palettes in the font, as returned
889     /// by IDWriteFontFace2::GetColorPaletteCount.</param>
890     /// <param name="colorLayers">If the function succeeds, receives a pointer
891     /// to an enumerator object that can be used to obtain the color glyph runs.
892     /// If the base run has no color glyphs, then the output pointer is NULL
893     /// and the method returns DWRITE_E_NOCOLOR.</param>
894     /// <returns>
895     /// Returns DWRITE_E_NOCOLOR if the font has no color information, the base
896     /// glyph run does not contain any color glyphs, or the specified color palette
897     /// index is out of range. In this case, the client should render the base glyph 
898     /// run. Otherwise, returns a standard HRESULT error code.
899     /// </returns>
900     HRESULT TranslateColorGlyphRun(
901         FLOAT baselineOriginX,
902         FLOAT baselineOriginY,
903         const(DWRITE_GLYPH_RUN)* glyphRun,
904         const(DWRITE_GLYPH_RUN_DESCRIPTION)* glyphRunDescription,
905         DWRITE_MEASURING_MODE measuringMode,
906         const(DWRITE_MATRIX)* worldToDeviceTransform,
907         UINT32 colorPaletteIndex,
908         /*out*/ IDWriteColorGlyphRunEnumerator* colorLayers
909         );
910 
911     /// <summary>
912     /// Creates a rendering parameters object with the specified properties.
913     /// </summary>
914     /// <param name="gamma">The gamma value used for gamma correction, which must be greater than zero and cannot exceed 256.</param>
915     /// <param name="enhancedContrast">The amount of contrast enhancement, zero or greater.</param>
916     /// <param name="clearTypeLevel">The degree of ClearType level, from 0.0f (no ClearType) to 1.0f (full ClearType).</param>
917     /// <param name="pixelGeometry">The geometry of a device pixel.</param>
918     /// <param name="renderingMode">Method of rendering glyphs. In most cases, this should be DWRITE_RENDERING_MODE_DEFAULT to automatically use an appropriate mode.</param>
919     /// <param name="gridFitMode">How to grid fit glyph outlines. In most cases, this should be DWRITE_GRID_FIT_DEFAULT to automatically choose an appropriate mode.</param>
920     /// <param name="renderingParams">Holds the newly created rendering parameters object, or NULL in case of failure.</param>
921     /// <returns>
922     /// Standard HRESULT error code.
923     /// </returns>
924     HRESULT CreateCustomRenderingParams(
925         FLOAT gamma,
926         FLOAT enhancedContrast,
927         FLOAT grayscaleEnhancedContrast,
928         FLOAT clearTypeLevel,
929         DWRITE_PIXEL_GEOMETRY pixelGeometry,
930         DWRITE_RENDERING_MODE renderingMode,
931         DWRITE_GRID_FIT_MODE gridFitMode,
932         /*out*/ IDWriteRenderingParams2* renderingParams
933         );
934 
935     //using IDWriteFactory::CreateCustomRenderingParams;
936     //using IDWriteFactory1::CreateCustomRenderingParams;
937 
938     /// <summary>
939     /// Creates a glyph run analysis object, which encapsulates information
940     /// used to render a glyph run.
941     /// </summary>
942     /// <param name="glyphRun">Structure specifying the properties of the glyph run.</param>
943     /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the
944     /// scaling specified the emSize and pixelsPerDip.</param>
945     /// <param name="renderingMode">Specifies the rendering mode, which must be one of the raster rendering modes (i.e., not default
946     /// and not outline).</param>
947     /// <param name="measuringMode">Specifies the method to measure glyphs.</param>
948     /// <param name="gridFitMode">How to grid-fit glyph outlines. This must be non-default.</param>
949     /// <param name="baselineOriginX">Horizontal position of the baseline origin, in DIPs.</param>
950     /// <param name="baselineOriginY">Vertical position of the baseline origin, in DIPs.</param>
951     /// <param name="glyphRunAnalysis">Receives a pointer to the newly created object.</param>
952     /// <returns>
953     /// Standard HRESULT error code.
954     /// </returns>
955     HRESULT CreateGlyphRunAnalysis(
956         const(DWRITE_GLYPH_RUN)* glyphRun,
957         const(DWRITE_MATRIX)* transform,
958         DWRITE_RENDERING_MODE renderingMode,
959         DWRITE_MEASURING_MODE measuringMode,
960         DWRITE_GRID_FIT_MODE gridFitMode,
961         DWRITE_TEXT_ANTIALIAS_MODE antialiasMode,
962         FLOAT baselineOriginX,
963         FLOAT baselineOriginY,
964         /*out*/ IDWriteGlyphRunAnalysis* glyphRunAnalysis
965         );
966 
967     //using IDWriteFactory::CreateGlyphRunAnalysis;
968 }