aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/renderer/mod.rs
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2022-01-06 00:45:06 +0300
committerGitHub <noreply@github.com>2022-01-06 00:45:06 +0300
commitf7177101eda589596ab08866892bd4629bd1ef44 (patch)
tree1aa31d8a3282d7c2e31671a90bfe6bc5c4f6197c /alacritty/src/renderer/mod.rs
parent2057ac243a9e38fe9789982ffe93d96d594652ef (diff)
downloadr-alacritty-f7177101eda589596ab08866892bd4629bd1ef44.tar.gz
r-alacritty-f7177101eda589596ab08866892bd4629bd1ef44.tar.bz2
r-alacritty-f7177101eda589596ab08866892bd4629bd1ef44.zip
Use builtin font for box drawing unicode characters
This commit adds hand rolled drawing of unicode box drawing[1] and block elements[2] from ranges U+2500 up to U+259f. While using system font for such characters will look better most of the time, the characters tend to overlap or not align, so providing builtin font is the lesser evil here. [1] - https://www.unicode.org/charts/PDF/U2500.pdf [2] - https://www.unicode.org/charts/PDF/U2580.pdf Fixes #5485.
Diffstat (limited to 'alacritty/src/renderer/mod.rs')
-rw-r--r--alacritty/src/renderer/mod.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs
index eaaa97bb..33c6a7e3 100644
--- a/alacritty/src/renderer/mod.rs
+++ b/alacritty/src/renderer/mod.rs
@@ -25,6 +25,7 @@ use crate::gl;
use crate::gl::types::*;
use crate::renderer::rects::{RectRenderer, RenderRect};
+pub mod builtin_font;
pub mod rects;
// Shader source.
@@ -265,8 +266,12 @@ impl GlyphCache {
return *glyph;
};
- // Rasterize glyph.
- let glyph = match self.rasterizer.get_glyph(glyph_key) {
+ // 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)
+ .map_or_else(|| self.rasterizer.get_glyph(glyph_key), Ok);
+
+ let glyph = match rasterized {
Ok(rasterized) => self.load_glyph(loader, rasterized),
// Load fallback glyph.
Err(RasterizerError::MissingGlyph(rasterized)) if show_missing => {
@@ -827,9 +832,9 @@ impl<'a> RenderApi<'a> {
self.batch.clear();
}
- /// Render a string in a variable location. Used for printing the render timer, warnings and
+ /// Draw a string in a variable location. Used for printing the render timer, warnings and
/// errors.
- pub fn render_string(
+ pub fn draw_string(
&mut self,
glyph_cache: &mut GlyphCache,
point: Point<usize>,
@@ -852,7 +857,7 @@ impl<'a> RenderApi<'a> {
.collect::<Vec<_>>();
for cell in cells {
- self.render_cell(cell, glyph_cache);
+ self.draw_cell(cell, glyph_cache);
}
}
@@ -871,7 +876,7 @@ impl<'a> RenderApi<'a> {
}
}
- pub fn render_cell(&mut self, mut cell: RenderableCell, glyph_cache: &mut GlyphCache) {
+ pub fn draw_cell(&mut self, mut cell: RenderableCell, glyph_cache: &mut GlyphCache) {
// Get font key for cell.
let font_key = match cell.flags & Flags::BOLD_ITALIC {
Flags::BOLD_ITALIC => glyph_cache.bold_italic_key,