diff options
author | Chris Loer <chris.loer@gmail.com> | 2016-11-09 18:23:49 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-11-17 14:33:03 -0800 |
commit | 40b0c8d0760f8a767ef4646607ac63251d86de8d (patch) | |
tree | 5840c35c21dcb593198093769db8c81be6ce3674 /src/mbgl/util/i18n.cpp | |
parent | 5c7aeec5c7170f47a127391cfdb5e25b42ec8b58 (diff) | |
download | qtlocation-mapboxgl-40b0c8d0760f8a767ef4646607ac63251d86de8d.tar.gz |
[core] Use UTF-16 instead of UTF-32 for label features to avoid extra conversions and reduce in-memory size.
Continue to use uint32 as glyph ID to maintain Glyph PBF, even though we're only using 16 bits of that uint32.
Use std::codecvt instead of boost::unicode_iterator for UTF8->UTF16 conversions.
Diffstat (limited to 'src/mbgl/util/i18n.cpp')
-rw-r--r-- | src/mbgl/util/i18n.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/mbgl/util/i18n.cpp b/src/mbgl/util/i18n.cpp index dbfa24c5cf..97dda76320 100644 --- a/src/mbgl/util/i18n.cpp +++ b/src/mbgl/util/i18n.cpp @@ -8,7 +8,7 @@ namespace { @param last The last codepoint in the block, inclusive. */ #define DEFINE_IS_IN_UNICODE_BLOCK(name, first, last) \ - inline bool isIn##name(uint32_t codepoint) { \ + inline bool isIn##name(uint16_t codepoint) { \ return codepoint >= first && codepoint <= last; \ } @@ -294,13 +294,13 @@ namespace mbgl { namespace util { namespace i18n { -bool isVisible(uint32_t chr) { +bool isVisible(uint16_t chr) { return (chr == 0x0a /* newline */ || chr == 0x20 /* space */ || chr == 0x200b /* zero-width space */); } -bool allowsWordBreaking(uint32_t chr) { +bool allowsWordBreaking(uint16_t chr) { return (chr == 0x0a /* newline */ || chr == 0x20 /* space */ || chr == 0x26 /* ampersand */ @@ -314,8 +314,8 @@ bool allowsWordBreaking(uint32_t chr) { || chr == 0x2013 /* en dash */); } -bool allowsIdeographicBreaking(const std::u32string& string) { - for (uint32_t chr : string) { +bool allowsIdeographicBreaking(const std::u16string& string) { + for (uint16_t chr : string) { if (!allowsIdeographicBreaking(chr)) { return false; } @@ -323,7 +323,7 @@ bool allowsIdeographicBreaking(const std::u32string& string) { return true; } -bool allowsIdeographicBreaking(uint32_t chr) { +bool allowsIdeographicBreaking(uint16_t chr) { // Return early for characters outside all ideographic ranges. if (chr < 0x2E80) return false; |