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
@@ -297,6 +297,12 @@ pub enum ParagraphFont {
|
||||
SansItalic,
|
||||
/// Roman small caps (`cmcsc10`, TeX `\scshape`).
|
||||
SmallCaps,
|
||||
/// Roman slanted (`cmsl10`, TeX `\slshape`).
|
||||
Slanted,
|
||||
/// Bold extended slanted (`cmbxsl10`).
|
||||
BoldSlanted,
|
||||
/// Italic typewriter (`cmitt10`, TeX `\ttfamily\itshape`).
|
||||
MonoItalic,
|
||||
}
|
||||
|
||||
impl ParagraphFont {
|
||||
@@ -312,6 +318,9 @@ impl ParagraphFont {
|
||||
Self::SansBold => Self::SansBold,
|
||||
Self::SansItalic => Self::Sans,
|
||||
Self::SmallCaps => Self::Italic,
|
||||
Self::Slanted => Self::Italic,
|
||||
Self::BoldSlanted => Self::BoldItalic,
|
||||
Self::MonoItalic => Self::Mono,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,6 +332,8 @@ impl ParagraphFont {
|
||||
Self::Mono => self,
|
||||
Self::Sans | Self::SansBold | Self::SansItalic => Self::SansBold,
|
||||
Self::SmallCaps => Self::Bold,
|
||||
Self::Slanted | Self::BoldSlanted => Self::BoldSlanted,
|
||||
Self::MonoItalic => Self::MonoItalic,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,19 +346,39 @@ impl ParagraphFont {
|
||||
Self::Sans | Self::SansItalic => self,
|
||||
Self::SansBold => Self::Sans,
|
||||
Self::SmallCaps => Self::SmallCaps,
|
||||
Self::Slanted | Self::BoldSlanted => Self::Slanted,
|
||||
Self::MonoItalic => Self::MonoItalic,
|
||||
}
|
||||
}
|
||||
|
||||
/// `\textit` / `\textsl`.
|
||||
/// `\textit`.
|
||||
pub const fn italicized(self) -> Self {
|
||||
match self {
|
||||
Self::Roman | Self::Italic => Self::Italic,
|
||||
Self::Bold | Self::BoldItalic => Self::BoldItalic,
|
||||
Self::Mono => self,
|
||||
Self::Mono => Self::MonoItalic,
|
||||
Self::MonoItalic => Self::MonoItalic,
|
||||
Self::Sans => Self::SansItalic,
|
||||
Self::SansBold => Self::SansBold,
|
||||
Self::SansItalic => Self::SansItalic,
|
||||
Self::SmallCaps => Self::Italic,
|
||||
Self::Slanted => Self::Italic,
|
||||
Self::BoldSlanted => Self::BoldItalic,
|
||||
}
|
||||
}
|
||||
|
||||
/// `\textsl`.
|
||||
pub const fn slanted(self) -> Self {
|
||||
match self {
|
||||
Self::Roman | Self::Slanted => Self::Slanted,
|
||||
Self::Bold | Self::BoldSlanted => Self::BoldSlanted,
|
||||
Self::Italic => Self::Slanted,
|
||||
Self::BoldItalic => Self::BoldSlanted,
|
||||
Self::Mono => Self::MonoItalic,
|
||||
Self::MonoItalic => Self::MonoItalic,
|
||||
Self::Sans | Self::SansItalic => Self::SansItalic,
|
||||
Self::SansBold => Self::SansBold,
|
||||
Self::SmallCaps => Self::Slanted,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,6 +391,8 @@ impl ParagraphFont {
|
||||
Self::Sans | Self::SansItalic => Self::Sans,
|
||||
Self::SansBold => Self::SansBold,
|
||||
Self::SmallCaps => Self::SmallCaps,
|
||||
Self::Slanted | Self::BoldSlanted => Self::Roman,
|
||||
Self::MonoItalic => Self::Mono,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,14 +415,17 @@ impl ParagraphFont {
|
||||
Self::SmallCaps => Self::SmallCaps,
|
||||
Self::Mono => Self::Mono,
|
||||
Self::Sans | Self::SansBold | Self::SansItalic => self,
|
||||
Self::Slanted => Self::SmallCaps,
|
||||
Self::BoldSlanted => Self::Bold,
|
||||
Self::MonoItalic => Self::Mono,
|
||||
}
|
||||
}
|
||||
|
||||
/// `\textsf`: change family, keeping the inherited weight and shape.
|
||||
pub const fn sans_family(self) -> Self {
|
||||
match self {
|
||||
Self::Bold | Self::BoldItalic => Self::SansBold,
|
||||
Self::Italic => Self::SansItalic,
|
||||
Self::Bold | Self::BoldItalic | Self::BoldSlanted => Self::SansBold,
|
||||
Self::Italic | Self::Slanted | Self::MonoItalic => Self::SansItalic,
|
||||
_ => Self::Sans,
|
||||
}
|
||||
}
|
||||
@@ -2383,5 +2419,23 @@ mod font_tests {
|
||||
assert_eq!(ParagraphFont::Bold.small_caps(), ParagraphFont::Bold);
|
||||
assert_eq!(ParagraphFont::Italic.small_caps(), ParagraphFont::SmallCaps);
|
||||
assert_eq!(ParagraphFont::SmallCaps.upright(), ParagraphFont::SmallCaps);
|
||||
assert_eq!(ParagraphFont::Slanted.italicized(), ParagraphFont::Italic);
|
||||
assert_eq!(ParagraphFont::Italic.slanted(), ParagraphFont::Slanted);
|
||||
assert_eq!(ParagraphFont::Bold.slanted(), ParagraphFont::BoldSlanted);
|
||||
assert_eq!(ParagraphFont::BoldSlanted.medium(), ParagraphFont::Slanted);
|
||||
assert_eq!(ParagraphFont::Slanted.upright(), ParagraphFont::Roman);
|
||||
assert_eq!(ParagraphFont::Slanted.emphasized(), ParagraphFont::Italic);
|
||||
assert_eq!(ParagraphFont::Mono.italicized(), ParagraphFont::MonoItalic);
|
||||
assert_eq!(ParagraphFont::MonoItalic.upright(), ParagraphFont::Mono);
|
||||
assert_eq!(ParagraphFont::Mono.slanted(), ParagraphFont::MonoItalic);
|
||||
assert_eq!(
|
||||
ParagraphFont::Slanted.small_caps(),
|
||||
ParagraphFont::SmallCaps
|
||||
);
|
||||
assert_eq!(ParagraphFont::BoldSlanted.small_caps(), ParagraphFont::Bold);
|
||||
assert_eq!(
|
||||
ParagraphFont::Slanted.sans_family(),
|
||||
ParagraphFont::SansItalic
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user