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