Index: src/ports/SkFontMgr_android_parser.cpp |
diff --git a/src/ports/SkFontMgr_android_parser.cpp b/src/ports/SkFontMgr_android_parser.cpp |
index 1d1a3b7ddb67236b8f3c9d2e76e29bc625c8f5aa..3f9c90cf318c045fd4be681042f390201c4a5d4b 100644 |
--- a/src/ports/SkFontMgr_android_parser.cpp |
+++ b/src/ports/SkFontMgr_android_parser.cpp |
@@ -7,6 +7,7 @@ |
// Despite the name and location, this is portable code. |
+#include "SkFontMgr.h" |
#include "SkFontMgr_android_parser.h" |
#include "SkStream.h" |
#include "SkTDArray.h" |
@@ -152,7 +153,10 @@ namespace lmpParser { |
static const TagHandler axisHandler = { |
/*start*/[](FamilyData* self, const char* tag, const char** attributes) { |
FontFileInfo& file = *self->fCurrentFontInfo; |
- FontFileInfo::Axis& axis = file.fAxes.push_back(); |
+ SkFourByteTag axisTag = SkSetFourByteTag('\0','\0','\0','\0'); |
+ SkFixed axisStyleValue = 0; |
+ bool axisTagIsValid = false; |
+ bool axisStyleValueIsValid = false; |
for (size_t i = 0; ATTS_NON_NULL(attributes, i); i += 2) { |
const char* name = attributes[i]; |
const char* value = attributes[i+1]; |
@@ -160,26 +164,34 @@ static const TagHandler axisHandler = { |
if (MEMEQ("tag", name, nameLen)) { |
size_t valueLen = strlen(value); |
if (valueLen == 4) { |
- SkFourByteTag tag = SkSetFourByteTag(value[0], value[1], value[2], value[3]); |
+ axisTag = SkSetFourByteTag(value[0], value[1], value[2], value[3]); |
+ axisTagIsValid = true; |
for (int j = 0; j < file.fAxes.count() - 1; ++j) { |
- if (file.fAxes[j].fTag == tag) { |
+ if (file.fAxes[j].fTag == axisTag) { |
+ axisTagIsValid = false; |
SK_FONTCONFIGPARSER_WARNING("'%c%c%c%c' axis specified more than once", |
- (tag >> 24) & 0xFF, |
- (tag >> 16) & 0xFF, |
- (tag >> 8) & 0xFF, |
- (tag ) & 0xFF); |
+ (axisTag >> 24) & 0xFF, |
+ (axisTag >> 16) & 0xFF, |
+ (axisTag >> 8) & 0xFF, |
+ (axisTag ) & 0xFF); |
} |
} |
- axis.fTag = SkSetFourByteTag(value[0], value[1], value[2], value[3]); |
} else { |
SK_FONTCONFIGPARSER_WARNING("'%s' is an invalid axis tag", value); |
} |
} else if (MEMEQ("stylevalue", name, nameLen)) { |
- if (!parse_fixed<16>(value, &axis.fValue)) { |
+ if (parse_fixed<16>(value, &axisStyleValue)) { |
+ axisStyleValueIsValid = true; |
+ } else { |
SK_FONTCONFIGPARSER_WARNING("'%s' is an invalid axis stylevalue", value); |
} |
} |
} |
+ if (axisTagIsValid && axisStyleValueIsValid) { |
+ SkFontMgr::FontParameters::Axis& axis = file.fAxes.push_back(); |
+ axis.fTag = axisTag; |
+ axis.fStyleValue = SkFixedToScalar(axisStyleValue); |
+ } |
}, |
/*end*/nullptr, |
/*tag*/nullptr, |