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:
1 parent
2ef5e29329
commit
e9bbd4bd87
11 files changed
+108
-29
No files matched your search
@@ -33,6 +33,8 @@ pub enum Cmr10Metrics {
|
||||
MathFraktur,
|
||||
/// Math face: italic letters from cmmi10, big operators from cmex10.
|
||||
Math,
|
||||
/// Times Roman text metrics (`ptmr8t.tfm`).
|
||||
TimesRoman,
|
||||
}
|
||||
|
||||
static CMR10_TFM: &[u8] = include_bytes!("../assets/cmr10.tfm");
|
||||
@@ -52,6 +54,7 @@ static CMEX10_TFM: &[u8] = include_bytes!("../assets/cmex10.tfm");
|
||||
static CMSY10_TFM: &[u8] = include_bytes!("../assets/cmsy10.tfm");
|
||||
static MSBM10_TFM: &[u8] = include_bytes!("../assets/msbm10.tfm");
|
||||
static EUFM10_TFM: &[u8] = include_bytes!("../assets/eufm10.tfm");
|
||||
static PTMR8T_TFM: &[u8] = include_bytes!("../assets/ptmr8t.tfm");
|
||||
|
||||
static CMR10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
static CMBX10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
@@ -70,6 +73,7 @@ static CMEX10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
static CMSY10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
static MSBM10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
static EUFM10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
static PTMR8T_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
|
||||
fn parse(bytes: &[u8]) -> TfmMetrics {
|
||||
TfmMetrics::parse(bytes).expect("embedded TFM must be valid")
|
||||
@@ -159,6 +163,10 @@ fn parse_fraktur() -> TfmMetrics {
|
||||
parse(EUFM10_TFM)
|
||||
}
|
||||
|
||||
fn parse_times_roman() -> TfmMetrics {
|
||||
parse(PTMR8T_TFM)
|
||||
}
|
||||
|
||||
fn math_fraktur_metrics() -> &'static TfmMetrics {
|
||||
EUFM10_METRICS.get_or_init(parse_fraktur)
|
||||
}
|
||||
@@ -181,6 +189,7 @@ fn metrics_for(font: Cmr10Metrics) -> &'static TfmMetrics {
|
||||
Cmr10Metrics::MathCalligraphic => CMSY10_METRICS.get_or_init(parse_math_symbol),
|
||||
Cmr10Metrics::MathBlackboard => MSBM10_METRICS.get_or_init(parse_blackboard),
|
||||
Cmr10Metrics::MathFraktur => EUFM10_METRICS.get_or_init(parse_fraktur),
|
||||
Cmr10Metrics::TimesRoman => PTMR8T_METRICS.get_or_init(parse_times_roman),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,6 +213,7 @@ impl Cmr10Metrics {
|
||||
ParagraphFont::Slanted => Self::Slanted,
|
||||
ParagraphFont::BoldSlanted => Self::BoldSlanted,
|
||||
ParagraphFont::MonoItalic => Self::MonoItalic,
|
||||
ParagraphFont::TimesRoman => Self::TimesRoman,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,6 +502,16 @@ mod tests {
|
||||
assert!(font.depth('g') > 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn times_roman_tfm_differs_from_cmr() {
|
||||
let roman = Cmr10Metrics::Roman;
|
||||
let times = Cmr10Metrics::TimesRoman;
|
||||
assert_ne!(times.width('A'), roman.width('A'));
|
||||
assert_ne!(times.width('m'), roman.width('m'));
|
||||
assert!(times.height('A') > 0);
|
||||
assert!(times.depth('g') > 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bold_and_italic_tfms_differ_from_roman() {
|
||||
let roman = Cmr10Metrics::Roman;
|
||||
|
||||
Reference in new issue
Block a user