Compose nested inline faces relative to the surrounding run
This commit is contained in:
1 parent
0e8999671b
commit
4cf64a4d55
6 files changed
+156
-38
No files matched your search
@@ -290,10 +290,68 @@ pub enum ParagraphFont {
|
||||
Roman,
|
||||
Bold,
|
||||
Italic,
|
||||
BoldItalic,
|
||||
Mono,
|
||||
Sans,
|
||||
}
|
||||
|
||||
impl ParagraphFont {
|
||||
/// `\emph`: toggles italic, combining with an inherited bold face.
|
||||
pub const fn emphasized(self) -> Self {
|
||||
match self {
|
||||
Self::Roman => Self::Italic,
|
||||
Self::Italic => Self::Roman,
|
||||
Self::Bold => Self::BoldItalic,
|
||||
Self::BoldItalic => Self::Bold,
|
||||
Self::Mono | Self::Sans => self,
|
||||
}
|
||||
}
|
||||
|
||||
/// `\textbf`.
|
||||
pub const fn bolded(self) -> Self {
|
||||
match self {
|
||||
Self::Roman | Self::Bold => Self::Bold,
|
||||
Self::Italic | Self::BoldItalic => Self::BoldItalic,
|
||||
Self::Mono | Self::Sans => self,
|
||||
}
|
||||
}
|
||||
|
||||
/// `\mdseries`.
|
||||
pub const fn medium(self) -> Self {
|
||||
match self {
|
||||
Self::Bold | Self::Roman => Self::Roman,
|
||||
Self::BoldItalic | Self::Italic => Self::Italic,
|
||||
Self::Mono | Self::Sans => self,
|
||||
}
|
||||
}
|
||||
|
||||
/// `\textit` / `\textsl`.
|
||||
pub const fn italicized(self) -> Self {
|
||||
match self {
|
||||
Self::Roman | Self::Italic => Self::Italic,
|
||||
Self::Bold | Self::BoldItalic => Self::BoldItalic,
|
||||
Self::Mono | Self::Sans => self,
|
||||
}
|
||||
}
|
||||
|
||||
/// `\textup`.
|
||||
pub const fn upright(self) -> Self {
|
||||
match self {
|
||||
Self::Roman | Self::Italic => Self::Roman,
|
||||
Self::Bold | Self::BoldItalic => Self::Bold,
|
||||
Self::Mono | Self::Sans => self,
|
||||
}
|
||||
}
|
||||
|
||||
/// `\textrm`.
|
||||
pub const fn roman_family(self) -> Self {
|
||||
match self {
|
||||
Self::Mono | Self::Sans => Self::Roman,
|
||||
other => other,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ParagraphFont {
|
||||
fn default() -> Self {
|
||||
Self::Roman
|
||||
|
||||
Reference in new issue
Block a user