diff --git a/TODO/_current.md b/TODO/_current.md index 1c03c4b82..6515b2675 100644 --- a/TODO/_current.md +++ b/TODO/_current.md @@ -34,12 +34,6 @@ # Config -* Config test sometimes reads empty. - - Empty is written on init, then quickly filled with defaults for the write test. - - Maybe the empty write is happening after the filled somehow? - - Nope, tracing shows a full write request and commit. - - But the file is empty on error.. (empty as in `#` for TOML, not zero-sized) - * Review save debounce. * Test concurrent access to same config. - Use multiple app threads. \ No newline at end of file diff --git a/zero-ui-core/src/text/shaping.rs b/zero-ui-core/src/text/shaping.rs index 1739b90e7..d72f9d47c 100644 --- a/zero-ui-core/src/text/shaping.rs +++ b/zero-ui-core/src/text/shaping.rs @@ -187,6 +187,11 @@ impl LineRangeVec { self.0[index].width } + /// Line x offset. + fn x_offset(&self, index: usize) -> f32 { + self.0[index].x_offset + } + /// Iter segment ranges. fn iter_segs(&self) -> impl Iterator + '_ { self.iter_segs_skip(0) @@ -901,7 +906,7 @@ impl ShapedText { let text_start = seg.text_range().start(); - for ((g, advance), cluster) in seg.glyphs_with_x_advance().flat_map(|(_, gx)| gx).zip(seg.clusters()) { + for ((_, advance), cluster) in seg.glyphs_with_x_advance().flat_map(|(_, gx)| gx).zip(seg.clusters()) { if text_start + *cluster as usize == index { break; } @@ -1839,16 +1844,15 @@ impl<'a> ShapedSegment<'a> { fn x_width(&self) -> (Px, Px) { let IndexRange(start, end) = self.glyphs_range(); - // !!: TODO, check align let is_line_break = start == end && matches!(self.kind(), TextSegmentKind::LineBreak); let start_x = match self.direction() { LayoutDirection::LTR => { if is_line_break { - let s = self.text.lines.width(self.line_index); - return (Px(s as i32), Px(0)); + let x = self.text.lines.x_offset(self.line_index); + let w = self.text.lines.width(self.line_index); + return (Px((x + w) as i32), Px(0)); } - self.text.glyphs[start].point.x } LayoutDirection::RTL => {