From f84eeaed7ace48fba7752dd09714c64d57b0b247 Mon Sep 17 00:00:00 2001 From: aiongg Date: Thu, 22 Oct 2026 04:15:17 +0000 Subject: [PATCH] =?UTF-8?q?Integration:=20a=20non-interactive=20XFA=20fiel?= =?UTF-8?q?d=20is=20measured=20at=20the=20width=20it=20is=20drawn=20(#3515?= =?UTF-8?q?=20=C3=97=20#3521)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #3515 measures a growing non-interactive field at its text's scale but with a widget's 4pt of padding, while the layout draws its text without it. Once #3521 fits lines by their ink, the narrower measuring width wrapped to one more line than the drawn text, leaving a blank line below it. The measurement leaves out the padding the draw doesn't have. --- crates/xfa/src/layout.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/xfa/src/layout.rs b/crates/xfa/src/layout.rs index b2c17a0597..326e7f7413 100644 --- a/crates/xfa/src/layout.rs +++ b/crates/xfa/src/layout.rs @@ -1148,12 +1148,15 @@ impl Layouter<'_> { } let value = self.data.and_then(|d| d.value_at(&data_path(self.tpl, &ctx.som))).filter(|t| !t.trim().is_empty()).or_else(|| f.value.plain()); let Some(value) = value.filter(|t| !t.trim().is_empty()) else { return 0.0 }; - // Beside a caption the text has what the caption leaves; 2pt of padding on each side. + // Beside a caption the text has what the caption leaves; a widget's text has 2pt of + // padding on each side, a non-interactive field's (drawn as text) none, so it wraps + // where it is drawn. let beside = match self.caption_reserve(f, inner_w, ctx) { Some((Placement::Top | Placement::Bottom, _)) | None => 0.0, Some((_, r)) => r, }; - let w = (inner_w - beside - f.ui_margin.horizontal() - 4.0).max(1.0); + let padding = if f.access == Access::NonInteractive { 0.0 } else { 4.0 }; + let w = (inner_w - beside - f.ui_margin.horizontal() - padding).max(1.0); let font = ctx.font.apply(&f.common.font); text::measure_height(&text::plain(value.trim_end()), w, &ctx.para, &Self::field_text_face(f, &font), &|_| String::new()) }