PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
M12: doc comments, and words keeps its own
Eric Kadena3b942021f8d
diff --git a/crates/xfa/src/tests.rs b/crates/xfa/src/tests.rsindex 9784986fe..1d027162b 100644--- a/crates/xfa/src/tests.rs+++ b/crates/xfa/src/tests.rs@@ -2085,6 +2085,8 @@ fn draw_spans(xdp: &str) -> Vec<text::Span> {layout_xml(xdp).unwrap().pages[0].items.iter().filter_map(|i| if let Item::Text(s) = i { Some(s.clone()) } else { None }).collect()}+/// A label that fits its box but is written with trailing spaces stays on one line and measures+/// as tall as without them; text wider than the box still wraps.#[test]fn a_space_at_the_end_of_a_line_does_not_count_when_fitting_it() {// The box is just wide enough for "a. DATE"; the label is written "a. DATE " (as forms@@ -2107,6 +2109,7 @@ fn a_space_at_the_end_of_a_line_does_not_count_when_fitting_it() {assert_eq!(baselines.len(), 2, "{spans:?}");}+/// Centered and right-aligned text is placed by its drawn width, whatever spaces follow it.#[test]fn trailing_spaces_do_not_shift_centered_or_right_aligned_text() {let w = 200.0;diff --git a/crates/xfa/src/text.rs b/crates/xfa/src/text.rsindex cbfd9fbc5..76035a2c4 100644--- a/crates/xfa/src/text.rs+++ b/crates/xfa/src/text.rs@@ -144,7 +144,6 @@ struct Word {width: f64,}-/// Break the runs of a paragraph into words (spaces stay attached to the word before them)./// The width of `w` without the spaces it ends with: what it takes at the end of a line, where/// a space is never drawn.fn ink_width(w: &Word) -> f64 {@@ -152,6 +151,7 @@ fn ink_width(w: &Word) -> f64 {if ink.len() == w.text.len() { w.width } else { w.face.width(ink) }}+/// Break the runs of a paragraph into words (spaces stay attached to the word before them).fn words(runs: &[Run], base: &Face, embed: &dyn Fn(&str) -> String) -> Vec<Word> {let mut out = Vec::new();for run in runs {