Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 1 | #Topic Font |
| 2 | #Alias Font_Reference ## |
| 3 | |
Cary Clark | 3e73dcf | 2018-12-06 08:41:14 -0500 | [diff] [blame] | 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 | |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 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 | |
Cary Clark | 3e73dcf | 2018-12-06 08:41:14 -0500 | [diff] [blame] | 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. |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 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 | |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 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 | |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 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 | |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 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 | |
Mike Reed | 42af492 | 2018-11-30 08:54:46 -0500 | [diff] [blame] | 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 ## |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 249 | |
| 250 | # ------------------------------------------------------------------------------ |
| 251 | |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 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 | |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 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 | |
Herb Derby | 114b5af | 2019-01-23 14:24:14 -0500 | [diff] [blame] | 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 | |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 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 | |
Herb Derby | 114b5af | 2019-01-23 14:24:14 -0500 | [diff] [blame] | 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 | |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 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 |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 686 | #In Utility |
| 687 | #Line # converts text into glyph indices ## |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 688 | #Populate |
| 689 | |
| 690 | #Example |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 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 | } |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 704 | ## |
| 705 | |
| 706 | #SeeAlso incomplete |
| 707 | |
| 708 | #Method ## |
| 709 | |
| 710 | # ------------------------------------------------------------------------------ |
| 711 | |
| 712 | #Method uint16_t 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 |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 729 | #In Utility |
| 730 | #Line # returns number of Glyphs in text ## |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 731 | #Populate |
| 732 | |
| 733 | #Example |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 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 | ## |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 741 | ## |
| 742 | |
| 743 | #SeeAlso incomplete |
| 744 | |
| 745 | #Method ## |
| 746 | |
| 747 | # ------------------------------------------------------------------------------ |
| 748 | |
Mike Reed | 42af492 | 2018-11-30 08:54:46 -0500 | [diff] [blame] | 749 | #Method bool containsText(const void* text, size_t byteLength, SkTextEncoding encoding) const |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 750 | #In Utility |
| 751 | #Line # returns if all text corresponds to Glyphs ## |
Mike Reed | 42af492 | 2018-11-30 08:54:46 -0500 | [diff] [blame] | 752 | #Populate |
| 753 | |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 754 | #NoExample |
| 755 | #Description |
| 756 | containsText succeeds for degree symbol, but cannot find a glyph index |
| 757 | corresponding to the Unicode surrogate code point. |
| 758 | ## |
| 759 | SkFont font; |
| 760 | const uint16_t goodChar = 0x00B0; // degree symbol |
| 761 | const uint16_t badChar = 0xD800; // Unicode surrogate |
| 762 | SkDebugf("0x%04x %c= has char\n", goodChar, |
| 763 | font.containsText(&goodChar, 2, SkTextEncoding::kUTF16) ? '=' : '!'); |
| 764 | SkDebugf("0x%04x %c= has char\n", badChar, |
| 765 | font.containsText(&badChar, 2, SkTextEncoding::kUTF16) ? '=' : '!'); |
| 766 | |
| 767 | #StdOut |
| 768 | 0x00b0 == has char |
| 769 | 0xd800 != has char |
| 770 | ## |
| 771 | ## |
| 772 | |
Mike Reed | 42af492 | 2018-11-30 08:54:46 -0500 | [diff] [blame] | 773 | #Example |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 774 | #Description |
| 775 | containsText returns true that glyph index is greater than zero, not |
| 776 | that it corresponds to an entry in Typeface. |
| 777 | ## |
| 778 | SkFont font; |
| 779 | const uint16_t goodGlyph = 511; |
| 780 | const uint16_t zeroGlyph = 0; |
| 781 | const uint16_t badGlyph = 65535; // larger than glyph count in font |
| 782 | SkDebugf("0x%04x %c= has glyph\n", goodGlyph, |
| 783 | font.containsText(&goodGlyph, 2, SkTextEncoding::kGlyphID) ? '=' : '!'); |
| 784 | SkDebugf("0x%04x %c= has glyph\n", zeroGlyph, |
| 785 | font.containsText(&zeroGlyph, 2, SkTextEncoding::kGlyphID) ? '=' : '!'); |
| 786 | SkDebugf("0x%04x %c= has glyph\n", badGlyph, |
| 787 | font.containsText(&badGlyph, 2, SkTextEncoding::kGlyphID) ? '=' : '!'); |
| 788 | |
| 789 | #StdOut |
| 790 | 0x01ff == has glyph |
| 791 | 0x0000 != has glyph |
| 792 | 0xffff == has glyph |
| 793 | ## |
Mike Reed | 42af492 | 2018-11-30 08:54:46 -0500 | [diff] [blame] | 794 | ## |
| 795 | |
| 796 | #SeeAlso incomplete |
| 797 | |
| 798 | #Method ## |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 799 | |
| 800 | # ------------------------------------------------------------------------------ |
Herb Derby | 114b5af | 2019-01-23 14:24:14 -0500 | [diff] [blame] | 801 | |
| 802 | #Method size_t breakText(const void* text, size_t length, SkTextEncoding encoding, SkScalar maxWidth, |
| 803 | SkScalar* measuredWidth = nullptr) const |
| 804 | #In incomplete |
| 805 | #Line # incomplete ## |
| 806 | #Populate |
| 807 | |
Cary Clark | 5b671c3 | 2018-12-03 04:53:21 -0500 | [diff] [blame] | 808 | #Example |
Cary Clark | e954b9d | 2018-12-10 09:22:56 -0500 | [diff] [blame] | 809 | #Description |
| 810 | Line under "Breakfast" shows desired width, shorter than available characters. |
| 811 | Line under "Bre" shows measured width after breaking text. |
| 812 | ## |
| 813 | #Height 128 |
| 814 | #Width 280 |
| 815 | void draw(SkCanvas* canvas) { |
| 816 | SkPaint paint; |
Hal Canary | 532c418 | 2019-01-09 11:37:29 -0500 | [diff] [blame] | 817 | SkFont font(nullptr, 50); |
Cary Clark | e954b9d | 2018-12-10 09:22:56 -0500 | [diff] [blame] | 818 | const char str[] = "Breakfast"; |
Hal Canary | 532c418 | 2019-01-09 11:37:29 -0500 | [diff] [blame] | 819 | const int count = strlen(str); |
| 820 | canvas->drawSimpleText(str, count, kUTF8_SkTextEncoding, |
| 821 | 25, 50, font, paint); |
Cary Clark | e954b9d | 2018-12-10 09:22:56 -0500 | [diff] [blame] | 822 | SkScalar measuredWidth; |
Cary Clark | e954b9d | 2018-12-10 09:22:56 -0500 | [diff] [blame] | 823 | int partialBytes = font.breakText(str, count, kUTF8_SkTextEncoding, |
Hal Canary | 532c418 | 2019-01-09 11:37:29 -0500 | [diff] [blame] | 824 | 100, &measuredWidth); |
| 825 | canvas->drawSimpleText(str, partialBytes, kUTF8_SkTextEncoding, |
| 826 | 25, 100, font, paint); |
Cary Clark | e954b9d | 2018-12-10 09:22:56 -0500 | [diff] [blame] | 827 | canvas->drawLine(25, 60, 25 + 100, 60, paint); |
| 828 | canvas->drawLine(25, 110, 25 + measuredWidth, 110, paint); |
| 829 | } |
Herb Derby | 114b5af | 2019-01-23 14:24:14 -0500 | [diff] [blame] | 830 | ## |
| 831 | |
| 832 | #SeeAlso incomplete |
| 833 | |
| 834 | #Method ## |
Cary Clark | 5b671c3 | 2018-12-03 04:53:21 -0500 | [diff] [blame] | 835 | |
| 836 | # ------------------------------------------------------------------------------ |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 837 | |
| 838 | #Method SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding encoding, |
| 839 | SkRect* bounds = nullptr) const |
| 840 | #In incomplete |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 841 | #Line # returns advance width and bounds of text ## |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 842 | #Populate |
| 843 | |
| 844 | #Example |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 845 | SkFont font; |
| 846 | SkDebugf("default width = %g\n", font.measureText("!", 1, SkTextEncoding::kUTF8)); |
| 847 | font.setSize(font.getSize() * 2); |
| 848 | SkDebugf("double width = %g\n", font.measureText("!", 1, SkTextEncoding::kUTF8)); |
| 849 | |
| 850 | #StdOut |
| 851 | default width = 5 |
| 852 | double width = 10 |
| 853 | ## |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 854 | ## |
| 855 | |
| 856 | #SeeAlso incomplete |
| 857 | |
| 858 | #Method ## |
| 859 | |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 860 | |
| 861 | #Method SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding encoding, |
| 862 | SkRect* bounds, const SkPaint* paint) const |
| 863 | #In incomplete |
| 864 | #Populate |
| 865 | |
| 866 | #Example |
| 867 | #Height 64 |
| 868 | void draw(SkCanvas* canvas) { |
| 869 | SkPaint paint; |
| 870 | paint.setAntiAlias(true); |
| 871 | SkFont font(nullptr, 50); |
| 872 | const char str[] = "ay^jZ"; |
| 873 | const int count = sizeof(str) - 1; |
| 874 | canvas->drawSimpleText(str, count, SkTextEncoding::kUTF8, 25, 50, font, paint); |
| 875 | SkRect bounds; |
| 876 | font.measureText(str, count, SkTextEncoding::kUTF8, &bounds, nullptr); |
| 877 | canvas->translate(25, 50); |
| 878 | paint.setStyle(SkPaint::kStroke_Style); |
| 879 | canvas->drawRect(bounds, paint); |
| 880 | } |
| 881 | ## |
| 882 | |
| 883 | #SeeAlso incomplete |
| 884 | |
| 885 | #Method ## |
| 886 | |
| 887 | #Method void getWidths(const uint16_t glyphs[], int count, SkScalar widths[]) const |
| 888 | #In incomplete |
| 889 | #Line # returns advance and bounds for each glyph in text ## |
| 890 | #Populate |
| 891 | #Example |
| 892 | // incomplete |
| 893 | ## |
| 894 | #SeeAlso incomplete |
| 895 | #Method ## |
| 896 | |
| 897 | #Method void getWidthsBounds(const uint16_t glyphs[], int count, SkScalar widths[], SkRect bounds[], |
| 898 | const SkPaint* paint) const |
| 899 | #In incomplete |
| 900 | #Populate |
| 901 | #Example |
| 902 | #Height 160 |
| 903 | #Description |
| 904 | Bounds of Glyphs increase for stroked text, but text advance remains the same. |
| 905 | The underlines show the text advance, spaced to keep them distinct. |
| 906 | ## |
| 907 | void draw(SkCanvas* canvas) { |
| 908 | SkPaint paint; |
| 909 | paint.setAntiAlias(true); |
| 910 | SkFont font(nullptr, 50); |
| 911 | const char str[] = "abc"; |
| 912 | const int bytes = sizeof(str) - 1; |
| 913 | int count = font.textToGlyphs(str, bytes, SkTextEncoding::kUTF8, nullptr, 0); |
| 914 | std::vector<SkGlyphID> glyphs; |
| 915 | std::vector<SkScalar> widths; |
| 916 | std::vector<SkRect> bounds; |
| 917 | glyphs.resize(count); |
| 918 | (void) font.textToGlyphs(str, bytes, SkTextEncoding::kUTF8, &glyphs.front(), count); |
| 919 | widths.resize(count); |
| 920 | bounds.resize(count); |
| 921 | for (int loop = 0; loop < 2; ++loop) { |
| 922 | (void) font.getWidthsBounds(&glyphs.front(), count, &widths.front(), &bounds.front(), |
| 923 | &paint); |
| 924 | SkPoint loc = { 25, 50 }; |
| 925 | canvas->drawSimpleText(str, bytes, SkTextEncoding::kUTF8, loc.fX, loc.fY, font, paint); |
| 926 | paint.setStyle(SkPaint::kStroke_Style); |
| 927 | paint.setStrokeWidth(0); |
| 928 | SkScalar advanceY = loc.fY + 10; |
| 929 | for (int index = 0; index < count; ++index) { |
| 930 | bounds[index].offset(loc.fX, loc.fY); |
| 931 | canvas->drawRect(bounds[index], paint); |
| 932 | canvas->drawLine(loc.fX, advanceY, loc.fX + widths[index], advanceY, paint); |
| 933 | loc.fX += widths[index]; |
| 934 | advanceY += 5; |
| 935 | } |
| 936 | canvas->translate(0, 80); |
| 937 | paint.setStrokeWidth(3); |
| 938 | } |
| 939 | } |
| 940 | ## |
| 941 | #SeeAlso incomplete |
| 942 | #Method ## |
| 943 | |
| 944 | #Method void getBounds(const uint16_t glyphs[], int count, SkRect bounds[], |
| 945 | const SkPaint* paint) const |
| 946 | #In incomplete |
| 947 | #Populate |
| 948 | #Example |
| 949 | // incomplete |
| 950 | ## |
| 951 | #SeeAlso incomplete |
| 952 | #Method ## |
| 953 | |
| 954 | #Method void getPos(const uint16_t glyphs[], int count, SkPoint pos[], SkPoint origin = {0, 0}) const |
| 955 | #In incomplete |
| 956 | #Populate |
| 957 | #Example |
| 958 | // incomplete |
| 959 | ## |
| 960 | #SeeAlso incomplete |
| 961 | #Method ## |
| 962 | |
| 963 | #Method void getXPos(const uint16_t glyphs[], int count, SkScalar xpos[], SkScalar origin = 0) const |
| 964 | #In incomplete |
| 965 | #Populate |
| 966 | #Example |
| 967 | // incomplete |
| 968 | ## |
| 969 | #SeeAlso incomplete |
| 970 | #Method ## |
| 971 | |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 972 | # ------------------------------------------------------------------------------ |
| 973 | |
| 974 | #Method bool getPath(uint16_t glyphID, SkPath* path) const |
| 975 | #In incomplete |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 976 | #Line # returns Path equivalent to text ## |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 977 | #Populate |
| 978 | |
| 979 | #Example |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 980 | #Description |
| 981 | Text is added to Path, offset, and subtracted from Path, then added at |
| 982 | the offset location. The result is rendered with one draw call. |
| 983 | ## |
| 984 | #Height 128 |
| 985 | void draw(SkCanvas* canvas) { |
Herb Derby | 114b5af | 2019-01-23 14:24:14 -0500 | [diff] [blame] | 986 | SkPaint paint; |
| 987 | SkFont font(nullptr, 80); |
| 988 | SkPath onePath, path, path2; |
| 989 | const char str[] = "ABC"; |
| 990 | const int bytes = sizeof(str) - 1; |
| 991 | int count = font.textToGlyphs(str, bytes, SkTextEncoding::kUTF8, nullptr, 0); |
| 992 | std::vector<SkGlyphID> glyphs; |
| 993 | glyphs.resize(count); |
| 994 | (void) font.textToGlyphs(str, bytes, SkTextEncoding::kUTF8, &glyphs.front(), count); |
| 995 | int xPos = 20; |
| 996 | for (auto oneGlyph : glyphs) { |
| 997 | font.getPath(oneGlyph, &onePath); |
| 998 | path.addPath(onePath, xPos, 60); |
| 999 | xPos += 60; |
| 1000 | } |
| 1001 | path.offset(20, 20, &path2); |
| 1002 | Op(path, path2, SkPathOp::kDifference_SkPathOp, &path); |
| 1003 | path.addPath(path2); |
| 1004 | paint.setStyle(SkPaint::kStroke_Style); |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 1005 | canvas->drawPath(path, paint); |
| 1006 | } |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 1007 | ## |
| 1008 | |
| 1009 | #SeeAlso incomplete |
| 1010 | |
| 1011 | #Method ## |
| 1012 | |
| 1013 | # ------------------------------------------------------------------------------ |
| 1014 | |
| 1015 | #Method void getPaths(const uint16_t glyphIDs[], int count, |
| 1016 | void (*glyphPathProc)(const SkPath* pathOrNull, const SkMatrix& mx, void* ctx), |
| 1017 | void* ctx) const |
| 1018 | #In incomplete |
| 1019 | #Line # incomplete ## |
| 1020 | |
| 1021 | #Populate |
| 1022 | |
| 1023 | #Example |
| 1024 | // incomplete |
| 1025 | ## |
| 1026 | |
| 1027 | #SeeAlso incomplete |
| 1028 | |
| 1029 | #Method ## |
| 1030 | |
| 1031 | # ------------------------------------------------------------------------------ |
| 1032 | |
| 1033 | #Method SkScalar getMetrics(SkFontMetrics* metrics) const |
| 1034 | #In incomplete |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 1035 | #Line # returns Typeface metrics scaled by text size ## |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 1036 | #Populate |
| 1037 | |
| 1038 | #Example |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 1039 | #Height 128 |
| 1040 | void draw(SkCanvas* canvas) { |
| 1041 | SkFont font(nullptr, 32); |
| 1042 | SkScalar lineHeight = font.getMetrics(nullptr); |
| 1043 | SkPaint paint; |
| 1044 | canvas->drawSimpleText("line 1", 6, SkTextEncoding::kUTF8, 10, 40, font, paint); |
| 1045 | canvas->drawSimpleText("line 2", 6, SkTextEncoding::kUTF8, 10, 40 + lineHeight, font, paint); |
| 1046 | } |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 1047 | ## |
| 1048 | |
| 1049 | #SeeAlso incomplete |
| 1050 | |
| 1051 | #Method ## |
| 1052 | |
| 1053 | # ------------------------------------------------------------------------------ |
| 1054 | |
| 1055 | #Method SkScalar getSpacing() const |
| 1056 | #In incomplete |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 1057 | #Line # returns recommended spacing between lines ## |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 1058 | |
| 1059 | #Populate |
| 1060 | |
| 1061 | #Example |
Cary Clark | 26d173f | 2019-01-07 15:16:56 -0500 | [diff] [blame] | 1062 | SkFont font; |
| 1063 | for (SkScalar textSize : { 12, 18, 24, 32 } ) { |
| 1064 | font.setSize(textSize); |
| 1065 | SkDebugf("textSize: %g spacing: %g\n", textSize, font.getSpacing()); |
| 1066 | } |
| 1067 | |
| 1068 | #StdOut |
| 1069 | textSize: 12 spacing: 13.9688 |
| 1070 | textSize: 18 spacing: 20.9531 |
| 1071 | textSize: 24 spacing: 27.9375 |
| 1072 | textSize: 32 spacing: 37.25 |
| 1073 | ## |
Cary Clark | cb6bef0 | 2018-11-29 12:05:25 -0500 | [diff] [blame] | 1074 | ## |
| 1075 | |
| 1076 | #SeeAlso incomplete |
| 1077 | |
| 1078 | #Method ## |
| 1079 | |
| 1080 | # ------------------------------------------------------------------------------ |
| 1081 | |
| 1082 | #Class SkFont ## |
| 1083 | |
| 1084 | #Topic Font ## |