OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef SkRemotableFontMgr_DEFINED |
| 9 #define SkRemotableFontMgr_DEFINED |
| 10 |
| 11 #include "SkFontStyle.h" |
| 12 #include "SkRefCnt.h" |
| 13 #include "SkTemplates.h" |
| 14 |
| 15 class SkDataTable; |
| 16 class SkStreamAsset; |
| 17 class SkString; |
| 18 |
| 19 struct SK_API SkFontIdentity { |
| 20 static const uint32_t kInvalidDataId = 0xFFFFFFFF; |
| 21 |
| 22 // Note that fDataId is a data identifier, not a font identifier. |
| 23 // (fDataID, fTtcIndex) can be seen as a font identifier. |
| 24 uint32_t fDataId; |
| 25 uint32_t fTtcIndex; |
| 26 |
| 27 // On Linux/FontConfig there is also the ability to specify preferences for
rendering |
| 28 // antialias, embedded bitmaps, autohint, hinting, hintstyle, lcd rendering |
| 29 // may all be set or set to no-preference |
| 30 // (No-preference is resolved against globals set by the platform) |
| 31 // Since they may be selected against, these are really 'extensions' to SkFo
ntStyle. |
| 32 // SkFontStyle should pick these up. |
| 33 SkFontStyle fFontStyle; |
| 34 }; |
| 35 |
| 36 class SK_API SkRemotableFontIdentitySet : public SkRefCnt { |
| 37 public: |
| 38 SK_DECLARE_INST_COUNT(SkRemotableFontIdentitySet) |
| 39 |
| 40 SkRemotableFontIdentitySet(int count, SkFontIdentity** data); |
| 41 |
| 42 int count() const { return fCount; } |
| 43 const SkFontIdentity& at(int index) const { return fData[index]; } |
| 44 |
| 45 static SkRemotableFontIdentitySet* NewEmpty(); |
| 46 |
| 47 private: |
| 48 SkRemotableFontIdentitySet() : fCount(0), fData() { } |
| 49 static void NewEmptyImpl(int); |
| 50 |
| 51 int fCount; |
| 52 SkAutoTMalloc<SkFontIdentity> fData; |
| 53 |
| 54 typedef SkRefCnt INHERITED; |
| 55 }; |
| 56 |
| 57 class SK_API SkRemotableFontMgr : public SkRefCnt { |
| 58 public: |
| 59 SK_DECLARE_INST_COUNT(SkRemotableFontMgr) |
| 60 |
| 61 /** |
| 62 * Returns the names of the known fonts on the system. |
| 63 * Will not return NULL, will return an empty table if no families exist. |
| 64 * |
| 65 * The indexes may be used with getIndex(int) and |
| 66 * matchIndexStyle(int, SkFontStyle). |
| 67 * |
| 68 * The caller must unref() the returned object. |
| 69 */ |
| 70 virtual SkDataTable* getFamilyNames() const = 0; |
| 71 |
| 72 /** |
| 73 * Returns all of the fonts with the given familyIndex. |
| 74 * Returns NULL if the index is out of bounds. |
| 75 * Returns empty if there are no fonts at the given index. |
| 76 * |
| 77 * The caller must unref() the returned object. |
| 78 */ |
| 79 virtual SkRemotableFontIdentitySet* getIndex(int familyIndex) const = 0; |
| 80 |
| 81 /** |
| 82 * Returns the closest match to the given style in the given index. |
| 83 * If there are no available fonts at the given index, the return value's |
| 84 * data id will be kInvalidDataId. |
| 85 */ |
| 86 virtual SkFontIdentity matchIndexStyle(int familyIndex, const SkFontStyle&)
const = 0; |
| 87 |
| 88 /** |
| 89 * Returns all the fonts on the system with the given name. |
| 90 * If the given name is NULL, will return the default font family. |
| 91 * Never returns NULL; will return an empty set if the name is not found. |
| 92 * |
| 93 * It is possible that this will return fonts not accessible from |
| 94 * getIndex(int) or matchIndexStyle(int, SkFontStyle) due to |
| 95 * hidden or auto-activated fonts. |
| 96 * |
| 97 * The matching may be done in a system dependent way. The name may be |
| 98 * matched case-insensitive, there may be system aliases which resolve, |
| 99 * and names outside the current locale may be considered. However, this |
| 100 * should only return fonts which are somehow associated with the requested |
| 101 * name. |
| 102 * |
| 103 * The caller must unref() the returned object. |
| 104 */ |
| 105 virtual SkRemotableFontIdentitySet* matchName(const char familyName[]) const
= 0; |
| 106 |
| 107 /** |
| 108 * Returns the closest matching font to the specified name and style. |
| 109 * If there are no available fonts which match the name, the return value's |
| 110 * data id will be kInvalidDataId. |
| 111 * If the given name is NULL, the match will be against any default fonts. |
| 112 * |
| 113 * It is possible that this will return a font identity not accessible from |
| 114 * methods returning sets due to hidden or auto-activated fonts. |
| 115 * |
| 116 * The matching may be done in a system dependent way. The name may be |
| 117 * matched case-insensitive, there may be system aliases which resolve, |
| 118 * and names outside the current locale may be considered. However, this |
| 119 * should only return a font which is somehow associated with the requested |
| 120 * name. |
| 121 * |
| 122 * The caller must unref() the returned object. |
| 123 */ |
| 124 virtual SkFontIdentity matchNameStyle(const char familyName[], const SkFontS
tyle&) const = 0; |
| 125 |
| 126 /** |
| 127 * Use the system fall-back to find a font for the given character. |
| 128 * If no font can be found for the character, the return value's data id |
| 129 * will be kInvalidDataId. |
| 130 * If the name is NULL, the match will start against any default fonts. |
| 131 * If the bpc47 is NULL, a default locale will be assumed. |
| 132 * |
| 133 * Note that bpc47 is a combination of ISO 639, 15924, and 3166-1 codes, |
| 134 * so it is fine to just pass a ISO 639 here. |
| 135 */ |
| 136 virtual SkFontIdentity matchNameStyleCharacter(const char familyName[], cons
t SkFontStyle&, |
| 137 const char bpc47[], SkUnichar
character) const=0; |
| 138 |
| 139 /** |
| 140 * Returns the data for the given data id. |
| 141 * Will return NULL if the data id is invalid. |
| 142 * Note that this is a data id, not a font id. |
| 143 * |
| 144 * The caller must unref() the returned object. |
| 145 */ |
| 146 virtual SkStreamAsset* getData(int dataId) const = 0; |
| 147 |
| 148 private: |
| 149 typedef SkRefCnt INHERITED; |
| 150 }; |
| 151 |
| 152 #endif |
| 153 |
OLD | NEW |