Add 10/11/12pt base font size options

This commit is contained in:
gloamxun committed 2026-10-19 13:52:24 +08:00
1 parent 269433abdb
commit 477e2124c8
8 files changed
+180 -69

No files matched your search

+16
View File
@@ -853,6 +853,7 @@ impl Parser {
self.finish_metadata(*field);
}
expanded::FrontendEventKind::Geometry(settings) => {
apply_class_font_size(&mut self.document, settings);
apply_geometry(&mut self.document, settings);
}
expanded::FrontendEventKind::TextStyleStart(style) => self.begin_style(*style),
@@ -2074,6 +2075,21 @@ fn apply_geometry(document: &mut DocumentModel, settings: &str) {
apply_geometry_settings(&mut document.page, &mut document.margins, settings);
}
/// Apply article-class base font size options (10pt, 11pt, 12pt).
fn apply_class_font_size(document: &mut DocumentModel, settings: &str) {
for setting in settings.split(',').map(str::trim) {
let size = match setting {
"10pt" => 10,
"11pt" => 11,
"12pt" => 12,
_ => continue,
};
document.base_font_size = size;
let indent = if size == 11 { 17 } else { 15 };
document.parindent = common::Scaled(indent * 65_536);
}
}
/// 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