Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4855 lines
193 KiB

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