Reserve title footnote space on the first page
This commit is contained in:
1 parent
09781d40e9
commit
9dc1f59f8e
4 files changed
+84
-3
No files matched your search
@@ -1184,6 +1184,62 @@ fn footnote_reserve(
|
||||
.saturating_add(i64::from(scaled_points(1.0).0))
|
||||
}
|
||||
|
||||
/// Height reserved for footnotes that are not attached to a body block.
|
||||
///
|
||||
/// Title/author `\thanks` notes fall into this category: they are painted at
|
||||
/// the bottom of page one, so the body on that page must stop above them.
|
||||
fn title_footnote_reserve(
|
||||
model: &DocumentModel,
|
||||
content_width_mm: f64,
|
||||
metrics: &BoxFontMetrics,
|
||||
font_cache: &fonts::FontCache,
|
||||
cjk_family: Option<FontFamily<fonts::Font>>,
|
||||
mono_family: Option<FontFamily<fonts::Font>>,
|
||||
sans_family: Option<FontFamily<fonts::Font>>,
|
||||
math_metrics: &math_font::MathFontMetrics,
|
||||
math_layout: &MathLayoutEnvironment,
|
||||
cache: &mut ParagraphLayoutCache,
|
||||
) -> i64 {
|
||||
let mut referenced = Vec::new();
|
||||
for block in 0..model.blocks.len() {
|
||||
for number in footnote_numbers_for_block(model, block) {
|
||||
if !referenced.contains(&number) {
|
||||
referenced.push(number);
|
||||
}
|
||||
}
|
||||
}
|
||||
let footnote_font_size = ((f32::from(model.base_font_size) * 0.82).round() as u8).max(1);
|
||||
let width_mm = (content_width_mm - 8.0).max(20.0);
|
||||
let mut height = 0_i64;
|
||||
for note in &model.footnotes {
|
||||
if referenced.contains(¬e.number) {
|
||||
continue;
|
||||
}
|
||||
for line in measure_positioned_lines(
|
||||
¬e.runs,
|
||||
footnote_font_size,
|
||||
width_mm,
|
||||
metrics,
|
||||
font_cache,
|
||||
cjk_family,
|
||||
mono_family,
|
||||
sans_family,
|
||||
math_metrics,
|
||||
math_layout,
|
||||
cache,
|
||||
) {
|
||||
height = height.saturating_add(line.height);
|
||||
}
|
||||
}
|
||||
if height == 0 {
|
||||
0
|
||||
} else {
|
||||
height
|
||||
.saturating_add(i64::from(scaled_points(2.0).0))
|
||||
.saturating_add(i64::from(scaled_points(1.0).0))
|
||||
}
|
||||
}
|
||||
|
||||
fn measure_positioned_lines(
|
||||
runs: &[Run],
|
||||
font_size: u8,
|
||||
@@ -1639,7 +1695,7 @@ pub(super) fn build_positioned_pages(
|
||||
let heading_gap = (normal_line_height as f64 * 0.65).round() as i64;
|
||||
// Leave a small descent guard so the last baseline and its descender stay
|
||||
// inside the page frame; TeX's \maxdepth plays the same role.
|
||||
let page_goal = scaled_points(content_height_mm * PDF_POINTS_PER_INCH / 25.4).0 as i64
|
||||
let mut page_goal = scaled_points(content_height_mm * PDF_POINTS_PER_INCH / 25.4).0 as i64
|
||||
- millimeters_to_scaled(3.0);
|
||||
let mut pages = vec![PositionedPage::default()];
|
||||
set_body_line_factor(if model.title_style == TitleStyle::Preprint {
|
||||
@@ -1647,6 +1703,22 @@ pub(super) fn build_positioned_pages(
|
||||
} else {
|
||||
1.2
|
||||
});
|
||||
// Reserve the bottom of page one for `\thanks` notes in the title block.
|
||||
// They are painted after pagination, so without this the last body line can
|
||||
// run into the footnote area.
|
||||
let title_reserve = title_footnote_reserve(
|
||||
model,
|
||||
content_width_mm,
|
||||
metrics,
|
||||
font_cache,
|
||||
cjk_family,
|
||||
mono_family,
|
||||
sans_family,
|
||||
math_metrics,
|
||||
math_layout,
|
||||
cache,
|
||||
);
|
||||
page_goal = page_goal.saturating_sub(title_reserve);
|
||||
let mut deferred: Vec<DeferredFloat> = Vec::new();
|
||||
let mut block_end_pages: HashMap<usize, usize> = HashMap::new();
|
||||
let mut block_start_pages: HashMap<usize, usize> = HashMap::new();
|
||||
|
||||
Reference in new issue
Block a user