| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 Google Inc. | 2 * Copyright 2008 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 "SkFontConfigInterface.h" | 8 #include "SkFontConfigInterface.h" |
| 9 #include "SkFontConfigTypeface.h" | 9 #include "SkFontConfigTypeface.h" |
| 10 #include "SkFontDescriptor.h" | 10 #include "SkFontDescriptor.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 if (!length) { | 115 if (!length) { |
| 116 return NULL; | 116 return NULL; |
| 117 } | 117 } |
| 118 if (length >= 1024 * 1024 * 1024) { | 118 if (length >= 1024 * 1024 * 1024) { |
| 119 return NULL; // don't accept too large fonts (>= 1GB) for safety. | 119 return NULL; // don't accept too large fonts (>= 1GB) for safety. |
| 120 } | 120 } |
| 121 | 121 |
| 122 // TODO should the caller give us the style? | 122 // TODO should the caller give us the style? |
| 123 SkTypeface::Style style = SkTypeface::kNormal; | 123 SkTypeface::Style style = SkTypeface::kNormal; |
| 124 SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, stream)); | 124 SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, stream)); |
| 125 SkTypefaceCache::Add(face, style); | |
| 126 return face; | 125 return face; |
| 127 } | 126 } |
| 128 | 127 |
| 129 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) { | 128 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) { |
| 130 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); | 129 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); |
| 131 return stream.get() ? CreateTypefaceFromStream(stream) : NULL; | 130 return stream.get() ? CreateTypefaceFromStream(stream) : NULL; |
| 132 } | 131 } |
| 133 | 132 |
| 134 /////////////////////////////////////////////////////////////////////////////// | 133 /////////////////////////////////////////////////////////////////////////////// |
| 135 | 134 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 : 0; | 188 : 0; |
| 190 } | 189 } |
| 191 | 190 |
| 192 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc, | 191 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc, |
| 193 bool* isLocalStream) const { | 192 bool* isLocalStream) const { |
| 194 desc->setFamilyName(this->getFamilyName()); | 193 desc->setFamilyName(this->getFamilyName()); |
| 195 *isLocalStream = SkToBool(this->getLocalStream()); | 194 *isLocalStream = SkToBool(this->getLocalStream()); |
| 196 } | 195 } |
| 197 | 196 |
| 198 /////////////////////////////////////////////////////////////////////////////// | 197 /////////////////////////////////////////////////////////////////////////////// |
| OLD | NEW |