OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCommandLineFlags.h" | 8 #include "SkCommandLineFlags.h" |
9 #include "SkFontMgr.h" | 9 #include "SkFontMgr.h" |
10 #include "SkTypeface.h" | 10 #include "SkTypeface.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 SkString sname; | 103 SkString sname; |
104 SkFontStyle fs; | 104 SkFontStyle fs; |
105 set->getStyle(j, &fs, &sname); | 105 set->getStyle(j, &fs, &sname); |
106 // REPORTER_ASSERT(reporter, sname.size() > 0); | 106 // REPORTER_ASSERT(reporter, sname.size() > 0); |
107 | 107 |
108 SkAutoTUnref<SkTypeface> face(set->createTypeface(j)); | 108 SkAutoTUnref<SkTypeface> face(set->createTypeface(j)); |
109 // REPORTER_ASSERT(reporter, face.get()); | 109 // REPORTER_ASSERT(reporter, face.get()); |
110 | 110 |
111 if (verbose) { | 111 if (verbose) { |
112 SkDebugf("\t[%d] %s [%3d %d %d]\n", j, sname.c_str(), | 112 SkDebugf("\t[%d] %s [%3d %d %d]\n", j, sname.c_str(), |
113 fs.weight(), fs.width(), fs.isItalic()); | 113 fs.weight(), fs.width(), fs.slant()); |
114 } | 114 } |
115 } | 115 } |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 static void test_matchStyleCSS3(skiatest::Reporter* reporter) { | 119 static void test_matchStyleCSS3(skiatest::Reporter* reporter) { |
120 static const SkFontID invalidFontID = std::numeric_limits<SkFontID>::max(); | 120 static const SkFontID invalidFontID = std::numeric_limits<SkFontID>::max(); |
121 static const SkFontStyle invalidFontStyle(101, SkFontStyle::kNormal_Width, S
kFontStyle::kUpright_Slant); | 121 static const SkFontStyle invalidFontStyle(101, SkFontStyle::kNormal_Width, S
kFontStyle::kUpright_Slant); |
122 | 122 |
123 class TestTypeface : public SkTypeface { | 123 class TestTypeface : public SkTypeface { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 return this->matchStyleCSS3(pattern); | 178 return this->matchStyleCSS3(pattern); |
179 } | 179 } |
180 private: | 180 private: |
181 std::vector<SkFontStyle> fStyles; | 181 std::vector<SkFontStyle> fStyles; |
182 }; | 182 }; |
183 | 183 |
184 SkFontStyle condensed_normal_100(SkFontStyle::kThin_Weight, SkFontStyle::kC
ondensed_Width, SkFontStyle::kUpright_Slant); | 184 SkFontStyle condensed_normal_100(SkFontStyle::kThin_Weight, SkFontStyle::kC
ondensed_Width, SkFontStyle::kUpright_Slant); |
185 SkFontStyle condensed_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle::kC
ondensed_Width, SkFontStyle::kUpright_Slant); | 185 SkFontStyle condensed_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle::kC
ondensed_Width, SkFontStyle::kUpright_Slant); |
186 SkFontStyle condensed_italic_100(SkFontStyle::kThin_Weight, SkFontStyle::kC
ondensed_Width, SkFontStyle::kItalic_Slant); | 186 SkFontStyle condensed_italic_100(SkFontStyle::kThin_Weight, SkFontStyle::kC
ondensed_Width, SkFontStyle::kItalic_Slant); |
187 SkFontStyle condensed_italic_900(SkFontStyle::kBlack_Weight, SkFontStyle::kC
ondensed_Width, SkFontStyle::kItalic_Slant); | 187 SkFontStyle condensed_italic_900(SkFontStyle::kBlack_Weight, SkFontStyle::kC
ondensed_Width, SkFontStyle::kItalic_Slant); |
| 188 SkFontStyle condensed_obliqu_100(SkFontStyle::kThin_Weight, SkFontStyle::kC
ondensed_Width, SkFontStyle::kOblique_Slant); |
| 189 SkFontStyle condensed_obliqu_900(SkFontStyle::kBlack_Weight, SkFontStyle::kC
ondensed_Width, SkFontStyle::kOblique_Slant); |
188 SkFontStyle expanded_normal_100(SkFontStyle::kThin_Weight, SkFontStyle::kE
xpanded_Width, SkFontStyle::kUpright_Slant); | 190 SkFontStyle expanded_normal_100(SkFontStyle::kThin_Weight, SkFontStyle::kE
xpanded_Width, SkFontStyle::kUpright_Slant); |
189 SkFontStyle expanded_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle::kE
xpanded_Width, SkFontStyle::kUpright_Slant); | 191 SkFontStyle expanded_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle::kE
xpanded_Width, SkFontStyle::kUpright_Slant); |
190 SkFontStyle expanded_italic_100(SkFontStyle::kThin_Weight, SkFontStyle::kE
xpanded_Width, SkFontStyle::kItalic_Slant); | 192 SkFontStyle expanded_italic_100(SkFontStyle::kThin_Weight, SkFontStyle::kE
xpanded_Width, SkFontStyle::kItalic_Slant); |
191 SkFontStyle expanded_italic_900(SkFontStyle::kBlack_Weight, SkFontStyle::kE
xpanded_Width, SkFontStyle::kItalic_Slant); | 193 SkFontStyle expanded_italic_900(SkFontStyle::kBlack_Weight, SkFontStyle::kE
xpanded_Width, SkFontStyle::kItalic_Slant); |
| 194 SkFontStyle expanded_obliqu_100(SkFontStyle::kThin_Weight, SkFontStyle::kE
xpanded_Width, SkFontStyle::kOblique_Slant); |
| 195 SkFontStyle expanded_obliqu_900(SkFontStyle::kBlack_Weight, SkFontStyle::kE
xpanded_Width, SkFontStyle::kOblique_Slant); |
192 | 196 |
193 SkFontStyle normal_normal_100(SkFontStyle::kThin_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); | 197 SkFontStyle normal_normal_100(SkFontStyle::kThin_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); |
194 SkFontStyle normal_normal_200(SkFontStyle::kExtraLight_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); | 198 SkFontStyle normal_normal_200(SkFontStyle::kExtraLight_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); |
195 SkFontStyle normal_normal_300(SkFontStyle::kLight_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); | 199 SkFontStyle normal_normal_300(SkFontStyle::kLight_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); |
196 SkFontStyle normal_normal_400(SkFontStyle::kNormal_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); | 200 SkFontStyle normal_normal_400(SkFontStyle::kNormal_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); |
197 SkFontStyle normal_normal_500(SkFontStyle::kMedium_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); | 201 SkFontStyle normal_normal_500(SkFontStyle::kMedium_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); |
198 SkFontStyle normal_normal_600(SkFontStyle::kSemiBold_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); | 202 SkFontStyle normal_normal_600(SkFontStyle::kSemiBold_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); |
199 SkFontStyle normal_normal_700(SkFontStyle::kBold_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); | 203 SkFontStyle normal_normal_700(SkFontStyle::kBold_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); |
200 SkFontStyle normal_normal_800(SkFontStyle::kExtraBold_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); | 204 SkFontStyle normal_normal_800(SkFontStyle::kExtraBold_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); |
201 SkFontStyle normal_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); | 205 SkFontStyle normal_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle::
kNormal_Width, SkFontStyle::kUpright_Slant); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 { condensed_italic_100, condensed_italic_900 }, | 459 { condensed_italic_100, condensed_italic_900 }, |
456 { condensed_italic_900, condensed_italic_900 }, | 460 { condensed_italic_900, condensed_italic_900 }, |
457 { expanded_normal_100, condensed_italic_900 }, | 461 { expanded_normal_100, condensed_italic_900 }, |
458 { expanded_normal_900, condensed_italic_900 }, | 462 { expanded_normal_900, condensed_italic_900 }, |
459 { expanded_italic_100, condensed_italic_900 }, | 463 { expanded_italic_100, condensed_italic_900 }, |
460 { expanded_italic_900, condensed_italic_900 }, | 464 { expanded_italic_900, condensed_italic_900 }, |
461 }, | 465 }, |
462 }, | 466 }, |
463 | 467 |
464 { | 468 { |
465 { expanded_normal_100,expanded_normal_900,expanded_italic_100,expand
ed_italic_900 }, | 469 { expanded_normal_100,expanded_normal_900, |
| 470 expanded_italic_100,expanded_italic_900 }, |
466 { | 471 { |
467 { condensed_normal_100, expanded_normal_100 }, | 472 { condensed_normal_100, expanded_normal_100 }, |
468 { condensed_normal_900, expanded_normal_900 }, | 473 { condensed_normal_900, expanded_normal_900 }, |
469 { condensed_italic_100, expanded_italic_100 }, | 474 { condensed_italic_100, expanded_italic_100 }, |
470 { condensed_italic_900, expanded_italic_900 }, | 475 { condensed_italic_900, expanded_italic_900 }, |
| 476 { condensed_obliqu_100, expanded_italic_100 }, |
| 477 { condensed_obliqu_900, expanded_italic_900 }, |
471 { expanded_normal_100, expanded_normal_100 }, | 478 { expanded_normal_100, expanded_normal_100 }, |
472 { expanded_normal_900, expanded_normal_900 }, | 479 { expanded_normal_900, expanded_normal_900 }, |
473 { expanded_italic_100, expanded_italic_100 }, | 480 { expanded_italic_100, expanded_italic_100 }, |
474 { expanded_italic_900, expanded_italic_900 }, | 481 { expanded_italic_900, expanded_italic_900 }, |
| 482 { expanded_obliqu_100, expanded_italic_100 }, |
| 483 { expanded_obliqu_900, expanded_italic_900 }, |
475 }, | 484 }, |
476 }, | 485 }, |
477 | 486 |
478 { | 487 { |
479 { expanded_normal_100,expanded_italic_100 }, | 488 { expanded_normal_100,expanded_italic_100 }, |
480 { | 489 { |
481 { condensed_normal_100, expanded_normal_100 }, | 490 { condensed_normal_100, expanded_normal_100 }, |
482 { condensed_normal_900, expanded_normal_100 }, | 491 { condensed_normal_900, expanded_normal_100 }, |
483 { condensed_italic_100, expanded_italic_100 }, | 492 { condensed_italic_100, expanded_italic_100 }, |
484 { condensed_italic_900, expanded_italic_100 }, | 493 { condensed_italic_900, expanded_italic_100 }, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 | 628 |
620 { | 629 { |
621 { }, | 630 { }, |
622 { | 631 { |
623 { normal_normal_300, invalidFontStyle }, | 632 { normal_normal_300, invalidFontStyle }, |
624 { normal_normal_400, invalidFontStyle }, | 633 { normal_normal_400, invalidFontStyle }, |
625 { normal_normal_500, invalidFontStyle }, | 634 { normal_normal_500, invalidFontStyle }, |
626 { normal_normal_600, invalidFontStyle }, | 635 { normal_normal_600, invalidFontStyle }, |
627 }, | 636 }, |
628 }, | 637 }, |
| 638 { |
| 639 { expanded_normal_100,expanded_normal_900, |
| 640 expanded_italic_100,expanded_italic_900, |
| 641 expanded_obliqu_100,expanded_obliqu_900, }, |
| 642 { |
| 643 { condensed_normal_100, expanded_normal_100 }, |
| 644 { condensed_normal_900, expanded_normal_900 }, |
| 645 { condensed_italic_100, expanded_italic_100 }, |
| 646 { condensed_italic_900, expanded_italic_900 }, |
| 647 { condensed_obliqu_100, expanded_obliqu_100 }, |
| 648 { condensed_obliqu_900, expanded_obliqu_900 }, |
| 649 { expanded_normal_100, expanded_normal_100 }, |
| 650 { expanded_normal_900, expanded_normal_900 }, |
| 651 { expanded_italic_100, expanded_italic_100 }, |
| 652 { expanded_italic_900, expanded_italic_900 }, |
| 653 { expanded_obliqu_100, expanded_obliqu_100 }, |
| 654 { expanded_obliqu_900, expanded_obliqu_900 }, |
| 655 }, |
| 656 }, |
| 657 { |
| 658 { expanded_normal_100,expanded_normal_900, |
| 659 expanded_obliqu_100,expanded_obliqu_900, }, |
| 660 { |
| 661 { condensed_normal_100, expanded_normal_100 }, |
| 662 { condensed_normal_900, expanded_normal_900 }, |
| 663 { condensed_italic_100, expanded_obliqu_100 }, |
| 664 { condensed_italic_900, expanded_obliqu_900 }, |
| 665 { condensed_obliqu_100, expanded_obliqu_100 }, |
| 666 { condensed_obliqu_900, expanded_obliqu_900 }, |
| 667 { expanded_normal_100, expanded_normal_100 }, |
| 668 { expanded_normal_900, expanded_normal_900 }, |
| 669 { expanded_italic_100, expanded_obliqu_100 }, |
| 670 { expanded_italic_900, expanded_obliqu_900 }, |
| 671 { expanded_obliqu_100, expanded_obliqu_100 }, |
| 672 { expanded_obliqu_900, expanded_obliqu_900 }, |
| 673 }, |
| 674 }, |
| 675 { |
| 676 { expanded_italic_100,expanded_italic_900, |
| 677 expanded_obliqu_100,expanded_obliqu_900, }, |
| 678 { |
| 679 { condensed_normal_100, expanded_obliqu_100 }, |
| 680 { condensed_normal_900, expanded_obliqu_900 }, |
| 681 { condensed_italic_100, expanded_italic_100 }, |
| 682 { condensed_italic_900, expanded_italic_900 }, |
| 683 { condensed_obliqu_100, expanded_obliqu_100 }, |
| 684 { condensed_obliqu_900, expanded_obliqu_900 }, |
| 685 { expanded_normal_100, expanded_obliqu_100 }, |
| 686 { expanded_normal_900, expanded_obliqu_900 }, |
| 687 { expanded_italic_100, expanded_italic_100 }, |
| 688 { expanded_italic_900, expanded_italic_900 }, |
| 689 { expanded_obliqu_100, expanded_obliqu_100 }, |
| 690 { expanded_obliqu_900, expanded_obliqu_900 }, |
| 691 }, |
| 692 }, |
629 }; | 693 }; |
630 | 694 |
631 for (StyleSetTest& test : tests) { | 695 for (StyleSetTest& test : tests) { |
632 for (const StyleSetTest::Case testCase : test.cases) { | 696 for (const StyleSetTest::Case testCase : test.cases) { |
633 SkAutoTUnref<SkTypeface> typeface(test.styleSet.matchStyle(testCase.
pattern)); | 697 SkAutoTUnref<SkTypeface> typeface(test.styleSet.matchStyle(testCase.
pattern)); |
634 if (typeface) { | 698 if (typeface) { |
635 REPORTER_ASSERT(reporter, typeface->fontStyle() == testCase.expe
ctedResult); | 699 REPORTER_ASSERT(reporter, typeface->fontStyle() == testCase.expe
ctedResult); |
636 } else { | 700 } else { |
637 REPORTER_ASSERT(reporter, invalidFontStyle == testCase.expectedR
esult); | 701 REPORTER_ASSERT(reporter, invalidFontStyle == testCase.expectedR
esult); |
638 } | 702 } |
639 } | 703 } |
640 } | 704 } |
641 } | 705 } |
642 | 706 |
643 DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests."); | 707 DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests."); |
644 | 708 |
645 DEF_TEST(FontMgr, reporter) { | 709 DEF_TEST(FontMgr, reporter) { |
646 test_matchStyleCSS3(reporter); | 710 test_matchStyleCSS3(reporter); |
647 test_fontiter(reporter, FLAGS_verboseFontMgr); | 711 test_fontiter(reporter, FLAGS_verboseFontMgr); |
648 test_alias_names(reporter); | 712 test_alias_names(reporter); |
649 test_font(reporter); | 713 test_font(reporter); |
650 } | 714 } |
OLD | NEW |