Skip to content

Commit

Permalink
Fix text size in inline layout (#610)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamRodri authored Jan 26, 2025
1 parent 3661c67 commit 4d0e2e2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

* Fix regression, some `Text!` in `Wrap!` not rendering.

# 0.13.9

Expand Down
22 changes: 21 additions & 1 deletion crates/zng-wgt-text/src/node/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,14 @@ impl LayoutTextFinal {
self.pending.insert(PendingLayout::RESHAPE_LINES);
}

if self.pending.contains(PendingLayout::RESHAPE_LINES) {
if self.pending.contains(PendingLayout::RESHAPE_LINES) && metrics.inline_constraints().is_none() {
// Affects block size in measure too
//
// This breaks inline context, so it is avoided here and called later in the `if !is_measure` block.
// This is needed to measure the same block size a layout call would output.
//
// Not sure if it is a bug that it does not work inlining, but it is not needed there anyway, so for now
// this fix is sufficient.
ctx.shaped_text.reshape_lines(
metrics.constraints(),
metrics.inline_constraints().map(|c| c.layout()),
Expand All @@ -574,6 +581,19 @@ impl LayoutTextFinal {
self.last_layout = (metrics.clone(), self.shaping_args.inline_constraints);

if self.pending.contains(PendingLayout::RESHAPE_LINES) {
if metrics.inline_constraints().is_some() {
// when inlining, only reshape lines in layout passes
ctx.shaped_text.reshape_lines(
metrics.constraints(),
metrics.inline_constraints().map(|c| c.layout()),
align,
overflow_align,
line_height,
line_spacing,
metrics.direction(),
);
}

ctx.shaped_text_version = ctx.shaped_text_version.wrapping_add(1);
drop(resolved);
self.baseline = ctx.shaped_text.baseline();
Expand Down

0 comments on commit 4d0e2e2

Please sign in to comment.