Index: src/ports/SkFontMgr_fontconfig.cpp |
diff --git a/src/ports/SkFontMgr_fontconfig.cpp b/src/ports/SkFontMgr_fontconfig.cpp |
index 4b26f41ea5ffced03e534aa6eb07029dc01c35d4..610a3001fb2c66e5df68e2fe08f0c34d7c0644f0 100644 |
--- a/src/ports/SkFontMgr_fontconfig.cpp |
+++ b/src/ports/SkFontMgr_fontconfig.cpp |
@@ -345,9 +345,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); |
} |
@@ -384,9 +388,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); |
} |
class SkTypeface_stream : public SkTypeface_FreeType { |