| 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" |
| 11 #include "Test.h" | 11 #include "Test.h" |
| 12 | 12 |
| 13 #include "SkFont.h" | 13 #include "SkFont.h" |
| 14 #include "SkPaint.h" | 14 #include "SkPaint.h" |
| 15 static void test_font(skiatest::Reporter* reporter) { | 15 static void test_font(skiatest::Reporter* reporter) { |
| 16 uint32_t flags = 0; | 16 uint32_t flags = 0; |
| 17 SkAutoTUnref<SkFont> font(SkFont::Create(NULL, 24, SkFont::kA8_MaskType, fla
gs)); | 17 SkAutoTUnref<SkFont> font(SkFont::Create(nullptr, 24, SkFont::kA8_MaskType,
flags)); |
| 18 | 18 |
| 19 REPORTER_ASSERT(reporter, font->getTypeface()); | 19 REPORTER_ASSERT(reporter, font->getTypeface()); |
| 20 REPORTER_ASSERT(reporter, 24 == font->getSize()); | 20 REPORTER_ASSERT(reporter, 24 == font->getSize()); |
| 21 REPORTER_ASSERT(reporter, 1 == font->getScaleX()); | 21 REPORTER_ASSERT(reporter, 1 == font->getScaleX()); |
| 22 REPORTER_ASSERT(reporter, 0 == font->getSkewX()); | 22 REPORTER_ASSERT(reporter, 0 == font->getSkewX()); |
| 23 REPORTER_ASSERT(reporter, SkFont::kA8_MaskType == font->getMaskType()); | 23 REPORTER_ASSERT(reporter, SkFont::kA8_MaskType == font->getMaskType()); |
| 24 | 24 |
| 25 uint16_t glyphs[5]; | 25 uint16_t glyphs[5]; |
| 26 sk_bzero(glyphs, sizeof(glyphs)); | 26 sk_bzero(glyphs, sizeof(glyphs)); |
| 27 | 27 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 54 * if we request the alias name multiple times. | 54 * if we request the alias name multiple times. |
| 55 */ | 55 */ |
| 56 static void test_alias_names(skiatest::Reporter* reporter) { | 56 static void test_alias_names(skiatest::Reporter* reporter) { |
| 57 const char* inNames[] = { | 57 const char* inNames[] = { |
| 58 "sans", "sans-serif", "serif", "monospace", "times", "helvetica" | 58 "sans", "sans-serif", "serif", "monospace", "times", "helvetica" |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 for (size_t i = 0; i < SK_ARRAY_COUNT(inNames); ++i) { | 61 for (size_t i = 0; i < SK_ARRAY_COUNT(inNames); ++i) { |
| 62 SkAutoTUnref<SkTypeface> first(SkTypeface::CreateFromName(inNames[i], | 62 SkAutoTUnref<SkTypeface> first(SkTypeface::CreateFromName(inNames[i], |
| 63 SkTypeface::kNormal)); | 63 SkTypeface::kNormal)); |
| 64 if (NULL == first.get()) { | 64 if (nullptr == first.get()) { |
| 65 continue; | 65 continue; |
| 66 } | 66 } |
| 67 for (int j = 0; j < 10; ++j) { | 67 for (int j = 0; j < 10; ++j) { |
| 68 SkAutoTUnref<SkTypeface> face(SkTypeface::CreateFromName(inNames[i], | 68 SkAutoTUnref<SkTypeface> face(SkTypeface::CreateFromName(inNames[i], |
| 69 SkTypeface::kNormal)); | 69 SkTypeface::kNormal)); |
| 70 #if 0 | 70 #if 0 |
| 71 SkString name; | 71 SkString name; |
| 72 face->getFamilyName(&name); | 72 face->getFamilyName(&name); |
| 73 printf("request %s, received %s, first id %x received %x\n", | 73 printf("request %s, received %s, first id %x received %x\n", |
| 74 inNames[i], name.c_str(), first->uniqueID(), face->uniqueID()
); | 74 inNames[i], name.c_str(), first->uniqueID(), face->uniqueID()
); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests."); | 114 DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests."); |
| 115 | 115 |
| 116 DEF_TEST(FontMgr, reporter) { | 116 DEF_TEST(FontMgr, reporter) { |
| 117 test_fontiter(reporter, FLAGS_verboseFontMgr); | 117 test_fontiter(reporter, FLAGS_verboseFontMgr); |
| 118 test_alias_names(reporter); | 118 test_alias_names(reporter); |
| 119 test_font(reporter); | 119 test_font(reporter); |
| 120 } | 120 } |
| OLD | NEW |