From c9ce515518dc8319133bf3f2b769f7df0dfcd761 Mon Sep 17 00:00:00 2001 From: Kulratan Thapar Date: Mon, 12 Jan 2026 15:31:49 +0000 Subject: [PATCH 1/3] Fix: correctly apply max width/height in text bounding box --- node-graph/nodes/text/src/text_context.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/node-graph/nodes/text/src/text_context.rs b/node-graph/nodes/text/src/text_context.rs index fc49ecd602..0c761411f3 100644 --- a/node-graph/nodes/text/src/text_context.rs +++ b/node-graph/nodes/text/src/text_context.rs @@ -107,15 +107,23 @@ impl TextContext { /// Calculate the bounding box of text using the specified font and typesetting configuration pub fn bounding_box(&mut self, text: &str, font: &Font, font_cache: &FontCache, typesetting: TypesettingConfig, for_clipping_test: bool) -> DVec2 { - if !for_clipping_test && let (Some(max_height), Some(max_width)) = (typesetting.max_height, typesetting.max_width) { - return DVec2::new(max_width, max_height); - } - let Some(layout) = self.layout_text(text, font, font_cache, typesetting) else { return DVec2::ZERO; }; - DVec2::new(layout.full_width() as f64, layout.height() as f64) + let layout_width = layout.full_width() as f64; + let layout_height = layout.height() as f64; + + // For clipping tests use of the actual layout dimensions to see if text overflows + if for_clipping_test { + return DVec2::new(layout_width, layout_height); + } + + // max_width/max_height used if set ,otherwise fall back to calculated layout dimensions + let width = typesetting.max_width.unwrap_or(layout_width); + let height = typesetting.max_height.unwrap_or(layout_height); + + DVec2::new(width, height) } /// Check if text lines are being clipped due to height constraints From fcd4608611ff4f6ecbd6163df6b6734fcf3380f2 Mon Sep 17 00:00:00 2001 From: Kulratan Thapar Date: Tue, 3 Feb 2026 07:44:13 +0000 Subject: [PATCH 2/3] bug fix --- node-graph/nodes/text/src/text_context.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/node-graph/nodes/text/src/text_context.rs b/node-graph/nodes/text/src/text_context.rs index 0c761411f3..79e802c112 100644 --- a/node-graph/nodes/text/src/text_context.rs +++ b/node-graph/nodes/text/src/text_context.rs @@ -97,6 +97,11 @@ impl TextContext { for line in layout.lines() { for item in line.items() { if let PositionedLayoutItem::GlyphRun(glyph_run) = item { + if let Some(max_height) = typesetting.max_height { + if glyph_run.baseline() > max_height as f32 { + continue; + } + } path_builder.render_glyph_run(&glyph_run, typesetting.tilt, per_glyph_instances); } } From 3eae1e40cd04f9d603117ae1fafda87a95c506b1 Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Sat, 14 Feb 2026 10:53:09 -0800 Subject: [PATCH 3/3] Code cleanup --- node-graph/nodes/text/src/text_context.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/node-graph/nodes/text/src/text_context.rs b/node-graph/nodes/text/src/text_context.rs index 79e802c112..7934feb885 100644 --- a/node-graph/nodes/text/src/text_context.rs +++ b/node-graph/nodes/text/src/text_context.rs @@ -96,12 +96,9 @@ impl TextContext { for line in layout.lines() { for item in line.items() { - if let PositionedLayoutItem::GlyphRun(glyph_run) = item { - if let Some(max_height) = typesetting.max_height { - if glyph_run.baseline() > max_height as f32 { - continue; - } - } + if let PositionedLayoutItem::GlyphRun(glyph_run) = item + && typesetting.max_height.filter(|&max_height| glyph_run.baseline() > max_height as f32).is_none() + { path_builder.render_glyph_run(&glyph_run, typesetting.tilt, per_glyph_instances); } } @@ -119,12 +116,10 @@ impl TextContext { let layout_width = layout.full_width() as f64; let layout_height = layout.height() as f64; - // For clipping tests use of the actual layout dimensions to see if text overflows if for_clipping_test { return DVec2::new(layout_width, layout_height); } - // max_width/max_height used if set ,otherwise fall back to calculated layout dimensions let width = typesetting.max_width.unwrap_or(layout_width); let height = typesetting.max_height.unwrap_or(layout_height);