diff options
author | Chris Loer <chris.loer@gmail.com> | 2016-11-20 09:36:07 -0800 |
---|---|---|
committer | Chris Loer <chris.loer@gmail.com> | 2016-11-30 11:54:08 -0800 |
commit | 5f29c3ba26f84c8aea6f70640c348b32cdf397bf (patch) | |
tree | 2767e2cbb6aa826280fd7afc2b71f2d620010528 /src/mbgl/layout | |
parent | d8cef7850293bb801778c82d2d196cdeb22862f5 (diff) | |
download | qtlocation-mapboxgl-5f29c3ba26f84c8aea6f70640c348b32cdf397bf.tar.gz |
[core] Full support for line breaking bidirectional text using ICU bidi functionality.
- Trim whitespace from labels before determining their max-width for alignment.
- Fix crash on labels that contain lines with only a single character of whitespace.
Diffstat (limited to 'src/mbgl/layout')
-rw-r--r-- | src/mbgl/layout/symbol_feature.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_layout.cpp | 10 |
2 files changed, 3 insertions, 9 deletions
diff --git a/src/mbgl/layout/symbol_feature.hpp b/src/mbgl/layout/symbol_feature.hpp index b1ac3ffe78..9e0eacaac5 100644 --- a/src/mbgl/layout/symbol_feature.hpp +++ b/src/mbgl/layout/symbol_feature.hpp @@ -1,6 +1,5 @@ #pragma once -#include <mbgl/text/bidi.hpp> #include <mbgl/tile/geometry_tile_data.hpp> #include <mbgl/util/optional.hpp> @@ -12,7 +11,6 @@ class SymbolFeature { public: GeometryCollection geometry; optional<std::u16string> text; - optional<WritingDirection> writingDirection; optional<std::string> icon; std::size_t index; }; diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index 41ad6f6452..7dad5c9429 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -20,8 +20,6 @@ #include <mbgl/util/platform.hpp> #include <mbgl/util/logging.hpp> -#include <mbgl/text/bidi.hpp> - namespace mbgl { using namespace style; @@ -92,9 +90,7 @@ SymbolLayout::SymbolLayout(std::string bucketName_, u8string = platform::lowercase(u8string); } - std::u16string u16string = util::utf8_to_utf16::convert(u8string); - ft.text = bidi.bidiTransform(u16string); - ft.writingDirection = bidi.baseWritingDirection(u16string); + ft.text = applyArabicShaping(util::utf8_to_utf16::convert(u8string)); // Loop through all characters of this text and collect unique codepoints. for (char16_t chr : *ft.text) { @@ -198,7 +194,6 @@ void SymbolLayout::prepare(uintptr_t tileUID, if (feature.text) { shapedText = glyphSet->getShaping( /* string */ *feature.text, - /* base direction of text */ *feature.writingDirection, /* maxWidth: ems */ layout.get<SymbolPlacement>() != SymbolPlacementType::Line ? layout.get<TextMaxWidth>() * 24 : 0, /* lineHeight: ems */ layout.get<TextLineHeight>() * 24, @@ -206,7 +201,8 @@ void SymbolLayout::prepare(uintptr_t tileUID, /* verticalAlign */ verticalAlign, /* justify */ justify, /* spacing: ems */ layout.get<TextLetterSpacing>() * 24, - /* translate */ Point<float>(layout.get<TextOffset>()[0], layout.get<TextOffset>()[1])); + /* translate */ Point<float>(layout.get<TextOffset>()[0], layout.get<TextOffset>()[1]), + /* bidirectional algorithm object */ bidi); // Add the glyphs we need for this label to the glyph atlas. if (shapedText) { |