[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.
This commit is contained in:
Chris Loer
2016-11-09 18:23:49 -08:00
committed by John Firebaugh
parent 5c7aeec5c7
commit 40b0c8d076
16 changed files with 40 additions and 39 deletions

View File

@@ -31,7 +31,7 @@ const std::map<uint32_t, SDFGlyph> &GlyphSet::getSDFs() const {
return sdfs;
}
const Shaping GlyphSet::getShaping(const std::u32string &string, const float maxWidth,
const Shaping GlyphSet::getShaping(const std::u16string &string, const float maxWidth,
const float lineHeight, const float horizontalAlign,
const float verticalAlign, const float justify,
const float spacing, const Point<float> &translate) const {
@@ -44,7 +44,7 @@ const Shaping GlyphSet::getShaping(const std::u32string &string, const float max
const float y = yOffset;
// Loop through all characters of this label and shape.
for (uint32_t chr : string) {
for (char16_t chr : string) {
auto it = sdfs.find(chr);
if (it != sdfs.end()) {
shaping.positionedGlyphs.emplace_back(chr, x, y);