Track textwidth and textheight from page geometry
This commit is contained in:
1 parent
ed1da06685
commit
269433abdb
7 files changed
+153
-28
No files matched your search
@@ -2071,7 +2071,15 @@ fn normalize_whitespace(text: &str) -> String {
|
||||
}
|
||||
|
||||
fn apply_geometry(document: &mut DocumentModel, settings: &str) {
|
||||
let page = &mut document.page;
|
||||
apply_geometry_settings(&mut document.page, &mut document.margins, settings);
|
||||
}
|
||||
|
||||
/// Apply comma-separated `geometry` settings to a page size and margins.
|
||||
///
|
||||
/// This is shared by the document parser and by the frontend's live length
|
||||
/// tracker, so `\textwidth`/`\textheight` expanded during macro processing
|
||||
/// match the layout that the parser will produce.
|
||||
pub fn apply_geometry_settings(page: &mut PageSize, margins: &mut PageMargins, settings: &str) {
|
||||
// Paper size first: explicit margins in the same list must be measured
|
||||
// against the final page dimensions.
|
||||
for setting in settings.split(',') {
|
||||
@@ -2105,7 +2113,6 @@ fn apply_geometry(document: &mut DocumentModel, settings: &str) {
|
||||
}
|
||||
}
|
||||
|
||||
let margins = &mut document.margins;
|
||||
for setting in settings.split(',') {
|
||||
let Some((key, value)) = setting.split_once('=') else {
|
||||
continue;
|
||||
@@ -2140,9 +2147,8 @@ fn apply_geometry(document: &mut DocumentModel, settings: &str) {
|
||||
|
||||
// Text-block dimensions are resolved after explicit margins so that top
|
||||
// influences the computed bottom margin in the same settings list.
|
||||
let page_width = document.page.width_mm;
|
||||
let page_height = document.page.height_mm;
|
||||
let margins = &mut document.margins;
|
||||
let page_width = page.width_mm;
|
||||
let page_height = page.height_mm;
|
||||
for setting in settings.split(',') {
|
||||
let Some((key, value)) = setting.split_once('=') else {
|
||||
continue;
|
||||
|
||||
Reference in new issue
Block a user