epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 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 | |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 8 | #include "SkFontConfigInterface.h" |
| 9 | #include "SkFontDescriptor.h" |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 10 | #include "SkFontHost.h" |
reed@google.com | 822bde7 | 2013-03-04 16:28:33 +0000 | [diff] [blame] | 11 | #include "SkFontStream.h" |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 12 | #include "SkStream.h" |
reed@google.com | 80f5465 | 2013-02-25 22:19:20 +0000 | [diff] [blame] | 13 | #include "SkTypeface.h" |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 14 | #include "SkTypefaceCache.h" |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 15 | |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 16 | SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex); |
| 17 | static SkFontConfigInterface* gFontConfigInterface; |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 18 | |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 19 | SkFontConfigInterface* SkFontConfigInterface::RefGlobal() { |
| 20 | SkAutoMutexAcquire ac(gFontConfigInterfaceMutex); |
skia.committer@gmail.com | 5ca3bd0 | 2013-02-26 07:01:22 +0000 | [diff] [blame] | 21 | |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 22 | return SkSafeRef(gFontConfigInterface); |
| 23 | } |
bungeman@google.com | b13d63c | 2012-11-06 16:55:24 +0000 | [diff] [blame] | 24 | |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 25 | SkFontConfigInterface* SkFontConfigInterface::SetGlobal(SkFontConfigInterface* fc) { |
| 26 | SkAutoMutexAcquire ac(gFontConfigInterfaceMutex); |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 27 | |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 28 | SkRefCnt_SafeAssign(gFontConfigInterface, fc); |
| 29 | return fc; |
| 30 | } |
bungeman@google.com | b13d63c | 2012-11-06 16:55:24 +0000 | [diff] [blame] | 31 | |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 32 | /////////////////////////////////////////////////////////////////////////////// |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 33 | /////////////////////////////////////////////////////////////////////////////// |
| 34 | |
| 35 | // convenience function to create the direct interface if none is installed. |
| 36 | extern SkFontConfigInterface* SkCreateDirectFontConfigInterface(); |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 37 | |
reed@google.com | 80f5465 | 2013-02-25 22:19:20 +0000 | [diff] [blame] | 38 | static SkFontConfigInterface* RefFCI() { |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 39 | for (;;) { |
| 40 | SkFontConfigInterface* fci = SkFontConfigInterface::RefGlobal(); |
| 41 | if (fci) { |
| 42 | return fci; |
| 43 | } |
reed@google.com | d66045e | 2013-03-04 19:07:02 +0000 | [diff] [blame] | 44 | fci = SkFontConfigInterface::GetSingletonDirectInterface(); |
| 45 | SkFontConfigInterface::SetGlobal(fci); |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 46 | } |
reed@google.com | 80f5465 | 2013-02-25 22:19:20 +0000 | [diff] [blame] | 47 | } |
| 48 | |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 49 | class FontConfigTypeface : public SkTypeface { |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 50 | SkFontConfigInterface::FontIdentity fIdentity; |
| 51 | SkString fFamilyName; |
| 52 | SkStream* fLocalStream; |
| 53 | |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 54 | public: |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 55 | FontConfigTypeface(Style style, |
| 56 | const SkFontConfigInterface::FontIdentity& fi, |
| 57 | const SkString& familyName) |
| 58 | : SkTypeface(style, SkTypefaceCache::NewFontID()) |
| 59 | , fIdentity(fi) |
| 60 | , fFamilyName(familyName) |
| 61 | , fLocalStream(NULL) {} |
| 62 | |
| 63 | FontConfigTypeface(Style style, SkStream* localStream) |
| 64 | : SkTypeface(style, SkTypefaceCache::NewFontID()) { |
| 65 | // we default to empty fFamilyName and fIdentity |
| 66 | fLocalStream = localStream; |
| 67 | SkSafeRef(localStream); |
| 68 | } |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 69 | |
reed@google.com | 80f5465 | 2013-02-25 22:19:20 +0000 | [diff] [blame] | 70 | virtual ~FontConfigTypeface() { |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 71 | SkSafeUnref(fLocalStream); |
| 72 | } |
| 73 | |
| 74 | const SkFontConfigInterface::FontIdentity& getIdentity() const { |
| 75 | return fIdentity; |
| 76 | } |
| 77 | |
| 78 | const char* getFamilyName() const { return fFamilyName.c_str(); } |
| 79 | SkStream* getLocalStream() const { return fLocalStream; } |
| 80 | |
| 81 | bool isFamilyName(const char* name) const { |
| 82 | return fFamilyName.equals(name); |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 83 | } |
reed@google.com | 822bde7 | 2013-03-04 16:28:33 +0000 | [diff] [blame] | 84 | |
| 85 | protected: |
| 86 | friend class SkFontHost; // hack until we can make public versions |
| 87 | |
| 88 | virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; |
| 89 | virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
| 90 | size_t length, void* data) const SK_OVERRIDE; |
| 91 | virtual void onGetFontDescriptor(SkFontDescriptor*) const SK_OVERRIDE; |
| 92 | |
| 93 | private: |
| 94 | typedef SkTypeface INHERITED; |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 95 | }; |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 96 | |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 97 | /////////////////////////////////////////////////////////////////////////////// |
| 98 | |
| 99 | struct FindRec { |
| 100 | FindRec(const char* name, SkTypeface::Style style) |
| 101 | : fFamilyName(name) // don't need to make a deep copy |
| 102 | , fStyle(style) {} |
| 103 | |
| 104 | const char* fFamilyName; |
| 105 | SkTypeface::Style fStyle; |
| 106 | }; |
| 107 | |
| 108 | static bool find_proc(SkTypeface* face, SkTypeface::Style style, void* ctx) { |
| 109 | FontConfigTypeface* fci = (FontConfigTypeface*)face; |
| 110 | const FindRec* rec = (const FindRec*)ctx; |
| 111 | |
| 112 | return rec->fStyle == style && fci->isFamilyName(rec->fFamilyName); |
| 113 | } |
| 114 | |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 115 | SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace, |
| 116 | const char familyName[], |
reed@google.com | 80f5465 | 2013-02-25 22:19:20 +0000 | [diff] [blame] | 117 | SkTypeface::Style style) { |
| 118 | SkAutoTUnref<SkFontConfigInterface> fci(RefFCI()); |
| 119 | if (NULL == fci.get()) { |
| 120 | return NULL; |
| 121 | } |
| 122 | |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 123 | if (familyFace) { |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 124 | FontConfigTypeface* fct = (FontConfigTypeface*)familyFace; |
| 125 | familyName = fct->getFamilyName(); |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 126 | } |
| 127 | |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 128 | FindRec rec(familyName, style); |
| 129 | SkTypeface* face = SkTypefaceCache::FindByProcAndRef(find_proc, &rec); |
| 130 | if (face) { |
| 131 | return face; |
| 132 | } |
| 133 | |
| 134 | SkFontConfigInterface::FontIdentity indentity; |
| 135 | SkString outFamilyName; |
| 136 | SkTypeface::Style outStyle; |
| 137 | |
| 138 | if (!fci->matchFamilyName(familyName, style, |
| 139 | &indentity, &outFamilyName, &outStyle)) { |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 140 | return NULL; |
| 141 | } |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 142 | |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 143 | face = SkNEW_ARGS(FontConfigTypeface, (outStyle, indentity, outFamilyName)); |
| 144 | SkTypefaceCache::Add(face, style); |
| 145 | return face; |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 146 | } |
| 147 | |
reed@google.com | 80f5465 | 2013-02-25 22:19:20 +0000 | [diff] [blame] | 148 | SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { |
| 149 | if (!stream) { |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 150 | return NULL; |
reed@google.com | 80f5465 | 2013-02-25 22:19:20 +0000 | [diff] [blame] | 151 | } |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 152 | const size_t length = stream->getLength(); |
reed@google.com | 80f5465 | 2013-02-25 22:19:20 +0000 | [diff] [blame] | 153 | if (!length) { |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 154 | return NULL; |
reed@google.com | 80f5465 | 2013-02-25 22:19:20 +0000 | [diff] [blame] | 155 | } |
| 156 | if (length >= 1024 * 1024 * 1024) { |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 157 | return NULL; // don't accept too large fonts (>= 1GB) for safety. |
reed@google.com | 80f5465 | 2013-02-25 22:19:20 +0000 | [diff] [blame] | 158 | } |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 159 | |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 160 | // TODO should the caller give us the style? |
| 161 | SkTypeface::Style style = SkTypeface::kNormal; |
| 162 | SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, stream)); |
| 163 | SkTypefaceCache::Add(face, style); |
| 164 | return face; |
reed@android.com | ac98154 | 2009-07-31 16:17:01 +0000 | [diff] [blame] | 165 | } |
| 166 | |
reed@google.com | 80f5465 | 2013-02-25 22:19:20 +0000 | [diff] [blame] | 167 | SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) { |
reed@google.com | 8d33a24 | 2013-02-26 17:11:07 +0000 | [diff] [blame] | 168 | SkTypeface* face = NULL; |
| 169 | SkFILEStream* stream = SkNEW_ARGS(SkFILEStream, (path)); |
| 170 | |
| 171 | if (stream->isValid()) { |
| 172 | face = CreateTypefaceFromStream(stream); |
| 173 | } |
| 174 | stream->unref(); |
| 175 | return face; |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 176 | } |
| 177 | |
reed@google.com | 822bde7 | 2013-03-04 16:28:33 +0000 | [diff] [blame] | 178 | /////////////////////////////////////////////////////////////////////////////// |
| 179 | |
| 180 | // DEPRECATED |
| 181 | int SkFontHost::CountTables(SkFontID fontID) { |
| 182 | SkTypeface* face = SkTypefaceCache::FindByID(fontID); |
| 183 | return face ? face->onGetTableTags(NULL) : 0; |
| 184 | } |
| 185 | |
| 186 | // DEPRECATED |
| 187 | int SkFontHost::GetTableTags(SkFontID fontID, SkFontTableTag tags[]) { |
| 188 | SkTypeface* face = SkTypefaceCache::FindByID(fontID); |
| 189 | return face ? face->onGetTableTags(tags) : 0; |
| 190 | } |
| 191 | |
| 192 | // DEPRECATED |
| 193 | size_t SkFontHost::GetTableSize(SkFontID fontID, SkFontTableTag tag) { |
| 194 | SkTypeface* face = SkTypefaceCache::FindByID(fontID); |
| 195 | return face ? face->onGetTableData(tag, 0, ~0U, NULL) : 0; |
| 196 | } |
| 197 | |
| 198 | // DEPRECATED |
| 199 | size_t SkFontHost::GetTableData(SkFontID fontID, SkFontTableTag tag, |
| 200 | size_t offset, size_t length, void* dst) { |
| 201 | SkTypeface* face = SkTypefaceCache::FindByID(fontID); |
| 202 | return face ? face->onGetTableData(tag, offset, length, dst) : 0; |
| 203 | } |
| 204 | |
| 205 | // DEPRECATED |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 206 | uint32_t SkFontHost::NextLogicalFont(SkFontID curr, SkFontID orig) { |
reed@google.com | 80f5465 | 2013-02-25 22:19:20 +0000 | [diff] [blame] | 207 | // We don't handle font fallback. |
agl@chromium.org | df8ecfb | 2009-04-28 17:30:01 +0000 | [diff] [blame] | 208 | return 0; |
| 209 | } |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 210 | |
| 211 | /////////////////////////////////////////////////////////////////////////////// |
| 212 | |
| 213 | // Serialize, Deserialize need to be compatible across platforms, hence the use |
| 214 | // of SkFontDescriptor. |
| 215 | |
| 216 | void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) { |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 217 | FontConfigTypeface* fct = (FontConfigTypeface*)face; |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 218 | |
reed@google.com | 822bde7 | 2013-03-04 16:28:33 +0000 | [diff] [blame] | 219 | SkFontDescriptor desc; |
| 220 | fct->onGetFontDescriptor(&desc); |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 221 | desc.serialize(stream); |
skia.committer@gmail.com | 5ca3bd0 | 2013-02-26 07:01:22 +0000 | [diff] [blame] | 222 | |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 223 | // by convention, we also write out the actual sfnt data, preceeded by |
| 224 | // a packed-length. For now we skip that, so we just write the zero. |
| 225 | stream->writePackedUInt(0); |
| 226 | } |
| 227 | |
| 228 | SkTypeface* SkFontHost::Deserialize(SkStream* stream) { |
reed@google.com | ee619a0 | 2013-02-26 22:58:09 +0000 | [diff] [blame] | 229 | SkFontDescriptor descriptor(stream); |
| 230 | const char* familyName = descriptor.getFamilyName(); |
| 231 | const SkTypeface::Style style = descriptor.getStyle(); |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 232 | |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 233 | size_t length = stream->readPackedUInt(); |
| 234 | if (length > 0) { |
| 235 | void* addr = sk_malloc_flags(length, 0); |
| 236 | if (addr) { |
| 237 | SkAutoTUnref<SkStream> localStream(SkNEW_ARGS(SkMemoryStream, |
| 238 | (addr, length, false))); |
| 239 | return SkFontHost::CreateTypefaceFromStream(localStream.get()); |
| 240 | } |
| 241 | // failed to allocate, so just skip and create-from-name |
| 242 | stream->skip(length); |
reed@google.com | ee619a0 | 2013-02-26 22:58:09 +0000 | [diff] [blame] | 243 | } |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 244 | |
| 245 | return SkFontHost::CreateTypeface(NULL, familyName, style); |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | /////////////////////////////////////////////////////////////////////////////// |
| 249 | |
reed@google.com | 5bfc839 | 2013-03-05 22:12:11 +0000 | [diff] [blame] | 250 | static SkStream* open_stream(const FontConfigTypeface* face, int* ttcIndex) { |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 251 | SkStream* stream = face->getLocalStream(); |
| 252 | if (stream) { |
| 253 | stream->ref(); |
reed@google.com | 5bfc839 | 2013-03-05 22:12:11 +0000 | [diff] [blame] | 254 | // should have been provided by CreateFromStream() |
| 255 | *ttcIndex = 0; |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 256 | } else { |
| 257 | SkAutoTUnref<SkFontConfigInterface> fci(RefFCI()); |
| 258 | if (NULL == fci.get()) { |
| 259 | return NULL; |
| 260 | } |
| 261 | stream = fci->openStream(face->getIdentity()); |
reed@google.com | 8c9737e | 2013-03-06 13:06:03 +0000 | [diff] [blame] | 262 | *ttcIndex = face->getIdentity().fTTCIndex; |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 263 | } |
| 264 | return stream; |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 265 | } |
| 266 | |
reed@google.com | 822bde7 | 2013-03-04 16:28:33 +0000 | [diff] [blame] | 267 | SkStream* SkFontHost::OpenStream(uint32_t id) { |
| 268 | FontConfigTypeface* face = (FontConfigTypeface*)SkTypefaceCache::FindByID(id); |
| 269 | if (NULL == face) { |
| 270 | return NULL; |
| 271 | } |
skia.committer@gmail.com | 6433435 | 2013-03-06 07:01:46 +0000 | [diff] [blame] | 272 | |
reed@google.com | 5bfc839 | 2013-03-05 22:12:11 +0000 | [diff] [blame] | 273 | int ttcIndex; |
| 274 | // We should return ttcIndex from this call. |
| 275 | return open_stream(face, &ttcIndex); |
reed@google.com | 822bde7 | 2013-03-04 16:28:33 +0000 | [diff] [blame] | 276 | } |
| 277 | |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 278 | size_t SkFontHost::GetFileName(SkFontID fontID, char path[], size_t length, |
| 279 | int32_t* index) { |
skia.committer@gmail.com | 631cdcb | 2013-03-01 12:12:55 +0000 | [diff] [blame] | 280 | FontConfigTypeface* face = (FontConfigTypeface*)SkTypefaceCache::FindByID(fontID); |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 281 | if (NULL == face || face->getLocalStream()) { |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 282 | return 0; |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 283 | } |
| 284 | |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 285 | // Here we cheat, and "know" what is in the identity fields. |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 286 | |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 287 | const SkString& filename = face->getIdentity().fString; |
| 288 | if (index) { |
reed@google.com | 8c9737e | 2013-03-06 13:06:03 +0000 | [diff] [blame] | 289 | *index = face->getIdentity().fTTCIndex; |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 290 | } |
| 291 | if (path) { |
| 292 | size_t len = SkMin32(length, filename.size()); |
| 293 | memcpy(path, filename.c_str(), len); |
| 294 | } |
| 295 | return filename.size(); |
reed@google.com | d71fe99 | 2013-02-25 20:38:07 +0000 | [diff] [blame] | 296 | } |
reed@google.com | 822bde7 | 2013-03-04 16:28:33 +0000 | [diff] [blame] | 297 | |
| 298 | /////////////////////////////////////////////////////////////////////////////// |
| 299 | |
| 300 | int FontConfigTypeface::onGetTableTags(SkFontTableTag tags[]) const { |
reed@google.com | 5bfc839 | 2013-03-05 22:12:11 +0000 | [diff] [blame] | 301 | int ttcIndex; |
| 302 | SkAutoTUnref<SkStream> stream(open_stream(this, &ttcIndex)); |
| 303 | return stream.get() |
| 304 | ? SkFontStream::GetTableTags(stream, ttcIndex, tags) |
| 305 | : 0; |
reed@google.com | 822bde7 | 2013-03-04 16:28:33 +0000 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | size_t FontConfigTypeface::onGetTableData(SkFontTableTag tag, size_t offset, |
| 309 | size_t length, void* data) const { |
reed@google.com | 5bfc839 | 2013-03-05 22:12:11 +0000 | [diff] [blame] | 310 | int ttcIndex; |
| 311 | SkAutoTUnref<SkStream> stream(open_stream(this, &ttcIndex)); |
| 312 | return stream.get() |
| 313 | ? SkFontStream::GetTableData(stream, ttcIndex, |
| 314 | tag, offset, length, data) |
| 315 | : 0; |
reed@google.com | 822bde7 | 2013-03-04 16:28:33 +0000 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc) const { |
| 319 | desc->setStyle(this->style()); |
| 320 | desc->setFamilyName(this->getFamilyName()); |
| 321 | } |