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

Unified Diff: src/ports/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/ports/SkFontMgr_custom.cpp ('k') | src/ports/SkFontMgr_win_dw.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « src/ports/SkFontMgr_custom.cpp ('k') | src/ports/SkFontMgr_win_dw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698