| 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 #ifndef SkFontMgr_DEFINED | 8 #ifndef SkFontMgr_DEFINED |
| 9 #define SkFontMgr_DEFINED | 9 #define SkFontMgr_DEFINED |
| 10 | 10 |
| 11 #include "SkRefCnt.h" | 11 #include "SkRefCnt.h" |
| 12 #include "SkFontStyle.h" | 12 #include "SkFontStyle.h" |
| 13 | 13 |
| 14 class SkData; | 14 class SkData; |
| 15 class SkStream; | 15 class SkStream; |
| 16 class SkString; | 16 class SkString; |
| 17 | 17 |
| 18 class SkFontStyleSet : public SkRefCnt { | 18 class SkFontStyleSet : public SkRefCnt { |
| 19 public: | 19 public: |
| 20 virtual int count() = 0; | 20 virtual int count() = 0; |
| 21 virtual void getStyle(int index, SkFontStyle*, SkString* style) = 0; | 21 virtual void getStyle(int index, SkFontStyle*, SkString* style) = 0; |
| 22 virtual SkTypeface* createTypeface(int index) = 0; | 22 virtual SkTypeface* createTypeface(int index) = 0; |
| 23 virtual SkTypeface* matchStyle(const SkFontStyle& pattern) = 0; |
| 24 |
| 25 static SkFontStyleSet* CreateEmpty(); |
| 23 }; | 26 }; |
| 24 | 27 |
| 25 class SkFontMgr : public SkRefCnt { | 28 class SkFontMgr : public SkRefCnt { |
| 26 public: | 29 public: |
| 27 int countFamilies(); | 30 int countFamilies(); |
| 28 void getFamilyName(int index, SkString* familyName); | 31 void getFamilyName(int index, SkString* familyName); |
| 29 SkFontStyleSet* createStyleSet(int index); | 32 SkFontStyleSet* createStyleSet(int index); |
| 30 | 33 |
| 34 SkFontStyleSet* matchFamily(const char familyName[]); |
| 35 |
| 31 /** | 36 /** |
| 32 * Find the closest matching typeface to the specified familyName and style | 37 * Find the closest matching typeface to the specified familyName and style |
| 33 * and return a ref to it. The caller must call unref() on the returned | 38 * and return a ref to it. The caller must call unref() on the returned |
| 34 * object. Will never return NULL, as it will return the default font if | 39 * object. Will never return NULL, as it will return the default font if |
| 35 * no matching font is found. | 40 * no matching font is found. |
| 36 */ | 41 */ |
| 37 SkTypeface* matchFamilyStyle(const char familyName[], const SkFontStyle&); | 42 SkTypeface* matchFamilyStyle(const char familyName[], const SkFontStyle&); |
| 38 | 43 |
| 39 SkTypeface* matchFaceStyle(const SkTypeface*, const SkFontStyle&); | 44 SkTypeface* matchFaceStyle(const SkTypeface*, const SkFontStyle&); |
| 40 | 45 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 64 * Return a ref to the default fontmgr. The caller must call unref() on | 69 * Return a ref to the default fontmgr. The caller must call unref() on |
| 65 * the returned object. | 70 * the returned object. |
| 66 */ | 71 */ |
| 67 static SkFontMgr* RefDefault(); | 72 static SkFontMgr* RefDefault(); |
| 68 | 73 |
| 69 protected: | 74 protected: |
| 70 virtual int onCountFamilies() = 0; | 75 virtual int onCountFamilies() = 0; |
| 71 virtual void onGetFamilyName(int index, SkString* familyName) = 0; | 76 virtual void onGetFamilyName(int index, SkString* familyName) = 0; |
| 72 virtual SkFontStyleSet* onCreateStyleSet(int index) = 0; | 77 virtual SkFontStyleSet* onCreateStyleSet(int index) = 0; |
| 73 | 78 |
| 79 virtual SkFontStyleSet* onMatchFamily(const char familyName[]) = 0; |
| 80 |
| 74 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], | 81 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], |
| 75 const SkFontStyle&) = 0; | 82 const SkFontStyle&) = 0; |
| 76 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, | 83 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, |
| 77 const SkFontStyle&) = 0; | 84 const SkFontStyle&) = 0; |
| 78 | 85 |
| 79 virtual SkTypeface* onCreateFromData(SkData*, int ttcIndex) = 0; | 86 virtual SkTypeface* onCreateFromData(SkData*, int ttcIndex) = 0; |
| 80 virtual SkTypeface* onCreateFromStream(SkStream*, int ttcIndex) = 0; | 87 virtual SkTypeface* onCreateFromStream(SkStream*, int ttcIndex) = 0; |
| 81 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) = 0; | 88 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) = 0; |
| 82 | 89 |
| 83 private: | 90 private: |
| 84 static SkFontMgr* Factory(); // implemented by porting layer | 91 static SkFontMgr* Factory(); // implemented by porting layer |
| 85 static SkMutex* Mutex(); // implemented by porting layer | 92 static SkMutex* Mutex(); // implemented by porting layer |
| 86 | 93 |
| 87 typedef SkRefCnt INHERITED; | 94 typedef SkRefCnt INHERITED; |
| 88 }; | 95 }; |
| 89 | 96 |
| 90 #endif | 97 #endif |
| OLD | NEW |