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
@@ -175,7 +175,10 @@ impl PositionedTable {
|
||||
mono_family: Option<FontFamily<fonts::Font>>,
|
||||
sans_family: Option<FontFamily<fonts::Font>>,
|
||||
) -> 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 {
|
||||
size: Size::new(0.0, Mm::from(0.0)),
|
||||
has_more: true,
|
||||
@@ -223,7 +226,7 @@ impl PositionedTable {
|
||||
let alignment = line.alignment;
|
||||
let mut line_area = cell_area.clone();
|
||||
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 {
|
||||
PositionedLineContent::Text { line, font_size } => {
|
||||
text_layout::TextLine::new(
|
||||
|
||||
@@ -1265,8 +1265,21 @@ fn measure_positioned_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 {
|
||||
let points = match font_size {
|
||||
10 if body_line_factor() < 1.15 => 11.0,
|
||||
10 => 12.0,
|
||||
11 => 13.6,
|
||||
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
|
||||
- millimeters_to_scaled(3.0);
|
||||
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 block_end_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
|
||||
.author
|
||||
.split('\u{F7001}')
|
||||
@@ -1886,7 +1904,7 @@ pub(super) fn build_positioned_pages(
|
||||
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() {
|
||||
crate::rust_typeset::frontend::current_date_utc()
|
||||
} else {
|
||||
@@ -2457,7 +2475,9 @@ pub(super) fn build_positioned_pages(
|
||||
let Some(table) = table else {
|
||||
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 {
|
||||
pages
|
||||
.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
|
||||
// baseline distance, rather than the much larger line box advertised
|
||||
// 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);
|
||||
return (grid_ascent, grid_height.saturating_sub(grid_ascent));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user