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

Unified Diff: src/ports/SkFontConfigInterface_direct.cpp

Issue 1471033002: Fix Google3 fonts. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: 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
« no previous file with comments | « BUILD.public ('k') | tools/BUILD.public.expected » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontConfigInterface_direct.cpp
diff --git a/src/ports/SkFontConfigInterface_direct.cpp b/src/ports/SkFontConfigInterface_direct.cpp
index 8a8e4a1b538dfcfa270ed40b24d9f60adb3be023..39dc9ca62c963585292ccbcaa64a5455df6b2c8d 100644
--- a/src/ports/SkFontConfigInterface_direct.cpp
+++ b/src/ports/SkFontConfigInterface_direct.cpp
@@ -23,6 +23,10 @@
#include <fontconfig/fontconfig.h>
#include <unistd.h>
+#if defined(GOOGLE3)
bungeman-skia 2015/11/23 19:04:54 I would very much like to minimize this craziness.
+#include "google_font_file_buffering.h"
+#endif
+
size_t SkFontConfigInterface::FontIdentity::writeToMemory(void* addr) const {
size_t size = sizeof(fID) + sizeof(fTTCIndex);
size += sizeof(int32_t) + sizeof(int32_t) + sizeof(uint8_t); // weight, width, italic
@@ -348,9 +352,19 @@ static bool valid_pattern(FcPattern* pattern) {
if (!c_filename) {
return false;
}
+
+#if defined(GOOGLE3)
bungeman-skia 2015/11/23 21:39:59 This block is harder to remove, but since it wasn'
bungeman-skia 2015/11/24 21:56:36 This block is needed, or at least the 'access' cod
+ // Check if this font has been pre-loaded into memory.
+ const char* unused;
+ if (GoogleFreeType::GoogleFt2ReadFontFromMemory(c_filename, &unused) >= 0) {
+ return true;
+ }
+#endif
+
if (access(c_filename, R_OK) != 0) {
return false;
}
+
return true;
}
@@ -559,7 +573,15 @@ bool SkFontConfigInterfaceDirect::matchFamilyName(const char familyName[],
}
SkStreamAsset* SkFontConfigInterfaceDirect::openStream(const FontIdentity& identity) {
- return SkStream::NewFromFile(identity.fString.c_str());
+ const char* c_filename = identity.fString.c_str();
+#if defined(GOOGLE3)
+ // 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);
+#endif
+ return SkStream::NewFromFile(c_filename);
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « BUILD.public ('k') | tools/BUILD.public.expected » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698