Skip to content

Commit

Permalink
Fix text size in inline layout
Browse files Browse the repository at this point in the history
  • Loading branch information
SamRodri committed Jan 26, 2025
1 parent 3661c67 commit ed959c0
Showing 1 changed file with 21 additions and 1 deletion.
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 ed959c0

Please sign in to comment.