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

Unified Diff: src/fonts/SkFontMgr_fontconfig.cpp

Issue 1921903002: Add oblique as a slant. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: static_assert what can be. Created 4 years, 8 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 | « src/core/SkTypeface.cpp ('k') | src/ports/SkFontConfigInterface_direct.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/fonts/SkFontMgr_fontconfig.cpp
diff --git a/src/fonts/SkFontMgr_fontconfig.cpp b/src/fonts/SkFontMgr_fontconfig.cpp
index fedd3dc53360fc3646ec5bdd23092ab800b06fbe..90511702bf480072e2fc02bf74f72a74adde8517 100644
--- a/src/fonts/SkFontMgr_fontconfig.cpp
+++ b/src/fonts/SkFontMgr_fontconfig.cpp
@@ -168,14 +168,19 @@ static int map_range(int value,
static SkFontStyle make_fontconfig_style(FcPattern* match) {
int weight = get_int(match, FC_WEIGHT);
int width = get_int(match, FC_WIDTH);
- int slant = get_int(match, FC_SLANT);
-// SkDebugf("old weight %d new weight %d\n", weight, map_range(weight, 0, 80, 0, 400));
+ int fcSlant = get_int(match, FC_SLANT);
// fontconfig weight seems to be 0..200 or so, so we remap it here
weight = map_range(weight, 0, 80, 0, 400);
width = map_range(width, 0, 200, 0, 9);
- return SkFontStyle(weight, width, slant > 0 ? SkFontStyle::kItalic_Slant
- : SkFontStyle::kUpright_Slant);
+ SkFontStyle::Slant skSlant = SkFontStyle::kUpright_Slant;
+ switch (fcSlant) {
+ case FC_SLANT_ROMAN: skSlant = SkFontStyle::kUpright_Slant; break;
+ case FC_SLANT_ITALIC : skSlant = SkFontStyle::kItalic_Slant ; break;
+ case FC_SLANT_OBLIQUE: skSlant = SkFontStyle::kOblique_Slant; break;
+ default: SkASSERT(false); break;
+ }
+ return SkFontStyle(weight, width, skSlant);
}
SkFontStyleSet_FC::SkFontStyleSet_FC(FcPattern** matches, int count) {
« no previous file with comments | « src/core/SkTypeface.cpp ('k') | src/ports/SkFontConfigInterface_direct.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698