[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.
This commit is contained in:
Chris Loer
2016-11-20 09:36:07 -08:00
parent d8cef78502
commit 5f29c3ba26
10 changed files with 347 additions and 196 deletions

View File

@@ -294,12 +294,6 @@ namespace mbgl {
namespace util {
namespace i18n {
bool isVisible(uint16_t chr) {
return (chr == 0x0a /* newline */
|| chr == 0x20 /* space */
|| chr == 0x200b /* zero-width space */);
}
bool allowsWordBreaking(uint16_t chr) {
return (chr == 0x0a /* newline */
|| chr == 0x20 /* space */
@@ -324,6 +318,10 @@ bool allowsIdeographicBreaking(const std::u16string& string) {
}
bool allowsIdeographicBreaking(uint16_t chr) {
// Allow U+2027 "Interpunct" for hyphenation of Chinese words
if (chr == 0x2027)
return true;
// Return early for characters outside all ideographic ranges.
if (chr < 0x2E80)
return false;