Skip to content

Commit 064ed9a

Browse files
committed
Fix RTL justification; clear TODOs
1 parent 8c4eacf commit 064ed9a

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

Cargo.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -3949,7 +3949,7 @@ dependencies = [
39493949
[[package]]
39503950
name = "swash"
39513951
version = "0.2.1"
3952-
source = "git+https://github.com/valadaptive/swash?branch=tight-bounds#059903eb7175c6a0a838fc1e4b7d445150cfe7d9"
3952+
source = "git+https://github.com/valadaptive/swash?branch=tight-bounds#2a6429fb81b692d7345a78986354f939f424d1f3"
39533953
dependencies = [
39543954
"skrifa",
39553955
"yazi",

crates/egui/src/text_selection/text_cursor_state.rs

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ pub fn cursor_rect(galley: &Galley, cursor: &ByteCursor, row_height: f32) -> Rec
105105
let mut cursor_pos = galley.pos_from_cursor(*cursor);
106106

107107
// Handle completely empty galleys
108-
// TODO(valadaptive): had to adjust this because Parley's row height is less than egui's. Is this necessary anymore?
109108
if cursor_pos.height() < 1.0 {
110109
cursor_pos.max.y = cursor_pos.max.y.at_least(cursor_pos.min.y + row_height);
111110
}

crates/epaint/src/text/glyph_atlas.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,14 @@ impl GlyphAtlas {
238238
let image = &mut self.scratch;
239239
let color = glyph_run.style().brush;
240240

241-
// TODO(valadaptive): there's also a faux embolden property, but it's always true with the defaut font because
242-
// it's "light" and we technically asked for "normal"
241+
// There's also a faux embolden property, but it's always true with the default font because it's "light" and we
242+
// technically asked for "normal", so we can't use it
243243
let skew = run.synthesis().skew();
244244

245245
let style_key = StyleKey::<'b>::new(
246246
font_id,
247247
size,
248+
// Parley stores skew as an i8 internally, so it's fine to convert it back into one
248249
skew.unwrap_or_default() as i8,
249250
hinting_enabled,
250251
normalized_coords,

crates/epaint/src/text/parley_layout.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ pub(super) fn layout(fonts: &mut FontsLayoutView<'_>, job: LayoutJob) -> Galley
154154
Some(alignment_width),
155155
match (justify, job.halign) {
156156
(true, _) => parley::Alignment::Justified,
157-
(false, emath::Align::Min) => parley::Alignment::Start,
157+
(false, emath::Align::Min) => parley::Alignment::Left,
158158
(false, emath::Align::Center) => parley::Alignment::Middle,
159-
(false, emath::Align::Max) => parley::Alignment::End,
159+
(false, emath::Align::Max) => parley::Alignment::Right,
160160
},
161161
AlignmentOptions::default(),
162162
);

crates/epaint/src/texture_atlas.rs

-2
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,6 @@ impl TextureAtlas {
290290
self.overflowed = false;
291291
self.discs.clear();
292292
self.initialize();
293-
294-
// TODO(valadaptive): reset to initial size?
295293
}
296294
}
297295

parley-todo.md

+15-10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- [ ] Support the tab character (https://github.com/linebender/parley/issues/302)
1414
- [ ] AccessKit improvements (https://github.com/linebender/parley/issues/310)
1515
- [ ] Not Parley, but Swash: tighter glyph bounds (https://github.com/dfrg/zeno/pull/15)
16+
- [ ] SystemUi doesn't properly fallback in some cases (e.g. Arabic text, macOS shortcut symbols) on my machine; SansSerif does (https://github.com/linebender/parley/issues/323)
1617

1718
## Here:
1819
- [ ] Text layout
@@ -30,9 +31,15 @@
3031
- [ ] `LayoutJob::break_on_newline`
3132
- [ ] RTL considerations
3233
- [ ] Label wrapping only occurs in LTR layouts, but make sure it doesn't do anything weird with RTL labels
33-
- [ ] Text is right-justified if a label is split in the middle of RTL text
34+
- [ ] Do label wrapping in RTL too?
35+
- [x] Text is right-justified if a label is split in the middle of RTL text, or if a line contains only an RTL label
3436
- This may be desirable behavior, but is weird
37+
- Whoops; we asked Parley for RTL-aware behavior and got it
3538
- [ ] overflow_character should appear at the "start" of the line for RTL text
39+
- [ ] RTL support for `egui::Align`
40+
- [ ] Once Parley has vertical alignment, remove the hack for leading_space/first_row_min_height
41+
- [ ] Align multiple consecutive labels to the same baseline, even with different fonts
42+
- [ ] Line height discrepancy between old and new layout (Parley line height is just the font size)
3643
- [ ] Text rendering
3744
- [x] Investigate whether swash is being too conservative with its shape bounds and cutting off rendered glyphs
3845
- The reverse is true https://github.com/dfrg/zeno/pull/15
@@ -52,12 +59,13 @@
5259
- Forgot to clear the glyph atlas
5360
- [ ] Text selection and editing
5461
- [x] Unify the three different cursor types and move to a Parley-like API before moving to the actual Parley API (done)
55-
- [ ] Rewrite selection code to use parley's API
62+
- [x] Rewrite selection code to use parley's API
5663
- [x] Basic API mapping (done)
5764
- [x] Selection painting (done but kinda janky)
58-
- [ ] Probably rework label_text_selection (does it take bidirectional text into account?)
65+
- [x] Probably rework label_text_selection (does it take bidirectional text into account?)
5966
- [x] Still some jank when the cursor is kinda below the first label and it selects the "rest of the line" (fixed)
60-
- [ ] Make it support bidirectional text (fun!)
67+
- [x] Make it support bidirectional text (fun!)
68+
- I think this... just works already?
6169
- [x] finish the gnarly parts that i've been putting off
6270
- [x] indentation (done, but untested because parley's tab character support is broken)
6371
- [x] selecting a range without having a Galley rendered already (done)
@@ -68,6 +76,7 @@
6876
- [ ] Do another pass over TextBuffer's API
6977
- [ ] Test IME support
7078
- [ ] Smoothe out AccessKit API integration (and reduce temp allocations)
79+
- [ ] Test AccessKit text bounding boxes (horiz_offset for alignment and vertical_offset for wrapped labels working)
7180
- [ ] Text styling
7281
- [x] Fix FontDefinitions and adding fonts
7382
- [x] Get fallback/ordering working properly
@@ -99,20 +108,16 @@
99108
- [ ] Smoothe out the janky parts of the new API
100109
- [ ] For mixed-DPI purposes, and because we don't need to store the FontStore as a mutex, ctx.fonts() now returns a "fonts view" that's technically read/write. But there are no operations that *semantically* modify the fonts from it
101110
- [ ] FontStore and Fonts are different and we should just expose them separately instead of passing through all the FontStore methods onto Fonts
102-
- [ ] SystemUi doesn't properly fallback in some cases (e.g. Arabic text, macOS shortcut symbols) on my machine; SansSerif does
103111
- [ ] Work around https://github.com/jslegers/emoji-icon-font/issues/18 / https://github.com/emilk/egui/issues/1284
104-
- [ ] Cross-cutting concerns
105-
- [ ] Global/scoped RTL? Do we get bidirectional support for free if we use Parley's APIs?
106-
- [ ] RTL support for `egui::Align`
107-
- [ ] RTL/bidi support for cross-label text selection
108-
- [ ] RTL support for cross-label text wrapping
112+
- [x] Cross-cutting concerns
109113
- [x] Actually remove all the ab_glyph stuff
110114
- Sayonara, ab_glyph 🫡
111115
- [ ] Perf optimizations!
112116
- [ ] Stop using TreeBuilder so we don't have to allocate a bunch of strings
113117
- [ ] https://github.com/emilk/egui/issues/1098
114118
- [ ] Line-level layout memoization (https://github.com/emilk/egui/pull/5411)
115119
- [ ] The other 90%
120+
- [ ] Comment the new code better
116121
- [ ] update All Of The Doctests...
117122
- [ ] Go over APIs and clean them up
118123
- [ ] New documentation for the new APIs

0 commit comments

Comments
 (0)