Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix text size in inline layout #610

Merged
merged 3 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading