Use Times metrics for ptm documents

Add a merged ptmr8t TFM asset, a TimesRoman paragraph face and Cmr10Metrics
entry, map a ptm Roman paragraph to it, and select the Liberation Serif
TrueType PDF backend for those projects. The title is uppercased rather than
small-capped so its widths use Times metrics.

The arXiv PDF now embeds Liberation Serif for body text; title/author/abstract
land at y=88/173/277pt with three pages and all references. Headings and bold/
italic Times faces still use CMR metrics.

Test count is 1075.
This commit is contained in:
gloamxun committed 2026-10-28 00:00:34 +08:00
1 parent 2ef5e29329
commit e9bbd4bd87
11 files changed
+108 -29

No files matched your search

+41 -11
View File
@@ -14,6 +14,7 @@ use texrra_tex_core::math::{AlignedRow, MathAtom, parse_math, split_math_lines};
use texrra_tex_core::paragraph::HorizontalItem;
use texrra_tex_core::pdf::{
PageOrigin, PdfMetadata, PdfOutlineEntry, display_lists_to_pdf_with_cm_type1_and_metadata,
display_lists_to_pdf_with_truetype_and_metadata,
};
pub use texrra_tex_core::render::RasterImage;
use texrra_tex_core::render::{DisplayItem, DisplayList, FontFace};
@@ -223,6 +224,8 @@ struct PageGeometry {
/// The source uses the `geometry` package, so a text block with no explicit
/// `\hoffset` is centred between the paper edges.
geometry_package: bool,
/// `\renewcommand{\rmdefault}{...}`: `ptm` selects Times.
roman_family: Option<String>,
par_indent: Option<i64>,
par_skip: Option<i64>,
par_skip_stretch: Option<i64>,
@@ -3323,6 +3326,10 @@ fn strip_page_geometry(
geometry.array_stretch = Some(spread);
continue;
}
if let Some(family) = renewcommand_text(trimmed, "rmdefault") {
geometry.roman_family = Some(family);
continue;
}
if let Some(name) = renewcommand_text(trimmed, "figurename") {
geometry.figure_name = Some(name);
continue;
@@ -7738,13 +7745,23 @@ pub fn pdf_bytes_with_images(
h_offset: document.h_offset,
v_offset: document.v_offset,
};
Ok(display_lists_to_pdf_with_cm_type1_and_metadata(
&pages,
document.paper_width,
document.paper_height,
origin,
&metadata,
))
if geometry.roman_family.as_deref() == Some("ptm") {
Ok(display_lists_to_pdf_with_truetype_and_metadata(
&pages,
document.paper_width,
document.paper_height,
origin,
&metadata,
))
} else {
Ok(display_lists_to_pdf_with_cm_type1_and_metadata(
&pages,
document.paper_width,
document.paper_height,
origin,
&metadata,
))
}
}
/// Apply one paragraph edit to the last route-D document and report page
@@ -9799,6 +9816,7 @@ fn nfss_font_with_size(
ParagraphFont::Slanted => (Family::Roman, false, false),
ParagraphFont::BoldSlanted => (Family::Roman, true, false),
ParagraphFont::MonoItalic => (Family::Mono, false, true),
ParagraphFont::TimesRoman => (Family::Roman, false, false),
};
let mut small_caps = base == ParagraphFont::SmallCaps;
let mut slanted = matches!(base, ParagraphFont::Slanted | ParagraphFont::BoldSlanted);
@@ -12724,7 +12742,12 @@ fn expand_maketitle(blocks: &[SourceParagraph], geometry: &PageGeometry) -> Vec<
title_size(base),
block.space_before + 18 * SCALE,
);
paragraph.font = ParagraphFont::SmallCaps;
if geometry.roman_family.as_deref() == Some("ptm") {
paragraph.text = paragraph.text.to_uppercase();
paragraph.font = ParagraphFont::Roman;
} else {
paragraph.font = ParagraphFont::SmallCaps;
}
paragraph.page_break = block.page_break;
result.push(paragraph);
}
@@ -14095,9 +14118,16 @@ fn build_document_with_labels(
xspace_skip: geometry.xspace_skip,
};
let plain = strip_hrefs(&text).replace('~', " ");
let face = if geometry.roman_family.as_deref() == Some("ptm")
&& paragraph.font == ParagraphFont::Roman
{
ParagraphFont::TimesRoman
} else {
paragraph.font
};
let mut unit = match inline_segments_with_boxes(
&text,
paragraph.font,
face,
&style,
&geometry.colors,
geometry
@@ -14111,7 +14141,7 @@ fn build_document_with_labels(
style.clone(),
segments,
),
None => match inline_runs(&plain, paragraph.font) {
None => match inline_runs(&plain, face) {
Some(runs) => Unit::paragraph_with_style_and_runs(
index as u64,
plain.clone(),
@@ -14122,7 +14152,7 @@ fn build_document_with_labels(
index as u64,
strip_group_braces(&plain),
style,
paragraph.font,
face,
),
},
};