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

Unified Diff: src/ports/SkFontConfigInterface_direct.cpp

Issue 2280053002: Restrict supported font formats in Chrome context (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: bungeman@'s review comments addressed Created 4 years, 4 months 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 | « no previous file | no next file » | 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 345544724695a1729e1644693199f45f49913148..8fe9898bc719e9cf4be76663ad3769d3caf55422 100644
--- a/src/ports/SkFontConfigInterface_direct.cpp
+++ b/src/ports/SkFontConfigInterface_direct.cpp
@@ -496,6 +496,10 @@ static void fcpattern_from_skfontstyle(SkFontStyle style, FcPattern* pattern) {
///////////////////////////////////////////////////////////////////////////////
#define kMaxFontFamilyLength 2048
+#ifdef SK_FONT_CONFIG_INTERFACE_ONLY_ALLOW_SFNT_FONTS
+const char* kFontFormatTrueType = "TrueType";
+const char* kFontFormatCFF = "CFF";
+#endif
SkFontConfigInterfaceDirect::SkFontConfigInterfaceDirect() {
FCLocker lock;
@@ -524,6 +528,16 @@ bool SkFontConfigInterfaceDirect::isValidPattern(FcPattern* pattern) {
}
#endif
+#ifdef SK_FONT_CONFIG_INTERFACE_ONLY_ALLOW_SFNT_FONTS
+ const char* font_format = get_name(pattern, FC_FONTFORMAT);
+ if (font_format
+ && strcmp(font_format, kFontFormatTrueType) != 0
+ && strcmp(font_format, kFontFormatCFF) != 0)
+ {
+ return false;
+ }
+#endif
+
// fontconfig can also return fonts which are unreadable
const char* c_filename = get_name(pattern, FC_FILE);
if (!c_filename) {
@@ -593,6 +607,11 @@ bool SkFontConfigInterfaceDirect::matchFamilyName(const char familyName[],
FcPatternAddBool(pattern, FC_SCALABLE, FcTrue);
+#ifdef SK_FONT_CONFIG_INTERFACE_ONLY_ALLOW_SFNT_FONTS
+ FcPatternAddString(pattern, FC_FONTFORMAT, reinterpret_cast<const FcChar8*>(kFontFormatTrueType));
+ FcPatternAddString(pattern, FC_FONTFORMAT, reinterpret_cast<const FcChar8*>(kFontFormatCFF));
+#endif
+
FcConfigSubstitute(nullptr, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698