-
Notifications
You must be signed in to change notification settings - Fork 6k
Custom RTL handling for ghost runs, NotoNaskhArabic test font #8638
Conversation
chinmaygarde
left a comment
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 started reviewing this but saw you were halfway through a conversation regarding this with @jason-simmons :) I'll defer to the conclusions from that.
third_party/txt/src/txt/paragraph.cc
Outdated
| for (size_t i = 0; i < runs_.size(); ++i) { | ||
| StyledRuns::Run run = runs_.GetRun(i); | ||
| // Initialize TextDirection to LTR as that is what ICU initializes it to. | ||
| styled_run_direction_map.emplace( |
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 don't think the emplace adds much value here as the enum value is not expensive to copy.
third_party/txt/src/txt/paragraph.cc
Outdated
| line_range.end_excluding_whitespace < line_range.end && | ||
| bidi_run.start() <= line_range.end && | ||
| bidi_run.end() > line_end_index) { | ||
| // Use the most recent TextDirection instead of the defaulted LTR value |
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.
ParagraphStyle has a field that sets the base TextDirection for the paragraph. What happens in this case if you set that field to RTL?
third_party/txt/src/txt/paragraph.cc
Outdated
| // impact on the layout. | ||
| if (paragraph_style_.ellipsis.empty() && | ||
| // | ||
| // RTL ghost run check (RTL ghost runs appear visually before the rest of |
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 this be merged with the LTR ghost run check below?
How about this:
- If (end_excluding_whitespace != line_range.end), then in a separate pass scan for the ghost run. The ghost run is the BidiRun that intersects the line's (end_excluding_whitespace, line_range.end) interval. Presumably there is only one such run.
- If the ghost run exists and its direction is RTL, then insert it into line_runs before doing the main pass that populates line_runs
- If it's LTR, then insert it after the main pass
third_party/txt/src/txt/paragraph.cc
Outdated
| } else if (run.is_rtl()) { | ||
| // For RTL ghost runs, we need to shift the ghost run over here as it is | ||
| // the offset is calculated in reverse order from LTR. | ||
| rtl_ghost_x_offset += layout.getAdvance(); |
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 think this can be reduced to doing
if (run.is_ghost() && run.is_rtl())
run_x_offset -= layout.getAdvance();
before converting the layout into text blobs
third_party/txt/src/txt/paragraph.cc
Outdated
|
|
||
| std::vector<GlyphPosition> line_glyph_positions; | ||
| std::vector<CodeUnitRun> line_code_unit_runs; | ||
| std::vector<CodeUnitRun*> ghost_code_unit_runs; |
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 should no longer be necessary
third_party/txt/src/txt/paragraph.cc
Outdated
|
|
||
| layout.doLayout(text_ptr, text_start, text_count, text_size, run.is_rtl(), | ||
| minikin_font, minikin_paint, minikin_font_collection); | ||
| if (run.is_ghost() && run.is_rtl()) |
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.
Move this to after the layout.nGlyphs() == 0 check and add a comment
…" (#8681) This reverts commit 6e79dcd. Reverts #8638 Reason: #8638 breaks the post-submit Cirrus tests. See https://cirrus-ci.com/build/5143341531398144 and subsequent post-submit failures. Specifically, ParagraphTest.RightAlignParagraph is failing. TBR: @GaryQian
flutter/engine@206cab6...ea28bfa git log 206cab6..ea28bfa --no-merges --oneline ea28bfa Custom RTL handling for ghost runs, NotoNaskhArabic test font (flutter/engine#8683) 1c9457c Revert "Only allow mappings for ICU initialization. (#8656)" (flutter/engine#8682) b4ed303 Revert "RTL handling for ghost runs, NotoNaskhArabic test font (#8638)" (flutter/engine#8681) 8b5f776 Remove support for downloading dynamic patches. (flutter/engine#8663) 1bcb96b Add framework test in engine presubmit checks (flutter/engine#8664) 6e79dcd RTL handling for ghost runs, NotoNaskhArabic test font (flutter/engine#8638) c37d459 Roll src/third_party/skia 1c0b05afdef8..a76fad2d494a (4 commits) (flutter/engine#8665) 2e4f0a4 Put the testing lib in the flutter namespace. (flutter/engine#8661) 1239df9 Allow native bindings in secondary isolates. (flutter/engine#8658) b0cbce4 Replace ThreadLocal with ThreadLocalUniquePtr<T> (flutter/engine#8659) bd8c5b1 Only allow mappings for ICU initialization. (flutter/engine#8656) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff ([email protected]), and stop the roller if necessary.
|
fix that with set textDirection to ltr. it's cool |
Fixes flutter/flutter#21679
Here, we track the TextDirection used for the styled run, and apply the most recent to ghost runs. This needs to be done because ICU interprets all non-language-specific (eg, normal space character) as LTR, which causes the space to be on the right side of the text in RTL languages. We handle this case manually and flip it to the opposite side.