diff options
-rw-r--r-- | site/dev/contrib/style.md | 17 | ||||
-rw-r--r-- | src/ports/SkFontConfigParser_android.cpp | 7 | ||||
-rw-r--r-- | src/ports/SkFontConfigParser_android.h | 3 | ||||
-rw-r--r-- | src/ports/SkFontMgr_android.cpp | 10 |
4 files changed, 30 insertions, 7 deletions
diff --git a/site/dev/contrib/style.md b/site/dev/contrib/style.md index e952ed1b68..177a58b8d4 100644 --- a/site/dev/contrib/style.md +++ b/site/dev/contrib/style.md @@ -78,10 +78,19 @@ int herdCats(const Array& cats) { } ~~~~ -Enum values are prefixed with k and have post fix that consists of an underscore -and singular name of the enum name. The enum itself should be singular for -exclusive values or plural for a bitfield. If a count is needed it is -k<singular enum name>Count and not be a member of the enum (see example): +Enum values are prefixed with k. Unscoped enum values are post fixed with +an underscore and singular name of the enum name. The enum itself should be +singular for exclusive values or plural for a bitfield. If a count is needed it +is k<singular enum name>Count and not be a member of the enum (see example): + +<!--?prettify?--> +~~~~ +enum class SkPancakeType { + kBlueberry, + kPlain, + kChocolateChip, +}; +~~~~ <!--?prettify?--> ~~~~ diff --git a/src/ports/SkFontConfigParser_android.cpp b/src/ports/SkFontConfigParser_android.cpp index ffc60427f4..9bab84556b 100644 --- a/src/ports/SkFontConfigParser_android.cpp +++ b/src/ports/SkFontConfigParser_android.cpp @@ -159,6 +159,13 @@ static void font_element_handler(FamilyData* self, FontFileInfo* file, const cha if (!parse_non_negative_integer(value, &file->fWeight)) { SkDebugf("---- Font weight %s (INVALID)", value); } + } else if (MEMEQ("style", name, nameLen)) { + size_t valueLen = strlen(value); + if (MEMEQ("normal", value, valueLen)) { + file->fStyle = FontFileInfo::Style::kNormal; + } else if (MEMEQ("italic", value, valueLen)) { + file->fStyle = FontFileInfo::Style::kItalic; + } } else if (MEMEQ("index", name, nameLen)) { if (!parse_non_negative_integer(value, &file->fIndex)) { SkDebugf("---- Font index %s (INVALID)", value); diff --git a/src/ports/SkFontConfigParser_android.h b/src/ports/SkFontConfigParser_android.h index 6dbf383590..dd856bf733 100644 --- a/src/ports/SkFontConfigParser_android.h +++ b/src/ports/SkFontConfigParser_android.h @@ -62,11 +62,12 @@ typedef uint32_t FontVariant; // Must remain trivially movable (can be memmoved). struct FontFileInfo { - FontFileInfo() : fIndex(0), fWeight(0) { } + FontFileInfo() : fIndex(0), fWeight(0), fStyle(Style::kAuto) { } SkString fFileName; int fIndex; int fWeight; + enum class Style { kAuto, kNormal, kItalic } fStyle; }; /** diff --git a/src/ports/SkFontMgr_android.cpp b/src/ports/SkFontMgr_android.cpp index 61f990c738..ae1b663e26 100644 --- a/src/ports/SkFontMgr_android.cpp +++ b/src/ports/SkFontMgr_android.cpp @@ -143,9 +143,15 @@ public: continue; } - if (fontFile.fWeight != 0) { - style = SkFontStyle(fontFile.fWeight, style.width(), style.slant()); + int weight = fontFile.fWeight != 0 ? fontFile.fWeight : style.weight(); + SkFontStyle::Slant slant = style.slant(); + switch (fontFile.fStyle) { + case FontFileInfo::Style::kAuto: slant = style.slant(); break; + case FontFileInfo::Style::kNormal: slant = SkFontStyle::kUpright_Slant; break; + case FontFileInfo::Style::kItalic: slant = SkFontStyle::kItalic_Slant; break; + default: SkASSERT(false); break; } + style = SkFontStyle(weight, style.width(), slant); const SkLanguage& lang = family.fLanguage; uint32_t variant = family.fVariant; |