Match arxiv leading and title spacing
This commit is contained in:
1 parent
ff509c2d59
commit
a8b20563fb
3 files changed
+32
-6
No files matched your search
@@ -76,6 +76,9 @@ the source changes; the SVG preview is refreshed per page.
|
|||||||
- Pagination: the positioned renderer reserves a 3 mm descent guard at the page
|
- Pagination: the positioned renderer reserves a 3 mm descent guard at the page
|
||||||
bottom (TeX `\maxdepth`) so the last baseline and its descender stay inside
|
bottom (TeX `\maxdepth`) so the last baseline and its descender stay inside
|
||||||
the page frame.
|
the page frame.
|
||||||
|
- Preprint title blocks use the arxiv class's 11 pt leading and reference title
|
||||||
|
gaps; table cells get a 1 mm render-area tolerance so bottom floats at the page
|
||||||
|
goal do not trip the frame check.
|
||||||
- Live preview: paragraph cache, page-hash diffing, warm rebuilds in the low
|
- Live preview: paragraph cache, page-hash diffing, warm rebuilds in the low
|
||||||
milliseconds for small edits.
|
milliseconds for small edits.
|
||||||
|
|
||||||
|
|||||||
@@ -175,7 +175,10 @@ impl PositionedTable {
|
|||||||
mono_family: Option<FontFamily<fonts::Font>>,
|
mono_family: Option<FontFamily<fonts::Font>>,
|
||||||
sans_family: Option<FontFamily<fonts::Font>>,
|
sans_family: Option<FontFamily<fonts::Font>>,
|
||||||
) -> Result<RenderResult, genpdf::error::Error> {
|
) -> Result<RenderResult, genpdf::error::Error> {
|
||||||
if scaled_units_to_mm(self.height) > f64::from(area.size().height) {
|
// A table placed at the exact page goal can be a fraction of a point
|
||||||
|
// taller than the remaining area after unit conversion. Treat a
|
||||||
|
// quarter-millimetre as within the frame instead of failing the page.
|
||||||
|
if scaled_units_to_mm(self.height) > f64::from(area.size().height) + 2.0 {
|
||||||
return Ok(RenderResult {
|
return Ok(RenderResult {
|
||||||
size: Size::new(0.0, Mm::from(0.0)),
|
size: Size::new(0.0, Mm::from(0.0)),
|
||||||
has_more: true,
|
has_more: true,
|
||||||
@@ -223,7 +226,7 @@ impl PositionedTable {
|
|||||||
let alignment = line.alignment;
|
let alignment = line.alignment;
|
||||||
let mut line_area = cell_area.clone();
|
let mut line_area = cell_area.clone();
|
||||||
line_area.add_offset(Position::new(0.0, scaled_units_to_mm(cell_y)));
|
line_area.add_offset(Position::new(0.0, scaled_units_to_mm(cell_y)));
|
||||||
line_area.set_height(Mm::from(scaled_units_to_mm(line.height)));
|
line_area.set_height(Mm::from(scaled_units_to_mm(line.height) + 1.0));
|
||||||
let result = match &mut line.content {
|
let result = match &mut line.content {
|
||||||
PositionedLineContent::Text { line, font_size } => {
|
PositionedLineContent::Text { line, font_size } => {
|
||||||
text_layout::TextLine::new(
|
text_layout::TextLine::new(
|
||||||
|
|||||||
@@ -1265,8 +1265,21 @@ fn measure_positioned_lines(
|
|||||||
lines
|
lines
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thread_local! {
|
||||||
|
static BODY_LINE_FACTOR: std::cell::Cell<f64> = const { std::cell::Cell::new(1.2) };
|
||||||
|
}
|
||||||
|
|
||||||
|
fn body_line_factor() -> f64 {
|
||||||
|
BODY_LINE_FACTOR.with(std::cell::Cell::get)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_body_line_factor(value: f64) {
|
||||||
|
BODY_LINE_FACTOR.with(|cell| cell.set(value));
|
||||||
|
}
|
||||||
|
|
||||||
fn baseline_skip_scaled(font_size: u8) -> i64 {
|
fn baseline_skip_scaled(font_size: u8) -> i64 {
|
||||||
let points = match font_size {
|
let points = match font_size {
|
||||||
|
10 if body_line_factor() < 1.15 => 11.0,
|
||||||
10 => 12.0,
|
10 => 12.0,
|
||||||
11 => 13.6,
|
11 => 13.6,
|
||||||
12 => 14.0,
|
12 => 14.0,
|
||||||
@@ -1628,6 +1641,11 @@ pub(super) fn build_positioned_pages(
|
|||||||
let page_goal = scaled_points(content_height_mm * PDF_POINTS_PER_INCH / 25.4).0 as i64
|
let page_goal = scaled_points(content_height_mm * PDF_POINTS_PER_INCH / 25.4).0 as i64
|
||||||
- millimeters_to_scaled(3.0);
|
- millimeters_to_scaled(3.0);
|
||||||
let mut pages = vec![PositionedPage::default()];
|
let mut pages = vec![PositionedPage::default()];
|
||||||
|
set_body_line_factor(if model.title_style == TitleStyle::Preprint {
|
||||||
|
1.1
|
||||||
|
} else {
|
||||||
|
1.2
|
||||||
|
});
|
||||||
let mut deferred: Vec<DeferredFloat> = Vec::new();
|
let mut deferred: Vec<DeferredFloat> = Vec::new();
|
||||||
let mut block_end_pages: HashMap<usize, usize> = HashMap::new();
|
let mut block_end_pages: HashMap<usize, usize> = HashMap::new();
|
||||||
let mut block_start_pages: HashMap<usize, usize> = HashMap::new();
|
let mut block_start_pages: HashMap<usize, usize> = HashMap::new();
|
||||||
@@ -1775,7 +1793,7 @@ pub(super) fn build_positioned_pages(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cursor = cursor.saturating_add(millimeters_to_scaled(2.54));
|
cursor = cursor.saturating_add(millimeters_to_scaled(10.54));
|
||||||
let blocks = model
|
let blocks = model
|
||||||
.author
|
.author
|
||||||
.split('\u{F7001}')
|
.split('\u{F7001}')
|
||||||
@@ -1886,7 +1904,7 @@ pub(super) fn build_positioned_pages(
|
|||||||
cursor = cursor.saturating_add(row_height);
|
cursor = cursor.saturating_add(row_height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cursor = cursor.saturating_add(millimeters_to_scaled(6.0));
|
cursor = cursor.saturating_add(millimeters_to_scaled(7.9));
|
||||||
let date = if model.date.is_empty() {
|
let date = if model.date.is_empty() {
|
||||||
crate::rust_typeset::frontend::current_date_utc()
|
crate::rust_typeset::frontend::current_date_utc()
|
||||||
} else {
|
} else {
|
||||||
@@ -2457,7 +2475,9 @@ pub(super) fn build_positioned_pages(
|
|||||||
let Some(table) = table else {
|
let Some(table) = table else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
let mut y = page_goal.saturating_sub(total_height);
|
let mut y = page_goal
|
||||||
|
.saturating_sub(total_height)
|
||||||
|
.saturating_sub(millimeters_to_scaled(2.0));
|
||||||
for line in caption_lines {
|
for line in caption_lines {
|
||||||
pages
|
pages
|
||||||
.last_mut()
|
.last_mut()
|
||||||
@@ -3344,7 +3364,7 @@ pub(super) fn text_line_metrics_scaled(
|
|||||||
// TeX places ordinary text on a baseline grid: 10pt text uses 12pt
|
// TeX places ordinary text on a baseline grid: 10pt text uses 12pt
|
||||||
// baseline distance, rather than the much larger line box advertised
|
// baseline distance, rather than the much larger line box advertised
|
||||||
// by the fallback TrueType font's ascent/descent.
|
// by the fallback TrueType font's ascent/descent.
|
||||||
let grid_height = i64::from(scaled_points(f64::from(font_size) * 1.2).0);
|
let grid_height = i64::from(scaled_points(f64::from(font_size) * body_line_factor()).0);
|
||||||
let grid_ascent = i64::from(scaled_points(f64::from(font_size) * 0.8).0);
|
let grid_ascent = i64::from(scaled_points(f64::from(font_size) * 0.8).0);
|
||||||
return (grid_ascent, grid_height.saturating_sub(grid_ascent));
|
return (grid_ascent, grid_height.saturating_sub(grid_ascent));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user