Subversion Repositories Games.Chess Giants

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. //+--------------------------------------------------------------------------
  2. //
  3. //  Copyright (c) Microsoft Corporation.  All rights reserved.
  4. //
  5. //  Abstract:
  6. //     DirectX Typography Services public API definitions.
  7. //
  8. //----------------------------------------------------------------------------
  9.  
  10. #ifndef DWRITE_H_INCLUDED
  11. #define DWRITE_H_INCLUDED
  12.  
  13. #if _MSC_VER > 1000
  14. #pragma once
  15. #endif
  16.  
  17. #ifndef DWRITE_NO_WINDOWS_H
  18.  
  19. #include <specstrings.h>
  20. #include <unknwn.h>
  21.  
  22. #endif // DWRITE_NO_WINDOWS_H
  23.  
  24. #include <dcommon.h>
  25.  
  26. #ifndef DWRITE_DECLARE_INTERFACE
  27. #define DWRITE_DECLARE_INTERFACE(iid) DECLSPEC_UUID(iid) DECLSPEC_NOVTABLE
  28. #endif
  29.  
  30. #ifndef DWRITE_EXPORT
  31. #define DWRITE_EXPORT __declspec(dllimport) WINAPI
  32. #endif
  33.  
  34. /// <summary>
  35. /// The type of a font represented by a single font file.
  36. /// Font formats that consist of multiple files, e.g. Type 1 .PFM and .PFB, have
  37. /// separate enum values for each of the file type.
  38. /// </summary>
  39. enum DWRITE_FONT_FILE_TYPE
  40. {
  41.     /// <summary>
  42.     /// Font type is not recognized by the DirectWrite font system.
  43.     /// </summary>
  44.     DWRITE_FONT_FILE_TYPE_UNKNOWN,
  45.  
  46.     /// <summary>
  47.     /// OpenType font with CFF outlines.
  48.     /// </summary>
  49.     DWRITE_FONT_FILE_TYPE_CFF,
  50.  
  51.     /// <summary>
  52.     /// OpenType font with TrueType outlines.
  53.     /// </summary>
  54.     DWRITE_FONT_FILE_TYPE_TRUETYPE,
  55.  
  56.     /// <summary>
  57.     /// OpenType font that contains a TrueType collection.
  58.     /// </summary>
  59.     DWRITE_FONT_FILE_TYPE_TRUETYPE_COLLECTION,
  60.  
  61.     /// <summary>
  62.     /// Type 1 PFM font.
  63.     /// </summary>
  64.     DWRITE_FONT_FILE_TYPE_TYPE1_PFM,
  65.  
  66.     /// <summary>
  67.     /// Type 1 PFB font.
  68.     /// </summary>
  69.     DWRITE_FONT_FILE_TYPE_TYPE1_PFB,
  70.  
  71.     /// <summary>
  72.     /// Vector .FON font.
  73.     /// </summary>
  74.     DWRITE_FONT_FILE_TYPE_VECTOR,
  75.  
  76.     /// <summary>
  77.     /// Bitmap .FON font.
  78.     /// </summary>
  79.     DWRITE_FONT_FILE_TYPE_BITMAP
  80. };
  81.  
  82. /// <summary>
  83. /// The file format of a complete font face.
  84. /// Font formats that consist of multiple files, e.g. Type 1 .PFM and .PFB, have
  85. /// a single enum entry.
  86. /// </summary>
  87. enum DWRITE_FONT_FACE_TYPE
  88. {
  89.     /// <summary>
  90.     /// OpenType font face with CFF outlines.
  91.     /// </summary>
  92.     DWRITE_FONT_FACE_TYPE_CFF,
  93.  
  94.     /// <summary>
  95.     /// OpenType font face with TrueType outlines.
  96.     /// </summary>
  97.     DWRITE_FONT_FACE_TYPE_TRUETYPE,
  98.  
  99.     /// <summary>
  100.     /// OpenType font face that is a part of a TrueType collection.
  101.     /// </summary>
  102.     DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION,
  103.  
  104.     /// <summary>
  105.     /// A Type 1 font face.
  106.     /// </summary>
  107.     DWRITE_FONT_FACE_TYPE_TYPE1,
  108.  
  109.     /// <summary>
  110.     /// A vector .FON format font face.
  111.     /// </summary>
  112.     DWRITE_FONT_FACE_TYPE_VECTOR,
  113.  
  114.     /// <summary>
  115.     /// A bitmap .FON format font face.
  116.     /// </summary>
  117.     DWRITE_FONT_FACE_TYPE_BITMAP,
  118.  
  119.     /// <summary>
  120.     /// Font face type is not recognized by the DirectWrite font system.
  121.     /// </summary>
  122.     DWRITE_FONT_FACE_TYPE_UNKNOWN
  123. };
  124.  
  125. /// <summary>
  126. /// Specifies algorithmic style simulations to be applied to the font face.
  127. /// Bold and oblique simulations can be combined via bitwise OR operation.
  128. /// </summary>
  129. enum DWRITE_FONT_SIMULATIONS
  130. {
  131.     /// <summary>
  132.     /// No simulations are performed.
  133.     /// </summary>
  134.     DWRITE_FONT_SIMULATIONS_NONE    = 0x0000,
  135.  
  136.     /// <summary>
  137.     /// Algorithmic emboldening is performed.
  138.     /// </summary>
  139.     DWRITE_FONT_SIMULATIONS_BOLD    = 0x0001,
  140.  
  141.     /// <summary>
  142.     /// Algorithmic italicization is performed.
  143.     /// </summary>
  144.     DWRITE_FONT_SIMULATIONS_OBLIQUE = 0x0002
  145. };
  146.  
  147. #ifdef DEFINE_ENUM_FLAG_OPERATORS
  148. DEFINE_ENUM_FLAG_OPERATORS(DWRITE_FONT_SIMULATIONS);
  149. #endif
  150.  
  151. /// <summary>
  152. /// The font weight enumeration describes common values for degree of blackness or thickness of strokes of characters in a font.
  153. /// Font weight values less than 1 or greater than 999 are considered to be invalid, and they are rejected by font API functions.
  154. /// </summary>
  155. enum DWRITE_FONT_WEIGHT
  156. {
  157.     /// <summary>
  158.     /// Predefined font weight : Thin (100).
  159.     /// </summary>
  160.     DWRITE_FONT_WEIGHT_THIN = 100,
  161.  
  162.     /// <summary>
  163.     /// Predefined font weight : Extra-light (200).
  164.     /// </summary>
  165.     DWRITE_FONT_WEIGHT_EXTRA_LIGHT = 200,
  166.  
  167.     /// <summary>
  168.     /// Predefined font weight : Ultra-light (200).
  169.     /// </summary>
  170.     DWRITE_FONT_WEIGHT_ULTRA_LIGHT = 200,
  171.  
  172.     /// <summary>
  173.     /// Predefined font weight : Light (300).
  174.     /// </summary>
  175.     DWRITE_FONT_WEIGHT_LIGHT = 300,
  176.  
  177.     /// <summary>
  178.     /// Predefined font weight : Normal (400).
  179.     /// </summary>
  180.     DWRITE_FONT_WEIGHT_NORMAL = 400,
  181.  
  182.     /// <summary>
  183.     /// Predefined font weight : Regular (400).
  184.     /// </summary>
  185.     DWRITE_FONT_WEIGHT_REGULAR = 400,
  186.  
  187.     /// <summary>
  188.     /// Predefined font weight : Medium (500).
  189.     /// </summary>
  190.     DWRITE_FONT_WEIGHT_MEDIUM = 500,
  191.  
  192.     /// <summary>
  193.     /// Predefined font weight : Demi-bold (600).
  194.     /// </summary>
  195.     DWRITE_FONT_WEIGHT_DEMI_BOLD = 600,
  196.  
  197.     /// <summary>
  198.     /// Predefined font weight : Semi-bold (600).
  199.     /// </summary>
  200.     DWRITE_FONT_WEIGHT_SEMI_BOLD = 600,
  201.  
  202.     /// <summary>
  203.     /// Predefined font weight : Bold (700).
  204.     /// </summary>
  205.     DWRITE_FONT_WEIGHT_BOLD = 700,
  206.  
  207.     /// <summary>
  208.     /// Predefined font weight : Extra-bold (800).
  209.     /// </summary>
  210.     DWRITE_FONT_WEIGHT_EXTRA_BOLD = 800,
  211.  
  212.     /// <summary>
  213.     /// Predefined font weight : Ultra-bold (800).
  214.     /// </summary>
  215.     DWRITE_FONT_WEIGHT_ULTRA_BOLD = 800,
  216.  
  217.     /// <summary>
  218.     /// Predefined font weight : Black (900).
  219.     /// </summary>
  220.     DWRITE_FONT_WEIGHT_BLACK = 900,
  221.  
  222.     /// <summary>
  223.     /// Predefined font weight : Heavy (900).
  224.     /// </summary>
  225.     DWRITE_FONT_WEIGHT_HEAVY = 900,
  226.  
  227.     /// <summary>
  228.     /// Predefined font weight : Extra-black (950).
  229.     /// </summary>
  230.     DWRITE_FONT_WEIGHT_EXTRA_BLACK = 950,
  231.  
  232.     /// <summary>
  233.     /// Predefined font weight : Ultra-black (950).
  234.     /// </summary>
  235.     DWRITE_FONT_WEIGHT_ULTRA_BLACK = 950
  236. };
  237.  
  238. /// <summary>
  239. /// The font stretch enumeration describes relative change from the normal aspect ratio
  240. /// as specified by a font designer for the glyphs in a font.
  241. /// Values less than 1 or greater than 9 are considered to be invalid, and they are rejected by font API functions.
  242. /// </summary>
  243. enum DWRITE_FONT_STRETCH
  244. {
  245.     /// <summary>
  246.     /// Predefined font stretch : Not known (0).
  247.     /// </summary>
  248.     DWRITE_FONT_STRETCH_UNDEFINED = 0,
  249.  
  250.     /// <summary>
  251.     /// Predefined font stretch : Ultra-condensed (1).
  252.     /// </summary>
  253.     DWRITE_FONT_STRETCH_ULTRA_CONDENSED = 1,
  254.  
  255.     /// <summary>
  256.     /// Predefined font stretch : Extra-condensed (2).
  257.     /// </summary>
  258.     DWRITE_FONT_STRETCH_EXTRA_CONDENSED = 2,
  259.  
  260.     /// <summary>
  261.     /// Predefined font stretch : Condensed (3).
  262.     /// </summary>
  263.     DWRITE_FONT_STRETCH_CONDENSED = 3,
  264.  
  265.     /// <summary>
  266.     /// Predefined font stretch : Semi-condensed (4).
  267.     /// </summary>
  268.     DWRITE_FONT_STRETCH_SEMI_CONDENSED = 4,
  269.  
  270.     /// <summary>
  271.     /// Predefined font stretch : Normal (5).
  272.     /// </summary>
  273.     DWRITE_FONT_STRETCH_NORMAL = 5,
  274.  
  275.     /// <summary>
  276.     /// Predefined font stretch : Medium (5).
  277.     /// </summary>
  278.     DWRITE_FONT_STRETCH_MEDIUM = 5,
  279.  
  280.     /// <summary>
  281.     /// Predefined font stretch : Semi-expanded (6).
  282.     /// </summary>
  283.     DWRITE_FONT_STRETCH_SEMI_EXPANDED = 6,
  284.  
  285.     /// <summary>
  286.     /// Predefined font stretch : Expanded (7).
  287.     /// </summary>
  288.     DWRITE_FONT_STRETCH_EXPANDED = 7,
  289.  
  290.     /// <summary>
  291.     /// Predefined font stretch : Extra-expanded (8).
  292.     /// </summary>
  293.     DWRITE_FONT_STRETCH_EXTRA_EXPANDED = 8,
  294.  
  295.     /// <summary>
  296.     /// Predefined font stretch : Ultra-expanded (9).
  297.     /// </summary>
  298.     DWRITE_FONT_STRETCH_ULTRA_EXPANDED = 9
  299. };
  300.  
  301. /// <summary>
  302. /// The font style enumeration describes the slope style of a font face, such as Normal, Italic or Oblique.
  303. /// Values other than the ones defined in the enumeration are considered to be invalid, and they are rejected by font API functions.
  304. /// </summary>
  305. enum DWRITE_FONT_STYLE
  306. {
  307.     /// <summary>
  308.     /// Font slope style : Normal.
  309.     /// </summary>
  310.     DWRITE_FONT_STYLE_NORMAL,
  311.  
  312.     /// <summary>
  313.     /// Font slope style : Oblique.
  314.     /// </summary>
  315.     DWRITE_FONT_STYLE_OBLIQUE,
  316.  
  317.     /// <summary>
  318.     /// Font slope style : Italic.
  319.     /// </summary>
  320.     DWRITE_FONT_STYLE_ITALIC
  321.  
  322. };
  323.  
  324. /// <summary>
  325. /// The informational string enumeration identifies a string in a font.
  326. /// </summary>
  327. enum DWRITE_INFORMATIONAL_STRING_ID
  328. {
  329.     /// <summary>
  330.     /// Unspecified name ID.
  331.     /// </summary>
  332.     DWRITE_INFORMATIONAL_STRING_NONE,
  333.  
  334.     /// <summary>
  335.     /// Copyright notice provided by the font.
  336.     /// </summary>
  337.     DWRITE_INFORMATIONAL_STRING_COPYRIGHT_NOTICE,
  338.  
  339.     /// <summary>
  340.     /// String containing a version number.
  341.     /// </summary>
  342.     DWRITE_INFORMATIONAL_STRING_VERSION_STRINGS,
  343.  
  344.     /// <summary>
  345.     /// Trademark information provided by the font.
  346.     /// </summary>
  347.     DWRITE_INFORMATIONAL_STRING_TRADEMARK,
  348.  
  349.     /// <summary>
  350.     /// Name of the font manufacturer.
  351.     /// </summary>
  352.     DWRITE_INFORMATIONAL_STRING_MANUFACTURER,
  353.  
  354.     /// <summary>
  355.     /// Name of the font designer.
  356.     /// </summary>
  357.     DWRITE_INFORMATIONAL_STRING_DESIGNER,
  358.  
  359.     /// <summary>
  360.     /// URL of font designer (with protocol, e.g., http://, ftp://).
  361.     /// </summary>
  362.     DWRITE_INFORMATIONAL_STRING_DESIGNER_URL,
  363.  
  364.     /// <summary>
  365.     /// Description of the font. Can contain revision information, usage recommendations, history, features, etc.
  366.     /// </summary>
  367.     DWRITE_INFORMATIONAL_STRING_DESCRIPTION,
  368.  
  369.     /// <summary>
  370.     /// URL of font vendor (with protocol, e.g., http://, ftp://). If a unique serial number is embedded in the URL, it can be used to register the font.
  371.     /// </summary>
  372.     DWRITE_INFORMATIONAL_STRING_FONT_VENDOR_URL,
  373.  
  374.     /// <summary>
  375.     /// Description of how the font may be legally used, or different example scenarios for licensed use. This field should be written in plain language, not legalese.
  376.     /// </summary>
  377.     DWRITE_INFORMATIONAL_STRING_LICENSE_DESCRIPTION,
  378.  
  379.     /// <summary>
  380.     /// URL where additional licensing information can be found.
  381.     /// </summary>
  382.     DWRITE_INFORMATIONAL_STRING_LICENSE_INFO_URL,
  383.  
  384.     /// <summary>
  385.     /// GDI-compatible family name. Because GDI allows a maximum of four fonts per family, fonts in the same family may have different GDI-compatible family names
  386.     /// (e.g., "Arial", "Arial Narrow", "Arial Black").
  387.     /// </summary>
  388.     DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES,
  389.  
  390.     /// <summary>
  391.     /// GDI-compatible subfamily name.
  392.     /// </summary>
  393.     DWRITE_INFORMATIONAL_STRING_WIN32_SUBFAMILY_NAMES,
  394.  
  395.     /// <summary>
  396.     /// Family name preferred by the designer. This enables font designers to group more than four fonts in a single family without losing compatibility with
  397.     /// GDI. This name is typically only present if it differs from the GDI-compatible family name.
  398.     /// </summary>
  399.     DWRITE_INFORMATIONAL_STRING_PREFERRED_FAMILY_NAMES,
  400.  
  401.     /// <summary>
  402.     /// Subfamily name preferred by the designer. This name is typically only present if it differs from the GDI-compatible subfamily name.
  403.     /// </summary>
  404.     DWRITE_INFORMATIONAL_STRING_PREFERRED_SUBFAMILY_NAMES,
  405.  
  406.     /// <summary>
  407.     /// Sample text. This can be the font name or any other text that the designer thinks is the best example to display the font in.
  408.     /// </summary>
  409.     DWRITE_INFORMATIONAL_STRING_SAMPLE_TEXT
  410. };
  411.  
  412.  
  413. /// <summary>
  414. /// The DWRITE_FONT_METRICS structure specifies the metrics of a font face that
  415. /// are applicable to all glyphs within the font face.
  416. /// </summary>
  417. struct DWRITE_FONT_METRICS
  418. {
  419.     /// <summary>
  420.     /// The number of font design units per em unit.
  421.     /// Font files use their own coordinate system of font design units.
  422.     /// A font design unit is the smallest measurable unit in the em square,
  423.     /// an imaginary square that is used to size and align glyphs.
  424.     /// The concept of em square is used as a reference scale factor when defining font size and device transformation semantics.
  425.     /// The size of one em square is also commonly used to compute the paragraph identation value.
  426.     /// </summary>
  427.     UINT16 designUnitsPerEm;
  428.  
  429.     /// <summary>
  430.     /// Ascent value of the font face in font design units.
  431.     /// Ascent is the distance from the top of font character alignment box to English baseline.
  432.     /// </summary>
  433.     UINT16 ascent;
  434.  
  435.     /// <summary>
  436.     /// Descent value of the font face in font design units.
  437.     /// Descent is the distance from the bottom of font character alignment box to English baseline.
  438.     /// </summary>
  439.     UINT16 descent;
  440.  
  441.     /// <summary>
  442.     /// Line gap in font design units.
  443.     /// Recommended additional white space to add between lines to improve legibility. The recommended line spacing
  444.     /// (baseline-to-baseline distance) is thus the sum of ascent, descent, and lineGap. The line gap is usually
  445.     /// positive or zero but can be negative, in which case the recommended line spacing is less than the height
  446.     /// of the character alignment box.
  447.     /// </summary>
  448.     INT16 lineGap;
  449.  
  450.     /// <summary>
  451.     /// Cap height value of the font face in font design units.
  452.     /// Cap height is the distance from English baseline to the top of a typical English capital.
  453.     /// Capital "H" is often used as a reference character for the purpose of calculating the cap height value.
  454.     /// </summary>
  455.     UINT16 capHeight;
  456.  
  457.     /// <summary>
  458.     /// x-height value of the font face in font design units.
  459.     /// x-height is the distance from English baseline to the top of lowercase letter "x", or a similar lowercase character.
  460.     /// </summary>
  461.     UINT16 xHeight;
  462.  
  463.     /// <summary>
  464.     /// The underline position value of the font face in font design units.
  465.     /// Underline position is the position of underline relative to the English baseline.
  466.     /// The value is usually made negative in order to place the underline below the baseline.
  467.     /// </summary>
  468.     INT16 underlinePosition;
  469.  
  470.     /// <summary>
  471.     /// The suggested underline thickness value of the font face in font design units.
  472.     /// </summary>
  473.     UINT16 underlineThickness;
  474.  
  475.     /// <summary>
  476.     /// The strikethrough position value of the font face in font design units.
  477.     /// Strikethrough position is the position of strikethrough relative to the English baseline.
  478.     /// The value is usually made positive in order to place the strikethrough above the baseline.
  479.     /// </summary>
  480.     INT16 strikethroughPosition;
  481.  
  482.     /// <summary>
  483.     /// The suggested strikethrough thickness value of the font face in font design units.
  484.     /// </summary>
  485.     UINT16 strikethroughThickness;
  486. };
  487.  
  488. /// <summary>
  489. /// The DWRITE_GLYPH_METRICS structure specifies the metrics of an individual glyph.
  490. /// The units depend on how the metrics are obtained.
  491. /// </summary>
  492. struct DWRITE_GLYPH_METRICS
  493. {
  494.     /// <summary>
  495.     /// Specifies the X offset from the glyph origin to the left edge of the black box.
  496.     /// The glyph origin is the current horizontal writing position.
  497.     /// A negative value means the black box extends to the left of the origin (often true for lowercase italic 'f').
  498.     /// </summary>
  499.     INT32 leftSideBearing;
  500.  
  501.     /// <summary>
  502.     /// Specifies the X offset from the origin of the current glyph to the origin of the next glyph when writing horizontally.
  503.     /// </summary>
  504.     UINT32 advanceWidth;
  505.  
  506.     /// <summary>
  507.     /// Specifies the X offset from the right edge of the black box to the origin of the next glyph when writing horizontally.
  508.     /// The value is negative when the right edge of the black box overhangs the layout box.
  509.     /// </summary>
  510.     INT32 rightSideBearing;
  511.  
  512.     /// <summary>
  513.     /// Specifies the vertical offset from the vertical origin to the top of the black box.
  514.     /// Thus, a positive value adds whitespace whereas a negative value means the glyph overhangs the top of the layout box.
  515.     /// </summary>
  516.     INT32 topSideBearing;
  517.  
  518.     /// <summary>
  519.     /// Specifies the Y offset from the vertical origin of the current glyph to the vertical origin of the next glyph when writing vertically.
  520.     /// (Note that the term "origin" by itself denotes the horizontal origin. The vertical origin is different.
  521.     /// Its Y coordinate is specified by verticalOriginY value,
  522.     /// and its X coordinate is half the advanceWidth to the right of the horizontal origin).
  523.     /// </summary>
  524.     UINT32 advanceHeight;
  525.  
  526.     /// <summary>
  527.     /// Specifies the vertical distance from the black box's bottom edge to the advance height.
  528.     /// Positive when the bottom edge of the black box is within the layout box.
  529.     /// Negative when the bottom edge of black box overhangs the layout box.
  530.     /// </summary>
  531.     INT32 bottomSideBearing;
  532.  
  533.     /// <summary>
  534.     /// Specifies the Y coordinate of a glyph's vertical origin, in the font's design coordinate system.
  535.     /// The y coordinate of a glyph's vertical origin is the sum of the glyph's top side bearing
  536.     /// and the top (i.e. yMax) of the glyph's bounding box.
  537.     /// </summary>
  538.     INT32 verticalOriginY;
  539. };
  540.  
  541. /// <summary>
  542. /// Optional adjustment to a glyph's position. An glyph offset changes the position of a glyph without affecting
  543. /// the pen position. Offsets are in logical, pre-transform units.
  544. /// </summary>
  545. struct DWRITE_GLYPH_OFFSET
  546. {
  547.     /// <summary>
  548.     /// Offset in the advance direction of the run. A positive advance offset moves the glyph to the right
  549.     /// (in pre-transform coordinates) if the run is left-to-right or to the left if the run is right-to-left.
  550.     /// </summary>
  551.     FLOAT advanceOffset;
  552.  
  553.     /// <summary>
  554.     /// Offset in the ascent direction, i.e., the direction ascenders point. A positive ascender offset moves
  555.     /// the glyph up (in pre-transform coordinates).
  556.     /// </summary>
  557.     FLOAT ascenderOffset;
  558. };
  559.  
  560. /// <summary>
  561. /// Specifies the type of DirectWrite factory object.
  562. /// DirectWrite factory contains internal state such as font loader registration and cached font data.
  563. /// In most cases it is recommended to use the shared factory object, because it allows multiple components
  564. /// that use DirectWrite to share internal DirectWrite state and reduce memory usage.
  565. /// However, there are cases when it is desirable to reduce the impact of a component,
  566. /// such as a plug-in from an untrusted source, on the rest of the process by sandboxing and isolating it
  567. /// from the rest of the process components. In such cases, it is recommended to use an isolated factory for the sandboxed
  568. /// component.
  569. /// </summary>
  570. enum DWRITE_FACTORY_TYPE
  571. {
  572.     /// <summary>
  573.     /// Shared factory allow for re-use of cached font data across multiple in process components.
  574.     /// Such factories also take advantage of cross process font caching components for better performance.
  575.     /// </summary>
  576.     DWRITE_FACTORY_TYPE_SHARED,
  577.  
  578.     /// <summary>
  579.     /// Objects created from the isolated factory do not interact with internal DirectWrite state from other components.
  580.     /// </summary>
  581.     DWRITE_FACTORY_TYPE_ISOLATED
  582. };
  583.  
  584. // Creates an OpenType tag as a 32bit integer such that
  585. // the first character in the tag is the lowest byte,
  586. // (least significant on little endian architectures)
  587. // which can be used to compare with tags in the font file.
  588. // This macro is compatible with DWRITE_FONT_FEATURE_TAG.
  589. //
  590. // Example: DWRITE_MAKE_OPENTYPE_TAG('c','c','m','p')
  591. // Dword:   0x706D6363
  592. //
  593. #define DWRITE_MAKE_OPENTYPE_TAG(a,b,c,d) ( \
  594.     (static_cast<UINT32>(static_cast<UINT8>(d)) << 24) | \
  595.     (static_cast<UINT32>(static_cast<UINT8>(c)) << 16) | \
  596.     (static_cast<UINT32>(static_cast<UINT8>(b)) << 8)  | \
  597.      static_cast<UINT32>(static_cast<UINT8>(a)))
  598.  
  599. interface IDWriteFontFileStream;
  600.  
  601. /// <summary>
  602. /// Font file loader interface handles loading font file resources of a particular type from a key.
  603. /// The font file loader interface is recommended to be implemented by a singleton object.
  604. /// IMPORTANT: font file loader implementations must not register themselves with DirectWrite factory
  605. /// inside their constructors and must not unregister themselves in their destructors, because
  606. /// registration and unregistraton operations increment and decrement the object reference count respectively.
  607. /// Instead, registration and unregistration of font file loaders with DirectWrite factory should be performed
  608. /// outside of the font file loader implementation as a separate step.
  609. /// </summary>
  610. interface DWRITE_DECLARE_INTERFACE("727cad4e-d6af-4c9e-8a08-d695b11caa49") IDWriteFontFileLoader : public IUnknown
  611. {
  612.     /// <summary>
  613.     /// Creates a font file stream object that encapsulates an open file resource.
  614.     /// The resource is closed when the last reference to fontFileStream is released.
  615.     /// </summary>
  616.     /// <param name="fontFileReferenceKey">Font file reference key that uniquely identifies the font file resource
  617.     /// within the scope of the font loader being used.</param>
  618.     /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param>
  619.     /// <param name="fontFileStream">Pointer to the newly created font file stream.</param>
  620.     /// <returns>
  621.     /// Standard HRESULT error code.
  622.     /// </returns>
  623.     STDMETHOD(CreateStreamFromKey)(
  624.         __in_bcount(fontFileReferenceKeySize) void const* fontFileReferenceKey,
  625.         UINT32 fontFileReferenceKeySize,
  626.         __out IDWriteFontFileStream** fontFileStream
  627.         ) PURE;
  628. };
  629.  
  630. /// <summary>
  631. /// A built-in implementation of IDWriteFontFileLoader interface that operates on local font files
  632. /// and exposes local font file information from the font file reference key.
  633. /// Font file references created using CreateFontFileReference use this font file loader.
  634. /// </summary>
  635. interface DWRITE_DECLARE_INTERFACE("b2d9f3ec-c9fe-4a11-a2ec-d86208f7c0a2") IDWriteLocalFontFileLoader : public IDWriteFontFileLoader
  636. {
  637.     /// <summary>
  638.     /// Obtains the length of the absolute file path from the font file reference key.
  639.     /// </summary>
  640.     /// <param name="fontFileReferenceKey">Font file reference key that uniquely identifies the local font file
  641.     /// within the scope of the font loader being used.</param>
  642.     /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param>
  643.     /// <param name="filePathLength">Length of the file path string not including the terminated NULL character.</param>
  644.     /// <returns>
  645.     /// Standard HRESULT error code.
  646.     /// </returns>
  647.     STDMETHOD(GetFilePathLengthFromKey)(
  648.         __in_bcount(fontFileReferenceKeySize) void const* fontFileReferenceKey,
  649.         UINT32 fontFileReferenceKeySize,
  650.         __out UINT32* filePathLength
  651.         ) PURE;
  652.  
  653.     /// <summary>
  654.     /// Obtains the absolute font file path from the font file reference key.
  655.     /// </summary>
  656.     /// <param name="fontFileReferenceKey">Font file reference key that uniquely identifies the local font file
  657.     /// within the scope of the font loader being used.</param>
  658.     /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param>
  659.     /// <param name="filePath">Character array that receives the local file path.</param>
  660.     /// <param name="filePathSize">Size of the filePath array in character count including the terminated NULL character.</param>
  661.     /// <returns>
  662.     /// Standard HRESULT error code.
  663.     /// </returns>
  664.     STDMETHOD(GetFilePathFromKey)(
  665.         __in_bcount(fontFileReferenceKeySize) void const* fontFileReferenceKey,
  666.         UINT32 fontFileReferenceKeySize,
  667.         __out_ecount_z(filePathSize) WCHAR* filePath,
  668.         UINT32 filePathSize
  669.         ) PURE;
  670.  
  671.     /// <summary>
  672.     /// Obtains the last write time of the file from the font file reference key.
  673.     /// </summary>
  674.     /// <param name="fontFileReferenceKey">Font file reference key that uniquely identifies the local font file
  675.     /// within the scope of the font loader being used.</param>
  676.     /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param>
  677.     /// <param name="lastWriteTime">Last modified time of the font file.</param>
  678.     /// <returns>
  679.     /// Standard HRESULT error code.
  680.     /// </returns>
  681.     STDMETHOD(GetLastWriteTimeFromKey)(
  682.         __in_bcount(fontFileReferenceKeySize) void const* fontFileReferenceKey,
  683.         UINT32 fontFileReferenceKeySize,
  684.         __out FILETIME* lastWriteTime
  685.         ) PURE;
  686. };
  687.  
  688. /// <summary>
  689. /// The interface for loading font file data.
  690. /// </summary>
  691. interface DWRITE_DECLARE_INTERFACE("6d4865fe-0ab8-4d91-8f62-5dd6be34a3e0") IDWriteFontFileStream : public IUnknown
  692. {
  693.     /// <summary>
  694.     /// Reads a fragment from a file.
  695.     /// </summary>
  696.     /// <param name="fragmentStart">Receives the pointer to the start of the font file fragment.</param>
  697.     /// <param name="fileOffset">Offset of the fragment from the beginning of the font file.</param>
  698.     /// <param name="fragmentSize">Size of the fragment in bytes.</param>
  699.     /// <param name="fragmentContext">The client defined context to be passed to the ReleaseFileFragment.</param>
  700.     /// <returns>
  701.     /// Standard HRESULT error code.
  702.     /// </returns>
  703.     /// <remarks>
  704.     /// IMPORTANT: ReadFileFragment() implementations must check whether the requested file fragment
  705.     /// is within the file bounds. Otherwise, an error should be returned from ReadFileFragment.
  706.     /// </remarks>
  707.     STDMETHOD(ReadFileFragment)(
  708.         __deref_out_bcount(fragmentSize) void const** fragmentStart,
  709.         UINT64 fileOffset,
  710.         UINT64 fragmentSize,
  711.         __out void** fragmentContext
  712.         ) PURE;
  713.  
  714.     /// <summary>
  715.     /// Releases a fragment from a file.
  716.     /// </summary>
  717.     /// <param name="fragmentContext">The client defined context of a font fragment returned from ReadFileFragment.</param>
  718.     STDMETHOD_(void, ReleaseFileFragment)(
  719.         void* fragmentContext
  720.         ) PURE;
  721.  
  722.     /// <summary>
  723.     /// Obtains the total size of a file.
  724.     /// </summary>
  725.     /// <param name="fileSize">Receives the total size of the file.</param>
  726.     /// <returns>
  727.     /// Standard HRESULT error code.
  728.     /// </returns>
  729.     /// <remarks>
  730.     /// Implementing GetFileSize() for asynchronously loaded font files may require
  731.     /// downloading the complete file contents, therefore this method should only be used for operations that
  732.     /// either require complete font file to be loaded (e.g., copying a font file) or need to make
  733.     /// decisions based on the value of the file size (e.g., validation against a persisted file size).
  734.     /// </remarks>
  735.     STDMETHOD(GetFileSize)(
  736.         __out UINT64* fileSize
  737.         ) PURE;
  738.  
  739.     /// <summary>
  740.     /// Obtains the last modified time of the file. The last modified time is used by DirectWrite font selection algorithms
  741.     /// to determine whether one font resource is more up to date than another one.
  742.     /// </summary>
  743.     /// <param name="lastWriteTime">Receives the last modifed time of the file in the format that represents
  744.     /// the number of 100-nanosecond intervals since January 1, 1601 (UTC).</param>
  745.     /// <returns>
  746.     /// Standard HRESULT error code. For resources that don't have a concept of the last modified time, the implementation of
  747.     /// GetLastWriteTime should return E_NOTIMPL.
  748.     /// </returns>
  749.     STDMETHOD(GetLastWriteTime)(
  750.         __out UINT64* lastWriteTime
  751.         ) PURE;
  752. };
  753.  
  754. /// <summary>
  755. /// The interface that represents a reference to a font file.
  756. /// </summary>
  757. interface DWRITE_DECLARE_INTERFACE("739d886a-cef5-47dc-8769-1a8b41bebbb0") IDWriteFontFile : public IUnknown
  758. {
  759.     /// <summary>
  760.     /// This method obtains the pointer to the reference key of a font file. The pointer is only valid until the object that refers to it is released.
  761.     /// </summary>
  762.     /// <param name="fontFileReferenceKey">Pointer to the font file reference key.
  763.     /// IMPORTANT: The pointer value is valid until the font file reference object it is obtained from is released.</param>
  764.     /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param>
  765.     /// <returns>
  766.     /// Standard HRESULT error code.
  767.     /// </returns>
  768.     STDMETHOD(GetReferenceKey)(
  769.         __deref_out_bcount(*fontFileReferenceKeySize) void const** fontFileReferenceKey,
  770.         __out UINT32* fontFileReferenceKeySize
  771.         ) PURE;
  772.  
  773.     /// <summary>
  774.     /// Obtains the file loader associated with a font file object.
  775.     /// </summary>
  776.     /// <param name="fontFileLoader">The font file loader associated with the font file object.</param>
  777.     /// <returns>
  778.     /// Standard HRESULT error code.
  779.     /// </returns>
  780.     STDMETHOD(GetLoader)(
  781.         __out IDWriteFontFileLoader** fontFileLoader
  782.         ) PURE;
  783.  
  784.     /// <summary>
  785.     /// Analyzes a file and returns whether it represents a font, and whether the font type is supported by the font system.
  786.     /// </summary>
  787.     /// <param name="isSupportedFontType">TRUE if the font type is supported by the font system, FALSE otherwise.</param>
  788.     /// <param name="fontFileType">The type of the font file. Note that even if isSupportedFontType is FALSE,
  789.     /// the fontFileType value may be different from DWRITE_FONT_FILE_TYPE_UNKNOWN.</param>
  790.     /// <param name="fontFaceType">The type of the font face that can be constructed from the font file.
  791.     /// Note that even if isSupportedFontType is FALSE, the fontFaceType value may be different from
  792.     /// DWRITE_FONT_FACE_TYPE_UNKNOWN.</param>
  793.     /// <param name="numberOfFaces">Number of font faces contained in the font file.</param>
  794.     /// <returns>
  795.     /// Standard HRESULT error code if there was a processing error during analysis.
  796.     /// </returns>
  797.     /// <remarks>
  798.     /// IMPORTANT: certain font file types are recognized, but not supported by the font system.
  799.     /// For example, the font system will recognize a file as a Type 1 font file,
  800.     /// but will not be able to construct a font face object from it. In such situations, Analyze will set
  801.     /// isSupportedFontType output parameter to FALSE.
  802.     /// </remarks>
  803.     STDMETHOD(Analyze)(
  804.         __out BOOL* isSupportedFontType,
  805.         __out DWRITE_FONT_FILE_TYPE* fontFileType,
  806.         __out_opt DWRITE_FONT_FACE_TYPE* fontFaceType,
  807.         __out UINT32* numberOfFaces
  808.         ) PURE;
  809. };
  810.  
  811. /// <summary>
  812. /// Represents the internal structure of a device pixel (i.e., the physical arrangement of red,
  813. /// green, and blue color components) that is assumed for purposes of rendering text.
  814. /// </summary>
  815. #ifndef DWRITE_PIXEL_GEOMETRY_DEFINED
  816. enum DWRITE_PIXEL_GEOMETRY
  817. {
  818.     /// <summary>
  819.     /// The red, green, and blue color components of each pixel are assumed to occupy the same point.
  820.     /// </summary>
  821.     DWRITE_PIXEL_GEOMETRY_FLAT,
  822.  
  823.     /// <summary>
  824.     /// Each pixel comprises three vertical stripes, with red on the left, green in the center, and
  825.     /// blue on the right. This is the most common pixel geometry for LCD monitors.
  826.     /// </summary>
  827.     DWRITE_PIXEL_GEOMETRY_RGB,
  828.  
  829.     /// <summary>
  830.     /// Each pixel comprises three vertical stripes, with blue on the left, green in the center, and
  831.     /// red on the right.
  832.     /// </summary>
  833.     DWRITE_PIXEL_GEOMETRY_BGR
  834. };
  835. #define DWRITE_PIXEL_GEOMETRY_DEFINED
  836. #endif
  837.  
  838. /// <summary>
  839. /// Represents a method of rendering glyphs.
  840. /// </summary>
  841. enum DWRITE_RENDERING_MODE
  842. {
  843.     /// <summary>
  844.     /// Specifies that the rendering mode is determined automatically based on the font and size.
  845.     /// </summary>
  846.     DWRITE_RENDERING_MODE_DEFAULT,
  847.  
  848.     /// <summary>
  849.     /// Specifies that no anti-aliasing is performed. Each pixel is either set to the foreground
  850.     /// color of the text or retains the color of the background.
  851.     /// </summary>
  852.     DWRITE_RENDERING_MODE_ALIASED,
  853.  
  854.     /// <summary>
  855.     /// Specifies ClearType rendering with the same metrics as aliased text. Glyphs can only
  856.     /// be positioned on whole-pixel boundaries.
  857.     /// </summary>
  858.     DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC,
  859.  
  860.     /// <summary>
  861.     /// Specifies ClearType rendering with the same metrics as text rendering using GDI using a font
  862.     /// created with CLEARTYPE_NATURAL_QUALITY. Glyph metrics are closer to their ideal values than
  863.     /// with aliased text, but glyphs are still positioned on whole-pixel boundaries.
  864.     /// </summary>
  865.     DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL,
  866.  
  867.     /// <summary>
  868.     /// Specifies ClearType rendering with anti-aliasing in the horizontal dimension only. This is
  869.     /// typically used with small to medium font sizes (up to 16 ppem).
  870.     /// </summary>
  871.     DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL,
  872.  
  873.     /// <summary>
  874.     /// Specifies ClearType rendering with anti-aliasing in both horizontal and vertical dimensions.
  875.     /// This is typically used at larger sizes to makes curves and diagonal lines look smoother, at
  876.     /// the expense of some softness.
  877.     /// </summary>
  878.     DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC,
  879.  
  880.     /// <summary>
  881.     /// Specifies that rendering should bypass the rasterizer and use the outlines directly. This is
  882.     /// typically used at very large sizes.
  883.     /// </summary>
  884.     DWRITE_RENDERING_MODE_OUTLINE
  885. };
  886.  
  887. /// <summary>
  888. /// The DWRITE_MATRIX structure specifies the graphics transform to be applied
  889. /// to rendered glyphs.
  890. /// </summary>
  891. struct DWRITE_MATRIX
  892. {
  893.     /// <summary>
  894.     /// Horizontal scaling / cosine of rotation
  895.     /// </summary>
  896.     FLOAT m11;
  897.  
  898.     /// <summary>
  899.     /// Vertical shear / sine of rotation
  900.     /// </summary>
  901.     FLOAT m12;
  902.  
  903.     /// <summary>
  904.     /// Horizontal shear / negative sine of rotation
  905.     /// </summary>
  906.     FLOAT m21;
  907.  
  908.     /// <summary>
  909.     /// Vertical scaling / cosine of rotation
  910.     /// </summary>
  911.     FLOAT m22;
  912.  
  913.     /// <summary>
  914.     /// Horizontal shift (always orthogonal regardless of rotation)
  915.     /// </summary>
  916.     FLOAT dx;
  917.  
  918.     /// <summary>
  919.     /// Vertical shift (always orthogonal regardless of rotation)
  920.     /// </summary>
  921.     FLOAT dy;
  922. };
  923.  
  924. /// <summary>
  925. /// The interface that represents text rendering settings for glyph rasterization and filtering.
  926. /// </summary>
  927. interface DWRITE_DECLARE_INTERFACE("2f0da53a-2add-47cd-82ee-d9ec34688e75") IDWriteRenderingParams : public IUnknown
  928. {
  929.     /// <summary>
  930.     /// Gets the gamma value used for gamma correction. Valid values must be
  931.     /// greater than zero and cannot exceed 256.
  932.     /// </summary>
  933.     STDMETHOD_(FLOAT, GetGamma)() PURE;
  934.  
  935.     /// <summary>
  936.     /// Gets the amount of contrast enhancement. Valid values are greater than
  937.     /// or equal to zero.
  938.     /// </summary>
  939.     STDMETHOD_(FLOAT, GetEnhancedContrast)() PURE;
  940.  
  941.     /// <summary>
  942.     /// Gets the ClearType level. Valid values range from 0.0f (no ClearType)
  943.     /// to 1.0f (full ClearType).
  944.     /// </summary>
  945.     STDMETHOD_(FLOAT, GetClearTypeLevel)() PURE;
  946.  
  947.     /// <summary>
  948.     /// Gets the pixel geometry.
  949.     /// </summary>
  950.     STDMETHOD_(DWRITE_PIXEL_GEOMETRY, GetPixelGeometry)() PURE;
  951.  
  952.     /// <summary>
  953.     /// Gets the rendering mode.
  954.     /// </summary>
  955.     STDMETHOD_(DWRITE_RENDERING_MODE, GetRenderingMode)() PURE;
  956. };
  957.  
  958. // Forward declarations of D2D types
  959. interface ID2D1SimplifiedGeometrySink;
  960.  
  961. typedef ID2D1SimplifiedGeometrySink IDWriteGeometrySink;
  962.  
  963. /// <summary>
  964. /// The interface that represents an absolute reference to a font face.
  965. /// It contains font face type, appropriate file references and face identification data.
  966. /// Various font data such as metrics, names and glyph outlines is obtained from IDWriteFontFace.
  967. /// </summary>
  968. interface DWRITE_DECLARE_INTERFACE("5f49804d-7024-4d43-bfa9-d25984f53849") IDWriteFontFace : public IUnknown
  969. {
  970.     /// <summary>
  971.     /// Obtains the file format type of a font face.
  972.     /// </summary>
  973.     STDMETHOD_(DWRITE_FONT_FACE_TYPE, GetType)() PURE;
  974.  
  975.     /// <summary>
  976.     /// Obtains the font files representing a font face.
  977.     /// </summary>
  978.     /// <param name="numberOfFiles">The number of files representing the font face.</param>
  979.     /// <param name="fontFiles">User provided array that stores pointers to font files representing the font face.
  980.     /// This parameter can be NULL if the user is only interested in the number of files representing the font face.
  981.     /// This API increments reference count of the font file pointers returned according to COM conventions, and the client
  982.     /// should release them when finished.</param>
  983.     /// <returns>
  984.     /// Standard HRESULT error code.
  985.     /// </returns>
  986.     STDMETHOD(GetFiles)(
  987.         __inout UINT32* numberOfFiles,
  988.         __out_ecount_opt(*numberOfFiles) IDWriteFontFile** fontFiles
  989.         ) PURE;
  990.  
  991.     /// <summary>
  992.     /// Obtains the zero-based index of the font face in its font file or files. If the font files contain a single face,
  993.     /// the return value is zero.
  994.     /// </summary>
  995.     STDMETHOD_(UINT32, GetIndex)() PURE;
  996.  
  997.     /// <summary>
  998.     /// Obtains the algorithmic style simulation flags of a font face.
  999.     /// </summary>
  1000.     STDMETHOD_(DWRITE_FONT_SIMULATIONS, GetSimulations)() PURE;
  1001.  
  1002.     /// <summary>
  1003.     /// Determines whether the font is a symbol font.
  1004.     /// </summary>
  1005.     STDMETHOD_(BOOL, IsSymbolFont)() PURE;
  1006.  
  1007.     /// <summary>
  1008.     /// Obtains design units and common metrics for the font face.
  1009.     /// These metrics are applicable to all the glyphs within a fontface and are used by applications for layout calculations.
  1010.     /// </summary>
  1011.     /// <param name="fontFaceMetrics">Points to a DWRITE_FONT_METRICS structure to fill in.
  1012.     /// The metrics returned by this function are in font design units.</param>
  1013.     STDMETHOD_(void, GetMetrics)(
  1014.         __out DWRITE_FONT_METRICS* fontFaceMetrics
  1015.         ) PURE;
  1016.  
  1017.     /// <summary>
  1018.     /// Obtains the number of glyphs in the font face.
  1019.     /// </summary>
  1020.     STDMETHOD_(UINT16, GetGlyphCount)() PURE;
  1021.  
  1022.     /// <summary>
  1023.     /// Obtains ideal glyph metrics in font design units. Design glyphs metrics are used for glyph positioning.
  1024.     /// </summary>
  1025.     /// <param name="glyphIndices">An array of glyph indices to compute the metrics for.</param>
  1026.     /// <param name="glyphCount">The number of elements in the glyphIndices array.</param>
  1027.     /// <param name="glyphMetrics">Array of DWRITE_GLYPH_METRICS structures filled by this function.
  1028.     /// The metrics returned by this function are in font design units.</param>
  1029.     /// <param name="isSideways">Indicates whether the font is being used in a sideways run.
  1030.     /// This can affect the glyph metrics if the font has oblique simulation
  1031.     /// because sideways oblique simulation differs from non-sideways oblique simulation.</param>
  1032.     /// <returns>
  1033.     /// Standard HRESULT error code. If any of the input glyph indices are outside of the valid glyph index range
  1034.     /// for the current font face, E_INVALIDARG will be returned.
  1035.     /// </returns>
  1036.     STDMETHOD(GetDesignGlyphMetrics)(
  1037.         __in_ecount(glyphCount) UINT16 const* glyphIndices,
  1038.         UINT32 glyphCount,
  1039.         __out_ecount(glyphCount) DWRITE_GLYPH_METRICS* glyphMetrics,
  1040.         BOOL isSideways = FALSE
  1041.         ) PURE;
  1042.  
  1043.     /// <summary>
  1044.     /// Returns the nominal mapping of UCS4 Unicode code points to glyph indices as defined by the font 'CMAP' table.
  1045.     /// Note that this mapping is primarily provided for line layout engines built on top of the physical font API.
  1046.     /// Because of OpenType glyph substitution and line layout character substitution, the nominal conversion does not always correspond
  1047.     /// to how a Unicode string will map to glyph indices when rendering using a particular font face.
  1048.     /// Also, note that Unicode Variant Selectors provide for alternate mappings for character to glyph.
  1049.     /// This call will always return the default variant.
  1050.     /// </summary>
  1051.     /// <param name="codePoints">An array of USC4 code points to obtain nominal glyph indices from.</param>
  1052.     /// <param name="codePointCount">The number of elements in the codePoints array.</param>
  1053.     /// <param name="glyphIndices">Array of nominal glyph indices filled by this function.</param>
  1054.     /// <returns>
  1055.     /// Standard HRESULT error code.
  1056.     /// </returns>
  1057.     STDMETHOD(GetGlyphIndices)(
  1058.         __in_ecount(codePointCount) UINT32 const* codePoints,
  1059.         UINT32 codePointCount,
  1060.         __out_ecount(codePointCount) UINT16* glyphIndices
  1061.         ) PURE;
  1062.  
  1063.     /// <summary>
  1064.     /// Finds the specified OpenType font table if it exists and returns a pointer to it.
  1065.     /// The function accesses the underling font data via the IDWriteFontStream interface
  1066.     /// implemented by the font file loader.
  1067.     /// </summary>
  1068.     /// <param name="openTypeTableTag">Four character tag of table to find.
  1069.     ///     Use the DWRITE_MAKE_OPENTYPE_TAG() macro to create it.
  1070.     ///     Unlike GDI, it does not support the special TTCF and null tags to access the whole font.</param>
  1071.     /// <param name="tableData">
  1072.     ///     Pointer to base of table in memory.
  1073.     ///     The pointer is only valid so long as the FontFace used to get the font table still exists
  1074.     ///     (not any other FontFace, even if it actually refers to the same physical font).
  1075.     /// </param>
  1076.     /// <param name="tableSize">Byte size of table.</param>
  1077.     /// <param name="tableContext">
  1078.     ///     Opaque context which must be freed by calling ReleaseFontTable.
  1079.     ///     The context actually comes from the lower level IDWriteFontFileStream,
  1080.     ///     which may be implemented by the application or DWrite itself.
  1081.     ///     It is possible for a NULL tableContext to be returned, especially if
  1082.     ///     the implementation directly memory maps the whole file.
  1083.     ///     Nevertheless, always release it later, and do not use it as a test for function success.
  1084.     ///     The same table can be queried multiple times,
  1085.     ///     but each returned context can be different, so release each separately.
  1086.     /// </param>
  1087.     /// <param name="exists">True if table exists.</param>
  1088.     /// <returns>
  1089.     /// Standard HRESULT error code.
  1090.     /// If a table can not be found, the function will not return an error, but the size will be 0, table NULL, and exists = FALSE.
  1091.     /// The context does not need to be freed if the table was not found.
  1092.     /// </returns>
  1093.     /// <remarks>
  1094.     /// The context for the same tag may be different for each call,
  1095.     /// so each one must be held and released separately.
  1096.     /// </remarks>
  1097.     STDMETHOD(TryGetFontTable)(
  1098.         __in UINT32 openTypeTableTag,
  1099.         __deref_out_bcount(*tableSize) const void** tableData,
  1100.         __out UINT32* tableSize,
  1101.         __out void** tableContext,
  1102.         __out BOOL* exists
  1103.         ) PURE;
  1104.  
  1105.     /// <summary>
  1106.     /// Releases the table obtained earlier from TryGetFontTable.
  1107.     /// </summary>
  1108.     /// <param name="tableContext">Opaque context from TryGetFontTable.</param>
  1109.     /// <returns>
  1110.     /// Standard HRESULT error code.
  1111.     /// </returns>
  1112.     STDMETHOD_(void, ReleaseFontTable)(
  1113.         __in void* tableContext
  1114.         ) PURE;
  1115.  
  1116.     /// <summary>
  1117.     /// Computes the outline of a run of glyphs by calling back to the outline sink interface.
  1118.     /// </summary>
  1119.     /// <param name="emSize">Logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch.</param>
  1120.     /// <param name="glyphIndices">Array of glyph indices.</param>
  1121.     /// <param name="glyphAdvances">Optional array of glyph advances in DIPs.</param>
  1122.     /// <param name="glyphOffsets">Optional array of glyph offsets.</param>
  1123.     /// <param name="glyphCount">Number of glyphs.</param>
  1124.     /// <param name="isSideways">If true, specifies that glyphs are rotated 90 degrees to the left and vertical metrics are used.
  1125.     /// A client can render a vertical run by specifying isSideways = true and rotating the resulting geometry 90 degrees to the
  1126.     /// right using a transform. The isSideways and isRightToLeft parameters cannot both be true.</param>
  1127.     /// <param name="isRightToLeft">If true, specifies that the advance direction is right to left. By default, the advance direction
  1128.     /// is left to right.</param>
  1129.     /// <param name="geometrySink">Interface the function calls back to draw each element of the geometry.</param>
  1130.     /// <returns>
  1131.     /// Standard HRESULT error code.
  1132.     /// </returns>
  1133.     STDMETHOD(GetGlyphRunOutline)(
  1134.         FLOAT emSize,
  1135.         __in_ecount(glyphCount) UINT16 const* glyphIndices,
  1136.         __in_ecount_opt(glyphCount) FLOAT const* glyphAdvances,
  1137.         __in_ecount_opt(glyphCount) DWRITE_GLYPH_OFFSET const* glyphOffsets,
  1138.         UINT32 glyphCount,
  1139.         BOOL isSideways,
  1140.         BOOL isRightToLeft,
  1141.         IDWriteGeometrySink* geometrySink
  1142.         ) PURE;
  1143.  
  1144.     /// <summary>
  1145.     /// Determines the recommended rendering mode for the font given the specified size and rendering parameters.
  1146.     /// </summary>
  1147.     /// <param name="emSize">Logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch.</param>
  1148.     /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if the DPI of the rendering surface is 96 this
  1149.     /// value is 1.0f. If the DPI is 120, this value is 120.0f/96.</param>
  1150.     /// <param name="measuringMode">Specifies measuring method that will be used for glyphs in the font.
  1151.     /// Renderer implementations may choose different rendering modes for given measuring methods, but
  1152.     /// best results are seen when the corresponding modes match:
  1153.     /// DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL for DWRITE_MEASURING_MODE_NATURAL
  1154.     /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC for DWRITE_MEASURING_MODE_GDI_CLASSIC
  1155.     /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL for DWRITE_MEASURING_MODE_GDI_NATURAL
  1156.     /// </param>
  1157.     /// <param name="renderingParams">Rendering parameters object. This parameter is necessary in case the rendering parameters
  1158.     /// object overrides the rendering mode.</param>
  1159.     /// <param name="renderingMode">Receives the recommended rendering mode to use.</param>
  1160.     /// <returns>
  1161.     /// Standard HRESULT error code.
  1162.     /// </returns>
  1163.     STDMETHOD(GetRecommendedRenderingMode)(
  1164.         FLOAT emSize,
  1165.         FLOAT pixelsPerDip,
  1166.         DWRITE_MEASURING_MODE measuringMode,
  1167.         IDWriteRenderingParams* renderingParams,
  1168.         __out DWRITE_RENDERING_MODE* renderingMode
  1169.         ) PURE;
  1170.  
  1171.     /// <summary>
  1172.     /// Obtains design units and common metrics for the font face.
  1173.     /// These metrics are applicable to all the glyphs within a fontface and are used by applications for layout calculations.
  1174.     /// </summary>
  1175.     /// <param name="emSize">Logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch.</param>
  1176.     /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if the DPI of the rendering surface is 96 this
  1177.     /// value is 1.0f. If the DPI is 120, this value is 120.0f/96.</param>
  1178.     /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the
  1179.     /// scaling specified by the font size and pixelsPerDip.</param>
  1180.     /// <param name="fontFaceMetrics">Points to a DWRITE_FONT_METRICS structure to fill in.
  1181.     /// The metrics returned by this function are in font design units.</param>
  1182.     STDMETHOD(GetGdiCompatibleMetrics)(
  1183.         FLOAT emSize,
  1184.         FLOAT pixelsPerDip,
  1185.         __in_opt DWRITE_MATRIX const* transform,
  1186.         __out DWRITE_FONT_METRICS* fontFaceMetrics
  1187.         ) PURE;
  1188.  
  1189.  
  1190.     /// <summary>
  1191.     /// Obtains glyph metrics in font design units with the return values compatible with what GDI would produce.
  1192.     /// Glyphs metrics are used for positioning of individual glyphs.
  1193.     /// </summary>
  1194.     /// <param name="emSize">Logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch.</param>
  1195.     /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if the DPI of the rendering surface is 96 this
  1196.     /// value is 1.0f. If the DPI is 120, this value is 120.0f/96.</param>
  1197.     /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the
  1198.     /// scaling specified by the font size and pixelsPerDip.</param>
  1199.     /// <param name="useGdiNatural">
  1200.     /// When set to FALSE, the metrics are the same as the metrics of GDI aliased text.
  1201.     /// When set to TRUE, the metrics are the same as the metrics of text measured by GDI using a font
  1202.     /// created with CLEARTYPE_NATURAL_QUALITY.
  1203.     /// </param>
  1204.     /// <param name="glyphIndices">An array of glyph indices to compute the metrics for.</param>
  1205.     /// <param name="glyphCount">The number of elements in the glyphIndices array.</param>
  1206.     /// <param name="glyphMetrics">Array of DWRITE_GLYPH_METRICS structures filled by this function.
  1207.     /// The metrics returned by this function are in font design units.</param>
  1208.     /// <param name="isSideways">Indicates whether the font is being used in a sideways run.
  1209.     /// This can affect the glyph metrics if the font has oblique simulation
  1210.     /// because sideways oblique simulation differs from non-sideways oblique simulation.</param>
  1211.     /// <returns>
  1212.     /// Standard HRESULT error code. If any of the input glyph indices are outside of the valid glyph index range
  1213.     /// for the current font face, E_INVALIDARG will be returned.
  1214.     /// </returns>
  1215.     STDMETHOD(GetGdiCompatibleGlyphMetrics)(
  1216.         FLOAT emSize,
  1217.         FLOAT pixelsPerDip,
  1218.         __in_opt DWRITE_MATRIX const* transform,
  1219.         BOOL useGdiNatural,
  1220.         __in_ecount(glyphCount) UINT16 const* glyphIndices,
  1221.         UINT32 glyphCount,
  1222.         __out_ecount(glyphCount) DWRITE_GLYPH_METRICS* glyphMetrics,
  1223.         BOOL isSideways = FALSE
  1224.         ) PURE;
  1225. };
  1226.  
  1227. interface IDWriteFactory;
  1228. interface IDWriteFontFileEnumerator;
  1229.  
  1230. /// <summary>
  1231. /// The font collection loader interface is used to construct a collection of fonts given a particular type of key.
  1232. /// The font collection loader interface is recommended to be implemented by a singleton object.
  1233. /// IMPORTANT: font collection loader implementations must not register themselves with a DirectWrite factory
  1234. /// inside their constructors and must not unregister themselves in their destructors, because
  1235. /// registration and unregistraton operations increment and decrement the object reference count respectively.
  1236. /// Instead, registration and unregistration of font file loaders with DirectWrite factory should be performed
  1237. /// outside of the font file loader implementation as a separate step.
  1238. /// </summary>
  1239. interface DWRITE_DECLARE_INTERFACE("cca920e4-52f0-492b-bfa8-29c72ee0a468") IDWriteFontCollectionLoader : public IUnknown
  1240. {
  1241.     /// <summary>
  1242.     /// Creates a font file enumerator object that encapsulates a collection of font files.
  1243.     /// The font system calls back to this interface to create a font collection.
  1244.     /// </summary>
  1245.     /// <param name="factory">Factory associated with the loader.</param>
  1246.     /// <param name="collectionKey">Font collection key that uniquely identifies the collection of font files within
  1247.     /// the scope of the font collection loader being used.</param>
  1248.     /// <param name="collectionKeySize">Size of the font collection key in bytes.</param>
  1249.     /// <param name="fontFileEnumerator">Pointer to the newly created font file enumerator.</param>
  1250.     /// <returns>
  1251.     /// Standard HRESULT error code.
  1252.     /// </returns>
  1253.     STDMETHOD(CreateEnumeratorFromKey)(
  1254.         IDWriteFactory* factory,
  1255.         __in_bcount(collectionKeySize) void const* collectionKey,
  1256.         UINT32 collectionKeySize,
  1257.         __out IDWriteFontFileEnumerator** fontFileEnumerator
  1258.         ) PURE;
  1259. };
  1260.  
  1261. /// <summary>
  1262. /// The font file enumerator interface encapsulates a collection of font files. The font system uses this interface
  1263. /// to enumerate font files when building a font collection.
  1264. /// </summary>
  1265. interface DWRITE_DECLARE_INTERFACE("72755049-5ff7-435d-8348-4be97cfa6c7c") IDWriteFontFileEnumerator : public IUnknown
  1266. {
  1267.     /// <summary>
  1268.     /// Advances to the next font file in the collection. When it is first created, the enumerator is positioned
  1269.     /// before the first element of the collection and the first call to MoveNext advances to the first file.
  1270.     /// </summary>
  1271.     /// <param name="hasCurrentFile">Receives the value TRUE if the enumerator advances to a file, or FALSE if
  1272.     /// the enumerator advanced past the last file in the collection.</param>
  1273.     /// <returns>
  1274.     /// Standard HRESULT error code.
  1275.     /// </returns>
  1276.     STDMETHOD(MoveNext)(
  1277.         __out BOOL* hasCurrentFile
  1278.         ) PURE;
  1279.  
  1280.     /// <summary>
  1281.     /// Gets a reference to the current font file.
  1282.     /// </summary>
  1283.     /// <param name="fontFile">Pointer to the newly created font file object.</param>
  1284.     /// <returns>
  1285.     /// Standard HRESULT error code.
  1286.     /// </returns>
  1287.     STDMETHOD(GetCurrentFontFile)(
  1288.         __out IDWriteFontFile** fontFile
  1289.         ) PURE;
  1290. };
  1291.  
  1292. /// <summary>
  1293. /// Represents a collection of strings indexed by locale name.
  1294. /// </summary>
  1295. interface DWRITE_DECLARE_INTERFACE("08256209-099a-4b34-b86d-c22b110e7771") IDWriteLocalizedStrings : public IUnknown
  1296. {
  1297.     /// <summary>
  1298.     /// Gets the number of language/string pairs.
  1299.     /// </summary>
  1300.     STDMETHOD_(UINT32, GetCount)() PURE;
  1301.  
  1302.     /// <summary>
  1303.     /// Gets the index of the item with the specified locale name.
  1304.     /// </summary>
  1305.     /// <param name="localeName">Locale name to look for.</param>
  1306.     /// <param name="index">Receives the zero-based index of the locale name/string pair.</param>
  1307.     /// <param name="exists">Receives TRUE if the locale name exists or FALSE if not.</param>
  1308.     /// <returns>
  1309.     /// Standard HRESULT error code. If the specified locale name does not exist, the return value is S_OK,
  1310.     /// but *index is UINT_MAX and *exists is FALSE.
  1311.     /// </returns>
  1312.     STDMETHOD(FindLocaleName)(
  1313.         __in_z WCHAR const* localeName,
  1314.         __out UINT32* index,
  1315.         __out BOOL* exists
  1316.         ) PURE;
  1317.  
  1318.     /// <summary>
  1319.     /// Gets the length in characters (not including the null terminator) of the locale name with the specified index.
  1320.     /// </summary>
  1321.     /// <param name="index">Zero-based index of the locale name.</param>
  1322.     /// <param name="length">Receives the length in characters, not including the null terminator.</param>
  1323.     /// <returns>
  1324.     /// Standard HRESULT error code.
  1325.     /// </returns>
  1326.     STDMETHOD(GetLocaleNameLength)(
  1327.         UINT32 index,
  1328.         __out UINT32* length
  1329.         ) PURE;
  1330.  
  1331.     /// <summary>
  1332.     /// Copies the locale name with the specified index to the specified array.
  1333.     /// </summary>
  1334.     /// <param name="index">Zero-based index of the locale name.</param>
  1335.     /// <param name="localeName">Character array that receives the locale name.</param>
  1336.     /// <param name="size">Size of the array in characters. The size must include space for the terminating
  1337.     /// null character.</param>
  1338.     /// <returns>
  1339.     /// Standard HRESULT error code.
  1340.     /// </returns>
  1341.     STDMETHOD(GetLocaleName)(
  1342.         UINT32 index,
  1343.         __out_ecount_z(size) WCHAR* localeName,
  1344.         UINT32 size
  1345.         ) PURE;
  1346.  
  1347.     /// <summary>
  1348.     /// Gets the length in characters (not including the null terminator) of the string with the specified index.
  1349.     /// </summary>
  1350.     /// <param name="index">Zero-based index of the string.</param>
  1351.     /// <param name="length">Receives the length in characters, not including the null terminator.</param>
  1352.     /// <returns>
  1353.     /// Standard HRESULT error code.
  1354.     /// </returns>
  1355.     STDMETHOD(GetStringLength)(
  1356.         UINT32 index,
  1357.         __out UINT32* length
  1358.         ) PURE;
  1359.  
  1360.     /// <summary>
  1361.     /// Copies the string with the specified index to the specified array.
  1362.     /// </summary>
  1363.     /// <param name="index">Zero-based index of the string.</param>
  1364.     /// <param name="stringBuffer">Character array that receives the string.</param>
  1365.     /// <param name="size">Size of the array in characters. The size must include space for the terminating
  1366.     /// null character.</param>
  1367.     /// <returns>
  1368.     /// Standard HRESULT error code.
  1369.     /// </returns>
  1370.     STDMETHOD(GetString)(
  1371.         UINT32 index,
  1372.         __out_ecount_z(size) WCHAR* stringBuffer,
  1373.         UINT32 size
  1374.         ) PURE;
  1375. };
  1376.  
  1377. interface IDWriteFontFamily;
  1378. interface IDWriteFont;
  1379.  
  1380. /// <summary>
  1381. /// The IDWriteFontCollection encapsulates a collection of fonts.
  1382. /// </summary>
  1383. interface DWRITE_DECLARE_INTERFACE("a84cee02-3eea-4eee-a827-87c1a02a0fcc") IDWriteFontCollection : public IUnknown
  1384. {
  1385.     /// <summary>
  1386.     /// Gets the number of font families in the collection.
  1387.     /// </summary>
  1388.     STDMETHOD_(UINT32, GetFontFamilyCount)() PURE;
  1389.  
  1390.     /// <summary>
  1391.     /// Creates a font family object given a zero-based font family index.
  1392.     /// </summary>
  1393.     /// <param name="index">Zero-based index of the font family.</param>
  1394.     /// <param name="fontFamily">Receives a pointer the newly created font family object.</param>
  1395.     /// <returns>
  1396.     /// Standard HRESULT error code.
  1397.     /// </returns>
  1398.     STDMETHOD(GetFontFamily)(
  1399.         UINT32 index,
  1400.         __out IDWriteFontFamily** fontFamily
  1401.         ) PURE;
  1402.  
  1403.     /// <summary>
  1404.     /// Finds the font family with the specified family name.
  1405.     /// </summary>
  1406.     /// <param name="familyName">Name of the font family. The name is not case-sensitive but must otherwise exactly match a family name in the collection.</param>
  1407.     /// <param name="index">Receives the zero-based index of the matching font family if the family name was found or UINT_MAX otherwise.</param>
  1408.     /// <param name="exists">Receives TRUE if the family name exists or FALSE otherwise.</param>
  1409.     /// <returns>
  1410.     /// Standard HRESULT error code. If the specified family name does not exist, the return value is S_OK, but *index is UINT_MAX and *exists is FALSE.
  1411.     /// </returns>
  1412.     STDMETHOD(FindFamilyName)(
  1413.         __in_z WCHAR const* familyName,
  1414.         __out UINT32* index,
  1415.         __out BOOL* exists
  1416.         ) PURE;
  1417.  
  1418.     /// <summary>
  1419.     /// Gets the font object that corresponds to the same physical font as the specified font face object. The specified physical font must belong
  1420.     /// to the font collection.
  1421.     /// </summary>
  1422.     /// <param name="fontFace">Font face object that specifies the physical font.</param>
  1423.     /// <param name="font">Receives a pointer to the newly created font object if successful or NULL otherwise.</param>
  1424.     /// <returns>
  1425.     /// Standard HRESULT error code. If the specified physical font is not part of the font collection the return value is DWRITE_E_NOFONT.
  1426.     /// </returns>
  1427.     STDMETHOD(GetFontFromFontFace)(
  1428.         IDWriteFontFace* fontFace,
  1429.         __out IDWriteFont** font
  1430.         ) PURE;
  1431. };
  1432.  
  1433. /// <summary>
  1434. /// The IDWriteFontList interface represents a list of fonts.
  1435. /// </summary>
  1436. interface DWRITE_DECLARE_INTERFACE("1a0d8438-1d97-4ec1-aef9-a2fb86ed6acb") IDWriteFontList : public IUnknown
  1437. {
  1438.     /// <summary>
  1439.     /// Gets the font collection that contains the fonts.
  1440.     /// </summary>
  1441.     /// <param name="fontCollection">Receives a pointer to the font collection object.</param>
  1442.     /// <returns>
  1443.     /// Standard HRESULT error code.
  1444.     /// </returns>
  1445.     STDMETHOD(GetFontCollection)(
  1446.         __out IDWriteFontCollection** fontCollection
  1447.         ) PURE;
  1448.  
  1449.     /// <summary>
  1450.     /// Gets the number of fonts in the font list.
  1451.     /// </summary>
  1452.     STDMETHOD_(UINT32, GetFontCount)() PURE;
  1453.  
  1454.     /// <summary>
  1455.     /// Gets a font given its zero-based index.
  1456.     /// </summary>
  1457.     /// <param name="index">Zero-based index of the font in the font list.</param>
  1458.     /// <param name="font">Receives a pointer to the newly created font object.</param>
  1459.     /// <returns>
  1460.     /// Standard HRESULT error code.
  1461.     /// </returns>
  1462.     STDMETHOD(GetFont)(
  1463.         UINT32 index,
  1464.         __out IDWriteFont** font
  1465.         ) PURE;
  1466. };
  1467.  
  1468. /// <summary>
  1469. /// The IDWriteFontFamily interface represents a set of fonts that share the same design but are differentiated
  1470. /// by weight, stretch, and style.
  1471. /// </summary>
  1472. interface DWRITE_DECLARE_INTERFACE("da20d8ef-812a-4c43-9802-62ec4abd7add") IDWriteFontFamily : public IDWriteFontList
  1473. {
  1474.     /// <summary>
  1475.     /// Creates an localized strings object that contains the family names for the font family, indexed by locale name.
  1476.     /// </summary>
  1477.     /// <param name="names">Receives a pointer to the newly created localized strings object.</param>
  1478.     /// <returns>
  1479.     /// Standard HRESULT error code.
  1480.     /// </returns>
  1481.     STDMETHOD(GetFamilyNames)(
  1482.         __out IDWriteLocalizedStrings** names
  1483.         ) PURE;
  1484.  
  1485.     /// <summary>
  1486.     /// Gets the font that best matches the specified properties.
  1487.     /// </summary>
  1488.     /// <param name="weight">Requested font weight.</param>
  1489.     /// <param name="stretch">Requested font stretch.</param>
  1490.     /// <param name="style">Requested font style.</param>
  1491.     /// <param name="matchingFont">Receives a pointer to the newly created font object.</param>
  1492.     /// <returns>
  1493.     /// Standard HRESULT error code.
  1494.     /// </returns>
  1495.     STDMETHOD(GetFirstMatchingFont)(
  1496.         DWRITE_FONT_WEIGHT  weight,
  1497.         DWRITE_FONT_STRETCH stretch,
  1498.         DWRITE_FONT_STYLE   style,
  1499.         __out IDWriteFont** matchingFont
  1500.         ) PURE;
  1501.  
  1502.     /// <summary>
  1503.     /// Gets a list of fonts in the font family ranked in order of how well they match the specified properties.
  1504.     /// </summary>
  1505.     /// <param name="weight">Requested font weight.</param>
  1506.     /// <param name="stretch">Requested font stretch.</param>
  1507.     /// <param name="style">Requested font style.</param>
  1508.     /// <param name="matchingFonts">Receives a pointer to the newly created font list object.</param>
  1509.     /// <returns>
  1510.     /// Standard HRESULT error code.
  1511.     /// </returns>
  1512.     STDMETHOD(GetMatchingFonts)(
  1513.         DWRITE_FONT_WEIGHT      weight,
  1514.         DWRITE_FONT_STRETCH     stretch,
  1515.         DWRITE_FONT_STYLE       style,
  1516.         __out IDWriteFontList** matchingFonts
  1517.         ) PURE;
  1518. };
  1519.  
  1520. /// <summary>
  1521. /// The IDWriteFont interface represents a physical font in a font collection.
  1522. /// </summary>
  1523. interface DWRITE_DECLARE_INTERFACE("acd16696-8c14-4f5d-877e-fe3fc1d32737") IDWriteFont : public IUnknown
  1524. {
  1525.     /// <summary>
  1526.     /// Gets the font family to which the specified font belongs.
  1527.     /// </summary>
  1528.     /// <param name="fontFamily">Receives a pointer to the font family object.</param>
  1529.     /// <returns>
  1530.     /// Standard HRESULT error code.
  1531.     /// </returns>
  1532.     STDMETHOD(GetFontFamily)(
  1533.         __out IDWriteFontFamily** fontFamily
  1534.         ) PURE;
  1535.  
  1536.     /// <summary>
  1537.     /// Gets the weight of the specified font.
  1538.     /// </summary>
  1539.     STDMETHOD_(DWRITE_FONT_WEIGHT, GetWeight)() PURE;
  1540.  
  1541.     /// <summary>
  1542.     /// Gets the stretch (aka. width) of the specified font.
  1543.     /// </summary>
  1544.     STDMETHOD_(DWRITE_FONT_STRETCH, GetStretch)() PURE;
  1545.  
  1546.     /// <summary>
  1547.     /// Gets the style (aka. slope) of the specified font.
  1548.     /// </summary>
  1549.     STDMETHOD_(DWRITE_FONT_STYLE, GetStyle)() PURE;
  1550.  
  1551.     /// <summary>
  1552.     /// Returns TRUE if the font is a symbol font or FALSE if not.
  1553.     /// </summary>
  1554.     STDMETHOD_(BOOL, IsSymbolFont)() PURE;
  1555.  
  1556.     /// <summary>
  1557.     /// Gets a localized strings collection containing the face names for the font (e.g., Regular or Bold), indexed by locale name.
  1558.     /// </summary>
  1559.     /// <param name="names">Receives a pointer to the newly created localized strings object.</param>
  1560.     /// <returns>
  1561.     /// Standard HRESULT error code.
  1562.     /// </returns>
  1563.     STDMETHOD(GetFaceNames)(
  1564.         __out IDWriteLocalizedStrings** names
  1565.         ) PURE;
  1566.  
  1567.     /// <summary>
  1568.     /// Gets a localized strings collection containing the specified informational strings, indexed by locale name.
  1569.     /// </summary>
  1570.     /// <param name="informationalStringID">Identifies the string to get.</param>
  1571.     /// <param name="informationalStrings">Receives a pointer to the newly created localized strings object.</param>
  1572.     /// <param name="exists">Receives the value TRUE if the font contains the specified string ID or FALSE if not.</param>
  1573.     /// <returns>
  1574.     /// Standard HRESULT error code. If the font does not contain the specified string, the return value is S_OK but
  1575.     /// informationalStrings receives a NULL pointer and exists receives the value FALSE.
  1576.     /// </returns>
  1577.     STDMETHOD(GetInformationalStrings)(
  1578.         DWRITE_INFORMATIONAL_STRING_ID informationalStringID,
  1579.         __out IDWriteLocalizedStrings** informationalStrings,
  1580.         __out BOOL* exists
  1581.         ) PURE;
  1582.  
  1583.     /// <summary>
  1584.     /// Gets a value that indicates what simulation are applied to the specified font.
  1585.     /// </summary>
  1586.     STDMETHOD_(DWRITE_FONT_SIMULATIONS, GetSimulations)() PURE;
  1587.  
  1588.     /// <summary>
  1589.     /// Gets the metrics for the font.
  1590.     /// </summary>
  1591.     /// <param name="fontMetrics">Receives the font metrics.</param>
  1592.     STDMETHOD_(void, GetMetrics)(
  1593.         __out DWRITE_FONT_METRICS* fontMetrics
  1594.         ) PURE;
  1595.  
  1596.     /// <summary>
  1597.     /// Determines whether the font supports the specified character.
  1598.     /// </summary>
  1599.     /// <param name="unicodeValue">Unicode (UCS-4) character value.</param>
  1600.     /// <param name="exists">Receives the value TRUE if the font supports the specified character or FALSE if not.</param>
  1601.     /// <returns>
  1602.     /// Standard HRESULT error code.
  1603.     /// </returns>
  1604.     STDMETHOD(HasCharacter)(
  1605.         UINT32 unicodeValue,
  1606.         __out BOOL* exists
  1607.         ) PURE;
  1608.  
  1609.     /// <summary>
  1610.     /// Creates a font face object for the font.
  1611.     /// </summary>
  1612.     /// <param name="fontFace">Receives a pointer to the newly created font face object.</param>
  1613.     /// <returns>
  1614.     /// Standard HRESULT error code.
  1615.     /// </returns>
  1616.     STDMETHOD(CreateFontFace)(
  1617.         __out IDWriteFontFace** fontFace
  1618.         ) PURE;
  1619. };
  1620.  
  1621. /// <summary>
  1622. /// Direction for how reading progresses.
  1623. /// </summary>
  1624. enum DWRITE_READING_DIRECTION
  1625. {
  1626.     /// <summary>
  1627.     /// Reading progresses from left to right.
  1628.     /// </summary>
  1629.     DWRITE_READING_DIRECTION_LEFT_TO_RIGHT,
  1630.  
  1631.     /// <summary>
  1632.     /// Reading progresses from right to left.
  1633.     /// </summary>
  1634.     DWRITE_READING_DIRECTION_RIGHT_TO_LEFT
  1635. };
  1636.  
  1637. /// <summary>
  1638. /// Direction for how lines of text are placed relative to one another.
  1639. /// </summary>
  1640. enum DWRITE_FLOW_DIRECTION
  1641. {
  1642.     /// <summary>
  1643.     /// Text lines are placed from top to bottom.
  1644.     /// </summary>
  1645.     DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM
  1646. };
  1647.  
  1648. /// <summary>
  1649. /// Alignment of paragraph text along the reading direction axis relative to
  1650. /// the leading and trailing edge of the layout box.
  1651. /// </summary>
  1652. enum DWRITE_TEXT_ALIGNMENT
  1653. {
  1654.     /// <summary>
  1655.     /// The leading edge of the paragraph text is aligned to the layout box's leading edge.
  1656.     /// </summary>
  1657.     DWRITE_TEXT_ALIGNMENT_LEADING,
  1658.  
  1659.     /// <summary>
  1660.     /// The trailing edge of the paragraph text is aligned to the layout box's trailing edge.
  1661.     /// </summary>
  1662.     DWRITE_TEXT_ALIGNMENT_TRAILING,
  1663.  
  1664.     /// <summary>
  1665.     /// The center of the paragraph text is aligned to the center of the layout box.
  1666.     /// </summary>
  1667.     DWRITE_TEXT_ALIGNMENT_CENTER
  1668. };
  1669.  
  1670. /// <summary>
  1671. /// Alignment of paragraph text along the flow direction axis relative to the
  1672. /// flow's beginning and ending edge of the layout box.
  1673. /// </summary>
  1674. enum DWRITE_PARAGRAPH_ALIGNMENT
  1675. {
  1676.     /// <summary>
  1677.     /// The first line of paragraph is aligned to the flow's beginning edge of the layout box.
  1678.     /// </summary>
  1679.     DWRITE_PARAGRAPH_ALIGNMENT_NEAR,
  1680.  
  1681.     /// <summary>
  1682.     /// The last line of paragraph is aligned to the flow's ending edge of the layout box.
  1683.     /// </summary>
  1684.     DWRITE_PARAGRAPH_ALIGNMENT_FAR,
  1685.  
  1686.     /// <summary>
  1687.     /// The center of the paragraph is aligned to the center of the flow of the layout box.
  1688.     /// </summary>
  1689.     DWRITE_PARAGRAPH_ALIGNMENT_CENTER
  1690. };
  1691.  
  1692. /// <summary>
  1693. /// Word wrapping in multiline paragraph.
  1694. /// </summary>
  1695. enum DWRITE_WORD_WRAPPING
  1696. {
  1697.     /// <summary>
  1698.     /// Words are broken across lines to avoid text overflowing the layout box.
  1699.     /// </summary>
  1700.     DWRITE_WORD_WRAPPING_WRAP,
  1701.  
  1702.     /// <summary>
  1703.     /// Words are kept within the same line even when it overflows the layout box.
  1704.     /// This option is often used with scrolling to reveal overflow text.
  1705.     /// </summary>
  1706.     DWRITE_WORD_WRAPPING_NO_WRAP
  1707. };
  1708.  
  1709. /// <summary>
  1710. /// The method used for line spacing in layout.
  1711. /// </summary>
  1712. enum DWRITE_LINE_SPACING_METHOD
  1713. {
  1714.     /// <summary>
  1715.     /// Line spacing depends solely on the content, growing to accomodate the size of fonts and inline objects.
  1716.     /// </summary>
  1717.     DWRITE_LINE_SPACING_METHOD_DEFAULT,
  1718.  
  1719.     /// <summary>
  1720.     /// Lines are explicitly set to uniform spacing, regardless of contained font sizes.
  1721.     /// This can be useful to avoid the uneven appearance that can occur from font fallback.
  1722.     /// </summary>
  1723.     DWRITE_LINE_SPACING_METHOD_UNIFORM
  1724. };
  1725.  
  1726. /// <summary>
  1727. /// Text granularity used to trim text overflowing the layout box.
  1728. /// </summary>
  1729. enum DWRITE_TRIMMING_GRANULARITY
  1730. {
  1731.     /// <summary>
  1732.     /// No trimming occurs. Text flows beyond the layout width.
  1733.     /// </summary>
  1734.     DWRITE_TRIMMING_GRANULARITY_NONE,
  1735.  
  1736.     /// <summary>
  1737.     /// Trimming occurs at character cluster boundary.
  1738.     /// </summary>
  1739.     DWRITE_TRIMMING_GRANULARITY_CHARACTER,
  1740.    
  1741.     /// <summary>
  1742.     /// Trimming occurs at word boundary.
  1743.     /// </summary>
  1744.     DWRITE_TRIMMING_GRANULARITY_WORD   
  1745. };
  1746.  
  1747. /// <summary>
  1748. /// Typographic feature of text supplied by the font.
  1749. /// </summary>
  1750. enum DWRITE_FONT_FEATURE_TAG
  1751. {
  1752.     DWRITE_FONT_FEATURE_TAG_ALTERNATIVE_FRACTIONS               = 0x63726661, // 'afrc'
  1753.     DWRITE_FONT_FEATURE_TAG_PETITE_CAPITALS_FROM_CAPITALS       = 0x63703263, // 'c2pc'
  1754.     DWRITE_FONT_FEATURE_TAG_SMALL_CAPITALS_FROM_CAPITALS        = 0x63733263, // 'c2sc'
  1755.     DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_ALTERNATES               = 0x746c6163, // 'calt'
  1756.     DWRITE_FONT_FEATURE_TAG_CASE_SENSITIVE_FORMS                = 0x65736163, // 'case'
  1757.     DWRITE_FONT_FEATURE_TAG_GLYPH_COMPOSITION_DECOMPOSITION     = 0x706d6363, // 'ccmp'
  1758.     DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_LIGATURES                = 0x67696c63, // 'clig'
  1759.     DWRITE_FONT_FEATURE_TAG_CAPITAL_SPACING                     = 0x70737063, // 'cpsp'
  1760.     DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_SWASH                    = 0x68777363, // 'cswh'
  1761.     DWRITE_FONT_FEATURE_TAG_CURSIVE_POSITIONING                 = 0x73727563, // 'curs'
  1762.     DWRITE_FONT_FEATURE_TAG_DEFAULT                             = 0x746c6664, // 'dflt'
  1763.     DWRITE_FONT_FEATURE_TAG_DISCRETIONARY_LIGATURES             = 0x67696c64, // 'dlig'
  1764.     DWRITE_FONT_FEATURE_TAG_EXPERT_FORMS                        = 0x74707865, // 'expt'
  1765.     DWRITE_FONT_FEATURE_TAG_FRACTIONS                           = 0x63617266, // 'frac'
  1766.     DWRITE_FONT_FEATURE_TAG_FULL_WIDTH                          = 0x64697766, // 'fwid'
  1767.     DWRITE_FONT_FEATURE_TAG_HALF_FORMS                          = 0x666c6168, // 'half'
  1768.     DWRITE_FONT_FEATURE_TAG_HALANT_FORMS                        = 0x6e6c6168, // 'haln'
  1769.     DWRITE_FONT_FEATURE_TAG_ALTERNATE_HALF_WIDTH                = 0x746c6168, // 'halt'
  1770.     DWRITE_FONT_FEATURE_TAG_HISTORICAL_FORMS                    = 0x74736968, // 'hist'
  1771.     DWRITE_FONT_FEATURE_TAG_HORIZONTAL_KANA_ALTERNATES          = 0x616e6b68, // 'hkna'
  1772.     DWRITE_FONT_FEATURE_TAG_HISTORICAL_LIGATURES                = 0x67696c68, // 'hlig'
  1773.     DWRITE_FONT_FEATURE_TAG_HALF_WIDTH                          = 0x64697768, // 'hwid'
  1774.     DWRITE_FONT_FEATURE_TAG_HOJO_KANJI_FORMS                    = 0x6f6a6f68, // 'hojo'
  1775.     DWRITE_FONT_FEATURE_TAG_JIS04_FORMS                         = 0x3430706a, // 'jp04'
  1776.     DWRITE_FONT_FEATURE_TAG_JIS78_FORMS                         = 0x3837706a, // 'jp78'
  1777.     DWRITE_FONT_FEATURE_TAG_JIS83_FORMS                         = 0x3338706a, // 'jp83'
  1778.     DWRITE_FONT_FEATURE_TAG_JIS90_FORMS                         = 0x3039706a, // 'jp90'
  1779.     DWRITE_FONT_FEATURE_TAG_KERNING                             = 0x6e72656b, // 'kern'
  1780.     DWRITE_FONT_FEATURE_TAG_STANDARD_LIGATURES                  = 0x6167696c, // 'liga'
  1781.     DWRITE_FONT_FEATURE_TAG_LINING_FIGURES                      = 0x6d756e6c, // 'lnum'
  1782.     DWRITE_FONT_FEATURE_TAG_LOCALIZED_FORMS                     = 0x6c636f6c, // 'locl'
  1783.     DWRITE_FONT_FEATURE_TAG_MARK_POSITIONING                    = 0x6b72616d, // 'mark'
  1784.     DWRITE_FONT_FEATURE_TAG_MATHEMATICAL_GREEK                  = 0x6b72676d, // 'mgrk'
  1785.     DWRITE_FONT_FEATURE_TAG_MARK_TO_MARK_POSITIONING            = 0x6b6d6b6d, // 'mkmk'
  1786.     DWRITE_FONT_FEATURE_TAG_ALTERNATE_ANNOTATION_FORMS          = 0x746c616e, // 'nalt'
  1787.     DWRITE_FONT_FEATURE_TAG_NLC_KANJI_FORMS                     = 0x6b636c6e, // 'nlck'
  1788.     DWRITE_FONT_FEATURE_TAG_OLD_STYLE_FIGURES                   = 0x6d756e6f, // 'onum'
  1789.     DWRITE_FONT_FEATURE_TAG_ORDINALS                            = 0x6e64726f, // 'ordn'
  1790.     DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_ALTERNATE_WIDTH        = 0x746c6170, // 'palt'
  1791.     DWRITE_FONT_FEATURE_TAG_PETITE_CAPITALS                     = 0x70616370, // 'pcap'
  1792.     DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_FIGURES                = 0x6d756e70, // 'pnum'
  1793.     DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_WIDTHS                 = 0x64697770, // 'pwid'
  1794.     DWRITE_FONT_FEATURE_TAG_QUARTER_WIDTHS                      = 0x64697771, // 'qwid'
  1795.     DWRITE_FONT_FEATURE_TAG_REQUIRED_LIGATURES                  = 0x67696c72, // 'rlig'
  1796.     DWRITE_FONT_FEATURE_TAG_RUBY_NOTATION_FORMS                 = 0x79627572, // 'ruby'
  1797.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_ALTERNATES                = 0x746c6173, // 'salt'
  1798.     DWRITE_FONT_FEATURE_TAG_SCIENTIFIC_INFERIORS                = 0x666e6973, // 'sinf'
  1799.     DWRITE_FONT_FEATURE_TAG_SMALL_CAPITALS                      = 0x70636d73, // 'smcp'
  1800.     DWRITE_FONT_FEATURE_TAG_SIMPLIFIED_FORMS                    = 0x6c706d73, // 'smpl'
  1801.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_1                     = 0x31307373, // 'ss01'
  1802.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_2                     = 0x32307373, // 'ss02'
  1803.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_3                     = 0x33307373, // 'ss03'
  1804.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_4                     = 0x34307373, // 'ss04'
  1805.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_5                     = 0x35307373, // 'ss05'
  1806.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_6                     = 0x36307373, // 'ss06'
  1807.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_7                     = 0x37307373, // 'ss07'
  1808.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_8                     = 0x38307373, // 'ss08'
  1809.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_9                     = 0x39307373, // 'ss09'
  1810.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_10                    = 0x30317373, // 'ss10'
  1811.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_11                    = 0x31317373, // 'ss11'
  1812.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_12                    = 0x32317373, // 'ss12'
  1813.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_13                    = 0x33317373, // 'ss13'
  1814.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_14                    = 0x34317373, // 'ss14'
  1815.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_15                    = 0x35317373, // 'ss15'
  1816.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_16                    = 0x36317373, // 'ss16'
  1817.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_17                    = 0x37317373, // 'ss17'
  1818.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_18                    = 0x38317373, // 'ss18'
  1819.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_19                    = 0x39317373, // 'ss19'
  1820.     DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_20                    = 0x30327373, // 'ss20'
  1821.     DWRITE_FONT_FEATURE_TAG_SUBSCRIPT                           = 0x73627573, // 'subs'
  1822.     DWRITE_FONT_FEATURE_TAG_SUPERSCRIPT                         = 0x73707573, // 'sups'
  1823.     DWRITE_FONT_FEATURE_TAG_SWASH                               = 0x68737773, // 'swsh'
  1824.     DWRITE_FONT_FEATURE_TAG_TITLING                             = 0x6c746974, // 'titl'
  1825.     DWRITE_FONT_FEATURE_TAG_TRADITIONAL_NAME_FORMS              = 0x6d616e74, // 'tnam'
  1826.     DWRITE_FONT_FEATURE_TAG_TABULAR_FIGURES                     = 0x6d756e74, // 'tnum'
  1827.     DWRITE_FONT_FEATURE_TAG_TRADITIONAL_FORMS                   = 0x64617274, // 'trad'
  1828.     DWRITE_FONT_FEATURE_TAG_THIRD_WIDTHS                        = 0x64697774, // 'twid'
  1829.     DWRITE_FONT_FEATURE_TAG_UNICASE                             = 0x63696e75, // 'unic'
  1830.     DWRITE_FONT_FEATURE_TAG_SLASHED_ZERO                        = 0x6f72657a, // 'zero'
  1831. };
  1832.  
  1833. /// <summary>
  1834. /// The DWRITE_TEXT_RANGE structure specifies a range of text positions where format is applied.
  1835. /// </summary>
  1836. struct DWRITE_TEXT_RANGE
  1837. {
  1838.     /// <summary>
  1839.     /// The start text position of the range.
  1840.     /// </summary>
  1841.     UINT32 startPosition;
  1842.  
  1843.     /// <summary>
  1844.     /// The number of text positions in the range.
  1845.     /// </summary>
  1846.     UINT32 length;
  1847. };
  1848.  
  1849. /// <summary>
  1850. /// The DWRITE_FONT_FEATURE structure specifies properties used to identify and execute typographic feature in the font.
  1851. /// </summary>
  1852. struct DWRITE_FONT_FEATURE
  1853. {
  1854.     /// <summary>
  1855.     /// The feature OpenType name identifier.
  1856.     /// </summary>
  1857.     DWRITE_FONT_FEATURE_TAG nameTag;
  1858.  
  1859.     /// <summary>
  1860.     /// Execution parameter of the feature.
  1861.     /// </summary>
  1862.     /// <remarks>
  1863.     /// The parameter should be non-zero to enable the feature.  Once enabled, a feature can't be disabled again within
  1864.     /// the same range.  Features requiring a selector use this value to indicate the selector index.
  1865.     /// </remarks>
  1866.     UINT32 parameter;
  1867. };
  1868.  
  1869. /// <summary>
  1870. /// Defines a set of typographic features to be applied during shaping.
  1871. /// Notice the character range which this feature list spans is specified
  1872. /// as a separate parameter to GetGlyphs.
  1873. /// </summary>
  1874. struct DWRITE_TYPOGRAPHIC_FEATURES
  1875. {
  1876.     /// <summary>
  1877.     /// Array of font features.
  1878.     /// </summary>
  1879.     __field_ecount(featureCount) DWRITE_FONT_FEATURE* features;
  1880.  
  1881.     /// <summary>
  1882.     /// The number of features.
  1883.     /// </summary>
  1884.     UINT32 featureCount;
  1885. };
  1886.  
  1887. /// <summary>
  1888. /// The DWRITE_TRIMMING structure specifies the trimming option for text overflowing the layout box.
  1889. /// </summary>
  1890. struct DWRITE_TRIMMING
  1891. {
  1892.     /// <summary>
  1893.     /// Text granularity of which trimming applies.
  1894.     /// </summary>
  1895.     DWRITE_TRIMMING_GRANULARITY granularity;
  1896.  
  1897.     /// <summary>
  1898.     /// Character code used as the delimiter signaling the beginning of the portion of text to be preserved,
  1899.     /// most useful for path ellipsis, where the delimeter would be a slash.
  1900.     /// </summary>
  1901.     UINT32 delimiter;
  1902.  
  1903.     /// <summary>
  1904.     /// How many occurences of the delimiter to step back.
  1905.     /// </summary>
  1906.     UINT32 delimiterCount;
  1907. };
  1908.  
  1909.  
  1910. interface IDWriteTypography;
  1911. interface IDWriteInlineObject;
  1912.  
  1913. /// <summary>
  1914. /// The format of text used for text layout purpose.
  1915. /// </summary>
  1916. /// <remarks>
  1917. /// This object may not be thread-safe and it may carry the state of text format change.
  1918. /// </remarks>
  1919. interface DWRITE_DECLARE_INTERFACE("9c906818-31d7-4fd3-a151-7c5e225db55a") IDWriteTextFormat : public IUnknown
  1920. {
  1921.     /// <summary>
  1922.     /// Set alignment option of text relative to layout box's leading and trailing edge.
  1923.     /// </summary>
  1924.     /// <param name="textAlignment">Text alignment option</param>
  1925.     /// <returns>
  1926.     /// Standard HRESULT error code.
  1927.     /// </returns>
  1928.     STDMETHOD(SetTextAlignment)(
  1929.         DWRITE_TEXT_ALIGNMENT textAlignment
  1930.         ) PURE;
  1931.  
  1932.     /// <summary>
  1933.     /// Set alignment option of paragraph relative to layout box's top and bottom edge.
  1934.     /// </summary>
  1935.     /// <param name="paragraphAlignment">Paragraph alignment option</param>
  1936.     /// <returns>
  1937.     /// Standard HRESULT error code.
  1938.     /// </returns>
  1939.     STDMETHOD(SetParagraphAlignment)(
  1940.         DWRITE_PARAGRAPH_ALIGNMENT paragraphAlignment
  1941.         ) PURE;
  1942.  
  1943.     /// <summary>
  1944.     /// Set word wrapping option.
  1945.     /// </summary>
  1946.     /// <param name="wordWrapping">Word wrapping option</param>
  1947.     /// <returns>
  1948.     /// Standard HRESULT error code.
  1949.     /// </returns>
  1950.     STDMETHOD(SetWordWrapping)(
  1951.         DWRITE_WORD_WRAPPING wordWrapping
  1952.         ) PURE;
  1953.  
  1954.     /// <summary>
  1955.     /// Set paragraph reading direction.
  1956.     /// </summary>
  1957.     /// <param name="readingDirection">Text reading direction</param>
  1958.     /// <returns>
  1959.     /// Standard HRESULT error code.
  1960.     /// </returns>
  1961.     STDMETHOD(SetReadingDirection)(
  1962.         DWRITE_READING_DIRECTION readingDirection
  1963.         ) PURE;
  1964.  
  1965.     /// <summary>
  1966.     /// Set paragraph flow direction.
  1967.     /// </summary>
  1968.     /// <param name="flowDirection">Paragraph flow direction</param>
  1969.     /// <returns>
  1970.     /// Standard HRESULT error code.
  1971.     /// </returns>
  1972.     STDMETHOD(SetFlowDirection)(
  1973.         DWRITE_FLOW_DIRECTION flowDirection
  1974.         ) PURE;
  1975.  
  1976.     /// <summary>
  1977.     /// Set incremental tab stop position.
  1978.     /// </summary>
  1979.     /// <param name="incrementalTabStop">The incremental tab stop value</param>
  1980.     /// <returns>
  1981.     /// Standard HRESULT error code.
  1982.     /// </returns>
  1983.     STDMETHOD(SetIncrementalTabStop)(
  1984.         FLOAT incrementalTabStop
  1985.         ) PURE;
  1986.  
  1987.     /// <summary>
  1988.     /// Set trimming options for any trailing text exceeding the layout width
  1989.     /// or for any far text exceeding the layout height.
  1990.     /// </summary>
  1991.     /// <param name="trimmingOptions">Text trimming options.</param>
  1992.     /// <param name="trimmingSign">Application-defined omission sign. This parameter may be NULL if no trimming sign is desired.</param>
  1993.     /// <remarks>
  1994.     /// Any inline object can be used for the trimming sign, but CreateEllipsisTrimmingSign
  1995.     /// provides a typical ellipsis symbol. Trimming is also useful vertically for hiding
  1996.     /// partial lines.
  1997.     /// </remarks>
  1998.     /// <returns>
  1999.     /// Standard HRESULT error code.
  2000.     /// </returns>
  2001.     STDMETHOD(SetTrimming)(
  2002.         __in DWRITE_TRIMMING const* trimmingOptions,
  2003.         IDWriteInlineObject* trimmingSign
  2004.         ) PURE;
  2005.  
  2006.     /// <summary>
  2007.     /// Set line spacing.
  2008.     /// </summary>
  2009.     /// <param name="lineSpacingMethod">How to determine line height.</param>
  2010.     /// <param name="lineSpacing">The line height, or rather distance between one baseline to another.</param>
  2011.     /// <param name="baseline">Distance from top of line to baseline. A reasonable ratio to lineSpacing is 80%.</param>
  2012.     /// <remarks>
  2013.     /// For the default method, spacing depends solely on the content.
  2014.     /// For uniform spacing, the given line height will override the content.
  2015.     /// </remarks>
  2016.     /// <returns>
  2017.     /// Standard HRESULT error code.
  2018.     /// </returns>
  2019.     STDMETHOD(SetLineSpacing)(
  2020.         DWRITE_LINE_SPACING_METHOD lineSpacingMethod,
  2021.         FLOAT lineSpacing,
  2022.         FLOAT baseline
  2023.         ) PURE;
  2024.  
  2025.     /// <summary>
  2026.     /// Get alignment option of text relative to layout box's leading and trailing edge.
  2027.     /// </summary>
  2028.     STDMETHOD_(DWRITE_TEXT_ALIGNMENT, GetTextAlignment)() PURE;
  2029.  
  2030.     /// <summary>
  2031.     /// Get alignment option of paragraph relative to layout box's top and bottom edge.
  2032.     /// </summary>
  2033.     STDMETHOD_(DWRITE_PARAGRAPH_ALIGNMENT, GetParagraphAlignment)() PURE;
  2034.  
  2035.     /// <summary>
  2036.     /// Get word wrapping option.
  2037.     /// </summary>
  2038.     STDMETHOD_(DWRITE_WORD_WRAPPING, GetWordWrapping)() PURE;
  2039.  
  2040.     /// <summary>
  2041.     /// Get paragraph reading direction.
  2042.     /// </summary>
  2043.     STDMETHOD_(DWRITE_READING_DIRECTION, GetReadingDirection)() PURE;
  2044.  
  2045.     /// <summary>
  2046.     /// Get paragraph flow direction.
  2047.     /// </summary>
  2048.     STDMETHOD_(DWRITE_FLOW_DIRECTION, GetFlowDirection)() PURE;
  2049.  
  2050.     /// <summary>
  2051.     /// Get incremental tab stop position.
  2052.     /// </summary>
  2053.     STDMETHOD_(FLOAT, GetIncrementalTabStop)() PURE;
  2054.  
  2055.     /// <summary>
  2056.     /// Get trimming options for text overflowing the layout width.
  2057.     /// </summary>
  2058.     /// <param name="trimmingOptions">Text trimming options.</param>
  2059.     /// <param name="trimmingSign">Trimming omission sign. This parameter may be NULL.</param>
  2060.     /// <returns>
  2061.     /// Standard HRESULT error code.
  2062.     /// </returns>
  2063.     STDMETHOD(GetTrimming)(
  2064.         __out DWRITE_TRIMMING* trimmingOptions,
  2065.         __out IDWriteInlineObject** trimmingSign
  2066.         ) PURE;
  2067.  
  2068.     /// <summary>
  2069.     /// Get line spacing.
  2070.     /// </summary>
  2071.     /// <param name="lineSpacingMethod">How line height is determined.</param>
  2072.     /// <param name="lineSpacing">The line height, or rather distance between one baseline to another.</param>
  2073.     /// <param name="baseline">Distance from top of line to baseline.</param>
  2074.     /// <returns>
  2075.     /// Standard HRESULT error code.
  2076.     /// </returns>
  2077.     STDMETHOD(GetLineSpacing)(
  2078.         __out DWRITE_LINE_SPACING_METHOD* lineSpacingMethod,
  2079.         __out FLOAT* lineSpacing,
  2080.         __out FLOAT* baseline
  2081.         ) PURE;
  2082.  
  2083.     /// <summary>
  2084.     /// Get the font collection.
  2085.     /// </summary>
  2086.     /// <param name="fontCollection">The current font collection.</param>
  2087.     /// <returns>
  2088.     /// Standard HRESULT error code.
  2089.     /// </returns>
  2090.     STDMETHOD(GetFontCollection)(
  2091.         __out IDWriteFontCollection** fontCollection
  2092.         ) PURE;
  2093.  
  2094.     /// <summary>
  2095.     /// Get the length of the font family name, in characters, not including the terminating NULL character.
  2096.     /// </summary>
  2097.     STDMETHOD_(UINT32, GetFontFamilyNameLength)() PURE;
  2098.  
  2099.     /// <summary>
  2100.     /// Get a copy of the font family name.
  2101.     /// </summary>
  2102.     /// <param name="fontFamilyName">Character array that receives the current font family name</param>
  2103.     /// <param name="nameSize">Size of the character array in character count including the terminated NULL character.</param>
  2104.     /// <returns>
  2105.     /// Standard HRESULT error code.
  2106.     /// </returns>
  2107.     STDMETHOD(GetFontFamilyName)(
  2108.         __out_ecount_z(nameSize) WCHAR* fontFamilyName,
  2109.         UINT32 nameSize
  2110.         ) PURE;
  2111.  
  2112.     /// <summary>
  2113.     /// Get the font weight.
  2114.     /// </summary>
  2115.     STDMETHOD_(DWRITE_FONT_WEIGHT, GetFontWeight)() PURE;
  2116.  
  2117.     /// <summary>
  2118.     /// Get the font style.
  2119.     /// </summary>
  2120.     STDMETHOD_(DWRITE_FONT_STYLE, GetFontStyle)() PURE;
  2121.  
  2122.     /// <summary>
  2123.     /// Get the font stretch.
  2124.     /// </summary>
  2125.     STDMETHOD_(DWRITE_FONT_STRETCH, GetFontStretch)() PURE;
  2126.  
  2127.     /// <summary>
  2128.     /// Get the font em height.
  2129.     /// </summary>
  2130.     STDMETHOD_(FLOAT, GetFontSize)() PURE;
  2131.  
  2132.     /// <summary>
  2133.     /// Get the length of the locale name, in characters, not including the terminating NULL character.
  2134.     /// </summary>
  2135.     STDMETHOD_(UINT32, GetLocaleNameLength)() PURE;
  2136.  
  2137.     /// <summary>
  2138.     /// Get a copy of the locale name.
  2139.     /// </summary>
  2140.     /// <param name="localeName">Character array that receives the current locale name</param>
  2141.     /// <param name="nameSize">Size of the character array in character count including the terminated NULL character.</param>
  2142.     /// <returns>
  2143.     /// Standard HRESULT error code.
  2144.     /// </returns>
  2145.     STDMETHOD(GetLocaleName)(
  2146.         __out_ecount_z(nameSize) WCHAR* localeName,
  2147.         UINT32 nameSize
  2148.         ) PURE;
  2149. };
  2150.  
  2151.  
  2152. /// <summary>
  2153. /// Font typography setting.
  2154. /// </summary>
  2155. interface DWRITE_DECLARE_INTERFACE("55f1112b-1dc2-4b3c-9541-f46894ed85b6") IDWriteTypography : public IUnknown
  2156. {
  2157.     /// <summary>
  2158.     /// Add font feature.
  2159.     /// </summary>
  2160.     /// <param name="fontFeature">The font feature to add.</param>
  2161.     /// <returns>
  2162.     /// Standard HRESULT error code.
  2163.     /// </returns>
  2164.     STDMETHOD(AddFontFeature)(
  2165.         DWRITE_FONT_FEATURE fontFeature
  2166.         ) PURE;
  2167.  
  2168.     /// <summary>
  2169.     /// Get the number of font features.
  2170.     /// </summary>
  2171.     STDMETHOD_(UINT32, GetFontFeatureCount)() PURE;
  2172.  
  2173.     /// <summary>
  2174.     /// Get the font feature at the specified index.
  2175.     /// </summary>
  2176.     /// <param name="fontFeatureIndex">The zero-based index of the font feature to get.</param>
  2177.     /// <param name="fontFeature">The font feature.</param>
  2178.     /// <returns>
  2179.     /// Standard HRESULT error code.
  2180.     /// </returns>
  2181.     STDMETHOD(GetFontFeature)(
  2182.         UINT32 fontFeatureIndex,
  2183.         __out DWRITE_FONT_FEATURE* fontFeature
  2184.         ) PURE;
  2185. };
  2186.  
  2187. enum DWRITE_SCRIPT_SHAPES
  2188. {
  2189.     /// <summary>
  2190.     /// No additional shaping requirement. Text is shaped with the writing system default behavior.
  2191.     /// </summary>
  2192.     DWRITE_SCRIPT_SHAPES_DEFAULT = 0,
  2193.  
  2194.     /// <summary>
  2195.     /// Text should leave no visual on display i.e. control or format control characters.
  2196.     /// </summary>
  2197.     DWRITE_SCRIPT_SHAPES_NO_VISUAL = 1
  2198. };
  2199.  
  2200. #ifdef DEFINE_ENUM_FLAG_OPERATORS
  2201. DEFINE_ENUM_FLAG_OPERATORS(DWRITE_SCRIPT_SHAPES);
  2202. #endif
  2203.  
  2204. /// <summary>
  2205. /// Association of text and its writing system script as well as some display attributes.
  2206. /// </summary>
  2207. struct DWRITE_SCRIPT_ANALYSIS
  2208. {
  2209.     /// <summary>
  2210.     /// Zero-based index representation of writing system script.
  2211.     /// </summary>
  2212.     UINT16 script;
  2213.  
  2214.     /// <summary>
  2215.     /// Additional shaping requirement of text.
  2216.     /// </summary>
  2217.     DWRITE_SCRIPT_SHAPES shapes;
  2218. };
  2219.  
  2220. /// <summary>
  2221. /// Condition at the edges of inline object or text used to determine
  2222. /// line-breaking behavior.
  2223. /// </summary>
  2224. enum DWRITE_BREAK_CONDITION
  2225. {
  2226.     /// <summary>
  2227.     /// Whether a break is allowed is determined by the condition of the
  2228.     /// neighboring text span or inline object.
  2229.     /// </summary>
  2230.     DWRITE_BREAK_CONDITION_NEUTRAL,
  2231.  
  2232.     /// <summary>
  2233.     /// A break is allowed, unless overruled by the condition of the
  2234.     /// neighboring text span or inline object, either prohibited by a
  2235.     /// May Not or forced by a Must.
  2236.     /// </summary>
  2237.     DWRITE_BREAK_CONDITION_CAN_BREAK,
  2238.  
  2239.     /// <summary>
  2240.     /// There should be no break, unless overruled by a Must condition from
  2241.     /// the neighboring text span or inline object.
  2242.     /// </summary>
  2243.     DWRITE_BREAK_CONDITION_MAY_NOT_BREAK,
  2244.  
  2245.     /// <summary>
  2246.     /// The break must happen, regardless of the condition of the adjacent
  2247.     /// text span or inline object.
  2248.     /// </summary>
  2249.     DWRITE_BREAK_CONDITION_MUST_BREAK
  2250. };
  2251.  
  2252. /// <summary>
  2253. /// Line breakpoint characteristics of a character.
  2254. /// </summary>
  2255. struct DWRITE_LINE_BREAKPOINT
  2256. {
  2257.     /// <summary>
  2258.     /// Breaking condition before the character.
  2259.     /// </summary>
  2260.     UINT8 breakConditionBefore  : 2;
  2261.  
  2262.     /// <summary>
  2263.     /// Breaking condition after the character.
  2264.     /// </summary>
  2265.     UINT8 breakConditionAfter   : 2;
  2266.  
  2267.     /// <summary>
  2268.     /// The character is some form of whitespace, which may be meaningful
  2269.     /// for justification.
  2270.     /// </summary>
  2271.     UINT8 isWhitespace          : 1;
  2272.  
  2273.     /// <summary>
  2274.     /// The character is a soft hyphen, often used to indicate hyphenation
  2275.     /// points inside words.
  2276.     /// </summary>
  2277.     UINT8 isSoftHyphen          : 1;
  2278.  
  2279.     UINT8 padding               : 2;
  2280. };
  2281.  
  2282. /// <summary>
  2283. /// How to apply number substitution on digits and related punctuation.
  2284. /// </summary>
  2285. enum DWRITE_NUMBER_SUBSTITUTION_METHOD
  2286. {
  2287.     /// <summary>
  2288.     /// Specifies that the substitution method should be determined based
  2289.     /// on LOCALE_IDIGITSUBSTITUTION value of the specified text culture.
  2290.     /// </summary>
  2291.     DWRITE_NUMBER_SUBSTITUTION_METHOD_FROM_CULTURE,
  2292.  
  2293.     /// <summary>
  2294.     /// If the culture is Arabic or Farsi, specifies that the number shape
  2295.     /// depend on the context. Either traditional or nominal number shape
  2296.     /// are used depending on the nearest preceding strong character or (if
  2297.     /// there is none) the reading direction of the paragraph.
  2298.     /// </summary>
  2299.     DWRITE_NUMBER_SUBSTITUTION_METHOD_CONTEXTUAL,
  2300.  
  2301.     /// <summary>
  2302.     /// Specifies that code points 0x30-0x39 are always rendered as nominal numeral
  2303.     /// shapes (ones of the European number), i.e., no substitution is performed.
  2304.     /// </summary>
  2305.     DWRITE_NUMBER_SUBSTITUTION_METHOD_NONE,
  2306.  
  2307.     /// <summary>
  2308.     /// Specifies that number are rendered using the national number shape
  2309.     /// as specified by the LOCALE_SNATIVEDIGITS value of the specified text culture.
  2310.     /// </summary>
  2311.     DWRITE_NUMBER_SUBSTITUTION_METHOD_NATIONAL,
  2312.  
  2313.     /// <summary>
  2314.     /// Specifies that number are rendered using the traditional shape
  2315.     /// for the specified culture. For most cultures, this is the same as
  2316.     /// NativeNational. However, NativeNational results in Latin number
  2317.     /// for some Arabic cultures, whereas this value results in Arabic
  2318.     /// number for all Arabic cultures.
  2319.     /// </summary>
  2320.     DWRITE_NUMBER_SUBSTITUTION_METHOD_TRADITIONAL
  2321. };
  2322.  
  2323. /// <summary>
  2324. /// Holds the appropriate digits and numeric punctuation for a given locale.
  2325. /// </summary>
  2326. interface DECLSPEC_UUID("14885CC9-BAB0-4f90-B6ED-5C366A2CD03D") DECLSPEC_NOVTABLE IDWriteNumberSubstitution : public IUnknown
  2327. {
  2328. };
  2329.  
  2330. /// <summary>
  2331. /// Shaping output properties per input character.
  2332. /// </summary>
  2333. struct DWRITE_SHAPING_TEXT_PROPERTIES
  2334. {
  2335.     /// <summary>
  2336.     /// This character can be shaped independently from the others
  2337.     /// (usually set for the space character).
  2338.     /// </summary>
  2339.     UINT16  isShapedAlone       : 1;
  2340.  
  2341.     /// <summary>
  2342.     /// Reserved for use by shaping engine.
  2343.     /// </summary>
  2344.     UINT16  reserved            : 15;
  2345. };
  2346.  
  2347. /// <summary>
  2348. /// Shaping output properties per output glyph.
  2349. /// </summary>
  2350. struct DWRITE_SHAPING_GLYPH_PROPERTIES
  2351. {
  2352.     /// <summary>
  2353.     /// Justification class, whether to use spacing, kashidas, or
  2354.     /// another method. This exists for backwards compatibility
  2355.     /// with Uniscribe's SCRIPT_JUSTIFY enum.
  2356.     /// </summary>
  2357.     UINT16  justification       : 4;
  2358.  
  2359.     /// <summary>
  2360.     /// Indicates glyph is the first of a cluster.
  2361.     /// </summary>
  2362.     UINT16  isClusterStart      : 1;
  2363.  
  2364.     /// <summary>
  2365.     /// Glyph is a diacritic.
  2366.     /// </summary>
  2367.     UINT16  isDiacritic         : 1;
  2368.  
  2369.     /// <summary>
  2370.     /// Glyph has no width, blank, ZWJ, ZWNJ etc.
  2371.     /// </summary>
  2372.     UINT16  isZeroWidthSpace    : 1;
  2373.  
  2374.     /// <summary>
  2375.     /// Reserved for use by shaping engine.
  2376.     /// </summary>
  2377.     UINT16  reserved            : 9;
  2378. };
  2379.  
  2380. /// <summary>
  2381. /// The interface implemented by the text analyzer's client to provide text to
  2382. /// the analyzer. It allows the separation between the logical view of text as
  2383. /// a continuous stream of characters identifiable by unique text positions,
  2384. /// and the actual memory layout of potentially discrete blocks of text in the
  2385. /// client's backing store.
  2386. ///
  2387. /// If any of these callbacks returns an error, the analysis functions will
  2388. /// stop prematurely and return a callback error. Rather than return E_NOTIMPL,
  2389. /// an application should stub the method and return a constant/null and S_OK.
  2390. /// </summary>
  2391. interface DECLSPEC_UUID("688e1a58-5094-47c8-adc8-fbcea60ae92b") DECLSPEC_NOVTABLE IDWriteTextAnalysisSource : public IUnknown
  2392. {
  2393.     /// <summary>
  2394.     /// Get a block of text starting at the specified text position.
  2395.     /// Returning NULL indicates the end of text - the position is after
  2396.     /// the last character. This function is called iteratively for
  2397.     /// each consecutive block, tying together several fragmented blocks
  2398.     /// in the backing store into a virtual contiguous string.
  2399.     /// </summary>
  2400.     /// <param name="textPosition">First position of the piece to obtain. All
  2401.     ///     positions are in UTF16 code-units, not whole characters, which
  2402.     ///     matters when supplementary characters are used.</param>
  2403.     /// <param name="textString">Address that receives a pointer to the text block
  2404.     ///     at the specified position.</param>
  2405.     /// <param name="textLength">Number of UTF16 units of the retrieved chunk.
  2406.     ///     The returned length is not the length of the block, but the length
  2407.     ///     remaining in the block, from the given position until its end.
  2408.     ///     So querying for a position that is 75 positions into a 100
  2409.     ///     postition block would return 25.</param>
  2410.     /// <returns>Pointer to the first character at the given text position.
  2411.     /// NULL indicates no chunk available at the specified position, either
  2412.     /// because textPosition >= the entire text content length or because the
  2413.     /// queried position is not mapped into the app's backing store.</returns>
  2414.     /// <remarks>
  2415.     /// Although apps can implement sparse textual content that only maps part of
  2416.     /// the backing store, the app must map any text that is in the range passed
  2417.     /// to any analysis functions.
  2418.     /// </remarks>
  2419.     STDMETHOD(GetTextAtPosition)(
  2420.         UINT32 textPosition,
  2421.         __out WCHAR const** textString,
  2422.         __out UINT32* textLength
  2423.         ) PURE;
  2424.  
  2425.     /// <summary>
  2426.     /// Get a block of text immediately preceding the specified position.
  2427.     /// </summary>
  2428.     /// <param name="textPosition">Position immediately after the last position of the chunk to obtain.</param>
  2429.     /// <param name="textString">Address that receives a pointer to the text block
  2430.     ///     at the specified position.</param>
  2431.     /// <param name="textLength">Number of UTF16 units of the retrieved block.
  2432.     ///     The length returned is from the given position to the front of
  2433.     ///     the block.</param>
  2434.     /// <returns>Pointer to the first character at (textPosition - textLength).
  2435.     /// NULL indicates no chunk available at the specified position, either
  2436.     /// because textPosition == 0,the textPosition > the entire text content
  2437.     /// length, or the queried position is not mapped into the app's backing
  2438.     /// store.</returns>
  2439.     /// <remarks>
  2440.     /// Although apps can implement sparse textual content that only maps part of
  2441.     /// the backing store, the app must map any text that is in the range passed
  2442.     /// to any analysis functions.
  2443.     /// </remarks>
  2444.     STDMETHOD(GetTextBeforePosition)(
  2445.         UINT32 textPosition,
  2446.         __out WCHAR const** textString,
  2447.         __out UINT32* textLength
  2448.         ) PURE;
  2449.  
  2450.     /// <summary>
  2451.     /// Get paragraph reading direction.
  2452.     /// </summary>
  2453.     STDMETHOD_(DWRITE_READING_DIRECTION, GetParagraphReadingDirection)() PURE;
  2454.  
  2455.     /// <summary>
  2456.     /// Get locale name on the range affected by it.
  2457.     /// </summary>
  2458.     /// <param name="textPosition">Position to get the locale name of.</param>
  2459.     /// <param name="textLength">Receives the length from the given position up to the
  2460.     ///     next differing locale.</param>
  2461.     /// <param name="localeName">Address that receives a pointer to the locale
  2462.     ///     at the specified position.</param>
  2463.     /// <remarks>
  2464.     /// The localeName pointer must remain valid until the next call or until
  2465.     /// the analysis returns.
  2466.     /// </remarks>
  2467.     STDMETHOD(GetLocaleName)(
  2468.         UINT32 textPosition,
  2469.         __out UINT32* textLength,
  2470.         __out_z WCHAR const** localeName
  2471.         ) PURE;
  2472.  
  2473.     /// <summary>
  2474.     /// Get number substitution on the range affected by it.
  2475.     /// </summary>
  2476.     /// <param name="textPosition">Position to get the number substitution of.</param>
  2477.     /// <param name="textLength">Receives the length from the given position up to the
  2478.     ///     next differing number substitution.</param>
  2479.     /// <param name="numberSubstitution">Address that receives a pointer to the number substitution
  2480.     ///     at the specified position.</param>
  2481.     /// <remarks>
  2482.     /// Any implementation should return the number substitution with an
  2483.     /// incremented ref count, and the analysis will release when finished
  2484.     /// with it (either before the next call or before it returns). However,
  2485.     /// the sink callback may hold onto it after that.
  2486.     /// </remarks>
  2487.     STDMETHOD(GetNumberSubstitution)(
  2488.         UINT32 textPosition,
  2489.         __out UINT32* textLength,
  2490.         __out IDWriteNumberSubstitution** numberSubstitution
  2491.         ) PURE;
  2492. };
  2493.  
  2494. /// <summary>
  2495. /// The interface implemented by the text analyzer's client to receive the
  2496. /// output of a given text analysis. The Text analyzer disregards any current
  2497. /// state of the analysis sink, therefore a Set method call on a range
  2498. /// overwrites the previously set analysis result of the same range.
  2499. /// </summary>
  2500. interface DECLSPEC_UUID("5810cd44-0ca0-4701-b3fa-bec5182ae4f6") DECLSPEC_NOVTABLE IDWriteTextAnalysisSink : public IUnknown
  2501. {
  2502.     /// <summary>
  2503.     /// Report script analysis for the text range.
  2504.     /// </summary>
  2505.     /// <param name="textPosition">Starting position to report from.</param>
  2506.     /// <param name="textLength">Number of UTF16 units of the reported range.</param>
  2507.     /// <param name="scriptAnalysis">Script analysis of characters in range.</param>
  2508.     /// <returns>
  2509.     /// A successful code or error code to abort analysis.
  2510.     /// </returns>
  2511.     STDMETHOD(SetScriptAnalysis)(
  2512.         UINT32 textPosition,
  2513.         UINT32 textLength,
  2514.         __in DWRITE_SCRIPT_ANALYSIS const* scriptAnalysis
  2515.         ) PURE;
  2516.  
  2517.     /// <summary>
  2518.     /// Repport line-break opportunities for each character, starting from
  2519.     /// the specified position.
  2520.     /// </summary>
  2521.     /// <param name="textPosition">Starting position to report from.</param>
  2522.     /// <param name="textLength">Number of UTF16 units of the reported range.</param>
  2523.     /// <param name="lineBreakpoints">Breaking conditions for each character.</param>
  2524.     /// <returns>
  2525.     /// A successful code or error code to abort analysis.
  2526.     /// </returns>
  2527.     STDMETHOD(SetLineBreakpoints)(
  2528.         UINT32 textPosition,
  2529.         UINT32 textLength,
  2530.         __in_ecount(textLength) DWRITE_LINE_BREAKPOINT const* lineBreakpoints
  2531.         ) PURE;
  2532.  
  2533.     /// <summary>
  2534.     /// Set bidirectional level on the range, called once per each
  2535.     /// level run change (either explicit or resolved implicit).
  2536.     /// </summary>
  2537.     /// <param name="textPosition">Starting position to report from.</param>
  2538.     /// <param name="textLength">Number of UTF16 units of the reported range.</param>
  2539.     /// <param name="explicitLevel">Explicit level from embedded control codes
  2540.     ///     RLE/RLO/LRE/LRO/PDF, determined before any additional rules.</param>
  2541.     /// <param name="resolvedLevel">Final implicit level considering the
  2542.     ///     explicit level and characters' natural directionality, after all
  2543.     ///     Bidi rules have been applied.</param>
  2544.     /// <returns>
  2545.     /// A successful code or error code to abort analysis.
  2546.     /// </returns>
  2547.     STDMETHOD(SetBidiLevel)(
  2548.         UINT32 textPosition,
  2549.         UINT32 textLength,
  2550.         UINT8 explicitLevel,
  2551.         UINT8 resolvedLevel
  2552.         ) PURE;
  2553.  
  2554.     /// <summary>
  2555.     /// Set number substitution on the range.
  2556.     /// </summary>
  2557.     /// <param name="textPosition">Starting position to report from.</param>
  2558.     /// <param name="textLength">Number of UTF16 units of the reported range.</param>
  2559.     /// <param name="numberSubstitution">The number substitution applicable to
  2560.     ///     the returned range of text. The sink callback may hold onto it by
  2561.     ///     incrementing its ref count.</param>
  2562.     /// <returns>
  2563.     /// A successful code or error code to abort analysis.
  2564.     /// </returns>
  2565.     /// <remark>
  2566.     /// Unlike script and bidi analysis, where every character passed to the
  2567.     /// analyzer has a result, this will only be called for those ranges where
  2568.     /// substitution is applicable. For any other range, you will simply not
  2569.     /// be called.
  2570.     /// </remark>
  2571.     STDMETHOD(SetNumberSubstitution)(
  2572.         UINT32 textPosition,
  2573.         UINT32 textLength,
  2574.         __notnull IDWriteNumberSubstitution* numberSubstitution
  2575.         ) PURE;
  2576. };
  2577.  
  2578. /// <summary>
  2579. /// Analyzes various text properties for complex script processing.
  2580. /// </summary>
  2581. interface DWRITE_DECLARE_INTERFACE("b7e6163e-7f46-43b4-84b3-e4e6249c365d") IDWriteTextAnalyzer : public IUnknown
  2582. {
  2583.     /// <summary>
  2584.     /// Analyzes a text range for script boundaries, reading text attributes
  2585.     /// from the source and reporting the Unicode script ID to the sink
  2586.     /// callback SetScript.
  2587.     /// </summary>
  2588.     /// <param name="analysisSource">Source object to analyze.</param>
  2589.     /// <param name="textPosition">Starting position within the source object.</param>
  2590.     /// <param name="textLength">Length to analyze.</param>
  2591.     /// <param name="analysisSink">Callback object.</param>
  2592.     /// <returns>
  2593.     /// Standard HRESULT error code.
  2594.     /// </returns>
  2595.     STDMETHOD(AnalyzeScript)(
  2596.         IDWriteTextAnalysisSource* analysisSource,
  2597.         UINT32 textPosition,
  2598.         UINT32 textLength,
  2599.         IDWriteTextAnalysisSink* analysisSink
  2600.         ) PURE;
  2601.  
  2602.     /// <summary>
  2603.     /// Analyzes a text range for script directionality, reading attributes
  2604.     /// from the source and reporting levels to the sink callback SetBidiLevel.
  2605.     /// </summary>
  2606.     /// <param name="analysisSource">Source object to analyze.</param>
  2607.     /// <param name="textPosition">Starting position within the source object.</param>
  2608.     /// <param name="textLength">Length to analyze.</param>
  2609.     /// <param name="analysisSink">Callback object.</param>
  2610.     /// <returns>
  2611.     /// Standard HRESULT error code.
  2612.     /// </returns>
  2613.     /// <remarks>
  2614.     /// While the function can handle multiple paragraphs, the text range
  2615.     /// should not arbitrarily split the middle of paragraphs. Otherwise the
  2616.     /// returned levels may be wrong, since the Bidi algorithm is meant to
  2617.     /// apply to the paragraph as a whole.
  2618.     /// </remarks>
  2619.     /// <remarks>
  2620.     /// Embedded control codes (LRE/LRO/RLE/RLO/PDF) are taken into account.
  2621.     /// </remarks>
  2622.     STDMETHOD(AnalyzeBidi)(
  2623.         IDWriteTextAnalysisSource* analysisSource,
  2624.         UINT32 textPosition,
  2625.         UINT32 textLength,
  2626.         IDWriteTextAnalysisSink* analysisSink
  2627.         ) PURE;
  2628.  
  2629.     /// <summary>
  2630.     /// Analyzes a text range for spans where number substitution is applicable,
  2631.     /// reading attributes from the source and reporting substitutable ranges
  2632.     /// to the sink callback SetNumberSubstitution.
  2633.     /// </summary>
  2634.     /// <param name="analysisSource">Source object to analyze.</param>
  2635.     /// <param name="textPosition">Starting position within the source object.</param>
  2636.     /// <param name="textLength">Length to analyze.</param>
  2637.     /// <param name="analysisSink">Callback object.</param>
  2638.     /// <returns>
  2639.     /// Standard HRESULT error code.
  2640.     /// </returns>
  2641.     /// <remarks>
  2642.     /// While the function can handle multiple ranges of differing number
  2643.     /// substitutions, the text ranges should not arbitrarily split the
  2644.     /// middle of numbers. Otherwise it will treat the numbers separately
  2645.     /// and will not translate any intervening punctuation.
  2646.     /// </remarks>
  2647.     /// <remarks>
  2648.     /// Embedded control codes (LRE/LRO/RLE/RLO/PDF) are taken into account.
  2649.     /// </remarks>
  2650.     STDMETHOD(AnalyzeNumberSubstitution)(
  2651.         IDWriteTextAnalysisSource* analysisSource,
  2652.         UINT32 textPosition,
  2653.         UINT32 textLength,
  2654.         IDWriteTextAnalysisSink* analysisSink
  2655.         ) PURE;
  2656.  
  2657.     /// <summary>
  2658.     /// Analyzes a text range for potential breakpoint opportunities, reading
  2659.     /// attributes from the source and reporting breakpoint opportunities to
  2660.     /// the sink callback SetLineBreakpoints.
  2661.     /// </summary>
  2662.     /// <param name="analysisSource">Source object to analyze.</param>
  2663.     /// <param name="textPosition">Starting position within the source object.</param>
  2664.     /// <param name="textLength">Length to analyze.</param>
  2665.     /// <param name="analysisSink">Callback object.</param>
  2666.     /// <returns>
  2667.     /// Standard HRESULT error code.
  2668.     /// </returns>
  2669.     /// <remarks>
  2670.     /// While the function can handle multiple paragraphs, the text range
  2671.     /// should not arbitrarily split the middle of paragraphs, unless the
  2672.     /// given text span is considered a whole unit. Otherwise the
  2673.     /// returned properties for the first and last characters will
  2674.     /// inappropriately allow breaks.
  2675.     /// </remarks>
  2676.     /// <remarks>
  2677.     /// Special cases include the first, last, and surrogate characters. Any
  2678.     /// text span is treated as if adjacent to inline objects on either side.
  2679.     /// So the rules with contingent-break opportunities are used, where the
  2680.     /// edge between text and inline objects is always treated as a potential
  2681.     /// break opportunity, dependent on any overriding rules of the adjacent
  2682.     /// objects to prohibit or force the break (see Unicode TR #14).
  2683.     /// Surrogate pairs never break between.
  2684.     /// </remarks>
  2685.     STDMETHOD(AnalyzeLineBreakpoints)(
  2686.         IDWriteTextAnalysisSource* analysisSource,
  2687.         UINT32 textPosition,
  2688.         UINT32 textLength,
  2689.         IDWriteTextAnalysisSink* analysisSink
  2690.         ) PURE;
  2691.  
  2692.     /// <summary>
  2693.     /// Parses the input text string and maps it to the set of glyphs and associated glyph data
  2694.     /// according to the font and the writing system's rendering rules.
  2695.     /// </summary>
  2696.     /// <param name="textString">The string to convert to glyphs.</param>
  2697.     /// <param name="textLength">The length of textString.</param>
  2698.     /// <param name="fontFace">The font face to get glyphs from.</param>
  2699.     /// <param name="isSideways">Set to true if the text is intended to be
  2700.     /// drawn vertically.</param>
  2701.     /// <param name="isRightToLeft">Set to TRUE for right-to-left text.</param>
  2702.     /// <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param>
  2703.     /// <param name="localeName">The locale to use when selecting glyphs.
  2704.     /// e.g. the same character may map to different glyphs for ja-jp vs zh-chs.
  2705.     /// If this is NULL then the default mapping based on the script is used.</param>
  2706.     /// <param name="numberSubstitution">Optional number substitution which
  2707.     /// selects the appropriate glyphs for digits and related numeric characters,
  2708.     /// depending on the results obtained from AnalyzeNumberSubstitution. Passing
  2709.     /// null indicates that no substitution is needed and that the digits should
  2710.     /// receive nominal glyphs.</param>
  2711.     /// <param name="features">An array of pointers to the sets of typographic
  2712.     /// features to use in each feature range.</param>
  2713.     /// <param name="featureRangeLengths">The length of each feature range, in characters.  
  2714.     /// The sum of all lengths should be equal to textLength.</param>
  2715.     /// <param name="featureRanges">The number of feature ranges.</param>
  2716.     /// <param name="maxGlyphCount">The maximum number of glyphs that can be
  2717.     /// returned.</param>
  2718.     /// <param name="clusterMap">The mapping from character ranges to glyph
  2719.     /// ranges.</param>
  2720.     /// <param name="textProps">Per-character output properties.</param>
  2721.     /// <param name="glyphIndices">Output glyph indices.</param>
  2722.     /// <param name="glyphProps">Per-glyph output properties.</param>
  2723.     /// <param name="actualGlyphCount">The actual number of glyphs returned if
  2724.     /// the call succeeds.</param>
  2725.     /// <returns>
  2726.     /// Standard HRESULT error code.
  2727.     /// </returns>
  2728.     /// <remarks>
  2729.     /// Note that the mapping from characters to glyphs is, in general, many-
  2730.     /// to-many.  The recommended estimate for the per-glyph output buffers is
  2731.     /// (3 * textLength / 2 + 16).  This is not guaranteed to be sufficient.
  2732.     ///
  2733.     /// The value of the actualGlyphCount parameter is only valid if the call
  2734.     /// succeeds.  In the event that maxGlyphCount is not big enough
  2735.     /// E_NOT_SUFFICIENT_BUFFER, which is equivalent to HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),
  2736.     /// will be returned.  The application should allocate a larger buffer and try again.
  2737.     /// </remarks>
  2738.     STDMETHOD(GetGlyphs)(
  2739.         __in_ecount(textLength) WCHAR const* textString,
  2740.         UINT32 textLength,
  2741.         IDWriteFontFace* fontFace,
  2742.         BOOL isSideways,
  2743.         BOOL isRightToLeft,
  2744.         __in DWRITE_SCRIPT_ANALYSIS const* scriptAnalysis,
  2745.         __in_z_opt WCHAR const* localeName,
  2746.         __maybenull IDWriteNumberSubstitution* numberSubstitution,
  2747.         __in_ecount_opt(featureRanges) DWRITE_TYPOGRAPHIC_FEATURES const** features,
  2748.         __in_ecount_opt(featureRanges) UINT32 const* featureRangeLengths,
  2749.         UINT32 featureRanges,
  2750.         UINT32 maxGlyphCount,
  2751.         __out_ecount(textLength) UINT16* clusterMap,
  2752.         __out_ecount(textLength) DWRITE_SHAPING_TEXT_PROPERTIES* textProps,
  2753.         __out_ecount(maxGlyphCount) UINT16* glyphIndices,
  2754.         __out_ecount(maxGlyphCount) DWRITE_SHAPING_GLYPH_PROPERTIES* glyphProps,
  2755.         __out UINT32* actualGlyphCount
  2756.         ) PURE;
  2757.  
  2758.     /// <summary>
  2759.     /// Place glyphs output from the GetGlyphs method according to the font
  2760.     /// and the writing system's rendering rules.
  2761.     /// </summary>
  2762.     /// <param name="textString">The original string the glyphs came from.</param>
  2763.     /// <param name="clusterMap">The mapping from character ranges to glyph
  2764.     /// ranges. Returned by GetGlyphs.</param>
  2765.     /// <param name="textProps">Per-character properties. Returned by
  2766.     /// GetGlyphs.</param>
  2767.     /// <param name="textLength">The length of textString.</param>
  2768.     /// <param name="glyphIndices">Glyph indices. See GetGlyphs</param>
  2769.     /// <param name="glyphProps">Per-glyph properties. See GetGlyphs</param>
  2770.     /// <param name="glyphCount">The number of glyphs.</param>
  2771.     /// <param name="fontFace">The font face the glyphs came from.</param>
  2772.     /// <param name="fontEmSize">Logical font size in DIP's.</param>
  2773.     /// <param name="isSideways">Set to true if the text is intended to be
  2774.     /// drawn vertically.</param>
  2775.     /// <param name="isRightToLeft">Set to TRUE for right-to-left text.</param>
  2776.     /// <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param>
  2777.     /// <param name="localeName">The locale to use when selecting glyphs.
  2778.     /// e.g. the same character may map to different glyphs for ja-jp vs zh-chs.
  2779.     /// If this is NULL then the default mapping based on the script is used.</param>
  2780.     /// <param name="features">An array of pointers to the sets of typographic
  2781.     /// features to use in each feature range.</param>
  2782.     /// <param name="featureRangeLengths">The length of each feature range, in characters.  
  2783.     /// The sum of all lengths should be equal to textLength.</param>
  2784.     /// <param name="featureRanges">The number of feature ranges.</param>
  2785.     /// <param name="glyphAdvances">The advance width of each glyph.</param>
  2786.     /// <param name="glyphOffsets">The offset of the origin of each glyph.</param>
  2787.     /// <returns>
  2788.     /// Standard HRESULT error code.
  2789.     /// </returns>
  2790.     STDMETHOD(GetGlyphPlacements)(
  2791.         __in_ecount(textLength) WCHAR const* textString,
  2792.         __in_ecount(textLength) UINT16 const* clusterMap,
  2793.         __in_ecount(textLength) DWRITE_SHAPING_TEXT_PROPERTIES* textProps,
  2794.         UINT32 textLength,
  2795.         __in_ecount(glyphCount) UINT16 const* glyphIndices,
  2796.         __in_ecount(glyphCount) DWRITE_SHAPING_GLYPH_PROPERTIES const* glyphProps,
  2797.         UINT32 glyphCount,
  2798.         IDWriteFontFace * fontFace,
  2799.         FLOAT fontEmSize,
  2800.         BOOL isSideways,
  2801.         BOOL isRightToLeft,
  2802.         __in DWRITE_SCRIPT_ANALYSIS const* scriptAnalysis,
  2803.         __in_z_opt WCHAR const* localeName,
  2804.         __in_ecount_opt(featureRanges) DWRITE_TYPOGRAPHIC_FEATURES const** features,
  2805.         __in_ecount_opt(featureRanges) UINT32 const* featureRangeLengths,
  2806.         UINT32 featureRanges,
  2807.         __out_ecount(glyphCount) FLOAT* glyphAdvances,
  2808.         __out_ecount(glyphCount) DWRITE_GLYPH_OFFSET* glyphOffsets
  2809.         ) PURE;
  2810.  
  2811.     /// <summary>
  2812.     /// Place glyphs output from the GetGlyphs method according to the font
  2813.     /// and the writing system's rendering rules.
  2814.     /// </summary>
  2815.     /// <param name="textString">The original string the glyphs came from.</param>
  2816.     /// <param name="clusterMap">The mapping from character ranges to glyph
  2817.     /// ranges. Returned by GetGlyphs.</param>
  2818.     /// <param name="textProps">Per-character properties. Returned by
  2819.     /// GetGlyphs.</param>
  2820.     /// <param name="textLength">The length of textString.</param>
  2821.     /// <param name="glyphIndices">Glyph indices. See GetGlyphs</param>
  2822.     /// <param name="glyphProps">Per-glyph properties. See GetGlyphs</param>
  2823.     /// <param name="glyphCount">The number of glyphs.</param>
  2824.     /// <param name="fontFace">The font face the glyphs came from.</param>
  2825.     /// <param name="fontEmSize">Logical font size in DIP's.</param>
  2826.     /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if the DPI of the rendering surface is 96 this
  2827.     /// value is 1.0f. If the DPI is 120, this value is 120.0f/96.</param>
  2828.     /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the
  2829.     /// scaling specified by the font size and pixelsPerDip.</param>
  2830.     /// <param name="useGdiNatural">
  2831.     /// When set to FALSE, the metrics are the same as the metrics of GDI aliased text.
  2832.     /// When set to TRUE, the metrics are the same as the metrics of text measured by GDI using a font
  2833.     /// created with CLEARTYPE_NATURAL_QUALITY.
  2834.     /// </param>
  2835.     /// <param name="isSideways">Set to true if the text is intended to be
  2836.     /// drawn vertically.</param>
  2837.     /// <param name="isRightToLeft">Set to TRUE for right-to-left text.</param>
  2838.     /// <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param>
  2839.     /// <param name="localeName">The locale to use when selecting glyphs.
  2840.     /// e.g. the same character may map to different glyphs for ja-jp vs zh-chs.
  2841.     /// If this is NULL then the default mapping based on the script is used.</param>
  2842.     /// <param name="features">An array of pointers to the sets of typographic
  2843.     /// features to use in each feature range.</param>
  2844.     /// <param name="featureRangeLengths">The length of each feature range, in characters.  
  2845.     /// The sum of all lengths should be equal to textLength.</param>
  2846.     /// <param name="featureRanges">The number of feature ranges.</param>
  2847.     /// <param name="glyphAdvances">The advance width of each glyph.</param>
  2848.     /// <param name="glyphOffsets">The offset of the origin of each glyph.</param>
  2849.     /// <returns>
  2850.     /// Standard HRESULT error code.
  2851.     /// </returns>
  2852.     STDMETHOD(GetGdiCompatibleGlyphPlacements)(
  2853.         __in_ecount(textLength) WCHAR const* textString,
  2854.         __in_ecount(textLength) UINT16 const* clusterMap,
  2855.         __in_ecount(textLength) DWRITE_SHAPING_TEXT_PROPERTIES* textProps,
  2856.         UINT32 textLength,
  2857.         __in_ecount(glyphCount) UINT16 const* glyphIndices,
  2858.         __in_ecount(glyphCount) DWRITE_SHAPING_GLYPH_PROPERTIES const* glyphProps,
  2859.         UINT32 glyphCount,
  2860.         IDWriteFontFace * fontFace,
  2861.         FLOAT fontEmSize,
  2862.         FLOAT pixelsPerDip,
  2863.         __in_opt DWRITE_MATRIX const* transform,
  2864.         BOOL useGdiNatural,
  2865.         BOOL isSideways,
  2866.         BOOL isRightToLeft,
  2867.         __in DWRITE_SCRIPT_ANALYSIS const* scriptAnalysis,
  2868.         __in_z_opt WCHAR const* localeName,
  2869.         __in_ecount_opt(featureRanges) DWRITE_TYPOGRAPHIC_FEATURES const** features,
  2870.         __in_ecount_opt(featureRanges) UINT32 const* featureRangeLengths,
  2871.         UINT32 featureRanges,
  2872.         __out_ecount(glyphCount) FLOAT* glyphAdvances,
  2873.         __out_ecount(glyphCount) DWRITE_GLYPH_OFFSET* glyphOffsets
  2874.         ) PURE;
  2875. };
  2876.  
  2877. /// <summary>
  2878. /// The DWRITE_GLYPH_RUN structure contains the information needed by renderers
  2879. /// to draw glyph runs. All coordinates are in device independent pixels (DIPs).
  2880. /// </summary>
  2881. struct DWRITE_GLYPH_RUN
  2882. {
  2883.     /// <summary>
  2884.     /// The physical font face to draw with.
  2885.     /// </summary>
  2886.     __notnull IDWriteFontFace* fontFace;
  2887.  
  2888.     /// <summary>
  2889.     /// Logical size of the font in DIPs, not points (equals 1/96 inch).
  2890.     /// </summary>
  2891.     FLOAT fontEmSize;
  2892.  
  2893.     /// <summary>
  2894.     /// The number of glyphs.
  2895.     /// </summary>
  2896.     UINT32 glyphCount;
  2897.  
  2898.     /// <summary>
  2899.     /// The indices to render.
  2900.     /// </summary>    
  2901.     __field_ecount(glyphCount) UINT16 const* glyphIndices;
  2902.  
  2903.     /// <summary>
  2904.     /// Glyph advance widths.
  2905.     /// </summary>
  2906.     __field_ecount_opt(glyphCount) FLOAT const* glyphAdvances;
  2907.  
  2908.     /// <summary>
  2909.     /// Glyph offsets.
  2910.     /// </summary>
  2911.     __field_ecount_opt(glyphCount) DWRITE_GLYPH_OFFSET const* glyphOffsets;
  2912.  
  2913.     /// <summary>
  2914.     /// If true, specifies that glyphs are rotated 90 degrees to the left and
  2915.     /// vertical metrics are used. Vertical writing is achieved by specifying
  2916.     /// isSideways = true and rotating the entire run 90 degrees to the right
  2917.     /// via a rotate transform.
  2918.     /// </summary>
  2919.     BOOL isSideways;
  2920.  
  2921.     /// <summary>
  2922.     /// The implicit resolved bidi level of the run. Odd levels indicate
  2923.     /// right-to-left languages like Hebrew and Arabic, while even levels
  2924.     /// indicate left-to-right languages like English and Japanese (when
  2925.     /// written horizontally). For right-to-left languages, the text origin
  2926.     /// is on the right, and text should be drawn to the left.
  2927.     /// </summary>
  2928.     UINT32 bidiLevel;
  2929. };
  2930.  
  2931. /// <summary>
  2932. /// The DWRITE_GLYPH_RUN_DESCRIPTION structure contains additional properties
  2933. /// related to those in DWRITE_GLYPH_RUN.
  2934. /// </summary>
  2935. struct DWRITE_GLYPH_RUN_DESCRIPTION
  2936. {
  2937.     /// <summary>
  2938.     /// The locale name associated with this run.
  2939.     /// </summary>
  2940.     __nullterminated WCHAR const* localeName;
  2941.  
  2942.     /// <summary>
  2943.     /// The text associated with the glyphs.
  2944.     /// </summary>
  2945.     __field_ecount(stringLength) WCHAR const* string;
  2946.  
  2947.     /// <summary>
  2948.     /// The number of characters (UTF16 code-units).
  2949.     /// Note that this may be different than the number of glyphs.
  2950.     /// </summary>
  2951.     UINT32 stringLength;
  2952.  
  2953.     /// <summary>
  2954.     /// An array of indices to the glyph indices array, of the first glyphs of
  2955.     /// all the glyph clusters of the glyphs to render.
  2956.     /// </summary>
  2957.     __field_ecount(stringLength) UINT16 const* clusterMap;
  2958.  
  2959.     /// <summary>
  2960.     /// Corresponding text position in the original string
  2961.     /// this glyph run came from.
  2962.     /// </summary>
  2963.     UINT32 textPosition;
  2964. };
  2965.  
  2966. /// <summary>
  2967. /// The DWRITE_UNDERLINE structure contains about the size and placement of
  2968. /// underlines. All coordinates are in device independent pixels (DIPs).
  2969. /// </summary>
  2970. struct DWRITE_UNDERLINE
  2971. {
  2972.     /// <summary>
  2973.     /// Width of the underline, measured parallel to the baseline.
  2974.     /// </summary>
  2975.     FLOAT width;
  2976.  
  2977.     /// <summary>
  2978.     /// Thickness of the underline, measured perpendicular to the
  2979.     /// baseline.
  2980.     /// </summary>
  2981.     FLOAT thickness;
  2982.  
  2983.     /// <summary>
  2984.     /// Offset of the underline from the baseline.
  2985.     /// A positive offset represents a position below the baseline and
  2986.     /// a negative offset is above.
  2987.     /// </summary>
  2988.     FLOAT offset;
  2989.  
  2990.     /// <summary>
  2991.     /// Height of the tallest run where the underline applies.
  2992.     /// </summary>
  2993.     FLOAT runHeight;
  2994.  
  2995.     /// <summary>
  2996.     /// Reading direction of the text associated with the underline.  This
  2997.     /// value is used to interpret whether the width value runs horizontally
  2998.     /// or vertically.
  2999.     /// </summary>
  3000.     DWRITE_READING_DIRECTION readingDirection;
  3001.  
  3002.     /// <summary>
  3003.     /// Flow direction of the text associated with the underline.  This value
  3004.     /// is used to interpret whether the thickness value advances top to
  3005.     /// bottom, left to right, or right to left.
  3006.     /// </summary>
  3007.     DWRITE_FLOW_DIRECTION flowDirection;
  3008.  
  3009.     /// <summary>
  3010.     /// Locale of the text the underline is being drawn under. Can be
  3011.     /// pertinent where the locale affects how the underline is drawn.
  3012.     /// For example, in vertical text, the underline belongs on the
  3013.     /// left for Chinese but on the right for Japanese.
  3014.     /// This choice is completely left up to higher levels.
  3015.     /// </summary>
  3016.     __nullterminated WCHAR const* localeName;
  3017.  
  3018.     /// <summary>
  3019.     /// The measuring mode can be useful to the renderer to determine how
  3020.     /// underlines are rendered, e.g. rounding the thickness to a whole pixel
  3021.     /// in GDI-compatible modes.
  3022.     /// </summary>
  3023.     DWRITE_MEASURING_MODE measuringMode;
  3024. };
  3025.  
  3026. /// <summary>
  3027. /// The DWRITE_STRIKETHROUGH structure contains about the size and placement of
  3028. /// strickthroughs. All coordinates are in device independent pixels (DIPs).
  3029. /// </summary>
  3030. struct DWRITE_STRIKETHROUGH
  3031. {
  3032.     /// <summary>
  3033.     /// Width of the strikethrough, measured parallel to the baseline.
  3034.     /// </summary>
  3035.     FLOAT width;
  3036.  
  3037.     /// <summary>
  3038.     /// Thickness of the strikethrough, measured perpendicular to the
  3039.     /// baseline.
  3040.     /// </summary>
  3041.     FLOAT thickness;
  3042.  
  3043.     /// <summary>
  3044.     /// Offset of the stikethrough from the baseline.
  3045.     /// A positive offset represents a position below the baseline and
  3046.     /// a negative offset is above.
  3047.     /// </summary>
  3048.     FLOAT offset;
  3049.  
  3050.     /// <summary>
  3051.     /// Reading direction of the text associated with the strikethrough.  This
  3052.     /// value is used to interpret whether the width value runs horizontally
  3053.     /// or vertically.
  3054.     /// </summary>
  3055.     DWRITE_READING_DIRECTION readingDirection;
  3056.  
  3057.     /// <summary>
  3058.     /// Flow direction of the text associated with the strikethrough.  This
  3059.     /// value is used to interpret whether the thickness value advances top to
  3060.     /// bottom, left to right, or right to left.
  3061.     /// </summary>
  3062.     DWRITE_FLOW_DIRECTION flowDirection;
  3063.  
  3064.     /// <summary>
  3065.     /// Locale of the range. Can be pertinent where the locale affects the style.
  3066.     /// </summary>
  3067.     __nullterminated WCHAR const* localeName;
  3068.  
  3069.     /// <summary>
  3070.     /// The measuring mode can be useful to the renderer to determine how
  3071.     /// underlines are rendered, e.g. rounding the thickness to a whole pixel
  3072.     /// in GDI-compatible modes.
  3073.     /// </summary>
  3074.     DWRITE_MEASURING_MODE measuringMode;
  3075. };
  3076.  
  3077. /// <summary>
  3078. /// The DWRITE_LINE_METRICS structure contains information about a formatted
  3079. /// line of text.
  3080. /// </summary>
  3081. struct DWRITE_LINE_METRICS
  3082. {
  3083.     /// <summary>
  3084.     /// The number of total text positions in the line.
  3085.     /// This includes any trailing whitespace and newline characters.
  3086.     /// </summary>
  3087.     UINT32 length;
  3088.  
  3089.     /// <summary>
  3090.     /// The number of whitespace positions at the end of the line.  Newline
  3091.     /// sequences are considered whitespace.
  3092.     /// </summary>
  3093.     UINT32 trailingWhitespaceLength;
  3094.  
  3095.     /// <summary>
  3096.     /// The number of characters in the newline sequence at the end of the line.
  3097.     /// If the count is zero, then the line was either wrapped or it is the
  3098.     /// end of the text.
  3099.     /// </summary>
  3100.     UINT32 newlineLength;
  3101.  
  3102.     /// <summary>
  3103.     /// Height of the line as measured from top to bottom.
  3104.     /// </summary>
  3105.     FLOAT height;
  3106.  
  3107.     /// <summary>
  3108.     /// Distance from the top of the line to its baseline.
  3109.     /// </summary>
  3110.     FLOAT baseline;
  3111.  
  3112.     /// <summary>
  3113.     /// The line is trimmed.
  3114.     /// </summary>
  3115.     BOOL isTrimmed;
  3116. };
  3117.  
  3118.  
  3119. /// <summary>
  3120. /// The DWRITE_CLUSTER_METRICS structure contains information about a glyph cluster.
  3121. /// </summary>
  3122. struct DWRITE_CLUSTER_METRICS
  3123. {
  3124.     /// <summary>
  3125.     /// The total advance width of all glyphs in the cluster.
  3126.     /// </summary>
  3127.     FLOAT width;
  3128.  
  3129.     /// <summary>
  3130.     /// The number of text positions in the cluster.
  3131.     /// </summary>
  3132.     UINT16 length;
  3133.  
  3134.     /// <summary>
  3135.     /// Indicate whether line can be broken right after the cluster.
  3136.     /// </summary>
  3137.     UINT16 canWrapLineAfter : 1;
  3138.  
  3139.     /// <summary>
  3140.     /// Indicate whether the cluster corresponds to whitespace character.
  3141.     /// </summary>
  3142.     UINT16 isWhitespace : 1;
  3143.  
  3144.     /// <summary>
  3145.     /// Indicate whether the cluster corresponds to a newline character.
  3146.     /// </summary>
  3147.     UINT16 isNewline : 1;
  3148.  
  3149.     /// <summary>
  3150.     /// Indicate whether the cluster corresponds to soft hyphen character.
  3151.     /// </summary>
  3152.     UINT16 isSoftHyphen : 1;
  3153.  
  3154.     /// <summary>
  3155.     /// Indicate whether the cluster is read from right to left.
  3156.     /// </summary>
  3157.     UINT16 isRightToLeft : 1;
  3158.  
  3159.     UINT16 padding : 11;
  3160. };
  3161.  
  3162.  
  3163. /// <summary>
  3164. /// Overall metrics associated with text after layout.
  3165. /// All coordinates are in device independent pixels (DIPs).
  3166. /// </summary>
  3167. struct DWRITE_TEXT_METRICS
  3168. {
  3169.     /// <summary>
  3170.     /// Left-most point of formatted text relative to layout box
  3171.     /// (excluding any glyph overhang).
  3172.     /// </summary>
  3173.     FLOAT left;
  3174.  
  3175.     /// <summary>
  3176.     /// Top-most point of formatted text relative to layout box
  3177.     /// (excluding any glyph overhang).
  3178.     /// </summary>
  3179.     FLOAT top;
  3180.  
  3181.     /// <summary>
  3182.     /// The width of the formatted text ignoring trailing whitespace
  3183.     /// at the end of each line.
  3184.     /// </summary>
  3185.     FLOAT width;
  3186.  
  3187.     /// <summary>
  3188.     /// The width of the formatted text taking into account the
  3189.     /// trailing whitespace at the end of each line.
  3190.     /// </summary>
  3191.     FLOAT widthIncludingTrailingWhitespace;
  3192.  
  3193.     /// <summary>
  3194.     /// The height of the formatted text. The height of an empty string
  3195.     /// is determined by the size of the default font's line height.
  3196.     /// </summary>
  3197.     FLOAT height;
  3198.  
  3199.     /// <summary>
  3200.     /// Initial width given to the layout. Depending on whether the text
  3201.     /// was wrapped or not, it can be either larger or smaller than the
  3202.     /// text content width.
  3203.     /// </summary>
  3204.     FLOAT layoutWidth;
  3205.  
  3206.     /// <summary>
  3207.     /// Initial height given to the layout. Depending on the length of the
  3208.     /// text, it may be larger or smaller than the text content height.
  3209.     /// </summary>
  3210.     FLOAT layoutHeight;
  3211.  
  3212.     /// <summary>
  3213.     /// The maximum reordering count of any line of text, used
  3214.     /// to calculate the most number of hit-testing boxes needed.
  3215.     /// If the layout has no bidirectional text or no text at all,
  3216.     /// the minimum level is 1.
  3217.     /// </summary>
  3218.     UINT32 maxBidiReorderingDepth;
  3219.  
  3220.     /// <summary>
  3221.     /// Total number of lines.
  3222.     /// </summary>
  3223.     UINT32 lineCount;
  3224. };
  3225.  
  3226.  
  3227. /// <summary>
  3228. /// Properties describing the geometric measurement of an
  3229. /// application-defined inline object.
  3230. /// </summary>
  3231. struct DWRITE_INLINE_OBJECT_METRICS
  3232. {
  3233.     /// <summary>
  3234.     /// Width of the inline object.
  3235.     /// </summary>
  3236.     FLOAT width;
  3237.  
  3238.     /// <summary>
  3239.     /// Height of the inline object as measured from top to bottom.
  3240.     /// </summary>
  3241.     FLOAT height;
  3242.  
  3243.     /// <summary>
  3244.     /// Distance from the top of the object to the baseline where it is lined up with the adjacent text.
  3245.     /// If the baseline is at the bottom, baseline simply equals height.
  3246.     /// </summary>
  3247.     FLOAT baseline;
  3248.  
  3249.     /// <summary>
  3250.     /// Flag indicating whether the object is to be placed upright or alongside the text baseline
  3251.     /// for vertical text.
  3252.     /// </summary>
  3253.     BOOL  supportsSideways;
  3254. };
  3255.  
  3256.  
  3257. /// <summary>
  3258. /// The DWRITE_OVERHANG_METRICS structure holds how much any visible pixels
  3259. /// (in DIPs) overshoot each side of the layout or inline objects.
  3260. /// </summary>
  3261. /// <remarks>
  3262. /// Positive overhangs indicate that the visible area extends outside the layout
  3263. /// box or inline object, while negative values mean there is whitespace inside.
  3264. /// The returned values are unaffected by rendering transforms or pixel snapping.
  3265. /// Additionally, they may not exactly match final target's pixel bounds after
  3266. /// applying grid fitting and hinting.
  3267. /// </remarks>
  3268. struct DWRITE_OVERHANG_METRICS
  3269. {
  3270.     /// <summary>
  3271.     /// The distance from the left-most visible DIP to its left alignment edge.
  3272.     /// </summary>
  3273.     FLOAT left;
  3274.  
  3275.     /// <summary>
  3276.     /// The distance from the top-most visible DIP to its top alignment edge.
  3277.     /// </summary>
  3278.     FLOAT top;
  3279.  
  3280.     /// <summary>
  3281.     /// The distance from the right-most visible DIP to its right alignment edge.
  3282.     /// </summary>
  3283.     FLOAT right;
  3284.  
  3285.     /// <summary>
  3286.     /// The distance from the bottom-most visible DIP to its bottom alignment edge.
  3287.     /// </summary>
  3288.     FLOAT bottom;
  3289. };
  3290.  
  3291.  
  3292. /// <summary>
  3293. /// Geometry enclosing of text positions.
  3294. /// </summary>
  3295. struct DWRITE_HIT_TEST_METRICS
  3296. {
  3297.     /// <summary>
  3298.     /// First text position within the geometry.
  3299.     /// </summary>
  3300.     UINT32 textPosition;
  3301.  
  3302.     /// <summary>
  3303.     /// Number of text positions within the geometry.
  3304.     /// </summary>
  3305.     UINT32 length;
  3306.  
  3307.     /// <summary>
  3308.     /// Left position of the top-left coordinate of the geometry.
  3309.     /// </summary>
  3310.     FLOAT left;
  3311.  
  3312.     /// <summary>
  3313.     /// Top position of the top-left coordinate of the geometry.
  3314.     /// </summary>
  3315.     FLOAT top;
  3316.  
  3317.     /// <summary>
  3318.     /// Geometry's width.
  3319.     /// </summary>
  3320.     FLOAT width;
  3321.  
  3322.     /// <summary>
  3323.     /// Geometry's height.
  3324.     /// </summary>
  3325.     FLOAT height;
  3326.  
  3327.     /// <summary>
  3328.     /// Bidi level of text positions enclosed within the geometry.
  3329.     /// </summary>
  3330.     UINT32 bidiLevel;
  3331.  
  3332.     /// <summary>
  3333.     /// Geometry encloses text?
  3334.     /// </summary>
  3335.     BOOL isText;
  3336.  
  3337.     /// <summary>
  3338.     /// Range is trimmed.
  3339.     /// </summary>
  3340.     BOOL isTrimmed;
  3341. };
  3342.  
  3343.  
  3344. interface IDWriteTextRenderer;
  3345.  
  3346.  
  3347. /// <summary>
  3348. /// The IDWriteInlineObject interface wraps an application defined inline graphic,
  3349. /// allowing DWrite to query metrics as if it was a glyph inline with the text.
  3350. /// </summary>
  3351. interface DWRITE_DECLARE_INTERFACE("8339FDE3-106F-47ab-8373-1C6295EB10B3") IDWriteInlineObject : public IUnknown
  3352. {
  3353.     /// <summary>
  3354.     /// The application implemented rendering callback (IDWriteTextRenderer::DrawInlineObject)
  3355.     /// can use this to draw the inline object without needing to cast or query the object
  3356.     /// type. The text layout does not call this method directly.
  3357.     /// </summary>
  3358.     /// <param name="clientDrawingContext">The context passed to IDWriteTextLayout::Draw.</param>
  3359.     /// <param name="renderer">The renderer passed to IDWriteTextLayout::Draw as the object's containing parent.</param>
  3360.     /// <param name="originX">X-coordinate at the top-left corner of the inline object.</param>
  3361.     /// <param name="originY">Y-coordinate at the top-left corner of the inline object.</param>
  3362.     /// <param name="isSideways">The object should be drawn on its side.</param>
  3363.     /// <param name="isRightToLeft">The object is in an right-to-left context and should be drawn flipped.</param>
  3364.     /// <param name="clientDrawingEffect">The drawing effect set in IDWriteTextLayout::SetDrawingEffect.</param>
  3365.     /// <returns>
  3366.     /// Standard HRESULT error code.
  3367.     /// </returns>
  3368.     STDMETHOD(Draw)(
  3369.         __maybenull void* clientDrawingContext,
  3370.         IDWriteTextRenderer* renderer,
  3371.         FLOAT originX,
  3372.         FLOAT originY,
  3373.         BOOL isSideways,
  3374.         BOOL isRightToLeft,
  3375.         __maybenull IUnknown* clientDrawingEffect
  3376.         ) PURE;
  3377.  
  3378.     /// <summary>
  3379.     /// TextLayout calls this callback function to get the measurement of the inline object.
  3380.     /// </summary>
  3381.     /// <param name="metrics">Returned metrics</param>
  3382.     /// <returns>
  3383.     /// Standard HRESULT error code.
  3384.     /// </returns>
  3385.     STDMETHOD(GetMetrics)(
  3386.         __out DWRITE_INLINE_OBJECT_METRICS* metrics
  3387.         ) PURE;
  3388.  
  3389.     /// <summary>
  3390.     /// TextLayout calls this callback function to get the visible extents (in DIPs) of the inline object.
  3391.     /// In the case of a simple bitmap, with no padding and no overhang, all the overhangs will
  3392.     /// simply be zeroes.
  3393.     /// </summary>
  3394.     /// <param name="overhangs">Overshoot of visible extents (in DIPs) outside the object.</param>
  3395.     /// <returns>
  3396.     /// Standard HRESULT error code.
  3397.     /// </returns>
  3398.     /// <remarks>
  3399.     /// The overhangs should be returned relative to the reported size of the object
  3400.     /// (DWRITE_INLINE_OBJECT_METRICS::width/height), and should not be baseline
  3401.     /// adjusted. If you have an image that is actually 100x100 DIPs, but you want it
  3402.     /// slightly inset (perhaps it has a glow) by 20 DIPs on each side, you would
  3403.     /// return a width/height of 60x60 and four overhangs of 20 DIPs.
  3404.     /// </remarks>
  3405.     STDMETHOD(GetOverhangMetrics)(
  3406.         __out DWRITE_OVERHANG_METRICS* overhangs
  3407.         ) PURE;
  3408.  
  3409.     /// <summary>
  3410.     /// Layout uses this to determine the line breaking behavior of the inline object
  3411.     /// amidst the text.
  3412.     /// </summary>
  3413.     /// <param name="breakConditionBefore">Line-breaking condition between the object and the content immediately preceding it.</param>
  3414.     /// <param name="breakConditionAfter" >Line-breaking condition between the object and the content immediately following it.</param>
  3415.     /// <returns>
  3416.     /// Standard HRESULT error code.
  3417.     /// </returns>
  3418.     STDMETHOD(GetBreakConditions)(
  3419.         __out DWRITE_BREAK_CONDITION* breakConditionBefore,
  3420.         __out DWRITE_BREAK_CONDITION* breakConditionAfter
  3421.         ) PURE;
  3422. };
  3423.  
  3424. /// <summary>
  3425. /// The IDWritePixelSnapping interface defines the pixel snapping properties of a text renderer.
  3426. /// </summary>
  3427. interface DWRITE_DECLARE_INTERFACE("eaf3a2da-ecf4-4d24-b644-b34f6842024b") IDWritePixelSnapping : public IUnknown
  3428. {
  3429.     /// <summary>
  3430.     /// Determines whether pixel snapping is disabled. The recommended default is FALSE,
  3431.     /// unless doing animation that requires subpixel vertical placement.
  3432.     /// </summary>
  3433.     /// <param name="clientDrawingContext">The context passed to IDWriteTextLayout::Draw.</param>
  3434.     /// <param name="isDisabled">Receives TRUE if pixel snapping is disabled or FALSE if it not.</param>
  3435.     /// <returns>
  3436.     /// Standard HRESULT error code.
  3437.     /// </returns>
  3438.     STDMETHOD(IsPixelSnappingDisabled)(
  3439.         __maybenull void* clientDrawingContext,
  3440.         __out BOOL* isDisabled
  3441.         ) PURE;
  3442.  
  3443.     /// <summary>
  3444.     /// Gets the current transform that maps abstract coordinates to DIPs,
  3445.     /// which may disable pixel snapping upon any rotation or shear.
  3446.     /// </summary>
  3447.     /// <param name="clientDrawingContext">The context passed to IDWriteTextLayout::Draw.</param>
  3448.     /// <param name="transform">Receives the transform.</param>
  3449.     /// <returns>
  3450.     /// Standard HRESULT error code.
  3451.     /// </returns>
  3452.     STDMETHOD(GetCurrentTransform)(
  3453.         __maybenull void* clientDrawingContext,
  3454.         __out DWRITE_MATRIX* transform
  3455.         ) PURE;
  3456.  
  3457.     /// <summary>
  3458.     /// Gets the number of physical pixels per DIP. A DIP (device-independent pixel) is 1/96 inch,
  3459.     /// so the pixelsPerDip value is the number of logical pixels per inch divided by 96 (yielding
  3460.     /// a value of 1 for 96 DPI and 1.25 for 120).
  3461.     /// </summary>
  3462.     /// <param name="clientDrawingContext">The context passed to IDWriteTextLayout::Draw.</param>
  3463.     /// <param name="pixelsPerDip">Receives the number of physical pixels per DIP.</param>
  3464.     /// <returns>
  3465.     /// Standard HRESULT error code.
  3466.     /// </returns>
  3467.     STDMETHOD(GetPixelsPerDip)(
  3468.         __maybenull void* clientDrawingContext,
  3469.         __out FLOAT* pixelsPerDip
  3470.         ) PURE;
  3471. };
  3472.  
  3473. /// <summary>
  3474. /// The IDWriteTextLayout interface represents a set of application-defined
  3475. /// callbacks that perform rendering of text, inline objects, and decorations
  3476. /// such as underlines.
  3477. /// </summary>
  3478. interface DWRITE_DECLARE_INTERFACE("ef8a8135-5cc6-45fe-8825-c5a0724eb819") IDWriteTextRenderer : public IDWritePixelSnapping
  3479. {
  3480.     /// <summary>
  3481.     /// IDWriteTextLayout::Draw calls this function to instruct the client to
  3482.     /// render a run of glyphs.
  3483.     /// </summary>
  3484.     /// <param name="clientDrawingContext">The context passed to
  3485.     /// IDWriteTextLayout::Draw.</param>
  3486.     /// <param name="baselineOriginX">X-coordinate of the baseline.</param>
  3487.     /// <param name="baselineOriginY">Y-coordinate of the baseline.</param>
  3488.     /// <param name="measuringMode">Specifies measuring method for glyphs in the run.
  3489.     /// Renderer implementations may choose different rendering modes for given measuring methods,
  3490.     /// but best results are seen when the rendering mode matches the corresponding measuring mode:
  3491.     /// DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL for DWRITE_MEASURING_MODE_NATURAL
  3492.     /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC for DWRITE_MEASURING_MODE_GDI_CLASSIC
  3493.     /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL for DWRITE_MEASURING_MODE_GDI_NATURAL
  3494.     /// </param>
  3495.     /// <param name="glyphRun">The glyph run to draw.</param>
  3496.     /// <param name="glyphRunDescription">Properties of the characters
  3497.     /// associated with this run.</param>
  3498.     /// <param name="clientDrawingEffect">The drawing effect set in
  3499.     /// IDWriteTextLayout::SetDrawingEffect.</param>
  3500.     /// <returns>
  3501.     /// Standard HRESULT error code.
  3502.     /// </returns>
  3503.     STDMETHOD(DrawGlyphRun)(
  3504.         __maybenull void* clientDrawingContext,
  3505.         FLOAT baselineOriginX,
  3506.         FLOAT baselineOriginY,
  3507.         DWRITE_MEASURING_MODE measuringMode,
  3508.         __in DWRITE_GLYPH_RUN const* glyphRun,
  3509.         __in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
  3510.         __maybenull IUnknown* clientDrawingEffect
  3511.         ) PURE;
  3512.  
  3513.     /// <summary>
  3514.     /// IDWriteTextLayout::Draw calls this function to instruct the client to draw
  3515.     /// an underline.
  3516.     /// </summary>
  3517.     /// <param name="clientDrawingContext">The context passed to
  3518.     /// IDWriteTextLayout::Draw.</param>
  3519.     /// <param name="baselineOriginX">X-coordinate of the baseline.</param>
  3520.     /// <param name="baselineOriginY">Y-coordinate of the baseline.</param>
  3521.     /// <param name="underline">Underline logical information.</param>
  3522.     /// <param name="clientDrawingEffect">The drawing effect set in
  3523.     /// IDWriteTextLayout::SetDrawingEffect.</param>
  3524.     /// <returns>
  3525.     /// Standard HRESULT error code.
  3526.     /// </returns>
  3527.     /// <remarks>
  3528.     /// A single underline can be broken into multiple calls, depending on
  3529.     /// how the formatting changes attributes. If font sizes/styles change
  3530.     /// within an underline, the thickness and offset will be averaged
  3531.     /// weighted according to characters.
  3532.     /// To get the correct top coordinate of the underline rect, add underline::offset
  3533.     /// to the baseline's Y. Otherwise the underline will be immediately under the text.
  3534.     /// The x coordinate will always be passed as the left side, regardless
  3535.     /// of text directionality. This simplifies drawing and reduces the
  3536.     /// problem of round-off that could potentially cause gaps or a double
  3537.     /// stamped alpha blend. To avoid alpha overlap, round the end points
  3538.     /// to the nearest device pixel.
  3539.     /// </remarks>
  3540.     STDMETHOD(DrawUnderline)(
  3541.         __maybenull void* clientDrawingContext,
  3542.         FLOAT baselineOriginX,
  3543.         FLOAT baselineOriginY,
  3544.         __in DWRITE_UNDERLINE const* underline,
  3545.         __maybenull IUnknown* clientDrawingEffect
  3546.         ) PURE;
  3547.  
  3548.     /// <summary>
  3549.     /// IDWriteTextLayout::Draw calls this function to instruct the client to draw
  3550.     /// a strikethrough.
  3551.     /// </summary>
  3552.     /// <param name="clientDrawingContext">The context passed to
  3553.     /// IDWriteTextLayout::Draw.</param>
  3554.     /// <param name="baselineOriginX">X-coordinate of the baseline.</param>
  3555.     /// <param name="baselineOriginY">Y-coordinate of the baseline.</param>
  3556.     /// <param name="strikethrough">Strikethrough logical information.</param>
  3557.     /// <param name="clientDrawingEffect">The drawing effect set in
  3558.     /// IDWriteTextLayout::SetDrawingEffect.</param>
  3559.     /// <returns>
  3560.     /// Standard HRESULT error code.
  3561.     /// </returns>
  3562.     /// <remarks>
  3563.     /// A single strikethrough can be broken into multiple calls, depending on
  3564.     /// how the formatting changes attributes. Strikethrough is not averaged
  3565.     /// across font sizes/styles changes.
  3566.     /// To get the correct top coordinate of the strikethrough rect,
  3567.     /// add strikethrough::offset to the baseline's Y.
  3568.     /// Like underlines, the x coordinate will always be passed as the left side,
  3569.     /// regardless of text directionality.
  3570.     /// </remarks>
  3571.     STDMETHOD(DrawStrikethrough)(
  3572.         __maybenull void* clientDrawingContext,
  3573.         FLOAT baselineOriginX,
  3574.         FLOAT baselineOriginY,
  3575.         __in DWRITE_STRIKETHROUGH const* strikethrough,
  3576.         __maybenull IUnknown* clientDrawingEffect
  3577.         ) PURE;
  3578.  
  3579.     /// <summary>
  3580.     /// IDWriteTextLayout::Draw calls this application callback when it needs to
  3581.     /// draw an inline object.
  3582.     /// </summary>
  3583.     /// <param name="clientDrawingContext">The context passed to IDWriteTextLayout::Draw.</param>
  3584.     /// <param name="originX">X-coordinate at the top-left corner of the inline object.</param>
  3585.     /// <param name="originY">Y-coordinate at the top-left corner of the inline object.</param>
  3586.     /// <param name="inlineObject">The object set using IDWriteTextLayout::SetInlineObject.</param>
  3587.     /// <param name="isSideways">The object should be drawn on its side.</param>
  3588.     /// <param name="isRightToLeft">The object is in an right-to-left context and should be drawn flipped.</param>
  3589.     /// <param name="clientDrawingEffect">The drawing effect set in
  3590.     /// IDWriteTextLayout::SetDrawingEffect.</param>
  3591.     /// <returns>
  3592.     /// Standard HRESULT error code.
  3593.     /// </returns>
  3594.     /// <remarks>
  3595.     /// The right-to-left flag is a hint for those cases where it would look
  3596.     /// strange for the image to be shown normally (like an arrow pointing to
  3597.     /// right to indicate a submenu).
  3598.     /// </remarks>
  3599.     STDMETHOD(DrawInlineObject)(
  3600.         __maybenull void* clientDrawingContext,
  3601.         FLOAT originX,
  3602.         FLOAT originY,
  3603.         IDWriteInlineObject* inlineObject,
  3604.         BOOL isSideways,
  3605.         BOOL isRightToLeft,
  3606.         __maybenull IUnknown* clientDrawingEffect
  3607.         ) PURE;
  3608. };
  3609.  
  3610. /// <summary>
  3611. /// The IDWriteTextLayout interface represents a block of text after it has
  3612. /// been fully analyzed and formatted.
  3613. ///
  3614. /// All coordinates are in device independent pixels (DIPs).
  3615. /// </summary>
  3616. interface DWRITE_DECLARE_INTERFACE("53737037-6d14-410b-9bfe-0b182bb70961") IDWriteTextLayout : public IDWriteTextFormat
  3617. {
  3618.     /// <summary>
  3619.     /// Set layout maximum width
  3620.     /// </summary>
  3621.     /// <param name="maxWidth">Layout maximum width</param>
  3622.     /// <returns>
  3623.     /// Standard HRESULT error code.
  3624.     /// </returns>
  3625.     STDMETHOD(SetMaxWidth)(
  3626.         FLOAT maxWidth
  3627.         ) PURE;
  3628.  
  3629.     /// <summary>
  3630.     /// Set layout maximum height
  3631.     /// </summary>
  3632.     /// <param name="maxHeight">Layout maximum height</param>
  3633.     /// <returns>
  3634.     /// Standard HRESULT error code.
  3635.     /// </returns>
  3636.     STDMETHOD(SetMaxHeight)(
  3637.         FLOAT maxHeight
  3638.         ) PURE;
  3639.  
  3640.     /// <summary>
  3641.     /// Set the font collection.
  3642.     /// </summary>
  3643.     /// <param name="fontCollection">The font collection to set</param>
  3644.     /// <param name="textRange">Text range to which this change applies.</param>
  3645.     /// <returns>
  3646.     /// Standard HRESULT error code.
  3647.     /// </returns>
  3648.     STDMETHOD(SetFontCollection)(
  3649.         IDWriteFontCollection* fontCollection,
  3650.         DWRITE_TEXT_RANGE textRange
  3651.         ) PURE;
  3652.  
  3653.     /// <summary>
  3654.     /// Set null-terminated font family name.
  3655.     /// </summary>
  3656.     /// <param name="fontFamilyName">Font family name</param>
  3657.     /// <param name="textRange">Text range to which this change applies.</param>
  3658.     /// <returns>
  3659.     /// Standard HRESULT error code.
  3660.     /// </returns>
  3661.     STDMETHOD(SetFontFamilyName)(
  3662.         __in_z WCHAR const* fontFamilyName,
  3663.         DWRITE_TEXT_RANGE textRange
  3664.         ) PURE;
  3665.  
  3666.     /// <summary>
  3667.     /// Set font weight.
  3668.     /// </summary>
  3669.     /// <param name="fontWeight">Font weight</param>
  3670.     /// <param name="textRange">Text range to which this change applies.</param>
  3671.     /// <returns>
  3672.     /// Standard HRESULT error code.
  3673.     /// </returns>
  3674.     STDMETHOD(SetFontWeight)(
  3675.         DWRITE_FONT_WEIGHT fontWeight,
  3676.         DWRITE_TEXT_RANGE textRange
  3677.         ) PURE;
  3678.  
  3679.     /// <summary>
  3680.     /// Set font style.
  3681.     /// </summary>
  3682.     /// <param name="fontStyle">Font style</param>
  3683.     /// <param name="textRange">Text range to which this change applies.</param>
  3684.     /// <returns>
  3685.     /// Standard HRESULT error code.
  3686.     /// </returns>
  3687.     STDMETHOD(SetFontStyle)(
  3688.         DWRITE_FONT_STYLE fontStyle,
  3689.         DWRITE_TEXT_RANGE textRange
  3690.         ) PURE;
  3691.  
  3692.     /// <summary>
  3693.     /// Set font stretch.
  3694.     /// </summary>
  3695.     /// <param name="fontStretch">font stretch</param>
  3696.     /// <param name="textRange">Text range to which this change applies.</param>
  3697.     /// <returns>
  3698.     /// Standard HRESULT error code.
  3699.     /// </returns>
  3700.     STDMETHOD(SetFontStretch)(
  3701.         DWRITE_FONT_STRETCH fontStretch,
  3702.         DWRITE_TEXT_RANGE textRange
  3703.         ) PURE;
  3704.  
  3705.     /// <summary>
  3706.     /// Set font em height.
  3707.     /// </summary>
  3708.     /// <param name="fontSize">Font em height</param>
  3709.     /// <param name="textRange">Text range to which this change applies.</param>
  3710.     /// <returns>
  3711.     /// Standard HRESULT error code.
  3712.     /// </returns>
  3713.     STDMETHOD(SetFontSize)(
  3714.         FLOAT fontSize,
  3715.         DWRITE_TEXT_RANGE textRange
  3716.         ) PURE;
  3717.  
  3718.     /// <summary>
  3719.     /// Set underline.
  3720.     /// </summary>
  3721.     /// <param name="hasUnderline">The Boolean flag indicates whether underline takes place</param>
  3722.     /// <param name="textRange">Text range to which this change applies.</param>
  3723.     /// <returns>
  3724.     /// Standard HRESULT error code.
  3725.     /// </returns>
  3726.     STDMETHOD(SetUnderline)(
  3727.         BOOL hasUnderline,
  3728.         DWRITE_TEXT_RANGE textRange
  3729.         ) PURE;
  3730.  
  3731.     /// <summary>
  3732.     /// Set strikethrough.
  3733.     /// </summary>
  3734.     /// <param name="hasStrikethrough">The Boolean flag indicates whether strikethrough takes place</param>
  3735.     /// <param name="textRange">Text range to which this change applies.</param>
  3736.     /// <returns>
  3737.     /// Standard HRESULT error code.
  3738.     /// </returns>
  3739.     STDMETHOD(SetStrikethrough)(
  3740.         BOOL hasStrikethrough,
  3741.         DWRITE_TEXT_RANGE textRange
  3742.         ) PURE;
  3743.  
  3744.     /// <summary>
  3745.     /// Set application-defined drawing effect.
  3746.     /// </summary>
  3747.     /// <param name="drawingEffect">Pointer to an application-defined drawing effect.</param>
  3748.     /// <param name="textRange">Text range to which this change applies.</param>
  3749.     /// <returns>
  3750.     /// Standard HRESULT error code.
  3751.     /// </returns>
  3752.     /// <remarks>
  3753.     /// This drawing effect is associated with the specified range and will be passed back
  3754.     /// to the application via the callback when the range is drawn at drawing time.
  3755.     /// </remarks>
  3756.     STDMETHOD(SetDrawingEffect)(
  3757.         IUnknown* drawingEffect,
  3758.         DWRITE_TEXT_RANGE textRange
  3759.         ) PURE;
  3760.  
  3761.     /// <summary>
  3762.     /// Set inline object.
  3763.     /// </summary>
  3764.     /// <param name="inlineObject">Pointer to an application-implemented inline object.</param>
  3765.     /// <param name="textRange">Text range to which this change applies.</param>
  3766.     /// <returns>
  3767.     /// Standard HRESULT error code.
  3768.     /// </returns>
  3769.     /// <remarks>
  3770.     /// This inline object applies to the specified range and will be passed back
  3771.     /// to the application via the DrawInlineObject callback when the range is drawn.
  3772.     /// Any text in that range will be suppressed.
  3773.     /// </remarks>
  3774.     STDMETHOD(SetInlineObject)(
  3775.         IDWriteInlineObject* inlineObject,
  3776.         DWRITE_TEXT_RANGE textRange
  3777.         ) PURE;
  3778.  
  3779.     /// <summary>
  3780.     /// Set font typography features.
  3781.     /// </summary>
  3782.     /// <param name="typography">Pointer to font typography setting.</param>
  3783.     /// <param name="textRange">Text range to which this change applies.</param>
  3784.     /// <returns>
  3785.     /// Standard HRESULT error code.
  3786.     /// </returns>
  3787.     STDMETHOD(SetTypography)(
  3788.         IDWriteTypography* typography,
  3789.         DWRITE_TEXT_RANGE textRange
  3790.         ) PURE;
  3791.  
  3792.     /// <summary>
  3793.     /// Set locale name.
  3794.     /// </summary>
  3795.     /// <param name="localeName">Locale name</param>
  3796.     /// <param name="textRange">Text range to which this change applies.</param>
  3797.     /// <returns>
  3798.     /// Standard HRESULT error code.
  3799.     /// </returns>
  3800.     STDMETHOD(SetLocaleName)(
  3801.         __in_z WCHAR const* localeName,
  3802.         DWRITE_TEXT_RANGE textRange
  3803.         ) PURE;
  3804.  
  3805.     /// <summary>
  3806.     /// Get layout maximum width
  3807.     /// </summary>
  3808.     STDMETHOD_(FLOAT, GetMaxWidth)() PURE;
  3809.  
  3810.     /// <summary>
  3811.     /// Get layout maximum height
  3812.     /// </summary>
  3813.     STDMETHOD_(FLOAT, GetMaxHeight)() PURE;
  3814.  
  3815.     /// <summary>
  3816.     /// Get the font collection where the current position is at.
  3817.     /// </summary>
  3818.     /// <param name="currentPosition">The current text position.</param>
  3819.     /// <param name="fontCollection">The current font collection</param>
  3820.     /// <param name="textRange">Text range to which this change applies.</param>
  3821.     /// <returns>
  3822.     /// Standard HRESULT error code.
  3823.     /// </returns>
  3824.     STDMETHOD(GetFontCollection)(
  3825.         UINT32 currentPosition,
  3826.         __out IDWriteFontCollection** fontCollection,
  3827.         __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3828.         ) PURE;
  3829.  
  3830.     /// <summary>
  3831.     /// Get the length of the font family name where the current position is at.
  3832.     /// </summary>
  3833.     /// <param name="currentPosition">The current text position.</param>
  3834.     /// <param name="nameLength">Size of the character array in character count not including the terminated NULL character.</param>
  3835.     /// <param name="textRange">The position range of the current format.</param>
  3836.     /// <returns>
  3837.     /// Standard HRESULT error code.
  3838.     /// </returns>
  3839.     STDMETHOD(GetFontFamilyNameLength)(
  3840.         UINT32 currentPosition,
  3841.         __out UINT32* nameLength,
  3842.         __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3843.         ) PURE;
  3844.  
  3845.     /// <summary>
  3846.     /// Copy the font family name where the current position is at.
  3847.     /// </summary>
  3848.     /// <param name="currentPosition">The current text position.</param>
  3849.     /// <param name="fontFamilyName">Character array that receives the current font family name</param>
  3850.     /// <param name="nameSize">Size of the character array in character count including the terminated NULL character.</param>
  3851.     /// <param name="textRange">The position range of the current format.</param>
  3852.     /// <returns>
  3853.     /// Standard HRESULT error code.
  3854.     /// </returns>
  3855.     STDMETHOD(GetFontFamilyName)(
  3856.         UINT32 currentPosition,
  3857.         __out_ecount_z(nameSize) WCHAR* fontFamilyName,
  3858.         UINT32 nameSize,
  3859.         __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3860.         ) PURE;
  3861.  
  3862.     /// <summary>
  3863.     /// Get the font weight where the current position is at.
  3864.     /// </summary>
  3865.     /// <param name="currentPosition">The current text position.</param>
  3866.     /// <param name="fontWeight">The current font weight</param>
  3867.     /// <param name="textRange">The position range of the current format.</param>
  3868.     /// <returns>
  3869.     /// Standard HRESULT error code.
  3870.     /// </returns>
  3871.     STDMETHOD(GetFontWeight)(
  3872.         UINT32 currentPosition,
  3873.         __out DWRITE_FONT_WEIGHT* fontWeight,
  3874.         __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3875.         ) PURE;
  3876.  
  3877.     /// <summary>
  3878.     /// Get the font style where the current position is at.
  3879.     /// </summary>
  3880.     /// <param name="currentPosition">The current text position.</param>
  3881.     /// <param name="fontStyle">The current font style</param>
  3882.     /// <param name="textRange">The position range of the current format.</param>
  3883.     /// <returns>
  3884.     /// Standard HRESULT error code.
  3885.     /// </returns>
  3886.     STDMETHOD(GetFontStyle)(
  3887.         UINT32 currentPosition,
  3888.         __out DWRITE_FONT_STYLE* fontStyle,
  3889.         __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3890.         ) PURE;
  3891.  
  3892.     /// <summary>
  3893.     /// Get the font stretch where the current position is at.
  3894.     /// </summary>
  3895.     /// <param name="currentPosition">The current text position.</param>
  3896.     /// <param name="fontStretch">The current font stretch</param>
  3897.     /// <param name="textRange">The position range of the current format.</param>
  3898.     /// <returns>
  3899.     /// Standard HRESULT error code.
  3900.     /// </returns>
  3901.     STDMETHOD(GetFontStretch)(
  3902.         UINT32 currentPosition,
  3903.         __out DWRITE_FONT_STRETCH* fontStretch,
  3904.         __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3905.         ) PURE;
  3906.  
  3907.     /// <summary>
  3908.     /// Get the font em height where the current position is at.
  3909.     /// </summary>
  3910.     /// <param name="currentPosition">The current text position.</param>
  3911.     /// <param name="fontSize">The current font em height</param>
  3912.     /// <param name="textRange">The position range of the current format.</param>
  3913.     /// <returns>
  3914.     /// Standard HRESULT error code.
  3915.     /// </returns>
  3916.     STDMETHOD(GetFontSize)(
  3917.         UINT32 currentPosition,
  3918.         __out FLOAT* fontSize,
  3919.         __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3920.         ) PURE;
  3921.  
  3922.     /// <summary>
  3923.     /// Get the underline presence where the current position is at.
  3924.     /// </summary>
  3925.     /// <param name="currentPosition">The current text position.</param>
  3926.     /// <param name="hasUnderline">The Boolean flag indicates whether text is underlined.</param>
  3927.     /// <param name="textRange">The position range of the current format.</param>
  3928.     /// <returns>
  3929.     /// Standard HRESULT error code.
  3930.     /// </returns>
  3931.     STDMETHOD(GetUnderline)(
  3932.         UINT32 currentPosition,
  3933.         __out BOOL* hasUnderline,
  3934.         __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3935.         ) PURE;
  3936.  
  3937.     /// <summary>
  3938.     /// Get the strikethrough presence where the current position is at.
  3939.     /// </summary>
  3940.     /// <param name="currentPosition">The current text position.</param>
  3941.     /// <param name="hasStrikethrough">The Boolean flag indicates whether text has strikethrough.</param>
  3942.     /// <param name="textRange">The position range of the current format.</param>
  3943.     /// <returns>
  3944.     /// Standard HRESULT error code.
  3945.     /// </returns>
  3946.     STDMETHOD(GetStrikethrough)(
  3947.         UINT32 currentPosition,
  3948.         __out BOOL* hasStrikethrough,
  3949.         __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3950.         ) PURE;
  3951.  
  3952.     /// <summary>
  3953.     /// Get the application-defined drawing effect where the current position is at.
  3954.     /// </summary>
  3955.     /// <param name="currentPosition">The current text position.</param>
  3956.     /// <param name="drawingEffect">The current application-defined drawing effect.</param>
  3957.     /// <param name="textRange">The position range of the current format.</param>
  3958.     /// <returns>
  3959.     /// Standard HRESULT error code.
  3960.     /// </returns>
  3961.     STDMETHOD(GetDrawingEffect)(
  3962.         UINT32 currentPosition,
  3963.         __out IUnknown** drawingEffect,
  3964.         __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3965.         ) PURE;
  3966.  
  3967.     /// <summary>
  3968.     /// Get the inline object at the given position.
  3969.     /// </summary>
  3970.     /// <param name="currentPosition">The given text position.</param>
  3971.     /// <param name="inlineObject">The inline object.</param>
  3972.     /// <param name="textRange">The position range of the current format.</param>
  3973.     /// <returns>
  3974.     /// Standard HRESULT error code.
  3975.     /// </returns>
  3976.     STDMETHOD(GetInlineObject)(
  3977.         UINT32 currentPosition,
  3978.         __out IDWriteInlineObject** inlineObject,
  3979.         __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3980.         ) PURE;
  3981.  
  3982.     /// <summary>
  3983.     /// Get the typography setting where the current position is at.
  3984.     /// </summary>
  3985.     /// <param name="currentPosition">The current text position.</param>
  3986.     /// <param name="typography">The current typography setting.</param>
  3987.     /// <param name="textRange">The position range of the current format.</param>
  3988.     /// <returns>
  3989.     /// Standard HRESULT error code.
  3990.     /// </returns>
  3991.     STDMETHOD(GetTypography)(
  3992.         UINT32 currentPosition,
  3993.         __out IDWriteTypography** typography,
  3994.         __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3995.         ) PURE;
  3996.  
  3997.     /// <summary>
  3998.     /// Get the length of the locale name where the current position is at.
  3999.     /// </summary>
  4000.     /// <param name="currentPosition">The current text position.</param>
  4001.     /// <param name="nameLength">Size of the character array in character count not including the terminated NULL character.</param>
  4002.     /// <param name="textRange">The position range of the current format.</param>
  4003.     /// <returns>
  4004.     /// Standard HRESULT error code.
  4005.     /// </returns>
  4006.     STDMETHOD(GetLocaleNameLength)(
  4007.         UINT32 currentPosition,
  4008.         __out UINT32* nameLength,
  4009.         __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  4010.         ) PURE;
  4011.  
  4012.     /// <summary>
  4013.     /// Get the locale name where the current position is at.
  4014.     /// </summary>
  4015.     /// <param name="currentPosition">The current text position.</param>
  4016.     /// <param name="localeName">Character array that receives the current locale name</param>
  4017.     /// <param name="nameSize">Size of the character array in character count including the terminated NULL character.</param>
  4018.     /// <param name="textRange">The position range of the current format.</param>
  4019.     /// <returns>
  4020.     /// Standard HRESULT error code.
  4021.     /// </returns>
  4022.     STDMETHOD(GetLocaleName)(
  4023.         UINT32 currentPosition,
  4024.         __out_ecount_z(nameSize) WCHAR* localeName,
  4025.         UINT32 nameSize,
  4026.         __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  4027.         ) PURE;
  4028.  
  4029.     /// <summary>
  4030.     /// Initiate drawing of the text.
  4031.     /// </summary>
  4032.     /// <param name="clientDrawingContext">An application defined value
  4033.     /// included in rendering callbacks.</param>
  4034.     /// <param name="renderer">The set of application-defined callbacks that do
  4035.     /// the actual rendering.</param>
  4036.     /// <param name="originX">X-coordinate of the layout's left side.</param>
  4037.     /// <param name="originY">Y-coordinate of the layout's top side.</param>
  4038.     /// <returns>
  4039.     /// Standard HRESULT error code.
  4040.     /// </returns>
  4041.     STDMETHOD(Draw)(
  4042.         __maybenull void* clientDrawingContext,
  4043.         IDWriteTextRenderer* renderer,
  4044.         FLOAT originX,
  4045.         FLOAT originY
  4046.         ) PURE;
  4047.  
  4048.     /// <summary>
  4049.     /// GetLineMetrics returns properties of each line.
  4050.     /// </summary>
  4051.     /// <param name="lineMetrics">The array to fill with line information.</param>
  4052.     /// <param name="maxLineCount">The maximum size of the lineMetrics array.</param>
  4053.     /// <param name="actualLineCount">The actual size of the lineMetrics
  4054.     /// array that is needed.</param>
  4055.     /// <returns>
  4056.     /// Standard HRESULT error code.
  4057.     /// </returns>
  4058.     /// <remarks>
  4059.     /// If maxLineCount is not large enough E_NOT_SUFFICIENT_BUFFER,
  4060.     /// which is equivalent to HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),
  4061.     /// is returned and *actualLineCount is set to the number of lines
  4062.     /// needed.
  4063.     /// </remarks>
  4064.     STDMETHOD(GetLineMetrics)(
  4065.         __out_ecount_opt(maxLineCount) DWRITE_LINE_METRICS* lineMetrics,
  4066.         UINT32 maxLineCount,
  4067.         __out UINT32* actualLineCount
  4068.         ) PURE;
  4069.  
  4070.     /// <summary>
  4071.     /// GetMetrics retrieves overall metrics for the formatted string.
  4072.     /// </summary>
  4073.     /// <param name="textMetrics">The returned metrics.</param>
  4074.     /// <returns>
  4075.     /// Standard HRESULT error code.
  4076.     /// </returns>
  4077.     /// <remarks>
  4078.     /// Drawing effects like underline and strikethrough do not contribute
  4079.     /// to the text size, which is essentially the sum of advance widths and
  4080.     /// line heights. Additionally, visible swashes and other graphic
  4081.     /// adornments may extend outside the returned width and height.
  4082.     /// </remarks>
  4083.     STDMETHOD(GetMetrics)(
  4084.         __out DWRITE_TEXT_METRICS* textMetrics
  4085.         ) PURE;
  4086.  
  4087.     /// <summary>
  4088.     /// GetOverhangMetrics returns the overhangs (in DIPs) of the layout and all
  4089.     /// objects contained in it, including text glyphs and inline objects.
  4090.     /// </summary>
  4091.     /// <param name="overhangs">Overshoots of visible extents (in DIPs) outside the layout.</param>
  4092.     /// <returns>
  4093.     /// Standard HRESULT error code.
  4094.     /// </returns>
  4095.     /// <remarks>
  4096.     /// Any underline and strikethrough do not contribute to the black box
  4097.     /// determination, since these are actually drawn by the renderer, which
  4098.     /// is allowed to draw them in any variety of styles.
  4099.     /// </remarks>
  4100.     STDMETHOD(GetOverhangMetrics)(
  4101.         __out DWRITE_OVERHANG_METRICS* overhangs
  4102.         ) PURE;
  4103.  
  4104.     /// <summary>
  4105.     /// Retrieve logical properties and measurement of each cluster.
  4106.     /// </summary>
  4107.     /// <param name="clusterMetrics">The array to fill with cluster information.</param>
  4108.     /// <param name="maxClusterCount">The maximum size of the clusterMetrics array.</param>
  4109.     /// <param name="actualClusterCount">The actual size of the clusterMetrics array that is needed.</param>
  4110.     /// <returns>
  4111.     /// Standard HRESULT error code.
  4112.     /// </returns>
  4113.     /// <remarks>
  4114.     /// If maxClusterCount is not large enough E_NOT_SUFFICIENT_BUFFER,
  4115.     /// which is equivalent to HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),
  4116.     /// is returned and *actualClusterCount is set to the number of clusters
  4117.     /// needed.
  4118.     /// </remarks>
  4119.     STDMETHOD(GetClusterMetrics)(
  4120.         __out_ecount_opt(maxClusterCount) DWRITE_CLUSTER_METRICS* clusterMetrics,
  4121.         UINT32 maxClusterCount,
  4122.         __out UINT32* actualClusterCount
  4123.         ) PURE;
  4124.  
  4125.     /// <summary>
  4126.     /// Determines the minimum possible width the layout can be set to without
  4127.     /// emergency breaking between the characters of whole words.
  4128.     /// </summary>
  4129.     /// <param name="minWidth">Minimum width.</param>
  4130.     /// <returns>
  4131.     /// Standard HRESULT error code.
  4132.     /// </returns>
  4133.     STDMETHOD(DetermineMinWidth)(
  4134.         __out FLOAT* minWidth
  4135.         ) PURE;
  4136.  
  4137.     /// <summary>
  4138.     /// Given a coordinate (in DIPs) relative to the top-left of the layout box,
  4139.     /// this returns the corresponding hit-test metrics of the text string where
  4140.     /// the hit-test has occurred. This is useful for mapping mouse clicks to caret
  4141.     /// positions. When the given coordinate is outside the text string, the function
  4142.     /// sets the output value *isInside to false but returns the nearest character
  4143.     /// position.
  4144.     /// </summary>
  4145.     /// <param name="pointX">X coordinate to hit-test, relative to the top-left location of the layout box.</param>
  4146.     /// <param name="pointY">Y coordinate to hit-test, relative to the top-left location of the layout box.</param>
  4147.     /// <param name="isTrailingHit">Output flag indicating whether the hit-test location is at the leading or the trailing
  4148.     ///     side of the character. When the output *isInside value is set to false, this value is set according to the output
  4149.     ///     *position value to represent the edge closest to the hit-test location. </param>
  4150.     /// <param name="isInside">Output flag indicating whether the hit-test location is inside the text string.
  4151.     ///     When false, the position nearest the text's edge is returned.</param>
  4152.     /// <param name="hitTestMetrics">Output geometry fully enclosing the hit-test location. When the output *isInside value
  4153.     ///     is set to false, this structure represents the geometry enclosing the edge closest to the hit-test location.</param>
  4154.     /// <returns>
  4155.     /// Standard HRESULT error code.
  4156.     /// </returns>
  4157.     STDMETHOD(HitTestPoint)(
  4158.         FLOAT pointX,
  4159.         FLOAT pointY,
  4160.         __out BOOL* isTrailingHit,
  4161.         __out BOOL* isInside,
  4162.         __out DWRITE_HIT_TEST_METRICS* hitTestMetrics
  4163.         ) PURE;
  4164.  
  4165.     /// <summary>
  4166.     /// Given a text position and whether the caret is on the leading or trailing
  4167.     /// edge of that position, this returns the corresponding coordinate (in DIPs)
  4168.     /// relative to the top-left of the layout box. This is most useful for drawing
  4169.     /// the caret's current position, but it could also be used to anchor an IME to the
  4170.     /// typed text or attach a floating menu near the point of interest. It may also be
  4171.     /// used to programmatically obtain the geometry of a particular text position
  4172.     /// for UI automation.
  4173.     /// </summary>
  4174.     /// <param name="textPosition">Text position to get the coordinate of.</param>
  4175.     /// <param name="isTrailingHit">Flag indicating whether the location is of the leading or the trailing side of the specified text position. </param>
  4176.     /// <param name="pointX">Output caret X, relative to the top-left of the layout box.</param>
  4177.     /// <param name="pointY">Output caret Y, relative to the top-left of the layout box.</param>
  4178.     /// <param name="hitTestMetrics">Output geometry fully enclosing the specified text position.</param>
  4179.     /// <returns>
  4180.     /// Standard HRESULT error code.
  4181.     /// </returns>
  4182.     /// <remarks>
  4183.     /// When drawing a caret at the returned X,Y, it should should be centered on X
  4184.     /// and drawn from the Y coordinate down. The height will be the size of the
  4185.     /// hit-tested text (which can vary in size within a line).
  4186.     /// Reading direction also affects which side of the character the caret is drawn.
  4187.     /// However, the returned X coordinate will be correct for either case.
  4188.     /// You can get a text length back that is larger than a single character.
  4189.     /// This happens for complex scripts when multiple characters form a single cluster,
  4190.     /// when diacritics join their base character, or when you test a surrogate pair.
  4191.     /// </remarks>
  4192.     STDMETHOD(HitTestTextPosition)(
  4193.         UINT32 textPosition,
  4194.         BOOL isTrailingHit,
  4195.         __out FLOAT* pointX,
  4196.         __out FLOAT* pointY,
  4197.         __out DWRITE_HIT_TEST_METRICS* hitTestMetrics
  4198.         ) PURE;
  4199.  
  4200.     /// <summary>
  4201.     /// The application calls this function to get a set of hit-test metrics
  4202.     /// corresponding to a range of text positions. The main usage for this
  4203.     /// is to draw highlighted selection of the text string.
  4204.     ///
  4205.     /// The function returns E_NOT_SUFFICIENT_BUFFER, which is equivalent to
  4206.     /// HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), when the buffer size of
  4207.     /// hitTestMetrics is too small to hold all the regions calculated by the
  4208.     /// function. In such situation, the function sets the output value
  4209.     /// *actualHitTestMetricsCount to the number of geometries calculated.
  4210.     /// The application is responsible to allocate a new buffer of greater
  4211.     /// size and call the function again.
  4212.     ///
  4213.     /// A good value to use as an initial value for maxHitTestMetricsCount may
  4214.     /// be calculated from the following equation:
  4215.     ///     maxHitTestMetricsCount = lineCount * maxBidiReorderingDepth
  4216.     ///
  4217.     /// where lineCount is obtained from the value of the output argument
  4218.     /// *actualLineCount from the function IDWriteTextLayout::GetLineMetrics,
  4219.     /// and the maxBidiReorderingDepth value from the DWRITE_TEXT_METRICS
  4220.     /// structure of the output argument *textMetrics from the function
  4221.     /// IDWriteFactory::CreateTextLayout.
  4222.     /// </summary>
  4223.     /// <param name="textPosition">First text position of the specified range.</param>
  4224.     /// <param name="textLength">Number of positions of the specified range.</param>
  4225.     /// <param name="originX">Offset of the X origin (left of the layout box) which is added to each of the hit-test metrics returned.</param>
  4226.     /// <param name="originY">Offset of the Y origin (top of the layout box) which is added to each of the hit-test metrics returned.</param>
  4227.     /// <param name="hitTestMetrics">Pointer to a buffer of the output geometry fully enclosing the specified position range.</param>
  4228.     /// <param name="maxHitTestMetricsCount">Maximum number of distinct metrics it could hold in its buffer memory.</param>
  4229.     /// <param name="actualHitTestMetricsCount">Actual number of metrics returned or needed.</param>
  4230.     /// <returns>
  4231.     /// Standard HRESULT error code.
  4232.     /// </returns>
  4233.     /// <remarks>
  4234.     /// There are no gaps in the returned metrics. While there could be visual gaps,
  4235.     /// depending on bidi ordering, each range is contiguous and reports all the text,
  4236.     /// including any hidden characters and trimmed text.
  4237.     /// The height of each returned range will be the same within each line, regardless
  4238.     /// of how the font sizes vary.
  4239.     /// </remarks>
  4240.     STDMETHOD(HitTestTextRange)(
  4241.         UINT32 textPosition,
  4242.         UINT32 textLength,
  4243.         FLOAT originX,
  4244.         FLOAT originY,
  4245.         __out_ecount_opt(maxHitTestMetricsCount) DWRITE_HIT_TEST_METRICS* hitTestMetrics,
  4246.         UINT32 maxHitTestMetricsCount,
  4247.         __out UINT32* actualHitTestMetricsCount
  4248.         ) PURE;
  4249. };
  4250.  
  4251. /// <summary>
  4252. /// Encapsulates a 32-bit device independent bitmap and device context, which can be used for rendering glyphs.
  4253. /// </summary>
  4254. interface DWRITE_DECLARE_INTERFACE("5e5a32a3-8dff-4773-9ff6-0696eab77267") IDWriteBitmapRenderTarget : public IUnknown
  4255. {
  4256.     /// <summary>
  4257.     /// Draws a run of glyphs to the bitmap.
  4258.     /// </summary>
  4259.     /// <param name="baselineOriginX">Horizontal position of the baseline origin, in DIPs, relative to the upper-left corner of the DIB.</param>
  4260.     /// <param name="baselineOriginY">Vertical position of the baseline origin, in DIPs, relative to the upper-left corner of the DIB.</param>
  4261.     /// <param name="measuringMode">Specifies measuring method for glyphs in the run.
  4262.     /// Renderer implementations may choose different rendering modes for different measuring methods, for example
  4263.     /// DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL for DWRITE_MEASURING_MODE_NATURAL,
  4264.     /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC for DWRITE_MEASURING_MODE_GDI_CLASSIC, and
  4265.     /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL for DWRITE_MEASURING_MODE_GDI_NATURAL.
  4266.     /// </param>
  4267.     /// <param name="glyphRun">Structure containing the properties of the glyph run.</param>
  4268.     /// <param name="renderingParams">Object that controls rendering behavior.</param>
  4269.     /// <param name="textColor">Specifies the foreground color of the text.</param>
  4270.     /// <param name="blackBoxRect">Optional rectangle that receives the bounding box (in pixels not DIPs) of all the pixels affected by
  4271.     /// drawing the glyph run. The black box rectangle may extend beyond the dimensions of the bitmap.</param>
  4272.     /// <returns>
  4273.     /// Standard HRESULT error code.
  4274.     /// </returns>
  4275.     STDMETHOD(DrawGlyphRun)(
  4276.         FLOAT baselineOriginX,
  4277.         FLOAT baselineOriginY,
  4278.         DWRITE_MEASURING_MODE measuringMode,
  4279.         __in DWRITE_GLYPH_RUN const* glyphRun,
  4280.         IDWriteRenderingParams* renderingParams,
  4281.         COLORREF textColor,
  4282.         __out_opt RECT* blackBoxRect = NULL
  4283.         ) PURE;
  4284.  
  4285.     /// <summary>
  4286.     /// Gets a handle to the memory device context.
  4287.     /// </summary>
  4288.     /// <returns>
  4289.     /// Returns the device context handle.
  4290.     /// </returns>
  4291.     /// <remarks>
  4292.     /// An application can use the device context to draw using GDI functions. An application can obtain the bitmap handle
  4293.     /// (HBITMAP) by calling GetCurrentObject. An application that wants information about the underlying bitmap, including
  4294.     /// a pointer to the pixel data, can call GetObject to fill in a DIBSECTION structure. The bitmap is always a 32-bit
  4295.     /// top-down DIB.
  4296.     /// </remarks>
  4297.     STDMETHOD_(HDC, GetMemoryDC)() PURE;
  4298.  
  4299.     /// <summary>
  4300.     /// Gets the number of bitmap pixels per DIP. A DIP (device-independent pixel) is 1/96 inch so this value is the number
  4301.     /// if pixels per inch divided by 96.
  4302.     /// </summary>
  4303.     /// <returns>
  4304.     /// Returns the number of bitmap pixels per DIP.
  4305.     /// </returns>
  4306.     STDMETHOD_(FLOAT, GetPixelsPerDip)() PURE;
  4307.  
  4308.     /// <summary>
  4309.     /// Sets the number of bitmap pixels per DIP. A DIP (device-independent pixel) is 1/96 inch so this value is the number
  4310.     /// if pixels per inch divided by 96.
  4311.     /// </summary>
  4312.     /// <param name="pixelsPerDip">Specifies the number of pixels per DIP.</param>
  4313.     /// <returns>
  4314.     /// Standard HRESULT error code.
  4315.     /// </returns>
  4316.     STDMETHOD(SetPixelsPerDip)(
  4317.         FLOAT pixelsPerDip
  4318.         ) PURE;
  4319.  
  4320.     /// <summary>
  4321.     /// Gets the transform that maps abstract coordinate to DIPs. By default this is the identity
  4322.     /// transform. Note that this is unrelated to the world transform of the underlying device
  4323.     /// context.
  4324.     /// </summary>
  4325.     /// <param name="transform">Receives the transform.</param>
  4326.     /// <returns>
  4327.     /// Standard HRESULT error code.
  4328.     /// </returns>
  4329.     STDMETHOD(GetCurrentTransform)(
  4330.         __out DWRITE_MATRIX* transform
  4331.         ) PURE;
  4332.  
  4333.     /// <summary>
  4334.     /// Sets the transform that maps abstract coordinate to DIPs. This does not affect the world
  4335.     /// transform of the underlying device context.
  4336.     /// </summary>
  4337.     /// <param name="transform">Specifies the new transform. This parameter can be NULL, in which
  4338.     /// case the identity transform is implied.</param>
  4339.     /// <returns>
  4340.     /// Standard HRESULT error code.
  4341.     /// </returns>
  4342.     STDMETHOD(SetCurrentTransform)(
  4343.         __in_opt DWRITE_MATRIX const* transform
  4344.         ) PURE;
  4345.  
  4346.     /// <summary>
  4347.     /// Gets the dimensions of the bitmap.
  4348.     /// </summary>
  4349.     /// <param name="size">Receives the size of the bitmap in pixels.</param>
  4350.     /// <returns>
  4351.     /// Standard HRESULT error code.
  4352.     /// </returns>
  4353.     STDMETHOD(GetSize)(
  4354.         __out SIZE* size
  4355.         ) PURE;
  4356.  
  4357.     /// <summary>
  4358.     /// Resizes the bitmap.
  4359.     /// </summary>
  4360.     /// <param name="width">New bitmap width, in pixels.</param>
  4361.     /// <param name="height">New bitmap height, in pixels.</param>
  4362.     /// <returns>
  4363.     /// Standard HRESULT error code.
  4364.     /// </returns>
  4365.     STDMETHOD(Resize)(
  4366.         UINT32 width,
  4367.         UINT32 height
  4368.         ) PURE;
  4369. };
  4370.  
  4371. /// <summary>
  4372. /// The GDI interop interface provides interoperability with GDI.
  4373. /// </summary>
  4374. interface DWRITE_DECLARE_INTERFACE("1edd9491-9853-4299-898f-6432983b6f3a") IDWriteGdiInterop : public IUnknown
  4375. {
  4376.     /// <summary>
  4377.     /// Creates a font object that matches the properties specified by the LOGFONT structure.
  4378.     /// </summary>
  4379.     /// <param name="logFont">Structure containing a GDI-compatible font description.</param>
  4380.     /// <param name="font">Receives a newly created font object if successful, or NULL in case of error.</param>
  4381.     /// <returns>
  4382.     /// Standard HRESULT error code.
  4383.     /// </returns>
  4384.     STDMETHOD(CreateFontFromLOGFONT)(
  4385.         __in LOGFONTW const* logFont,
  4386.         __out IDWriteFont** font
  4387.         ) PURE;
  4388.  
  4389.     /// <summary>
  4390.     /// Initializes a LOGFONT structure based on the GDI-compatible properties of the specified font.
  4391.     /// </summary>
  4392.     /// <param name="font">Specifies a font in the system font collection.</param>
  4393.     /// <param name="logFont">Structure that receives a GDI-compatible font description.</param>
  4394.     /// <param name="isSystemFont">Contains TRUE if the specified font object is part of the system font collection
  4395.     /// or FALSE otherwise.</param>
  4396.     /// <returns>
  4397.     /// Standard HRESULT error code.
  4398.     /// </returns>
  4399.     STDMETHOD(ConvertFontToLOGFONT)(
  4400.         IDWriteFont* font,
  4401.         __out LOGFONTW* logFont,
  4402.         __out BOOL* isSystemFont
  4403.         ) PURE;
  4404.  
  4405.     /// <summary>
  4406.     /// Initializes a LOGFONT structure based on the GDI-compatible properties of the specified font.
  4407.     /// </summary>
  4408.     /// <param name="font">Specifies a font face.</param>
  4409.     /// <param name="logFont">Structure that receives a GDI-compatible font description.</param>
  4410.     /// <returns>
  4411.     /// Standard HRESULT error code.
  4412.     /// </returns>
  4413.     STDMETHOD(ConvertFontFaceToLOGFONT)(
  4414.         IDWriteFontFace* font,
  4415.         __out LOGFONTW* logFont
  4416.         ) PURE;
  4417.  
  4418.     /// <summary>
  4419.     /// Creates a font face object that corresponds to the currently selected HFONT.
  4420.     /// </summary>
  4421.     /// <param name="hdc">Handle to a device context into which a font has been selected. It is assumed that the client
  4422.     /// has already performed font mapping and that the font selected into the DC is the actual font that would be used
  4423.     /// for rendering glyphs.</param>
  4424.     /// <param name="fontFace">Contains the newly created font face object, or NULL in case of failure.</param>
  4425.     /// <returns>
  4426.     /// Standard HRESULT error code.
  4427.     /// </returns>
  4428.     STDMETHOD(CreateFontFaceFromHdc)(
  4429.         HDC hdc,
  4430.         __out IDWriteFontFace** fontFace
  4431.         ) PURE;
  4432.  
  4433.     /// <summary>
  4434.     /// Creates an object that encapsulates a bitmap and memory DC which can be used for rendering glyphs.
  4435.     /// </summary>
  4436.     /// <param name="hdc">Optional device context used to create a compatible memory DC.</param>
  4437.     /// <param name="width">Width of the bitmap.</param>
  4438.     /// <param name="height">Height of the bitmap.</param>
  4439.     /// <param name="renderTarget">Receives a pointer to the newly created render target.</param>
  4440.     STDMETHOD(CreateBitmapRenderTarget)(
  4441.         __in_opt HDC hdc,
  4442.         UINT32 width,
  4443.         UINT32 height,
  4444.         __out IDWriteBitmapRenderTarget** renderTarget
  4445.         ) PURE;
  4446. };
  4447.  
  4448. /// <summary>
  4449. /// The DWRITE_TEXTURE_TYPE enumeration identifies a type of alpha texture. An alpha texture is a bitmap of alpha values, each
  4450. /// representing the darkness (i.e., opacity) of a pixel or subpixel.
  4451. /// </summary>
  4452. enum DWRITE_TEXTURE_TYPE
  4453. {
  4454.     /// <summary>
  4455.     /// Specifies an alpha texture for aliased text rendering (i.e., bi-level, where each pixel is either fully opaque or fully transparent),
  4456.     /// with one byte per pixel.
  4457.     /// </summary>
  4458.     DWRITE_TEXTURE_ALIASED_1x1,
  4459.  
  4460.     /// <summary>
  4461.     /// Specifies an alpha texture for ClearType text rendering, with three bytes per pixel in the horizontal dimension and
  4462.     /// one byte per pixel in the vertical dimension.
  4463.     /// </summary>
  4464.     DWRITE_TEXTURE_CLEARTYPE_3x1
  4465. };
  4466.  
  4467. /// <summary>
  4468. /// Maximum alpha value in a texture returned by IDWriteGlyphRunAnalysis::CreateAlphaTexture.
  4469. /// </summary>
  4470. #define DWRITE_ALPHA_MAX 255
  4471.  
  4472. /// <summary>
  4473. /// Interface that encapsulates information used to render a glyph run.
  4474. /// </summary>
  4475. interface DWRITE_DECLARE_INTERFACE("7d97dbf7-e085-42d4-81e3-6a883bded118") IDWriteGlyphRunAnalysis : public IUnknown
  4476. {
  4477.     /// <summary>
  4478.     /// Gets the bounding rectangle of the physical pixels affected by the glyph run.
  4479.     /// </summary>
  4480.     /// <param name="textureType">Specifies the type of texture requested. If a bi-level texture is requested, the
  4481.     /// bounding rectangle includes only bi-level glyphs. Otherwise, the bounding rectangle includes only anti-aliased
  4482.     /// glyphs.</param>
  4483.     /// <param name="textureBounds">Receives the bounding rectangle, or an empty rectangle if there are no glyphs
  4484.     /// if the specified type.</param>
  4485.     /// <returns>
  4486.     /// Standard HRESULT error code.
  4487.     /// </returns>
  4488.     STDMETHOD(GetAlphaTextureBounds)(
  4489.         DWRITE_TEXTURE_TYPE textureType,
  4490.         __out RECT* textureBounds
  4491.         ) PURE;
  4492.  
  4493.     /// <summary>
  4494.     /// Creates an alpha texture of the specified type.
  4495.     /// </summary>
  4496.     /// <param name="textureType">Specifies the type of texture requested. If a bi-level texture is requested, the
  4497.     /// texture contains only bi-level glyphs. Otherwise, the texture contains only anti-aliased glyphs.</param>
  4498.     /// <param name="textureBounds">Specifies the bounding rectangle of the texture, which can be different than
  4499.     /// the bounding rectangle returned by GetAlphaTextureBounds.</param>
  4500.     /// <param name="alphaValues">Receives the array of alpha values.</param>
  4501.     /// <param name="bufferSize">Size of the alphaValues array. The minimum size depends on the dimensions of the
  4502.     /// rectangle and the type of texture requested.</param>
  4503.     /// <returns>
  4504.     /// Standard HRESULT error code.
  4505.     /// </returns>
  4506.     STDMETHOD(CreateAlphaTexture)(
  4507.         DWRITE_TEXTURE_TYPE textureType,
  4508.         __in RECT const* textureBounds,
  4509.         __out_bcount(bufferSize) BYTE* alphaValues,
  4510.         UINT32 bufferSize
  4511.         ) PURE;
  4512.  
  4513.     /// <summary>
  4514.     /// Gets properties required for ClearType blending.
  4515.     /// </summary>
  4516.     /// <param name="renderingParams">Rendering parameters object. In most cases, the values returned in the output
  4517.     /// parameters are based on the properties of this object. The exception is if a GDI-compatible rendering mode
  4518.     /// is specified.</param>
  4519.     /// <param name="blendGamma">Receives the gamma value to use for gamma correction.</param>
  4520.     /// <param name="blendEnhancedContrast">Receives the enhanced contrast value.</param>
  4521.     /// <param name="blendClearTypeLevel">Receives the ClearType level.</param>
  4522.     STDMETHOD(GetAlphaBlendParams)(
  4523.         IDWriteRenderingParams* renderingParams,
  4524.         __out FLOAT* blendGamma,
  4525.         __out FLOAT* blendEnhancedContrast,
  4526.         __out FLOAT* blendClearTypeLevel
  4527.         ) PURE;
  4528. };
  4529.  
  4530. /// <summary>
  4531. /// The root factory interface for all DWrite objects.
  4532. /// </summary>
  4533. interface DWRITE_DECLARE_INTERFACE("b859ee5a-d838-4b5b-a2e8-1adc7d93db48") IDWriteFactory : public IUnknown
  4534. {
  4535.     /// <summary>
  4536.     /// Gets a font collection representing the set of installed fonts.
  4537.     /// </summary>
  4538.     /// <param name="fontCollection">Receives a pointer to the system font collection object, or NULL in case of failure.</param>
  4539.     /// <param name="checkForUpdates">If this parameter is nonzero, the function performs an immediate check for changes to the set of
  4540.     /// installed fonts. If this parameter is FALSE, the function will still detect changes if the font cache service is running, but
  4541.     /// there may be some latency. For example, an application might specify TRUE if it has itself just installed a font and wants to
  4542.     /// be sure the font collection contains that font.</param>
  4543.     /// <returns>
  4544.     /// Standard HRESULT error code.
  4545.     /// </returns>
  4546.     STDMETHOD(GetSystemFontCollection)(
  4547.         __out IDWriteFontCollection** fontCollection,
  4548.         BOOL checkForUpdates = FALSE
  4549.         ) PURE;
  4550.  
  4551.     /// <summary>
  4552.     /// Creates a font collection using a custom font collection loader.
  4553.     /// </summary>
  4554.     /// <param name="collectionLoader">Application-defined font collection loader, which must have been previously
  4555.     /// registered using RegisterFontCollectionLoader.</param>
  4556.     /// <param name="collectionKey">Key used by the loader to identify a collection of font files.</param>
  4557.     /// <param name="collectionKeySize">Size in bytes of the collection key.</param>
  4558.     /// <param name="fontCollection">Receives a pointer to the system font collection object, or NULL in case of failure.</param>
  4559.     /// <returns>
  4560.     /// Standard HRESULT error code.
  4561.     /// </returns>
  4562.     STDMETHOD(CreateCustomFontCollection)(
  4563.         IDWriteFontCollectionLoader* collectionLoader,
  4564.         __in_bcount(collectionKeySize) void const* collectionKey,
  4565.         UINT32 collectionKeySize,
  4566.         __out IDWriteFontCollection** fontCollection
  4567.         ) PURE;
  4568.  
  4569.     /// <summary>
  4570.     /// Registers a custom font collection loader with the factory object.
  4571.     /// </summary>
  4572.     /// <param name="fontCollectionLoader">Application-defined font collection loader.</param>
  4573.     /// <returns>
  4574.     /// Standard HRESULT error code.
  4575.     /// </returns>
  4576.     STDMETHOD(RegisterFontCollectionLoader)(
  4577.         IDWriteFontCollectionLoader* fontCollectionLoader
  4578.         ) PURE;
  4579.  
  4580.     /// <summary>
  4581.     /// Unregisters a custom font collection loader that was previously registered using RegisterFontCollectionLoader.
  4582.     /// </summary>
  4583.     /// <param name="fontCollectionLoader">Application-defined font collection loader.</param>
  4584.     /// <returns>
  4585.     /// Standard HRESULT error code.
  4586.     /// </returns>
  4587.     STDMETHOD(UnregisterFontCollectionLoader)(
  4588.         IDWriteFontCollectionLoader* fontCollectionLoader
  4589.         ) PURE;
  4590.  
  4591.     /// <summary>
  4592.     /// CreateFontFileReference creates a font file reference object from a local font file.
  4593.     /// </summary>
  4594.     /// <param name="filePath">Absolute file path. Subsequent operations on the constructed object may fail
  4595.     /// if the user provided filePath doesn't correspond to a valid file on the disk.</param>
  4596.     /// <param name="lastWriteTime">Last modified time of the input file path. If the parameter is omitted,
  4597.     /// the function will access the font file to obtain its last write time, so the clients are encouraged to specify this value
  4598.     /// to avoid extra disk access. Subsequent operations on the constructed object may fail
  4599.     /// if the user provided lastWriteTime doesn't match the file on the disk.</param>
  4600.     /// <param name="fontFile">Contains newly created font file reference object, or NULL in case of failure.</param>
  4601.     /// <returns>
  4602.     /// Standard HRESULT error code.
  4603.     /// </returns>
  4604.     STDMETHOD(CreateFontFileReference)(
  4605.         __in_z WCHAR const* filePath,
  4606.         __in_opt FILETIME const* lastWriteTime,
  4607.         __out IDWriteFontFile** fontFile
  4608.         ) PURE;
  4609.  
  4610.     /// <summary>
  4611.     /// CreateCustomFontFileReference creates a reference to an application specific font file resource.
  4612.     /// This function enables an application or a document to use a font without having to install it on the system.
  4613.     /// The fontFileReferenceKey has to be unique only in the scope of the fontFileLoader used in this call.
  4614.     /// </summary>
  4615.     /// <param name="fontFileReferenceKey">Font file reference key that uniquely identifies the font file resource
  4616.     /// during the lifetime of fontFileLoader.</param>
  4617.     /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param>
  4618.     /// <param name="fontFileLoader">Font file loader that will be used by the font system to load data from the file identified by
  4619.     /// fontFileReferenceKey.</param>
  4620.     /// <param name="fontFile">Contains the newly created font file object, or NULL in case of failure.</param>
  4621.     /// <returns>
  4622.     /// Standard HRESULT error code.
  4623.     /// </returns>
  4624.     /// <remarks>
  4625.     /// This function is provided for cases when an application or a document needs to use a font
  4626.     /// without having to install it on the system. fontFileReferenceKey has to be unique only in the scope
  4627.     /// of the fontFileLoader used in this call.
  4628.     /// </remarks>
  4629.     STDMETHOD(CreateCustomFontFileReference)(
  4630.         __in_bcount(fontFileReferenceKeySize) void const* fontFileReferenceKey,
  4631.         UINT32 fontFileReferenceKeySize,
  4632.         IDWriteFontFileLoader* fontFileLoader,
  4633.         __out IDWriteFontFile** fontFile
  4634.         ) PURE;
  4635.  
  4636.     /// <summary>
  4637.     /// Creates a font face object.
  4638.     /// </summary>
  4639.     /// <param name="fontFaceType">The file format of the font face.</param>
  4640.     /// <param name="numberOfFiles">The number of font files require to represent the font face.</param>
  4641.     /// <param name="fontFiles">Font files representing the font face. Since IDWriteFontFace maintains its own references
  4642.     /// to the input font file objects, it's OK to release them after this call.</param>
  4643.     /// <param name="faceIndex">The zero based index of a font face in cases when the font files contain a collection of font faces.
  4644.     /// If the font files contain a single face, this value should be zero.</param>
  4645.     /// <param name="fontFaceSimulationFlags">Font face simulation flags for algorithmic emboldening and italicization.</param>
  4646.     /// <param name="fontFace">Contains the newly created font face object, or NULL in case of failure.</param>
  4647.     /// <returns>
  4648.     /// Standard HRESULT error code.
  4649.     /// </returns>
  4650.     STDMETHOD(CreateFontFace)(
  4651.         DWRITE_FONT_FACE_TYPE fontFaceType,
  4652.         UINT32 numberOfFiles,
  4653.         __in_ecount(numberOfFiles) IDWriteFontFile* const* fontFiles,
  4654.         UINT32 faceIndex,
  4655.         DWRITE_FONT_SIMULATIONS fontFaceSimulationFlags,
  4656.         __out IDWriteFontFace** fontFace
  4657.         ) PURE;
  4658.  
  4659.     /// <summary>
  4660.     /// Creates a rendering parameters object with default settings for the primary monitor.
  4661.     /// </summary>
  4662.     /// <param name="renderingParams">Holds the newly created rendering parameters object, or NULL in case of failure.</param>
  4663.     /// <returns>
  4664.     /// Standard HRESULT error code.
  4665.     /// </returns>
  4666.     STDMETHOD(CreateRenderingParams)(
  4667.         __out IDWriteRenderingParams** renderingParams
  4668.         ) PURE;
  4669.  
  4670.     /// <summary>
  4671.     /// Creates a rendering parameters object with default settings for the specified monitor.
  4672.     /// </summary>
  4673.     /// <param name="monitor">The monitor to read the default values from.</param>
  4674.     /// <param name="renderingParams">Holds the newly created rendering parameters object, or NULL in case of failure.</param>
  4675.     /// <returns>
  4676.     /// Standard HRESULT error code.
  4677.     /// </returns>
  4678.     STDMETHOD(CreateMonitorRenderingParams)(
  4679.         HMONITOR monitor,
  4680.         __out IDWriteRenderingParams** renderingParams
  4681.         ) PURE;
  4682.  
  4683.     /// <summary>
  4684.     /// Creates a rendering parameters object with the specified properties.
  4685.     /// </summary>
  4686.     /// <param name="gamma">The gamma value used for gamma correction, which must be greater than zero and cannot exceed 256.</param>
  4687.     /// <param name="enhancedContrast">The amount of contrast enhancement, zero or greater.</param>
  4688.     /// <param name="clearTypeLevel">The degree of ClearType level, from 0.0f (no ClearType) to 1.0f (full ClearType).</param>
  4689.     /// <param name="pixelGeometry">The geometry of a device pixel.</param>
  4690.     /// <param name="renderingMode">Method of rendering glyphs. In most cases, this should be DWRITE_RENDERING_MODE_DEFAULT to automatically use an appropriate mode.</param>
  4691.     /// <param name="renderingParams">Holds the newly created rendering parameters object, or NULL in case of failure.</param>
  4692.     /// <returns>
  4693.     /// Standard HRESULT error code.
  4694.     /// </returns>
  4695.     STDMETHOD(CreateCustomRenderingParams)(
  4696.         FLOAT gamma,
  4697.         FLOAT enhancedContrast,
  4698.         FLOAT clearTypeLevel,
  4699.         DWRITE_PIXEL_GEOMETRY pixelGeometry,
  4700.         DWRITE_RENDERING_MODE renderingMode,
  4701.         __out IDWriteRenderingParams** renderingParams
  4702.         ) PURE;
  4703.  
  4704.     /// <summary>
  4705.     /// Registers a font file loader with DirectWrite.
  4706.     /// </summary>
  4707.     /// <param name="fontFileLoader">Pointer to the implementation of the IDWriteFontFileLoader for a particular file resource type.</param>
  4708.     /// <returns>
  4709.     /// Standard HRESULT error code.
  4710.     /// </returns>
  4711.     /// <remarks>
  4712.     /// This function registers a font file loader with DirectWrite.
  4713.     /// Font file loader interface handles loading font file resources of a particular type from a key.
  4714.     /// The font file loader interface is recommended to be implemented by a singleton object.
  4715.     /// A given instance can only be registered once.
  4716.     /// Succeeding attempts will return an error that it has already been registered.
  4717.     /// IMPORTANT: font file loader implementations must not register themselves with DirectWrite
  4718.     /// inside their constructors and must not unregister themselves in their destructors, because
  4719.     /// registration and unregistraton operations increment and decrement the object reference count respectively.
  4720.     /// Instead, registration and unregistration of font file loaders with DirectWrite should be performed
  4721.     /// outside of the font file loader implementation as a separate step.
  4722.     /// </remarks>
  4723.     STDMETHOD(RegisterFontFileLoader)(
  4724.         IDWriteFontFileLoader* fontFileLoader
  4725.         ) PURE;
  4726.  
  4727.     /// <summary>
  4728.     /// Unregisters a font file loader that was previously registered with the DirectWrite font system using RegisterFontFileLoader.
  4729.     /// </summary>
  4730.     /// <param name="fontFileLoader">Pointer to the file loader that was previously registered with the DirectWrite font system using RegisterFontFileLoader.</param>
  4731.     /// <returns>
  4732.     /// This function will succeed if the user loader is requested to be removed.
  4733.     /// It will fail if the pointer to the file loader identifies a standard DirectWrite loader,
  4734.     /// or a loader that is never registered or has already been unregistered.
  4735.     /// </returns>
  4736.     /// <remarks>
  4737.     /// This function unregisters font file loader callbacks with the DirectWrite font system.
  4738.     /// The font file loader interface is recommended to be implemented by a singleton object.
  4739.     /// IMPORTANT: font file loader implementations must not register themselves with DirectWrite
  4740.     /// inside their constructors and must not unregister themselves in their destructors, because
  4741.     /// registration and unregistraton operations increment and decrement the object reference count respectively.
  4742.     /// Instead, registration and unregistration of font file loaders with DirectWrite should be performed
  4743.     /// outside of the font file loader implementation as a separate step.
  4744.     /// </remarks>
  4745.     STDMETHOD(UnregisterFontFileLoader)(
  4746.         IDWriteFontFileLoader* fontFileLoader
  4747.         ) PURE;
  4748.  
  4749.     /// <summary>
  4750.     /// Create a text format object used for text layout.
  4751.     /// </summary>
  4752.     /// <param name="fontFamilyName">Name of the font family</param>
  4753.     /// <param name="fontCollection">Font collection. NULL indicates the system font collection.</param>
  4754.     /// <param name="fontWeight">Font weight</param>
  4755.     /// <param name="fontStyle">Font style</param>
  4756.     /// <param name="fontStretch">Font stretch</param>
  4757.     /// <param name="fontSize">Logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch.</param>
  4758.     /// <param name="localeName">Locale name</param>
  4759.     /// <param name="textFormat">Contains newly created text format object, or NULL in case of failure.</param>
  4760.     /// <returns>
  4761.     /// Standard HRESULT error code.
  4762.     /// </returns>
  4763.     STDMETHOD(CreateTextFormat)(
  4764.         __in_z WCHAR const* fontFamilyName,
  4765.         __maybenull IDWriteFontCollection* fontCollection,
  4766.         DWRITE_FONT_WEIGHT fontWeight,
  4767.         DWRITE_FONT_STYLE fontStyle,
  4768.         DWRITE_FONT_STRETCH fontStretch,
  4769.         FLOAT fontSize,
  4770.         __in_z WCHAR const* localeName,
  4771.         __out IDWriteTextFormat** textFormat
  4772.         ) PURE;
  4773.  
  4774.     /// <summary>
  4775.     /// Create a typography object used in conjunction with text format for text layout.
  4776.     /// </summary>
  4777.     /// <param name="typography">Contains newly created typography object, or NULL in case of failure.</param>
  4778.     /// <returns>
  4779.     /// Standard HRESULT error code.
  4780.     /// </returns>
  4781.     STDMETHOD(CreateTypography)(
  4782.         __out IDWriteTypography** typography
  4783.         ) PURE;
  4784.  
  4785.     /// <summary>
  4786.     /// Create an object used for interoperability with GDI.
  4787.     /// </summary>
  4788.     /// <param name="gdiInterop">Receives the GDI interop object if successful, or NULL in case of failure.</param>
  4789.     /// <returns>
  4790.     /// Standard HRESULT error code.
  4791.     /// </returns>
  4792.     STDMETHOD(GetGdiInterop)(
  4793.         __out IDWriteGdiInterop** gdiInterop
  4794.         ) PURE;
  4795.  
  4796.     /// <summary>
  4797.     /// CreateTextLayout takes a string, format, and associated constraints
  4798.     /// and produces and object representing the fully analyzed
  4799.     /// and formatted result.
  4800.     /// </summary>
  4801.     /// <param name="string">The string to layout.</param>
  4802.     /// <param name="stringLength">The length of the string.</param>
  4803.     /// <param name="textFormat">The format to apply to the string.</param>
  4804.     /// <param name="maxWidth">Width of the layout box.</param>
  4805.     /// <param name="maxHeight">Height of the layout box.</param>
  4806.     /// <param name="textLayout">The resultant object.</param>
  4807.     /// <returns>
  4808.     /// Standard HRESULT error code.
  4809.     /// </returns>
  4810.     STDMETHOD(CreateTextLayout)(
  4811.         __in_ecount(stringLength) WCHAR const* string,
  4812.         UINT32 stringLength,
  4813.         IDWriteTextFormat* textFormat,
  4814.         FLOAT maxWidth,
  4815.         FLOAT maxHeight,
  4816.         __out IDWriteTextLayout** textLayout
  4817.         ) PURE;
  4818.  
  4819.     /// <summary>
  4820.     /// CreateGdiCompatibleTextLayout takes a string, format, and associated constraints
  4821.     /// and produces and object representing the result formatted for a particular display resolution
  4822.     /// and measuring method. The resulting text layout should only be used for the intended resolution,
  4823.     /// and for cases where text scalability is desired, CreateTextLayout should be used instead.
  4824.     /// </summary>
  4825.     /// <param name="string">The string to layout.</param>
  4826.     /// <param name="stringLength">The length of the string.</param>
  4827.     /// <param name="textFormat">The format to apply to the string.</param>
  4828.     /// <param name="layoutWidth">Width of the layout box.</param>
  4829.     /// <param name="layoutHeight">Height of the layout box.</param>
  4830.     /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if rendering onto a 96 DPI device then pixelsPerDip
  4831.     /// is 1. If rendering onto a 120 DPI device then pixelsPerDip is 120/96.</param>
  4832.     /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the
  4833.     /// scaling specified the font size and pixelsPerDip.</param>
  4834.     /// <param name="useGdiNatural">
  4835.     /// When set to FALSE, instructs the text layout to use the same metrics as GDI aliased text.
  4836.     /// When set to TRUE, instructs the text layout to use the same metrics as text measured by GDI using a font
  4837.     /// created with CLEARTYPE_NATURAL_QUALITY.
  4838.     /// </param>
  4839.     /// <param name="textLayout">The resultant object.</param>
  4840.     /// <returns>
  4841.     /// Standard HRESULT error code.
  4842.     /// </returns>
  4843.     STDMETHOD(CreateGdiCompatibleTextLayout)(
  4844.         __in_ecount(stringLength) WCHAR const* string,
  4845.         UINT32 stringLength,
  4846.         IDWriteTextFormat* textFormat,
  4847.         FLOAT layoutWidth,
  4848.         FLOAT layoutHeight,
  4849.         FLOAT pixelsPerDip,
  4850.         __in_opt DWRITE_MATRIX const* transform,
  4851.         BOOL useGdiNatural,
  4852.         __out IDWriteTextLayout** textLayout
  4853.         ) PURE;
  4854.  
  4855.     /// <summary>
  4856.     /// The application may call this function to create an inline object for trimming, using an ellipsis as the omission sign.
  4857.     /// The ellipsis will be created using the current settings of the format, including base font, style, and any effects.
  4858.     /// Alternate omission signs can be created by the application by implementing IDWriteInlineObject.
  4859.     /// </summary>
  4860.     /// <param name="textFormat">Text format used as a template for the omission sign.</param>
  4861.     /// <param name="trimmingSign">Created omission sign.</param>
  4862.     /// <returns>
  4863.     /// Standard HRESULT error code.
  4864.     /// </returns>
  4865.     STDMETHOD(CreateEllipsisTrimmingSign)(
  4866.         IDWriteTextFormat* textFormat,
  4867.         __out IDWriteInlineObject** trimmingSign
  4868.         ) PURE;
  4869.  
  4870.     /// <summary>
  4871.     /// Return an interface to perform text analysis with.
  4872.     /// </summary>
  4873.     /// <param name="textAnalyzer">The resultant object.</param>
  4874.     /// <returns>
  4875.     /// Standard HRESULT error code.
  4876.     /// </returns>
  4877.     STDMETHOD(CreateTextAnalyzer)(
  4878.         __out IDWriteTextAnalyzer** textAnalyzer
  4879.         ) PURE;
  4880.  
  4881.     /// <summary>
  4882.     /// Creates a number substitution object using a locale name,
  4883.     /// substitution method, and whether to ignore user overrides (uses NLS
  4884.     /// defaults for the given culture instead).
  4885.     /// </summary>
  4886.     /// <param name="substitutionMethod">Method of number substitution to use.</param>
  4887.     /// <param name="localeName">Which locale to obtain the digits from.</param>
  4888.     /// <param name="ignoreUserOverride">Ignore the user's settings and use the locale defaults</param>
  4889.     /// <param name="numberSubstitution">Receives a pointer to the newly created object.</param>
  4890.     STDMETHOD(CreateNumberSubstitution)(
  4891.         __in DWRITE_NUMBER_SUBSTITUTION_METHOD substitutionMethod,
  4892.         __in_z WCHAR const* localeName,
  4893.         __in BOOL ignoreUserOverride,
  4894.         __out IDWriteNumberSubstitution** numberSubstitution
  4895.         ) PURE;
  4896.  
  4897.     /// <summary>
  4898.     /// Creates a glyph run analysis object, which encapsulates information
  4899.     /// used to render a glyph run.
  4900.     /// </summary>
  4901.     /// <param name="glyphRun">Structure specifying the properties of the glyph run.</param>
  4902.     /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if rendering onto a 96 DPI bitmap then pixelsPerDip
  4903.     /// is 1. If rendering onto a 120 DPI bitmap then pixelsPerDip is 120/96.</param>
  4904.     /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the
  4905.     /// scaling specified the emSize and pixelsPerDip.</param>
  4906.     /// <param name="renderingMode">Specifies the rendering mode, which must be one of the raster rendering modes (i.e., not default
  4907.     /// and not outline).</param>
  4908.     /// <param name="measuringMode">Specifies the method to measure glyphs.</param>
  4909.     /// <param name="baselineOriginX">Horizontal position of the baseline origin, in DIPs.</param>
  4910.     /// <param name="baselineOriginY">Vertical position of the baseline origin, in DIPs.</param>
  4911.     /// <param name="glyphRunAnalysis">Receives a pointer to the newly created object.</param>
  4912.     /// <returns>
  4913.     /// Standard HRESULT error code.
  4914.     /// </returns>
  4915.     STDMETHOD(CreateGlyphRunAnalysis)(
  4916.         __in DWRITE_GLYPH_RUN const* glyphRun,
  4917.         FLOAT pixelsPerDip,
  4918.         __in_opt DWRITE_MATRIX const* transform,
  4919.         DWRITE_RENDERING_MODE renderingMode,
  4920.         DWRITE_MEASURING_MODE measuringMode,
  4921.         FLOAT baselineOriginX,
  4922.         FLOAT baselineOriginY,
  4923.         __out IDWriteGlyphRunAnalysis** glyphRunAnalysis
  4924.         ) PURE;
  4925.  
  4926. }; // interface IDWriteFactory
  4927.  
  4928. /// <summary>
  4929. /// Creates a DirectWrite factory object that is used for subsequent creation of individual DirectWrite objects.
  4930. /// </summary>
  4931. /// <param name="factoryType">Identifies whether the factory object will be shared or isolated.</param>
  4932. /// <param name="iid">Identifies the DirectWrite factory interface, such as __uuidof(IDWriteFactory).</param>
  4933. /// <param name="factory">Receives the DirectWrite factory object.</param>
  4934. /// <returns>
  4935. /// Standard HRESULT error code.
  4936. /// </returns>
  4937. /// <remarks>
  4938. /// Obtains DirectWrite factory object that is used for subsequent creation of individual DirectWrite classes.
  4939. /// DirectWrite factory contains internal state such as font loader registration and cached font data.
  4940. /// In most cases it is recommended to use the shared factory object, because it allows multiple components
  4941. /// that use DirectWrite to share internal DirectWrite state and reduce memory usage.
  4942. /// However, there are cases when it is desirable to reduce the impact of a component,
  4943. /// such as a plug-in from an untrusted source, on the rest of the process by sandboxing and isolating it
  4944. /// from the rest of the process components. In such cases, it is recommended to use an isolated factory for the sandboxed
  4945. /// component.
  4946. /// </remarks>
  4947. EXTERN_C HRESULT DWRITE_EXPORT DWriteCreateFactory(
  4948.     __in DWRITE_FACTORY_TYPE factoryType,
  4949.     __in REFIID iid,
  4950.     __out IUnknown **factory
  4951.     );
  4952.  
  4953. // Macros used to define DirectWrite error codes.
  4954. #define FACILITY_DWRITE 0x898
  4955. #define DWRITE_ERR_BASE 0x5000
  4956. #define MAKE_DWRITE_HR(severity, code) MAKE_HRESULT(severity, FACILITY_DWRITE, (DWRITE_ERR_BASE + code))
  4957. #define MAKE_DWRITE_HR_ERR(code) MAKE_DWRITE_HR(SEVERITY_ERROR, code)
  4958.  
  4959. /// <summary>
  4960. /// Indicates an error in an input file such as a font file.
  4961. /// </summary>
  4962. #define DWRITE_E_FILEFORMAT             MAKE_DWRITE_HR_ERR(0x000)
  4963.  
  4964. /// <summary>
  4965. /// Indicates an error originating in DirectWrite code, which is not expected to occur but is safe to recover from.
  4966. /// </summary>
  4967. #define DWRITE_E_UNEXPECTED             MAKE_DWRITE_HR_ERR(0x001)
  4968.  
  4969. /// <summary>
  4970. /// Indicates the specified font does not exist.
  4971. /// </summary>
  4972. #define DWRITE_E_NOFONT                 MAKE_DWRITE_HR_ERR(0x002)
  4973.  
  4974. /// <summary>
  4975. /// A font file could not be opened because the file, directory, network location, drive, or other storage
  4976. /// location does not exist or is unavailable.
  4977. /// </summary>
  4978. #define DWRITE_E_FILENOTFOUND           MAKE_DWRITE_HR_ERR(0x003)
  4979.  
  4980. /// <summary>
  4981. /// A font file exists but could not be opened due to access denied, sharing violation, or similar error.
  4982. /// </summary>
  4983. #define DWRITE_E_FILEACCESS             MAKE_DWRITE_HR_ERR(0x004)
  4984.  
  4985. /// <summary>
  4986. /// A font collection is obsolete due to changes in the system.
  4987. /// </summary>
  4988. #define DWRITE_E_FONTCOLLECTIONOBSOLETE MAKE_DWRITE_HR_ERR(0x005)
  4989.  
  4990. /// <summary>
  4991. /// The given interface is already registered.
  4992. /// </summary>
  4993. #define DWRITE_E_ALREADYREGISTERED      MAKE_DWRITE_HR_ERR(0x006)
  4994.  
  4995. #endif /* DWRITE_H_INCLUDED */
  4996.