fix(core): break a label before a left parenthesis, not after it (#4553)
This commit is contained in:
@@ -385,7 +385,10 @@ std::set<std::size_t> determineLineBreaks(const TaggedString& logicalInput,
|
||||
// often appear without surrounding spaces.
|
||||
if (i < logicalInput.length() - 1) {
|
||||
const bool allowsIdeographicBreak = util::i18n::allowsIdeographicBreaking(codePoint);
|
||||
if (section.imageID || allowsIdeographicBreak || util::i18n::allowsWordBreaking(codePoint)) {
|
||||
const bool allowsBreakBeforeNext = i != logicalInput.length() - 2 &&
|
||||
util::i18n::allowsWordBreakingBefore(logicalInput.getCharCodeAt(i + 1));
|
||||
if (section.imageID || allowsIdeographicBreak || util::i18n::allowsWordBreaking(codePoint) ||
|
||||
allowsBreakBeforeNext) {
|
||||
const bool penalizableIdeographicBreak = allowsIdeographicBreak && hasServerSuggestedBreaks;
|
||||
const std::size_t nextIndex = i + 1;
|
||||
potentialBreaks.push_back(evaluateBreak(
|
||||
|
||||
@@ -352,7 +352,6 @@ bool allowsWordBreaking(char16_t chr) {
|
||||
return (chr == 0x0a /* newline */
|
||||
|| chr == 0x20 /* space */
|
||||
|| chr == 0x26 /* ampersand */
|
||||
|| chr == 0x28 /* open parenthesis */
|
||||
|| chr == 0x29 /* close parenthesis */
|
||||
|| chr == 0x2b /* plus sign */
|
||||
|| chr == 0x2d /* hyphen-minus */
|
||||
@@ -365,6 +364,10 @@ bool allowsWordBreaking(char16_t chr) {
|
||||
);
|
||||
}
|
||||
|
||||
bool allowsWordBreakingBefore(char16_t chr) {
|
||||
return chr == 0x28; /* open parenthesis */
|
||||
}
|
||||
|
||||
bool charAllowsLetterSpacing(char16_t chr) {
|
||||
return !(isInArabic(chr) || isInArabicSupplement(chr) || isInArabicExtendedA(chr) ||
|
||||
isInArabicPresentationFormsA(chr) || isInArabicPresentationFormsB(chr));
|
||||
|
||||
@@ -10,6 +10,10 @@ namespace i18n {
|
||||
by the given Unicode codepoint due to word breaking. */
|
||||
bool allowsWordBreaking(char16_t chr);
|
||||
|
||||
/** Returns whether a line break can be inserted before the character indicated
|
||||
by the given Unicode codepoint due to word breaking. */
|
||||
bool allowsWordBreakingBefore(char16_t chr);
|
||||
|
||||
/** Returns whether the given string can be displayed with letter-spacing.
|
||||
False for Arabic scripts, where letter-spacing will break ligatures. */
|
||||
bool allowsLetterSpacing(const std::u16string& string);
|
||||
|
||||
Reference in New Issue
Block a user