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