Select real Computer Modern small caps
Add the cmcsc10 face for \scshape and \textsc, including its Type1 outline, and compose the sc shape with the surrounding family and series. Bold small caps substitute cmbx10 and a later shape command wins, matching NFSS.
This commit is contained in:
1 parent
9140990a7d
commit
e303f7852f
11 files changed
+150
-13
No files matched your search
@@ -17,6 +17,8 @@ pub enum Cmr10Metrics {
|
||||
Sans,
|
||||
SansBold,
|
||||
SansItalic,
|
||||
/// Roman small caps (cmcsc10).
|
||||
SmallCaps,
|
||||
/// Calligraphic capitals from cmsy10 (`\mathcal`).
|
||||
MathCalligraphic,
|
||||
/// Blackboard-bold capitals from msbm10 (`\mathbb`).
|
||||
@@ -35,6 +37,7 @@ static CMTT10_TFM: &[u8] = include_bytes!("../assets/cmtt10.tfm");
|
||||
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 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");
|
||||
@@ -49,6 +52,7 @@ static CMTT10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
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 CMMI10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
static CMEX10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
static CMSY10_METRICS: OnceLock<TfmMetrics> = OnceLock::new();
|
||||
@@ -91,6 +95,10 @@ fn parse_sans_italic() -> TfmMetrics {
|
||||
parse(CMSSI10_TFM)
|
||||
}
|
||||
|
||||
fn parse_small_caps() -> TfmMetrics {
|
||||
parse(CMCSC10_TFM)
|
||||
}
|
||||
|
||||
fn parse_math_italic() -> TfmMetrics {
|
||||
parse(CMMI10_TFM)
|
||||
}
|
||||
@@ -141,6 +149,7 @@ fn metrics_for(font: Cmr10Metrics) -> &'static TfmMetrics {
|
||||
Cmr10Metrics::Sans => CMSS10_METRICS.get_or_init(parse_sans),
|
||||
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::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),
|
||||
@@ -164,6 +173,7 @@ impl Cmr10Metrics {
|
||||
ParagraphFont::Sans => Self::Sans,
|
||||
ParagraphFont::SansBold => Self::SansBold,
|
||||
ParagraphFont::SansItalic => Self::SansItalic,
|
||||
ParagraphFont::SmallCaps => Self::SmallCaps,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,6 +192,7 @@ impl Cmr10Metrics {
|
||||
10 => Self::MathFraktur,
|
||||
11 => Self::SansBold,
|
||||
12 => Self::SansItalic,
|
||||
13 => Self::SmallCaps,
|
||||
_ => Self::Roman,
|
||||
}
|
||||
}
|
||||
@@ -693,5 +704,9 @@ mod cmex_delimiter_tests {
|
||||
assert!(italic > 0);
|
||||
assert_eq!(Cmr10Metrics::for_pdf_slot(11), Cmr10Metrics::SansBold);
|
||||
assert_eq!(Cmr10Metrics::for_pdf_slot(12), Cmr10Metrics::SansItalic);
|
||||
assert_eq!(Cmr10Metrics::for_pdf_slot(13), Cmr10Metrics::SmallCaps);
|
||||
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'));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user