Index: src/ports/SkFontConfigParser_android.cpp |
diff --git a/src/ports/SkFontConfigParser_android.cpp b/src/ports/SkFontConfigParser_android.cpp |
index e60f4e4ea307a3e74e58495c4ca6f80be0f2b668..d1bcec2c7b0256aa4a95e8e39922b80f2f154eff 100644 |
--- a/src/ports/SkFontConfigParser_android.cpp |
+++ b/src/ports/SkFontConfigParser_android.cpp |
@@ -263,6 +263,19 @@ static void XMLCALL start_element_handler(void* data, const char* tag, const cha |
} |
} |
+static void trim_string(SkString* s) { |
+ char* str = s->writable_str(); |
+ const char* start = str; |
+ const char* end = start + s->size(); |
+ for (; *start == ' ' || *start == '\n'|| *start == '\r' || *start == '\t'; ++start) { } |
djsollen
2015/05/08 13:56:13
while I can appreciate the compactness of this it
bungeman-skia
2015/05/08 15:05:04
Done.
|
+ if (start != end) { |
+ for (--end; *end == ' ' || *end == '\n'|| *end == '\r' || *end == '\t'; --end) { } |
djsollen
2015/05/08 13:56:13
comment why you need the --end at the begin and en
bungeman-skia
2015/05/08 15:05:04
Done.
|
+ ++end; |
+ } |
+ memmove(str, start, end - start); |
+ s->resize(end - start); |
+} |
+ |
static void XMLCALL end_element_handler(void* data, const char* tag) { |
FamilyData* self = static_cast<FamilyData*>(data); |
size_t len = strlen(tag); |
@@ -270,6 +283,7 @@ static void XMLCALL end_element_handler(void* data, const char* tag) { |
*self->fFamilies.append() = self->fCurrentFamily.detach(); |
} else if (MEMEQ("font", tag, len)) { |
XML_SetCharacterDataHandler(self->fParser, NULL); |
+ trim_string(&self->fCurrentFontInfo->fFileName); |
} |
} |