Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Draw a checkbox's border at the item's stroke weight

Brandon Thomas44b07403b150
diff --git a/crates/pdf/src/forms.rs b/crates/pdf/src/forms.rs
index bf0d955fc..73165dc7a 100644
--- a/crates/pdf/src/forms.rs
+++ b/crates/pdf/src/forms.rs
@@ -179,7 +179,7 @@ pub(crate) fn add_fields(pdf: &[u8], fields: &[Placed], media: &[PlacedMedia]) -
FieldKind::CheckBox => {
// Appearances: an empty box, and a box with a check mark.
let border =
- if *bw > 0.0 { format!("0.45 G 1 w 0.5 0.5 {:.2} {:.2} re S", (w - 1.0).max(0.0), (h - 1.0).max(0.0)) } else { String::new() };
+ if *bw > 0.0 { format!("0.45 G {bw:.2} w {i:.2} {i:.2} {:.2} {:.2} re S", (w - bw).max(0.0), (h - bw).max(0.0), i = bw / 2.0) } else { String::new() };
let check = format!(
"{border} 0 g {:.2} w 1 J 1 j {:.2} {:.2} m {:.2} {:.2} l {:.2} {:.2} l S",
(w.min(h) * 0.12).max(0.8),