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