diff options
author | Joe Wilm <joe@jwilm.com> | 2017-01-02 18:52:41 -0800 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2017-01-02 19:49:38 -0800 |
commit | 86301856391b05047f1fd9f2e8999d61b26d982e (patch) | |
tree | 2163b2fead9d1c45bb72670b32558cb781f2d4a5 /src/renderer | |
parent | 04d69e3c2902bca56605ad59e60b2ae1e5ce91a3 (diff) | |
download | alacritty-86301856391b05047f1fd9f2e8999d61b26d982e.tar.gz alacritty-86301856391b05047f1fd9f2e8999d61b26d982e.zip |
Rework font loading
This work started because we wanted to be able to simply say "monospace"
on Linux and have it give us some sort of font. The config format for
fonts changed to accomodate this new paradigm. As a result, italic and
bold can have different families from the normal (roman) face.
The fontconfig based font resolution probably works a lot better than
the CoreText version at this point. With CoreText, we simply iterate
over fonts and check it they match the requested properties. What's
worse is that the CoreText version requires a valid family. With
fontconfig, it will just provide the closest matching thing and use it
(unless a specific style is requested).
Diffstat (limited to 'src/renderer')
-rw-r--r-- | src/renderer/mod.rs | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index d800a1b5..81ac7fd4 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -166,13 +166,29 @@ impl GlyphCache { let size = font.size(); // Load regular font - let regular_desc = FontDesc::new(font.family(), font.style()); + let regular_desc = if let Some(ref style) = font.normal.style { + FontDesc::new(&font.normal.family[..], font::Style::Specific(style.to_owned())) + } else { + let style = font::Style::Description { + slant: font::Slant::Normal, + weight: font::Weight::Normal + }; + FontDesc::new(&font.normal.family[..], style) + }; + let regular = rasterizer .load_font(®ular_desc, size)?; // Load bold font - let bold_style = font.bold_style().unwrap_or("Bold"); - let bold_desc = FontDesc::new(font.family(), bold_style); + let bold_desc = if let Some(ref style) = font.bold.style { + FontDesc::new(&font.bold.family[..], font::Style::Specific(style.to_owned())) + } else { + let style = font::Style::Description { + slant: font::Slant::Normal, + weight: font::Weight::Bold + }; + FontDesc::new(&font.bold.family[..], style) + }; let bold = if bold_desc == regular_desc { regular @@ -181,8 +197,15 @@ impl GlyphCache { }; // Load italic font - let italic_style = font.italic_style().unwrap_or("Italic"); - let italic_desc = FontDesc::new(font.family(), italic_style); + let italic_desc = if let Some(ref style) = font.italic.style { + FontDesc::new(&font.italic.family[..], font::Style::Specific(style.to_owned())) + } else { + let style = font::Style::Description { + slant: font::Slant::Italic, + weight: font::Weight::Normal + }; + FontDesc::new(&font.italic.family[..], style) + }; let italic = if italic_desc == regular_desc { regular |