| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkFontDescriptor.h" | 8 #include "SkFontDescriptor.h" |
| 9 #include "SkFontMgr.h" | 9 #include "SkFontMgr.h" |
| 10 #include "SkOnce.h" | 10 #include "SkOncePtr.h" |
| 11 #include "SkStream.h" | 11 #include "SkStream.h" |
| 12 #include "SkTypes.h" | 12 #include "SkTypes.h" |
| 13 | 13 |
| 14 class SkFontStyle; | 14 class SkFontStyle; |
| 15 class SkTypeface; | 15 class SkTypeface; |
| 16 | 16 |
| 17 class SkEmptyFontStyleSet : public SkFontStyleSet { | 17 class SkEmptyFontStyleSet : public SkFontStyleSet { |
| 18 public: | 18 public: |
| 19 int count() override { return 0; } | 19 int count() override { return 0; } |
| 20 void getStyle(int, SkFontStyle*, SkString*) override { | 20 void getStyle(int, SkFontStyle*, SkString*) override { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 if (nullptr == path) { | 162 if (nullptr == path) { |
| 163 return nullptr; | 163 return nullptr; |
| 164 } | 164 } |
| 165 return this->onCreateFromFile(path, ttcIndex); | 165 return this->onCreateFromFile(path, ttcIndex); |
| 166 } | 166 } |
| 167 | 167 |
| 168 SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[], SkFontStyle
style) const { | 168 SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[], SkFontStyle
style) const { |
| 169 return this->onLegacyCreateTypeface(familyName, style); | 169 return this->onLegacyCreateTypeface(familyName, style); |
| 170 } | 170 } |
| 171 | 171 |
| 172 SK_DECLARE_STATIC_ONCE_PTR(SkFontMgr, singleton); |
| 172 SkFontMgr* SkFontMgr::RefDefault() { | 173 SkFontMgr* SkFontMgr::RefDefault() { |
| 173 static SkOnce once; | 174 return SkRef(singleton.get([]{ |
| 174 static SkFontMgr* singleton; | |
| 175 | |
| 176 once([]{ | |
| 177 SkFontMgr* fm = SkFontMgr::Factory(); | 175 SkFontMgr* fm = SkFontMgr::Factory(); |
| 178 singleton = fm ? fm : new SkEmptyFontMgr; | 176 return fm ? fm : new SkEmptyFontMgr; |
| 179 }); | 177 })); |
| 180 return SkRef(singleton); | |
| 181 } | 178 } |
| 182 | 179 |
| 183 /** | 180 /** |
| 184 * Width has the greatest priority. | 181 * Width has the greatest priority. |
| 185 * If the value of pattern.width is 5 (normal) or less, | 182 * If the value of pattern.width is 5 (normal) or less, |
| 186 * narrower width values are checked first, then wider values. | 183 * narrower width values are checked first, then wider values. |
| 187 * If the value of pattern.width is greater than 5 (normal), | 184 * If the value of pattern.width is greater than 5 (normal), |
| 188 * wider values are checked first, followed by narrower values. | 185 * wider values are checked first, followed by narrower values. |
| 189 * | 186 * |
| 190 * Italic/Oblique has the next highest priority. | 187 * Italic/Oblique has the next highest priority. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 } | 285 } |
| 289 } | 286 } |
| 290 | 287 |
| 291 if (maxScore < currentScore) { | 288 if (maxScore < currentScore) { |
| 292 maxScore = currentScore; | 289 maxScore = currentScore; |
| 293 } | 290 } |
| 294 } | 291 } |
| 295 | 292 |
| 296 return this->createTypeface(maxScore.index); | 293 return this->createTypeface(maxScore.index); |
| 297 } | 294 } |
| OLD | NEW |