1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-26 06:42:12 +03:00

remove old fontconfig pattern code

This commit is contained in:
Wez Furlong 2019-03-13 09:33:30 -07:00
parent 9d9fd6eb6b
commit 4b5d51f708
2 changed files with 10 additions and 23 deletions

View File

@ -133,10 +133,6 @@ impl Default for FontAttributes {
}
}
fn default_fontconfig_pattern() -> String {
FONT_FAMILY.into()
}
fn empty_font_attributes() -> Vec<FontAttributes> {
Vec::new()
}
@ -144,12 +140,6 @@ fn empty_font_attributes() -> Vec<FontAttributes> {
/// Represents textual styling.
#[derive(Debug, Deserialize, Clone, PartialEq, Eq, Hash)]
pub struct TextStyle {
/// A font config pattern to parse to locate the font.
/// Note that the dpi and current font_size for the terminal
/// will be set on the parsed result.
#[serde(default = "default_fontconfig_pattern")]
pub fontconfig_pattern: String,
#[serde(default = "empty_font_attributes")]
pub font: Vec<FontAttributes>,
@ -163,7 +153,6 @@ pub struct TextStyle {
impl Default for TextStyle {
fn default() -> Self {
Self {
fontconfig_pattern: FONT_FAMILY.into(),
foreground: None,
font: vec![FontAttributes::default()],
}
@ -172,13 +161,8 @@ impl Default for TextStyle {
impl TextStyle {
/// Make a version of this style with bold enabled.
/// Semi-lame: we just append fontconfig style settings
/// to the string blindly. We could get more involved
/// but it would mean adding in the fontsystem stuff here
/// and this is probably good enough.
fn make_bold(&self) -> Self {
Self {
fontconfig_pattern: format!("{}:weight=bold", self.fontconfig_pattern),
foreground: self.foreground,
font: self
.font
@ -193,13 +177,8 @@ impl TextStyle {
}
/// Make a version of this style with italic enabled.
/// Semi-lame: we just append fontconfig style settings
/// to the string blindly. We could get more involved
/// but it would mean adding in the fontsystem stuff here
/// and this is probably good enough.
fn make_italic(&self) -> Self {
Self {
fontconfig_pattern: format!("{}:style=Italic", self.fontconfig_pattern),
foreground: self.foreground,
font: self
.font
@ -217,6 +196,14 @@ impl TextStyle {
pub fn font_with_fallback(&self) -> Vec<FontAttributes> {
#[allow(unused_mut)]
let mut font = self.font.clone();
if font.is_empty() {
// This can happen when migratin from the old fontconfig_pattern
// configuration syntax; ensure that we have something likely
// sane in the font configuration
font.push(FontAttributes::default());
}
#[cfg(target_os = "macos")]
font.push(FontAttributes {
family: "Apple Color Emoji".into(),
@ -260,7 +247,7 @@ impl TextStyle {
/// ```
/// [[font_rules]]
/// italic = true
/// font = { fontconfig_pattern = "Operator Mono SSm Lig:style=Italic" }
/// font = { font = [{family = "Operator Mono SSm Lig", italic=true}]}
/// ```
///
/// The above is translated as: "if the `CellAttributes` have the italic bit

View File

@ -44,7 +44,7 @@ impl FontSystem for FontConfigAndFreeType {
}
pattern
} else {
FontPattern::parse(&style.fontconfig_pattern)?
bail!("no fonts specified!? {:?}", fonts);
};
pattern.add_double("size", config.font_size * font_scale)?;
pattern.add_double("dpi", config.dpi)?;