summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2018-10-09 13:00:35 -0700
committerChris Loer <chris.loer@mapbox.com>2018-10-15 13:15:46 -0700
commitfc11d2e872bfcfbd07b4f81114e0336d10650b84 (patch)
tree007b753eb8a73012d7804dc4edad61b0eebe28bc /platform
parent6cbf150a3391c87d895222b2b1ddc2046ccc8dad (diff)
downloadqtlocation-mapboxgl-fc11d2e872bfcfbd07b4f81114e0336d10650b84.tar.gz
[core, test] Add BiDi unit test
- Port of arabic.test.js from mapbox-gl-rtl-text - Modify BiDi::getLine to remove trailing nulls in the event UBIDI_REMOVE_BIDI_CONTROLS causes the string to shorten. - Patch vendored ICU to avoid undefined undefined bit shifting behavior (triggered sanitizer failure)
Diffstat (limited to 'platform')
-rw-r--r--platform/default/bidi.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/platform/default/bidi.cpp b/platform/default/bidi.cpp
index f972e43cc1..32a3dc23ef 100644
--- a/platform/default/bidi.cpp
+++ b/platform/default/bidi.cpp
@@ -220,8 +220,13 @@ std::u16string BiDi::getLine(std::size_t start, std::size_t end) {
// UBIDI_DO_MIRRORING: Apply unicode mirroring of characters like parentheses
// UBIDI_REMOVE_BIDI_CONTROLS: Now that all the lines are set, remove control characters so that
// they don't show up on screen (some fonts have glyphs representing them)
- ubidi_writeReordered(impl->bidiLine, mbgl::utf16char_cast<UChar*>(&outputText[0]), outputLength,
- UBIDI_DO_MIRRORING | UBIDI_REMOVE_BIDI_CONTROLS, &errorCode);
+ int32_t finalLength = ubidi_writeReordered(impl->bidiLine,
+ mbgl::utf16char_cast<UChar*>(&outputText[0]),
+ outputLength,
+ UBIDI_DO_MIRRORING | UBIDI_REMOVE_BIDI_CONTROLS,
+ &errorCode);
+
+ outputText.resize(finalLength); // REMOVE_BIDI_CONTROLS may have shrunk the string
if (U_FAILURE(errorCode)) {
throw std::runtime_error(std::string("BiDi::getLine (writeReordered): ") +