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

Unified Diff: skia/ext/SkFontHost_fontconfig_direct.cpp

Issue 147005: Linux: fix fake italics for font's without italic variants. (Closed)
Patch Set: ... Created 11 years, 6 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 | « skia/ext/SkFontHost_fontconfig_direct.h ('k') | skia/ext/SkFontHost_fontconfig_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/SkFontHost_fontconfig_direct.cpp
diff --git a/skia/ext/SkFontHost_fontconfig_direct.cpp b/skia/ext/SkFontHost_fontconfig_direct.cpp
index 5d425c20cd0d82cf4d17b814e1d8ec087290f15d..dc20afffc51c6b4b98215e3073ad8c2e7bd9f9ff 100644
--- a/skia/ext/SkFontHost_fontconfig_direct.cpp
+++ b/skia/ext/SkFontHost_fontconfig_direct.cpp
@@ -43,8 +43,8 @@ static bool IsFallbackFontAllowed(const std::string& family)
bool FontConfigDirect::Match(std::string* result_family,
unsigned* result_fileid,
bool fileid_valid, unsigned fileid,
- const std::string& family, int is_bold,
- int is_italic) {
+ const std::string& family, bool* is_bold,
+ bool* is_italic) {
SkAutoMutexAcquire ac(mutex_);
FcPattern* pattern = FcPatternCreate();
@@ -66,16 +66,14 @@ bool FontConfigDirect::Match(std::string* result_family,
fcvalue.u.s = (FcChar8*) family.c_str();
FcPatternAdd(pattern, FC_FAMILY, fcvalue, 0);
}
- if (is_bold > 0) {
- fcvalue.type = FcTypeInteger;
- fcvalue.u.i = is_bold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL;
- FcPatternAdd(pattern, FC_WEIGHT, fcvalue, 0);
- }
- if (is_italic > 0) {
- fcvalue.type = FcTypeInteger;
- fcvalue.u.i = is_italic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN;
- FcPatternAdd(pattern, FC_SLANT, fcvalue, 0);
- }
+
+ fcvalue.type = FcTypeInteger;
+ fcvalue.u.i = is_bold && *is_bold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL;
+ FcPatternAdd(pattern, FC_WEIGHT, fcvalue, 0);
+
+ fcvalue.type = FcTypeInteger;
+ fcvalue.u.i = is_italic && *is_italic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN;
+ FcPatternAdd(pattern, FC_SLANT, fcvalue, 0);
FcConfigSubstitute(0, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);
@@ -173,6 +171,19 @@ bool FontConfigDirect::Match(std::string* result_family,
return NULL;
}
+ int resulting_bold;
+ if (FcPatternGetInteger(match, FC_WEIGHT, 0, &resulting_bold))
+ resulting_bold = FC_WEIGHT_NORMAL;
+
+ int resulting_italic;
+ if (FcPatternGetInteger(match, FC_SLANT, 0, &resulting_italic))
+ resulting_italic = FC_SLANT_ROMAN;
+
+ if (is_bold)
+ *is_bold = resulting_bold >= FC_WEIGHT_BOLD;
+ if (is_italic)
+ *is_italic = resulting_italic == FC_SLANT_ITALIC;
+
if (result_family)
*result_family = (char *) c_family;
« no previous file with comments | « skia/ext/SkFontHost_fontconfig_direct.h ('k') | skia/ext/SkFontHost_fontconfig_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698