From fb361b7df9ec3a214a7224c9dbc4024b173dcfc8 Mon Sep 17 00:00:00 2001 From: GloamXun Date: Tue, 20 Oct 2026 01:19:40 +0800 Subject: [PATCH] Polish journal author and abstract typography --- src/rust_typeset/pdf/layout.rs | 78 ++++++++++++++++++++-------------- tests/typeset.rs | 2 +- 2 files changed, 46 insertions(+), 34 deletions(-) diff --git a/src/rust_typeset/pdf/layout.rs b/src/rust_typeset/pdf/layout.rs index feb4ce6..f2b06a1 100644 --- a/src/rust_typeset/pdf/layout.rs +++ b/src/rust_typeset/pdf/layout.rs @@ -1855,7 +1855,11 @@ pub(super) fn build_positioned_pages( .collect() }; let mut author_emails = Vec::new(); - for author in &model.authors { + let mut author_runs = Vec::new(); + for (author_index, author) in model.authors.iter().enumerate() { + if author_index > 0 { + author_runs.push(Run::plain(" and ".to_string())); + } let mut runs = author.runs.clone(); if !author.affiliations.is_empty() || author.corresponding { let mut marks = author @@ -1868,36 +1872,37 @@ pub(super) fn build_positioned_pages( } runs.push(Run::plain(marks)); } - for line in measure_positioned_lines( - &runs, - base_font_size, - content_width_mm, - metrics, - font_cache, - cjk_family, - mono_family, - sans_family, - math_metrics, - math_layout, - cache, - ) { - push_title_line( - &mut pages, - &mut deferred, - &mut cursor, - page_breaks, - page_goal, - top_skip, - max_depth, - line, - 0, - true, - ); - } + author_runs.extend(runs); if let Some(email) = &author.email { author_emails.push(email.clone()); } } + for line in measure_positioned_lines( + &author_runs, + base_font_size, + content_width_mm, + metrics, + font_cache, + cjk_family, + mono_family, + sans_family, + math_metrics, + math_layout, + cache, + ) { + push_title_line( + &mut pages, + &mut deferred, + &mut cursor, + page_breaks, + page_goal, + top_skip, + max_depth, + line, + 0, + true, + ); + } for affiliation in &model.affiliations { let mut runs = vec![Run::plain(format!("{} ", superscript(affiliation.index)))]; @@ -1969,12 +1974,15 @@ pub(super) fn build_positioned_pages( } if !model.abstract_runs.is_empty() { + let abstract_width = (content_width_mm - 12.0).max(40.0); + let abstract_inset = millimeters_to_scaled(6.0); let mut heading = Run::plain("Abstract".to_string()); heading.bold = true; + heading.small_caps = true; for line in measure_positioned_lines( std::slice::from_ref(&heading), base_font_size, - content_width_mm, + abstract_width, metrics, font_cache, cjk_family, @@ -2028,11 +2036,15 @@ pub(super) fn build_positioned_pages( } if !model.keywords.is_empty() { - let mut runs = vec![Run::plain("Keywords: ".to_string())]; - let mut keyword_run = Run::plain(String::new()); - keyword_run.bold = true; - runs.push(keyword_run); - runs.extend(model.keywords.clone()); + let mut label = Run::plain("Keywords: ".to_string()); + label.bold = true; + let mut runs = vec![label]; + for (index, keyword) in model.keywords.iter().enumerate() { + if index > 0 { + runs.push(Run::plain(", ".to_string())); + } + runs.push(keyword.clone()); + } for line in measure_positioned_lines( &runs, base_font_size.saturating_sub(1).max(1), diff --git a/tests/typeset.rs b/tests/typeset.rs index cdf8c6f..e960056 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -1896,7 +1896,7 @@ Body paragraph. ">Alice<", ">Bob<", ">Department<", - ">Abstract<", + ">BSTRACT<", ">Keywords:<", ">abstract<", ">body<",