OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2009-2015 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 /* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */ |
| 9 |
| 10 #include "google_font_file_buffering.h" |
| 11 |
| 12 #include "SkFontConfigInterface_direct_google3.h" |
| 13 #include "SkStream.h" |
| 14 #include "SkString.h" |
| 15 #include "SkTypes.h" |
| 16 |
| 17 bool SkFontConfigInterfaceDirectGoogle3::isAccessible(const char* filename) { |
| 18 // Check if this font has been pre-loaded into memory. |
| 19 const char* unused; |
| 20 if (GoogleFreeType::GoogleFt2ReadFontFromMemory(filename, &unused) >= 0) { |
| 21 return true; |
| 22 } |
| 23 return this->INHERITED::isAccessible(filename); |
| 24 } |
| 25 |
| 26 SkStreamAsset* SkFontConfigInterfaceDirectGoogle3::openStream(const FontIdentity
& identity) { |
| 27 const char* c_filename = identity.fString.c_str(); |
| 28 // Read the system fonts from the fonts we've pre-loaded into memory. |
| 29 const char* buffer; |
| 30 int length = GoogleFreeType::GoogleFt2ReadFontFromMemory( |
| 31 c_filename, &buffer); |
| 32 if (length >= 0) return new SkMemoryStream(buffer, length); |
| 33 return this->INHERITED::openStream(identity); |
| 34 } |
OLD | NEW |