Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(884)

Unified Diff: src/ports/SkFontConfigInterface_direct_google3.cpp

Issue 1471033002: Fix Google3 fonts. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Rename back to SkFontConfigInterface_direct.h Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/ports/SkFontConfigInterface_direct_google3.cpp
diff --git a/src/ports/SkFontConfigInterface_direct_google3.cpp b/src/ports/SkFontConfigInterface_direct_google3.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d3f34d0abcff27407a2f26a51c7f84b5144d5ebc
--- /dev/null
+++ b/src/ports/SkFontConfigInterface_direct_google3.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009-2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */
+
+#include "google_font_file_buffering.h"
+
+#include "SkFontConfigInterface_direct_google3.h"
+#include "SkStream.h"
+#include "SkString.h"
+#include "SkTypes.h"
+
+bool SkFontConfigInterfaceDirectGoogle3::isAccessible(const char* filename) {
+ // Check if this font has been pre-loaded into memory.
+ const char* unused;
+ if (GoogleFreeType::GoogleFt2ReadFontFromMemory(filename, &unused) >= 0) {
+ return true;
+ }
+ return this->INHERITED::isAccessible(filename);
+}
+
+SkStreamAsset* SkFontConfigInterfaceDirectGoogle3::openStream(const FontIdentity& identity) {
+ const char* c_filename = identity.fString.c_str();
+ // Read the system fonts from the fonts we've pre-loaded into memory.
+ const char* buffer;
+ int length = GoogleFreeType::GoogleFt2ReadFontFromMemory(
+ c_filename, &buffer);
+ if (length >= 0) return new SkMemoryStream(buffer, length);
+ return this->INHERITED::openStream(identity);
+}
« no previous file with comments | « src/ports/SkFontConfigInterface_direct_google3.h ('k') | src/ports/SkFontConfigInterface_direct_google3_factory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698