Index: src/ports/SkFontConfigInterface_direct.cpp |
diff --git a/src/ports/SkFontConfigInterface_direct.cpp b/src/ports/SkFontConfigInterface_direct.cpp |
index cc80fbe647c212e14cfaf71430122c8475d850f2..d384f707b1812d629e0481aaf67816899d67b04c 100644 |
--- a/src/ports/SkFontConfigInterface_direct.cpp |
+++ b/src/ports/SkFontConfigInterface_direct.cpp |
@@ -387,9 +387,13 @@ static SkFontStyle skfontstyle_from_fcpattern(FcPattern* pattern) { |
int width = map_ranges(get_int(pattern, FC_WIDTH, FC_WIDTH_NORMAL), |
widthRanges, SK_ARRAY_COUNT(widthRanges)); |
- SkFS::Slant slant = get_int(pattern, FC_SLANT, FC_SLANT_ROMAN) > 0 |
- ? SkFS::kItalic_Slant |
- : SkFS::kUpright_Slant; |
+ SkFS::Slant slant = SkFS::kUpright_Slant; |
+ switch (get_int(pattern, FC_SLANT, FC_SLANT_ROMAN)) { |
+ case FC_SLANT_ROMAN: slant = SkFS::kUpright_Slant; break; |
+ case FC_SLANT_ITALIC : slant = SkFS::kItalic_Slant ; break; |
+ case FC_SLANT_OBLIQUE: slant = SkFS::kOblique_Slant; break; |
+ default: SkASSERT(false); break; |
+ } |
return SkFontStyle(weight, width, slant); |
} |
@@ -424,9 +428,17 @@ static void fcpattern_from_skfontstyle(SkFontStyle style, FcPattern* pattern) { |
}; |
int width = map_ranges(style.width(), widthRanges, SK_ARRAY_COUNT(widthRanges)); |
+ int slant = FC_SLANT_ROMAN; |
+ switch (style.slant()) { |
+ case SkFS::kUpright_Slant: slant = FC_SLANT_ROMAN ; break; |
+ case SkFS::kItalic_Slant : slant = FC_SLANT_ITALIC ; break; |
+ case SkFS::kOblique_Slant: slant = FC_SLANT_OBLIQUE; break; |
+ default: SkASSERT(false); break; |
+ } |
+ |
FcPatternAddInteger(pattern, FC_WEIGHT, weight); |
- FcPatternAddInteger(pattern, FC_WIDTH, width); |
- FcPatternAddInteger(pattern, FC_SLANT, style.isItalic() ? FC_SLANT_ITALIC : FC_SLANT_ROMAN); |
+ FcPatternAddInteger(pattern, FC_WIDTH , width); |
+ FcPatternAddInteger(pattern, FC_SLANT , slant); |
} |
} // anonymous namespace |