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:
gloamxun committed 2026-10-24 12:52:15 +08:00
1 parent 9140990a7d
commit e303f7852f
11 files changed
+150 -13

No files matched your search

+23
View File
@@ -295,6 +295,8 @@ pub enum ParagraphFont {
Sans,
SansBold,
SansItalic,
/// Roman small caps (`cmcsc10`, TeX `\scshape`).
SmallCaps,
}
impl ParagraphFont {
@@ -309,6 +311,7 @@ impl ParagraphFont {
Self::Sans => Self::SansItalic,
Self::SansBold => Self::SansBold,
Self::SansItalic => Self::Sans,
Self::SmallCaps => Self::Italic,
}
}
@@ -319,6 +322,7 @@ impl ParagraphFont {
Self::Italic | Self::BoldItalic => Self::BoldItalic,
Self::Mono => self,
Self::Sans | Self::SansBold | Self::SansItalic => Self::SansBold,
Self::SmallCaps => Self::Bold,
}
}
@@ -330,6 +334,7 @@ impl ParagraphFont {
Self::Mono => self,
Self::Sans | Self::SansItalic => self,
Self::SansBold => Self::Sans,
Self::SmallCaps => Self::SmallCaps,
}
}
@@ -342,6 +347,7 @@ impl ParagraphFont {
Self::Sans => Self::SansItalic,
Self::SansBold => Self::SansBold,
Self::SansItalic => Self::SansItalic,
Self::SmallCaps => Self::Italic,
}
}
@@ -353,6 +359,7 @@ impl ParagraphFont {
Self::Mono => self,
Self::Sans | Self::SansItalic => Self::Sans,
Self::SansBold => Self::SansBold,
Self::SmallCaps => Self::SmallCaps,
}
}
@@ -366,6 +373,18 @@ impl ParagraphFont {
}
}
/// `\textsc` / `\scshape`: roman small caps, with TeX's substitution for
/// a bold series (Computer Modern has no bold small caps).
pub const fn small_caps(self) -> Self {
match self {
Self::Roman | Self::Italic => Self::SmallCaps,
Self::Bold | Self::BoldItalic => Self::Bold,
Self::SmallCaps => Self::SmallCaps,
Self::Mono => Self::Mono,
Self::Sans | Self::SansBold | Self::SansItalic => self,
}
}
/// `\textsf`: change family, keeping the inherited weight and shape.
pub const fn sans_family(self) -> Self {
match self {
@@ -2360,5 +2379,9 @@ mod font_tests {
ParagraphFont::SansItalic
);
assert_eq!(ParagraphFont::Mono.sans_family(), ParagraphFont::Sans);
assert_eq!(ParagraphFont::SmallCaps.emphasized(), ParagraphFont::Italic);
assert_eq!(ParagraphFont::Bold.small_caps(), ParagraphFont::Bold);
assert_eq!(ParagraphFont::Italic.small_caps(), ParagraphFont::SmallCaps);
assert_eq!(ParagraphFont::SmallCaps.upright(), ParagraphFont::SmallCaps);
}
}