-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prefer breaking lines at a zero width space. #8255
Conversation
Mapbox data sources use zero width spaces to suggest better break points for Japanese labels. This somewhat hacky approach avoids adding more complex line breaking logic to -gl-js.
@ansis I think I should port it to gl-native, right? |
A negative penalty on zero width spaces was not enough to prioritize them.
@lily-chai found that prioritizing zero width spaces couldn't effectively both break at zws and not break too often. Instead I've implemented penalization for ideographic breaks which seems to work better. @alexshalamov yes! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A render test would be good too. Could this be done with a GeoJSON source?
Can you verify and update the changes to the render tests for text-max-width/ideographic-punctuation-breaking
and text-max-width/ideographic-breaking
?
src/symbol/shaping.js
Outdated
calculatePenalty(codePoint, logicalInput.getCharCode(i + 1)), | ||
false)); | ||
if ((i < logicalInput.length() - 1)) { | ||
const ideographicBreak = !breakable[codePoint] && charAllowsIdeographicBreaking(codePoint); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont see any overlap between charAllowsIdeographicBreaking
and breakable
codepoints. This check could be just charAllowsIdeographicBreaking
;
// Penalize breaks between characters that allow ideographic breaking because | ||
// they are less preferable than breaks at spaces (or zero width spaces). | ||
if (penalizableIdeographicBreak) { | ||
penalty += 150; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the rendering test failures, it looks like this change regresses the balanced line breaking in #3743. The penalty is probably too high.
if (penalizableIdeographicBreak) { | ||
penalty += 150; | ||
} | ||
|
||
// Penalize open parenthesis at end of line | ||
if (codePoint === 0x28 || codePoint === 0xff08) { | ||
penalty += 50; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text-max-width/ideographic-punctuation-breaking test failure shows that this penalty is too low compared to the new penalty introduced above.
I've fixed the render tests by enabling the penalty only when a zws is present in the string. Capturing a conversation with @1ec5 from chat: This exception isn't great but shouldn't pose any problems if we change our approach in the future. |
Mapbox data sources use zero width spaces to suggest better break points for Japanese labels. This somewhat hacky approach avoids adding more complex line breaking logic to -gl-js.
@asheemmamoowala @lily-chai
Launch Checklist