-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Support text-writing-mode
property for line placement symbols
#10647
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
Conversation
8f636c7
to
d0ee812
Compare
bc50689
to
b90ba0f
Compare
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.
Looks great! I asked a couple questions about things that were unclear to me but I didn't see any issues
if (symbolInstance.placedIconSymbolIndex >= 0) { | ||
const horizontalOpacity = useHorizontal ? packedOpacity : PACKED_HIDDEN_OPACITY; |
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.
This changed from !hasIconTextFit || !verticalPlacedIconSymbolIndex || !horizontalHidden
to just !horizontalHidden
. I understand why !verticalPlacedIconSymbolIndex
would be dropped but I'm not sure about !hasIconTextFit
. Do you know what the purpose of !hasIconTextFit
was in the previous version?
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 am not quite sure why hiasIconTextFit
is used for this case. I cross-compared with the gl-native parity code, it doesn't have this precondition. And one problem for only having useHorizontal
check is it will disable either vertical or horizontal symbols, now this is not feasible for line label cases of having placedOrientation == undefined
const placedOrientation = this.placedOrientations[symbolInstance.crossTileID];
const horizontalHidden = placedOrientation === WritingMode.vertical;
const verticalHidden = placedOrientation === WritingMode.horizontal || placedOrientation === WritingMode.horizontalOnly;
@@ -175,6 +175,12 @@ function updateLineLabels(bucket: SymbolBucket, | |||
for (let s = 0; s < placedSymbols.length; s++) { | |||
const symbol: any = placedSymbols.get(s); | |||
|
|||
if (symbol.writingMode === WritingMode.vertical && !useVertical) { | |||
if (s === 0 || placedSymbols.get(s - 1).writingMode !== WritingMode.horizontal) { |
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.
Can you explain what this line is doing? especially the s - 1
part
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.
Yeah, it is a little confusing, I will add comment for it:
Normally, the 'Horizontal|Vertical' writing mode is followed by a 'Vertical' counterpart,
this is not true for 'Vertical' only line labels. For this case, we'll have to overwrite the
'useVertical' status before further checks.
Add more render tests for line label text-writing-mode
Update render tests
3dc4e4a
to
d271e93
Compare
d271e93
to
756efbb
Compare
…ox#10647) * Remove Symbol placement checking when examing text writing modes * Add default values of text-writing-mode for line labels * Enable horizontal writing mode for vertical line label * Add support for vertical only case for line label * Fix lint errors * Update render tests * Update render tests Add more render tests for line label text-writing-mode * Add new render tests Update render tests * Fix vertical text shaping * Fix punctuation verticalization * Fix icon-text-fit * Update comments * Update style spec contents
Launch Checklist
The line labels now can be configured with
text-writing-mode
as the following JSON shows:The text-writing-mode configuration can be added as an array, whose values are enumeration values from a ( horizontal | vertical ) set.
To keep the previous rendering behavior as much as possible, the default
text-writing-mode
configuration for line label would be either:"text-writing-mode": ["horizontal", "vertical"]
or
"text-writing-mode": ["vertical", "horizontal"]
It means for line labels, the order of the writing modes in the array doesn’t affect the rendering behavior if both writing modes are provided. The decision is based on the assumption that the default map text-rotation-alignment is applied for the line labels.
The rendering result will keep almost the same as previous except that for vertical line labels, non-CJK characters along with CJK characters will also be upright. The following table shows the rendering effects with different
text-writing-mode
configs, to be aware thatvertical
writing mode will only be effective for text that is verticalizable, for pure Latin/numbers, the text will still be rendered horizontally withvertical
writing mode:mapbox-gl-js
changelog:<changelog>Support 'text-writing-mode' property for line symbol-placement text labels. Note: This change will bring following changes for CJK text block: 1. For vertical CJK text, all the characters including Latin and Numbers will be vertically placed now. Previously, Latin and Numbers are horizontally placed. 2. For horizontal CJK text, it may have a slight horizontal shift due to the anchor shift.</changelog>