Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: tests/FontMgrTest.cpp

Issue 2147733002: Remove user specified typeface id. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove one last straggler. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ports/SkTypeface_win_dw.h ('k') | tests/TypefaceTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 108
109 if (verbose) { 109 if (verbose) {
110 SkDebugf("\t[%d] %s [%3d %d %d]\n", j, sname.c_str(), 110 SkDebugf("\t[%d] %s [%3d %d %d]\n", j, sname.c_str(),
111 fs.weight(), fs.width(), fs.slant()); 111 fs.weight(), fs.width(), fs.slant());
112 } 112 }
113 } 113 }
114 } 114 }
115 } 115 }
116 116
117 static void test_matchStyleCSS3(skiatest::Reporter* reporter) { 117 static void test_matchStyleCSS3(skiatest::Reporter* reporter) {
118 static const SkFontID invalidFontID = std::numeric_limits<SkFontID>::max();
119 static const SkFontStyle invalidFontStyle(101, SkFontStyle::kNormal_Width, S kFontStyle::kUpright_Slant); 118 static const SkFontStyle invalidFontStyle(101, SkFontStyle::kNormal_Width, S kFontStyle::kUpright_Slant);
120 119
121 class TestTypeface : public SkTypeface { 120 class TestTypeface : public SkTypeface {
122 public: 121 public:
123 TestTypeface(const SkFontStyle& fontStyle, SkFontID id) : SkTypeface(fon tStyle, id, false){} 122 TestTypeface(const SkFontStyle& fontStyle) : SkTypeface(fontStyle, false ){}
124 protected: 123 protected:
125 SkStreamAsset* onOpenStream(int* ttcIndex) const override { return nullp tr; } 124 SkStreamAsset* onOpenStream(int* ttcIndex) const override { return nullp tr; }
126 SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, 125 SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&,
127 const SkDescriptor*) const overri de { 126 const SkDescriptor*) const overri de {
128 return nullptr; 127 return nullptr;
129 } 128 }
130 void onFilterRec(SkScalerContextRec*) const override { } 129 void onFilterRec(SkScalerContextRec*) const override { }
131 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( 130 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
132 PerGlyphInfo, 131 PerGlyphInfo,
133 const uint32_t*, uint32_t) const override { return nullptr; } 132 const uint32_t*, uint32_t) const override { return nullptr; }
(...skipping 27 matching lines...) Expand all
161 public: 160 public:
162 TestFontStyleSet(std::initializer_list<SkFontStyle> styles) : fStyles(st yles) {} 161 TestFontStyleSet(std::initializer_list<SkFontStyle> styles) : fStyles(st yles) {}
163 int count() override { return static_cast<int>(fStyles.size()); } 162 int count() override { return static_cast<int>(fStyles.size()); }
164 void getStyle(int index, SkFontStyle* style, SkString*) override { 163 void getStyle(int index, SkFontStyle* style, SkString*) override {
165 if (style) { 164 if (style) {
166 *style = fStyles[index]; 165 *style = fStyles[index];
167 } 166 }
168 } 167 }
169 SkTypeface* createTypeface(int index) override { 168 SkTypeface* createTypeface(int index) override {
170 if (index < 0 || this->count() <= index) { 169 if (index < 0 || this->count() <= index) {
171 return new TestTypeface(invalidFontStyle, invalidFontID); 170 return new TestTypeface(invalidFontStyle);
172 } 171 }
173 return new TestTypeface(fStyles[index], index); 172 return new TestTypeface(fStyles[index]);
174 } 173 }
175 SkTypeface* matchStyle(const SkFontStyle& pattern) override { 174 SkTypeface* matchStyle(const SkFontStyle& pattern) override {
176 return this->matchStyleCSS3(pattern); 175 return this->matchStyleCSS3(pattern);
177 } 176 }
178 private: 177 private:
179 std::vector<SkFontStyle> fStyles; 178 std::vector<SkFontStyle> fStyles;
180 }; 179 };
181 180
182 SkFontStyle condensed_normal_100(SkFontStyle::kThin_Weight, SkFontStyle::kC ondensed_Width, SkFontStyle::kUpright_Slant); 181 SkFontStyle condensed_normal_100(SkFontStyle::kThin_Weight, SkFontStyle::kC ondensed_Width, SkFontStyle::kUpright_Slant);
183 SkFontStyle condensed_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle::kC ondensed_Width, SkFontStyle::kUpright_Slant); 182 SkFontStyle condensed_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle::kC ondensed_Width, SkFontStyle::kUpright_Slant);
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 } 702 }
704 703
705 DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests."); 704 DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests.");
706 705
707 DEF_TEST(FontMgr, reporter) { 706 DEF_TEST(FontMgr, reporter) {
708 test_matchStyleCSS3(reporter); 707 test_matchStyleCSS3(reporter);
709 test_fontiter(reporter, FLAGS_verboseFontMgr); 708 test_fontiter(reporter, FLAGS_verboseFontMgr);
710 test_alias_names(reporter); 709 test_alias_names(reporter);
711 test_font(reporter); 710 test_font(reporter);
712 } 711 }
OLDNEW
« no previous file with comments | « src/ports/SkTypeface_win_dw.h ('k') | tests/TypefaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698