This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Full support for line breaking bidirectional text using ICU bi…
…di 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.
- Loading branch information
Showing
10 changed files
with
337 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,47 @@ | ||
#pragma once | ||
|
||
#include <set> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include <mbgl/util/noncopyable.hpp> | ||
|
||
struct UBiDiTransform; | ||
struct UBiDi; | ||
|
||
namespace mbgl { | ||
|
||
enum class WritingDirection : bool { LeftToRight, RightToLeft }; | ||
|
||
|
||
class BiDi; | ||
|
||
std::u16string applyArabicShaping(const std::u16string&); | ||
|
||
class ProcessedBiDiText { | ||
public: | ||
ProcessedBiDiText(BiDi&); | ||
|
||
std::vector<std::u16string> applyLineBreaking(std::set<int32_t>); | ||
|
||
private: | ||
void mergeParagraphLineBreaks(std::set<int32_t>&); | ||
|
||
BiDi& bidi; | ||
}; | ||
|
||
class BiDi : private util::noncopyable { | ||
public: | ||
BiDi(); | ||
~BiDi(); | ||
|
||
std::u16string bidiTransform(const std::u16string&); | ||
WritingDirection baseWritingDirection(const std::u16string&); | ||
// Calling processText resets internal state, invalidating any existing ProcessedBiDiText | ||
// objects | ||
ProcessedBiDiText processText(const std::u16string&); | ||
|
||
friend class ProcessedBiDiText; | ||
|
||
private: | ||
UBiDiTransform* transform; | ||
std::u16string getLine(int32_t start, int32_t end); | ||
|
||
UBiDi* bidiText; | ||
UBiDi* bidiLine; | ||
}; | ||
|
||
} // end namespace mbgl |
Oops, something went wrong.