summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzandr <7629614+deathlyfrantic@users.noreply.github.com>2022-01-29 14:50:44 -0500
committerKirill Chibisov <contact@kchibisov.com>2022-02-10 03:17:21 +0300
commitf466fde35d37bb7f358bdba56c85080c90938a60 (patch)
treef62501ffe8dd8b25525649392d1391618f84af01
parent84db2ff950af6e0f8005c011eda583956ae5a618 (diff)
downloadalacritty-f466fde35d37bb7f358bdba56c85080c90938a60.tar.gz
alacritty-f466fde35d37bb7f358bdba56c85080c90938a60.zip
Add option to control built-in box drawing chars
This commit adds the config `font.builtin_box_drawing` option to control built-in font, which is enabled by default.
-rw-r--r--CHANGELOG.md4
-rw-r--r--alacritty.yml7
-rw-r--r--alacritty/src/config/font.rs21
-rw-r--r--alacritty/src/renderer/mod.rs10
4 files changed, 40 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6f293d74..74887563 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## 0.11.0-dev
+### Added
+
+ - Option `font.builtin_box_drawing` to disable the built-in font for drawing box characters
+
### Fixed
- OSC 4 not handling `?`
diff --git a/alacritty.yml b/alacritty.yml
index 00c16ce3..c9959497 100644
--- a/alacritty.yml
+++ b/alacritty.yml
@@ -178,6 +178,13 @@
# it is recommended to set `use_thin_strokes` to `false`.
#use_thin_strokes: true
+ # Use built-in font for box drawing characters.
+ #
+ # If `true`, Alacritty will use a custom built-in font for box drawing
+ # characters (Unicode points 2500 - 259f).
+ #
+ #builtin_box_drawing: true
+
# If `true`, bold text is drawn using the bright color variants.
#draw_bold_text_with_bright_colors: false
diff --git a/alacritty/src/config/font.rs b/alacritty/src/config/font.rs
index 3dc11671..cdd84ff9 100644
--- a/alacritty/src/config/font.rs
+++ b/alacritty/src/config/font.rs
@@ -14,7 +14,7 @@ use crate::config::ui_config::Delta;
/// field in this struct. It might be nice in the future to have defaults for
/// each value independently. Alternatively, maybe erroring when the user
/// doesn't provide complete config is Ok.
-#[derive(ConfigDeserialize, Default, Debug, Clone, PartialEq, Eq)]
+#[derive(ConfigDeserialize, Debug, Clone, PartialEq, Eq)]
pub struct Font {
/// Extra spacing per character.
pub offset: Delta<i8>,
@@ -38,6 +38,9 @@ pub struct Font {
/// Font size in points.
size: Size,
+
+ /// Whether to use the built-in font for box drawing characters.
+ pub builtin_box_drawing: bool,
}
impl Font {
@@ -72,6 +75,22 @@ impl Font {
}
}
+impl Default for Font {
+ fn default() -> Font {
+ Self {
+ builtin_box_drawing: true,
+ use_thin_strokes: Default::default(),
+ glyph_offset: Default::default(),
+ bold_italic: Default::default(),
+ italic: Default::default(),
+ offset: Default::default(),
+ normal: Default::default(),
+ bold: Default::default(),
+ size: Default::default(),
+ }
+ }
+}
+
/// Description of the normal font.
#[derive(ConfigDeserialize, Debug, Clone, PartialEq, Eq)]
pub struct FontDescription {
diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs
index 33c6a7e3..50a0e7d7 100644
--- a/alacritty/src/renderer/mod.rs
+++ b/alacritty/src/renderer/mod.rs
@@ -137,6 +137,9 @@ pub struct GlyphCache {
/// Font metrics.
metrics: crossfont::Metrics,
+
+ /// Whether to use the built-in font for box drawing characters.
+ builtin_box_drawing: bool,
}
impl GlyphCache {
@@ -167,6 +170,7 @@ impl GlyphCache {
bold_italic_key: bold_italic,
glyph_offset: font.glyph_offset,
metrics,
+ builtin_box_drawing: font.builtin_box_drawing,
};
cache.load_common_glyphs(loader);
@@ -268,7 +272,10 @@ impl GlyphCache {
// Rasterize the glyph using the built-in font for special characters or the user's font
// for everything else.
- let rasterized = builtin_font::builtin_glyph(glyph_key.character, &self.metrics)
+ let rasterized = self
+ .builtin_box_drawing
+ .then(|| builtin_font::builtin_glyph(glyph_key.character, &self.metrics))
+ .flatten()
.map_or_else(|| self.rasterizer.get_glyph(glyph_key), Ok);
let glyph = match rasterized {
@@ -355,6 +362,7 @@ impl GlyphCache {
self.italic_key = italic;
self.bold_italic_key = bold_italic;
self.metrics = metrics;
+ self.builtin_box_drawing = font.builtin_box_drawing;
self.clear_glyph_cache(loader);