1 #Topic Font 2 #Alias Font_Reference ## 3 4 #Code 5 #Populate 6 ## 7 8 #PhraseDef font_metrics 9 Typeface, Font_Size, Font_Scale_X, 10 Font_Skew_X, Font_Hinting, Paint_Anti_Alias, Font_Embolden, Font_Force_Hinting, 11 Font_Embedded_Bitmaps, Font_Hinting_Spacing, Font_Anti_Alias, Font_Linear, 12 and Font_Subpixel 13 ## 14 15 #Subtopic Advance 16 # incomplete, should probably be in overview, not reference 17 ## 18 #Subtopic Engine 19 # incomplete, should probably be in overview, not reference 20 ## 21 22 #Subtopic Size 23 #Line # overall height in points ## 24 Font_Size adjusts the overall text size in points. 25 Font_Size can be set to any positive value or zero. 26 Font_Size defaults to 12. 27 Font_Size 28 ## 29 30 #Subtopic Scale_X 31 #Line # text horizontal scale ## 32 Font_Scale_X adjusts the text horizontal scale. 33 Text scaling approximates condensed and expanded type faces when the actual face 34 is not available. 35 Font_Scale_X can be set to any value. 36 Font_Scale_X defaults to 1. 37 ## 38 39 #Subtopic Skew_X 40 #Line # text horizontal slant ## 41 Font_Skew_X adjusts the text horizontal slant. 42 Text skewing approximates italic and oblique type faces when the actual face 43 is not available. 44 Font_Skew_X can be set to any value. 45 Font_Skew_X defaults to 0. 46 ## 47 48 #Subtopic Embolden 49 #Line # approximate font styles ## 50 51 Font_Embolden approximates the bold font style accompanying a normal font when a bold font face 52 is not available. Skia does not provide font substitution; it is up to the client to find the 53 bold font face using the platform Font_Manager. 54 55 Use Font_Skew_X to approximate an italic font style when the italic font face 56 is not available. 57 58 A FreeType based port may define SK_USE_FREETYPE_EMBOLDEN at compile time to direct 59 the font engine to create the bold Glyphs. Otherwise, the extra bold is computed 60 by increasing the stroke width and setting the SkPaint::Style to 61 SkPaint::kStrokeAndFill_Style as needed. 62 63 Font_Embolden is disabled by default. 64 #Subtopic Embolden ## 65 66 #Subtopic Hinting_Spacing 67 #Line # glyph spacing affected by hinting ## 68 69 If Hinting is set to SkFontHinting::kFull, Hinting_Spacing adjusts the character 70 spacing by the difference of the hinted and unhinted Left_Side_Bearing and 71 Right_Side_Bearing. Hinting_Spacing only applies to platforms that use 72 FreeType as their Font_Engine. 73 74 Hinting_Spacing is not related to text kerning, where the space between 75 a specific pair of characters is adjusted using data in the font kerning tables. 76 #Subtopic Hinting_Spacing ## 77 78 #Subtopic Linear 79 #Line # selects text rendering as Glyph or Path ## 80 Font_Linear selects whether text is rendered as a Glyph or as a Path. 81 If Font_Linear is set, it has the same effect as setting Hinting to SkFontHinting::kNormal. 82 If Font_Linear is clear, it is the same as setting Hinting to SkFontHinting::kNone. 83 #Subtopic Linear ## 84 85 #Subtopic Subpixel 86 #Line # uses pixel transparency to represent fractional offset ## 87 #Substitute sub-pixel 88 Font_Subpixel uses the pixel transparency to represent a fractional offset. 89 As the opaqueness of the color increases, the edge of the glyph appears to move 90 towards the outside of the pixel. 91 #Subtopic Subpixel ## 92 93 #Subtopic Anti_Alias 94 #Line # text relying on the order of RGB stripes ## 95 When set, Anti_Alias positions glyphs within a pixel, using alpha and 96 possibly RGB striping. It can take advantage of the organization of RGB stripes 97 that create a color, and relies on the small size of the stripe and visual perception 98 to make the color fringing imperceptible. 99 100 Anti_Alias can be enabled on devices that orient stripes horizontally 101 or vertically, and that order the color components as RGB or BGR. Internally, the 102 glyph cache may store multiple copies of the same glyph with different sub-pixel 103 positions, requiring more memory. 104 #Subtopic Anti_Alias ## 105 106 #Subtopic Force_Hinting 107 #Line # always adjust glyph paths ## 108 109 If Hinting is set to SkFontHinting::kNormal or SkFontHinting::kFull, Force_Hinting 110 instructs the Font_Manager to always hint Glyphs. 111 Force_Hinting has no effect if Hinting is set to SkFontHinting::kNone or 112 SkFontHinting::kSlight. 113 114 Force_Hinting only affects platforms that use FreeType as the Font_Manager. 115 #Subtopic Force_Hinting ## 116 117 #Subtopic Embedded_Bitmaps 118 #Line # custom sized bitmap Glyphs ## 119 Embedded_Bitmaps allows selecting custom sized bitmap Glyphs. 120 Embedded_Bitmaps when set chooses an embedded bitmap glyph over an outline contained 121 in a font if the platform supports this option. 122 123 FreeType selects the bitmap glyph if available when Embedded_Bitmaps is set, and selects 124 the outline glyph if Embedded_Bitmaps is clear. 125 Windows may select the bitmap glyph but is not required to do so. 126 OS_X and iOS do not support this option. 127 ## 128 129 # ------------------------------------------------------------------------------ 130 131 #Class SkFont 132 133 SkFont controls options applied when drawing and measuring text. 134 135 #Code 136 #Populate 137 ## 138 139 # ------------------------------------------------------------------------------ 140 141 #EnumClass Edging 142 143 #Code 144 #Populate 145 ## 146 147 Whether edge pixels draw opaque or with partial transparency. 148 149 #Const kAlias 0 # incomplete; replace '0' with member value 150 #Line # no transparent pixels on glyph edges ## 151 # incomplete; add description or delete 152 ## 153 #Const kAntiAlias 0 # incomplete; replace '0' with member value 154 #Line # may have transparent pixels on glyph edges ## 155 # incomplete; add description or delete 156 ## 157 #Const kSubpixelAntiAlias 0 # incomplete; replace '0' with member value 158 #Line # glyph positioned in pixel using transparency ## 159 # incomplete; add description or delete 160 ## 161 162 # incomplete; add description or delete 163 164 #Example 165 // incomplete 166 ## 167 168 #SeeAlso incomplete 169 170 #EnumClass ## 171 172 # ------------------------------------------------------------------------------ 173 174 #Method SkFont() 175 #In Constructor 176 #Line # incomplete ## 177 178 #Populate 179 180 #Example 181 // incomplete 182 ## 183 184 #SeeAlso incomplete 185 186 #Method ## 187 188 # ------------------------------------------------------------------------------ 189 190 #Method SkFont(sk_sp<SkTypeface> typeface, SkScalar size) 191 #In Constructor 192 #Line # incomplete ## 193 194 #Populate 195 196 #Example 197 // incomplete 198 ## 199 200 #SeeAlso incomplete 201 202 #Method ## 203 204 # ------------------------------------------------------------------------------ 205 206 #Method explicit SkFont(sk_sp<SkTypeface> typeface) 207 #In Constructor 208 #Line # incomplete ## 209 #Populate 210 #Example 211 // incomplete 212 ## 213 214 #SeeAlso incomplete 215 216 #Method ## 217 218 # ------------------------------------------------------------------------------ 219 220 #Method SkFont(sk_sp<SkTypeface> typeface, SkScalar size, SkScalar scaleX, SkScalar skewX) 221 #In Constructor 222 #Line # incomplete ## 223 224 #Populate 225 226 #Example 227 // incomplete 228 ## 229 230 #SeeAlso incomplete 231 232 #Method ## 233 234 # ------------------------------------------------------------------------------ 235 236 #Method bool operator==(const SkFont& font) const 237 #In Operator 238 #Line # compares fonts for equality ## 239 240 #Populate 241 242 #Example 243 // incomplete 244 ## 245 246 #SeeAlso incomplete 247 248 #Method ## 249 250 # ------------------------------------------------------------------------------ 251 252 #Method bool operator!=(const SkFont& font) const 253 #In Operator 254 #Line # compares fonts for inequality ## 255 256 #Populate 257 258 #Example 259 // incomplete 260 ## 261 262 #SeeAlso incomplete 263 264 #Method ## 265 266 # ------------------------------------------------------------------------------ 267 268 #Method bool isForceAutoHinting() const 269 #In incomplete 270 #Line # incomplete ## 271 272 #Populate 273 274 #Example 275 // incomplete 276 ## 277 278 #SeeAlso incomplete 279 280 #Method ## 281 282 # ------------------------------------------------------------------------------ 283 284 #Method bool isEmbeddedBitmaps() const 285 #In incomplete 286 #Line # incomplete ## 287 288 #Populate 289 290 #Example 291 // incomplete 292 ## 293 294 #SeeAlso incomplete 295 296 #Method ## 297 298 # ------------------------------------------------------------------------------ 299 300 #Method bool isSubpixel() const 301 #In incomplete 302 #Line # incomplete ## 303 304 #Populate 305 306 #Example 307 // incomplete 308 ## 309 310 #SeeAlso incomplete 311 312 #Method ## 313 314 # ------------------------------------------------------------------------------ 315 316 #Method bool isLinearMetrics() const 317 #In incomplete 318 #Line # incomplete ## 319 320 #Populate 321 322 #Example 323 // incomplete 324 ## 325 326 #SeeAlso incomplete 327 328 #Method ## 329 330 # ------------------------------------------------------------------------------ 331 332 #Method bool isEmbolden() const 333 #In incomplete 334 #Line # incomplete ## 335 336 #Populate 337 338 #Example 339 // incomplete 340 ## 341 342 #SeeAlso incomplete 343 344 #Method ## 345 346 # ------------------------------------------------------------------------------ 347 348 #Method void setForceAutoHinting(bool forceAutoHinting) 349 #In incomplete 350 #Line # incomplete ## 351 352 #Populate 353 354 #Example 355 // incomplete 356 ## 357 358 #SeeAlso incomplete 359 360 #Method ## 361 362 # ------------------------------------------------------------------------------ 363 364 #Method void setEmbeddedBitmaps(bool embeddedBitmaps) 365 #In incomplete 366 #Line # incomplete ## 367 368 #Populate 369 370 #Example 371 // incomplete 372 ## 373 374 #SeeAlso incomplete 375 376 #Method ## 377 378 # ------------------------------------------------------------------------------ 379 380 #Method void setSubpixel(bool subpixel) 381 #In incomplete 382 #Line # incomplete ## 383 384 #Populate 385 386 #Example 387 // incomplete 388 ## 389 390 #SeeAlso incomplete 391 392 #Method ## 393 394 # ------------------------------------------------------------------------------ 395 396 #Method void setLinearMetrics(bool linearMetrics) 397 #In incomplete 398 #Line # incomplete ## 399 400 #Populate 401 402 #Example 403 // incomplete 404 ## 405 406 #SeeAlso incomplete 407 408 #Method ## 409 410 # ------------------------------------------------------------------------------ 411 412 #Method void setEmbolden(bool embolden) 413 #In incomplete 414 #Line # incomplete ## 415 416 #Populate 417 418 #Example 419 // incomplete 420 ## 421 422 #SeeAlso incomplete 423 424 #Method ## 425 426 # ------------------------------------------------------------------------------ 427 428 #Method Edging getEdging() const 429 #In incomplete 430 #Line # incomplete ## 431 432 #Populate 433 434 #Example 435 // incomplete 436 ## 437 438 #SeeAlso incomplete 439 440 #Method ## 441 442 # ------------------------------------------------------------------------------ 443 444 #Method void setEdging(Edging edging) 445 #In incomplete 446 #Line # incomplete ## 447 448 #Populate 449 450 #Example 451 // incomplete 452 ## 453 454 #SeeAlso incomplete 455 456 #Method ## 457 458 # ------------------------------------------------------------------------------ 459 460 #Method void setHinting(SkFontHinting hintingLevel) 461 #In incomplete 462 #Line # incomplete ## 463 464 #Populate 465 466 #Example 467 // incomplete 468 ## 469 470 #SeeAlso incomplete 471 472 #Method ## 473 474 # ------------------------------------------------------------------------------ 475 476 #Method SkFontHinting getHinting() const 477 #In incomplete 478 #Line # incomplete ## 479 480 #Populate 481 482 #Example 483 // incomplete 484 ## 485 486 #SeeAlso incomplete 487 488 #Method ## 489 490 # ------------------------------------------------------------------------------ 491 492 #Method SkFont makeWithSize(SkScalar size) const 493 #In incomplete 494 #Line # incomplete ## 495 496 #Populate 497 498 #Example 499 // incomplete 500 ## 501 502 #SeeAlso incomplete 503 504 #Method ## 505 506 # ------------------------------------------------------------------------------ 507 508 #Method SkTypeface* getTypeface() const 509 #In incomplete 510 #Line # incomplete ## 511 512 #Populate 513 514 #Example 515 // incomplete 516 ## 517 518 #SeeAlso incomplete 519 520 #Method ## 521 522 # ------------------------------------------------------------------------------ 523 524 #Method SkTypeface* getTypefaceOrDefault() const 525 #In incomplete 526 #Line # incomplete ## 527 528 #Populate 529 530 #Example 531 // incomplete 532 ## 533 534 #SeeAlso incomplete 535 536 #Method ## 537 538 # ------------------------------------------------------------------------------ 539 540 #Method SkScalar getSize() const 541 #In incomplete 542 #Line # incomplete ## 543 544 #Populate 545 546 #Example 547 // incomplete 548 ## 549 550 #SeeAlso incomplete 551 552 #Method ## 553 554 # ------------------------------------------------------------------------------ 555 556 #Method SkScalar getScaleX() const 557 #In incomplete 558 #Line # incomplete ## 559 560 #Populate 561 562 #Example 563 // incomplete 564 ## 565 566 #SeeAlso incomplete 567 568 #Method ## 569 570 # ------------------------------------------------------------------------------ 571 572 #Method SkScalar getSkewX() const 573 #In incomplete 574 #Line # incomplete ## 575 576 #Populate 577 578 #Example 579 // incomplete 580 ## 581 582 #SeeAlso incomplete 583 584 #Method ## 585 586 # ------------------------------------------------------------------------------ 587 588 #Method sk_sp<SkTypeface> refTypeface() const 589 #In incomplete 590 #Line # incomplete ## 591 592 #Populate 593 594 #Example 595 // incomplete 596 ## 597 598 #SeeAlso incomplete 599 600 #Method ## 601 602 # ------------------------------------------------------------------------------ 603 604 #Method sk_sp<SkTypeface> refTypefaceOrDefault() const 605 #In incomplete 606 #Line # incomplete ## 607 608 #Populate 609 610 #Example 611 // incomplete 612 ## 613 614 #SeeAlso incomplete 615 616 #Method ## 617 618 # ------------------------------------------------------------------------------ 619 620 #Method void setTypeface(sk_sp<SkTypeface> tf) 621 #In incomplete 622 #Line # incomplete ## 623 624 #Populate 625 626 #Example 627 // incomplete 628 ## 629 630 #SeeAlso incomplete 631 632 #Method ## 633 634 # ------------------------------------------------------------------------------ 635 636 #Method void setSize(SkScalar textSize) 637 #In incomplete 638 #Line # incomplete ## 639 640 #Populate 641 642 #Example 643 // incomplete 644 ## 645 646 #SeeAlso incomplete 647 648 #Method ## 649 650 # ------------------------------------------------------------------------------ 651 652 #Method void setScaleX(SkScalar scaleX) 653 #In incomplete 654 #Line # incomplete ## 655 656 #Populate 657 658 #Example 659 // incomplete 660 ## 661 662 #SeeAlso incomplete 663 664 #Method ## 665 666 # ------------------------------------------------------------------------------ 667 668 #Method void setSkewX(SkScalar skewX) 669 #In incomplete 670 #Line # incomplete ## 671 672 #Populate 673 674 #Example 675 // incomplete 676 ## 677 678 #SeeAlso incomplete 679 680 #Method ## 681 682 # ------------------------------------------------------------------------------ 683 684 #Method int textToGlyphs(const void* text, size_t byteLength, SkTextEncoding encoding, 685 SkGlyphID glyphs[], int maxGlyphCount) const 686 #In Utility 687 #Line # converts text into glyph indices ## 688 #Populate 689 690 #Example 691 #Height 64 692 void draw(SkCanvas* canvas) { 693 SkFont font; 694 const uint8_t utf8[] = { 0x24, 0xC2, 0xA2, 0xE2, 0x82, 0xAC, 0xC2, 0xA5, 0xC2, 0xA3 }; 695 std::vector<SkGlyphID> glyphs; 696 int count = font.textToGlyphs(utf8, sizeof(utf8), SkTextEncoding::kUTF8, nullptr, 0); 697 glyphs.resize(count); 698 (void) font.textToGlyphs(utf8, sizeof(utf8), SkTextEncoding::kUTF8, &glyphs.front(), 699 count); 700 font.setSize(32); 701 canvas->drawSimpleText(&glyphs.front(), glyphs.size() * sizeof(SkGlyphID), 702 SkTextEncoding::kGlyphID, 10, 40, font, SkPaint()); 703 } 704 ## 705 706 #SeeAlso incomplete 707 708 #Method ## 709 710 # ------------------------------------------------------------------------------ 711 712 #Method SkGlyphID unicharToGlyph(SkUnichar uni) const 713 #In incomplete 714 #Line # incomplete ## 715 716 #Populate 717 718 #Example 719 // incomplete 720 ## 721 722 #SeeAlso incomplete 723 724 #Method ## 725 726 # ------------------------------------------------------------------------------ 727 728 #Method int countText(const void* text, size_t byteLength, SkTextEncoding encoding) const 729 #In Utility 730 #Line # returns number of Glyphs in text ## 731 #Populate 732 733 #Example 734 SkFont font; 735 const uint8_t utf8[] = { 0x24, 0xC2, 0xA2, 0xE2, 0x82, 0xAC, 0xC2, 0xA5, 0xC2, 0xA3 }; 736 SkDebugf("count = %d\n", font.countText(utf8, sizeof(utf8), SkTextEncoding::kUTF8)); 737 738 #StdOut 739 count = 5 740 ## 741 ## 742 743 #SeeAlso incomplete 744 745 #Method ## 746 747 # ------------------------------------------------------------------------------ 748 749 #Method SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding encoding, 750 SkRect* bounds = nullptr) const 751 #In incomplete 752 #Line # returns advance width and bounds of text ## 753 #Populate 754 755 #Example 756 SkFont font; 757 SkDebugf("default width = %g\n", font.measureText("!", 1, SkTextEncoding::kUTF8)); 758 font.setSize(font.getSize() * 2); 759 SkDebugf("double width = %g\n", font.measureText("!", 1, SkTextEncoding::kUTF8)); 760 761 #StdOut 762 default width = 5 763 double width = 10 764 ## 765 ## 766 767 #SeeAlso incomplete 768 769 #Method ## 770 771 772 #Method SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding encoding, 773 SkRect* bounds, const SkPaint* paint) const 774 #In incomplete 775 #Populate 776 777 #Example 778 #Height 64 779 void draw(SkCanvas* canvas) { 780 SkPaint paint; 781 paint.setAntiAlias(true); 782 SkFont font(nullptr, 50); 783 const char str[] = "ay^jZ"; 784 const int count = sizeof(str) - 1; 785 canvas->drawSimpleText(str, count, SkTextEncoding::kUTF8, 25, 50, font, paint); 786 SkRect bounds; 787 font.measureText(str, count, SkTextEncoding::kUTF8, &bounds, nullptr); 788 canvas->translate(25, 50); 789 paint.setStyle(SkPaint::kStroke_Style); 790 canvas->drawRect(bounds, paint); 791 } 792 ## 793 794 #SeeAlso incomplete 795 796 #Method ## 797 798 #Method void getWidths(const uint16_t glyphs[], int count, SkScalar widths[]) const 799 #In incomplete 800 #Line # returns advance and bounds for each glyph in text ## 801 #Populate 802 #Example 803 // incomplete 804 ## 805 #SeeAlso incomplete 806 #Method ## 807 808 #Method void getWidthsBounds(const uint16_t glyphs[], int count, SkScalar widths[], SkRect bounds[], 809 const SkPaint* paint) const 810 #In incomplete 811 #Populate 812 #Example 813 #Height 160 814 #Description 815 Bounds of Glyphs increase for stroked text, but text advance remains the same. 816 The underlines show the text advance, spaced to keep them distinct. 817 ## 818 void draw(SkCanvas* canvas) { 819 SkPaint paint; 820 paint.setAntiAlias(true); 821 SkFont font(nullptr, 50); 822 const char str[] = "abc"; 823 const int bytes = sizeof(str) - 1; 824 int count = font.textToGlyphs(str, bytes, SkTextEncoding::kUTF8, nullptr, 0); 825 std::vector<SkGlyphID> glyphs; 826 std::vector<SkScalar> widths; 827 std::vector<SkRect> bounds; 828 glyphs.resize(count); 829 (void) font.textToGlyphs(str, bytes, SkTextEncoding::kUTF8, &glyphs.front(), count); 830 widths.resize(count); 831 bounds.resize(count); 832 for (int loop = 0; loop < 2; ++loop) { 833 (void) font.getWidthsBounds(&glyphs.front(), count, &widths.front(), &bounds.front(), 834 &paint); 835 SkPoint loc = { 25, 50 }; 836 canvas->drawSimpleText(str, bytes, SkTextEncoding::kUTF8, loc.fX, loc.fY, font, paint); 837 paint.setStyle(SkPaint::kStroke_Style); 838 paint.setStrokeWidth(0); 839 SkScalar advanceY = loc.fY + 10; 840 for (int index = 0; index < count; ++index) { 841 bounds[index].offset(loc.fX, loc.fY); 842 canvas->drawRect(bounds[index], paint); 843 canvas->drawLine(loc.fX, advanceY, loc.fX + widths[index], advanceY, paint); 844 loc.fX += widths[index]; 845 advanceY += 5; 846 } 847 canvas->translate(0, 80); 848 paint.setStrokeWidth(3); 849 } 850 } 851 ## 852 #SeeAlso incomplete 853 #Method ## 854 855 #Method void getBounds(const uint16_t glyphs[], int count, SkRect bounds[], 856 const SkPaint* paint) const 857 #In incomplete 858 #Populate 859 #Example 860 // incomplete 861 ## 862 #SeeAlso incomplete 863 #Method ## 864 865 #Method void getPos(const uint16_t glyphs[], int count, SkPoint pos[], SkPoint origin = {0, 0}) const 866 #In incomplete 867 #Populate 868 #Example 869 // incomplete 870 ## 871 #SeeAlso incomplete 872 #Method ## 873 874 #Method void getXPos(const uint16_t glyphs[], int count, SkScalar xpos[], SkScalar origin = 0) const 875 #In incomplete 876 #Populate 877 #Example 878 // incomplete 879 ## 880 #SeeAlso incomplete 881 #Method ## 882 883 # ------------------------------------------------------------------------------ 884 885 #Method bool getPath(uint16_t glyphID, SkPath* path) const 886 #In incomplete 887 #Line # returns Path equivalent to text ## 888 #Populate 889 890 #Example 891 #Description 892 Text is added to Path, offset, and subtracted from Path, then added at 893 the offset location. The result is rendered with one draw call. 894 ## 895 #Height 128 896 void draw(SkCanvas* canvas) { 897 SkPaint paint; 898 SkFont font(nullptr, 80); 899 SkPath onePath, path, path2; 900 const char str[] = "ABC"; 901 const int bytes = sizeof(str) - 1; 902 int count = font.textToGlyphs(str, bytes, SkTextEncoding::kUTF8, nullptr, 0); 903 std::vector<SkGlyphID> glyphs; 904 glyphs.resize(count); 905 (void) font.textToGlyphs(str, bytes, SkTextEncoding::kUTF8, &glyphs.front(), count); 906 int xPos = 20; 907 for (auto oneGlyph : glyphs) { 908 font.getPath(oneGlyph, &onePath); 909 path.addPath(onePath, xPos, 60); 910 xPos += 60; 911 } 912 path.offset(20, 20, &path2); 913 Op(path, path2, SkPathOp::kDifference_SkPathOp, &path); 914 path.addPath(path2); 915 paint.setStyle(SkPaint::kStroke_Style); 916 canvas->drawPath(path, paint); 917 } 918 ## 919 920 #SeeAlso incomplete 921 922 #Method ## 923 924 # ------------------------------------------------------------------------------ 925 926 #Method void getPaths(const uint16_t glyphIDs[], int count, 927 void (*glyphPathProc)(const SkPath* pathOrNull, const SkMatrix& mx, void* ctx), 928 void* ctx) const 929 #In incomplete 930 #Line # incomplete ## 931 932 #Populate 933 934 #Example 935 // incomplete 936 ## 937 938 #SeeAlso incomplete 939 940 #Method ## 941 942 # ------------------------------------------------------------------------------ 943 944 #Method SkScalar getMetrics(SkFontMetrics* metrics) const 945 #In incomplete 946 #Line # returns Typeface metrics scaled by text size ## 947 #Populate 948 949 #Example 950 #Height 128 951 void draw(SkCanvas* canvas) { 952 SkFont font(nullptr, 32); 953 SkScalar lineHeight = font.getMetrics(nullptr); 954 SkPaint paint; 955 canvas->drawSimpleText("line 1", 6, SkTextEncoding::kUTF8, 10, 40, font, paint); 956 canvas->drawSimpleText("line 2", 6, SkTextEncoding::kUTF8, 10, 40 + lineHeight, font, paint); 957 } 958 ## 959 960 #SeeAlso incomplete 961 962 #Method ## 963 964 # ------------------------------------------------------------------------------ 965 966 #Method SkScalar getSpacing() const 967 #In incomplete 968 #Line # returns recommended spacing between lines ## 969 970 #Populate 971 972 #Example 973 SkFont font; 974 for (SkScalar textSize : { 12, 18, 24, 32 } ) { 975 font.setSize(textSize); 976 SkDebugf("textSize: %g spacing: %g\n", textSize, font.getSpacing()); 977 } 978 979 #StdOut 980 textSize: 12 spacing: 13.9688 981 textSize: 18 spacing: 20.9531 982 textSize: 24 spacing: 27.9375 983 textSize: 32 spacing: 37.25 984 ## 985 ## 986 987 #SeeAlso incomplete 988 989 #Method ## 990 991 # ------------------------------------------------------------------------------ 992 993 #Class SkFont ## 994 995 #Topic Font ## 996