Add 10/11/12pt base font size options
This commit is contained in:
1 parent
269433abdb
commit
477e2124c8
8 files changed
+180
-69
No files matched your search
@@ -68,6 +68,8 @@ pub struct DocumentModel {
|
||||
pub date: String,
|
||||
pub page: PageSize,
|
||||
pub parindent: common::Scaled,
|
||||
/// Base font size selected by the document class (10, 11, or 12pt).
|
||||
pub base_font_size: u8,
|
||||
pub margins: PageMargins,
|
||||
pub show_title: bool,
|
||||
pub blocks: Vec<Block>,
|
||||
@@ -88,6 +90,7 @@ impl Default for DocumentModel {
|
||||
page: PageSize::default(),
|
||||
// article's default \parindent for 10/11pt text.
|
||||
parindent: common::Scaled(17 * 65_536),
|
||||
base_font_size: 11,
|
||||
margins: PageMargins::default(),
|
||||
show_title: false,
|
||||
blocks: Vec::new(),
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user