mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-24 18:33:22 +00:00
#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.
This commit is contained in:
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user