Chromium Code Reviews| Index: src/ports/SkFontConfigInterface_direct.cpp |
| diff --git a/src/ports/SkFontConfigInterface_direct.cpp b/src/ports/SkFontConfigInterface_direct.cpp |
| index 345544724695a1729e1644693199f45f49913148..e4b7ede0faaaca573b892628cb182f2b0f08e5a1 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_RESTRICT_FONT_FORMATS_OPENTYPE |
| +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_RESTRICT_FONT_FORMATS_OPENTYPE |
| + char* font_format; |
| + if (FcPatternGetString(pattern, FC_FONTFORMAT, 0, reinterpret_cast<FcChar8**>(&font_format)) == |
| + FcResultMatch |
| + && strcmp(font_format, kFontFormatTrueType) != 0 |
| + && strcmp(font_format, kFontFormatCFF) != 0) { |
| + return false; |
|
bungeman-skia
2016/08/26 15:52:36
nit: Skia uses four space indents.
I think I woul
drott
2016/08/26 16:19:04
Reformatted according to your suggestion.
|
| + } |
| +#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_RESTRICT_FONT_FORMATS_OPENTYPE |
| + 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); |