Distinguish slanted from italic and add italic typewriter
Add cmsl10/cmbxsl10/cmitt10 faces so \slshape and \textsl no longer reuse the italic cmti10 and \ttfamily\itshape reaches cmitt10. The NFSS state tracks italic, slanted and small caps separately, with last-shape-wins semantics for \em and the shape commands.
This commit is contained in:
1 parent
6df38ced25
commit
aa4d86d735
15 files changed
+328
-34
No files matched your search
@@ -19,6 +19,12 @@ pub enum Cmr10Metrics {
|
||||
SansItalic,
|
||||
/// Roman small caps (cmcsc10).
|
||||
SmallCaps,
|
||||
/// Roman slanted (cmsl10).
|
||||
Slanted,
|
||||
/// Bold extended slanted (cmbxsl10).
|
||||
BoldSlanted,
|
||||
/// Italic typewriter (cmitt10).
|
||||
MonoItalic,
|
||||
/// Calligraphic capitals from cmsy10 (`\mathcal`).
|
||||
MathCalligraphic,
|
||||
/// Blackboard-bold capitals from msbm10 (`\mathbb`).
|
||||
@@ -38,6 +44,9 @@ static CMSS10_TFM: &[u8] = include_bytes!("../assets/cmss10.tfm");
|
||||
static CMSSBX10_TFM: &[u8] = include_bytes!("../assets/cmssbx10.tfm");
|
||||
static CMSSI10_TFM: &[u8] = include_bytes!("../assets/cmssi10.tfm");
|
||||
static CMCSC10_TFM: &[u8] = include_bytes!("../assets/cmcsc10.tfm");
|
||||
static CMSL10_TFM: &[u8] = include_bytes!("../assets/cmsl10.tfm");
|
||||
static CMBXSL10_TFM: &[u8] = include_bytes!("../assets/cmbxsl10.tfm");
|
||||
static CMITT10_TFM: &[u8] = include_bytes!("../assets/cmitt10.tfm");
|
||||
static CMMI10_TFM: &[u8] = include_bytes!("../assets/cmmi10.tfm");
|
||||
static CMEX10_TFM: &[u8] = include_bytes!("../assets/cmex10.tfm");
|
||||
static CMSY10_TFM: &[u8] = include_bytes!("../assets/cmsy10.tfm");
|
||||
@@ -53,6 +62,9 @@ static CMSS10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
static CMSSBX10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
static CMSSI10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
static CMCSC10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
static CMSL10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
static CMBXSL10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
static CMITT10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
static CMMI10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
static CMEX10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
static CMSY10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
@@ -99,6 +111,18 @@ fn parse_small_caps() -> TfmMetrics {
|
||||
parse(CMCSC10_TFM)
|
||||
}
|
||||
|
||||
fn parse_slanted() -> TfmMetrics {
|
||||
parse(CMSL10_TFM)
|
||||
}
|
||||
|
||||
fn parse_bold_slanted() -> TfmMetrics {
|
||||
parse(CMBXSL10_TFM)
|
||||
}
|
||||
|
||||
fn parse_mono_italic() -> TfmMetrics {
|
||||
parse(CMITT10_TFM)
|
||||
}
|
||||
|
||||
fn parse_math_italic() -> TfmMetrics {
|
||||
parse(CMMI10_TFM)
|
||||
}
|
||||
@@ -150,6 +174,9 @@ fn metrics_for(font: Cmr10Metrics) -> &'static TfmMetrics {
|
||||
Cmr10Metrics::SansBold => CMSSBX10_METRICS.get_or_init(parse_sans_bold),
|
||||
Cmr10Metrics::SansItalic => CMSSI10_METRICS.get_or_init(parse_sans_italic),
|
||||
Cmr10Metrics::SmallCaps => CMCSC10_METRICS.get_or_init(parse_small_caps),
|
||||
Cmr10Metrics::Slanted => CMSL10_METRICS.get_or_init(parse_slanted),
|
||||
Cmr10Metrics::BoldSlanted => CMBXSL10_METRICS.get_or_init(parse_bold_slanted),
|
||||
Cmr10Metrics::MonoItalic => CMITT10_METRICS.get_or_init(parse_mono_italic),
|
||||
Cmr10Metrics::Math => CMR10_METRICS.get_or_init(parse_roman),
|
||||
Cmr10Metrics::MathCalligraphic => CMSY10_METRICS.get_or_init(parse_math_symbol),
|
||||
Cmr10Metrics::MathBlackboard => MSBM10_METRICS.get_or_init(parse_blackboard),
|
||||
@@ -174,6 +201,9 @@ impl Cmr10Metrics {
|
||||
ParagraphFont::SansBold => Self::SansBold,
|
||||
ParagraphFont::SansItalic => Self::SansItalic,
|
||||
ParagraphFont::SmallCaps => Self::SmallCaps,
|
||||
ParagraphFont::Slanted => Self::Slanted,
|
||||
ParagraphFont::BoldSlanted => Self::BoldSlanted,
|
||||
ParagraphFont::MonoItalic => Self::MonoItalic,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,6 +223,9 @@ impl Cmr10Metrics {
|
||||
11 => Self::SansBold,
|
||||
12 => Self::SansItalic,
|
||||
13 => Self::SmallCaps,
|
||||
14 => Self::Slanted,
|
||||
15 => Self::BoldSlanted,
|
||||
16 => Self::MonoItalic,
|
||||
_ => Self::Roman,
|
||||
}
|
||||
}
|
||||
@@ -708,5 +741,19 @@ mod cmex_delimiter_tests {
|
||||
let small_caps = Cmr10Metrics::SmallCaps.width('a');
|
||||
assert_eq!(small_caps, metrics_for(Cmr10Metrics::SmallCaps).width('a'));
|
||||
assert_ne!(small_caps, Cmr10Metrics::Roman.width('a'));
|
||||
assert_eq!(Cmr10Metrics::for_pdf_slot(14), Cmr10Metrics::Slanted);
|
||||
assert_eq!(Cmr10Metrics::for_pdf_slot(15), Cmr10Metrics::BoldSlanted);
|
||||
assert_eq!(Cmr10Metrics::for_pdf_slot(16), Cmr10Metrics::MonoItalic);
|
||||
let slanted = Cmr10Metrics::Slanted.width('a');
|
||||
assert_eq!(slanted, metrics_for(Cmr10Metrics::Slanted).width('a'));
|
||||
assert_ne!(slanted, Cmr10Metrics::Italic.width('a'));
|
||||
assert_eq!(
|
||||
Cmr10Metrics::BoldSlanted.width('a'),
|
||||
metrics_for(Cmr10Metrics::BoldSlanted).width('a')
|
||||
);
|
||||
assert_eq!(
|
||||
Cmr10Metrics::MonoItalic.width('a'),
|
||||
metrics_for(Cmr10Metrics::MonoItalic).width('a')
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user