Make default margin behavior more precise (#1666)

This commit is contained in:
lolstork 2023-07-06 09:38:04 +02:00 committed by GitHub
parent a4756d8576
commit 286dec3f0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,8 +90,9 @@ pub struct PageElem {
/// The page's margins. /// The page's margins.
/// ///
/// - `{auto}`: The margins are set automatically to 2.5/21 times the smaller
/// dimension of the page. This results in 2.5cm margins for an A4 page.
/// - A single length: The same margin on all sides. /// - A single length: The same margin on all sides.
/// - `{auto}`: The margin is set to the default value for the page's size.
/// - A dictionary: With a dictionary, the margins can be set individually. /// - A dictionary: With a dictionary, the margins can be set individually.
/// The dictionary can contain the following keys in order of precedence: /// The dictionary can contain the following keys in order of precedence:
/// - `top`: The top margin. /// - `top`: The top margin.
@ -325,7 +326,7 @@ impl PageElem {
} }
// Determine the margins. // Determine the margins.
let default = Rel::<Length>::from(0.1190 * min); let default = Rel::<Length>::from((2.5 / 21.0) * min);
let margin = self.margin(styles); let margin = self.margin(styles);
let two_sided = margin.two_sided.unwrap_or(false); let two_sided = margin.two_sided.unwrap_or(false);
let margin = margin let margin = margin