summaryrefslogtreecommitdiffstats
path: root/alacritty
diff options
context:
space:
mode:
authorPopa Ioan Alexandru <49609151+ALEX11BR@users.noreply.github.com>2024-01-26 14:45:26 +0200
committerGitHub <noreply@github.com>2024-01-26 16:45:26 +0400
commitb48ab148ff54c7e2e816765840568614d9e966f9 (patch)
tree58a07d25344bdb44ee61b4b7bd70bbcd7f9961d8 /alacritty
parent79b686df419d90e5557d1b7000f51f012986c141 (diff)
Use builtin font to draw sextants
Sextants are similar to quadrants and should align with them and other box drawing, thus use builtin font to align them properly. Part-of: #7422.
Diffstat (limited to 'alacritty')
-rw-r--r--alacritty/src/renderer/text/builtin_font.rs92
1 files changed, 88 insertions, 4 deletions
diff --git a/alacritty/src/renderer/text/builtin_font.rs b/alacritty/src/renderer/text/builtin_font.rs
index f59616d5..ece7eb86 100644
--- a/alacritty/src/renderer/text/builtin_font.rs
+++ b/alacritty/src/renderer/text/builtin_font.rs
@@ -1,5 +1,4 @@
-//! Hand-rolled drawing of unicode [box drawing](http://www.unicode.org/charts/PDF/U2500.pdf)
-//! and [block elements](https://www.unicode.org/charts/PDF/U2580.pdf), and also powerline symbols.
+//! Hand-rolled drawing of unicode characters that need to fully cover their character area.
use std::{cmp, mem, ops};
@@ -29,7 +28,9 @@ pub fn builtin_glyph(
) -> Option<RasterizedGlyph> {
let mut glyph = match character {
// Box drawing characters and block elements.
- '\u{2500}'..='\u{259f}' => box_drawing(character, metrics, offset),
+ '\u{2500}'..='\u{259f}' | '\u{1fb00}'..='\u{1fb3b}' => {
+ box_drawing(character, metrics, offset)
+ },
// Powerline symbols: '','','',''
POWERLINE_TRIANGLE_LTR..=POWERLINE_ARROW_RTL => {
powerline_drawing(character, metrics, offset)?
@@ -487,6 +488,89 @@ fn box_drawing(character: char, metrics: &Metrics, offset: &Delta<i8>) -> Raster
// Fourth quadrant.
canvas.draw_rect(x_center, y_center, w_fourth, h_fourth, COLOR_FILL);
},
+ // Sextants: '🬀', '🬁', '🬂', '🬃', '🬄', '🬅', '🬆', '🬇', '🬈', '🬉', '🬊', '🬋', '🬌', '🬍', '🬎',
+ // '🬏', '🬐', '🬑', '🬒', '🬓', '🬔', '🬕', '🬖', '🬗', '🬘', '🬙', '🬚', '🬛', '🬜', '🬝', '🬞', '🬟',
+ // '🬠', '🬡', '🬢', '🬣', '🬤', '🬥', '🬦', '🬧', '🬨', '🬩', '🬪', '🬫', '🬬', '🬭', '🬮', '🬯', '🬰',
+ // '🬱', '🬲', '🬳', '🬴', '🬵', '🬶', '🬷', '🬸', '🬹', '🬺', '🬻'.
+ '\u{1fb00}'..='\u{1fb3b}' => {
+ let x_center = canvas.x_center().round().max(1.);
+ let y_third = (height as f32 / 3.).round().max(1.);
+ let y_last_third = height as f32 - 2. * y_third;
+
+ let (w_top_left, h_top_left) = match character {
+ '\u{1fb00}' | '\u{1fb02}' | '\u{1fb04}' | '\u{1fb06}' | '\u{1fb08}'
+ | '\u{1fb0a}' | '\u{1fb0c}' | '\u{1fb0e}' | '\u{1fb10}' | '\u{1fb12}'
+ | '\u{1fb15}' | '\u{1fb17}' | '\u{1fb19}' | '\u{1fb1b}' | '\u{1fb1d}'
+ | '\u{1fb1f}' | '\u{1fb21}' | '\u{1fb23}' | '\u{1fb25}' | '\u{1fb27}'
+ | '\u{1fb28}' | '\u{1fb2a}' | '\u{1fb2c}' | '\u{1fb2e}' | '\u{1fb30}'
+ | '\u{1fb32}' | '\u{1fb34}' | '\u{1fb36}' | '\u{1fb38}' | '\u{1fb3a}' => {
+ (x_center, y_third)
+ },
+ _ => (0., 0.),
+ };
+ let (w_top_right, h_top_right) = match character {
+ '\u{1fb01}' | '\u{1fb02}' | '\u{1fb05}' | '\u{1fb06}' | '\u{1fb09}'
+ | '\u{1fb0a}' | '\u{1fb0d}' | '\u{1fb0e}' | '\u{1fb11}' | '\u{1fb12}'
+ | '\u{1fb14}' | '\u{1fb15}' | '\u{1fb18}' | '\u{1fb19}' | '\u{1fb1c}'
+ | '\u{1fb1d}' | '\u{1fb20}' | '\u{1fb21}' | '\u{1fb24}' | '\u{1fb25}'
+ | '\u{1fb28}' | '\u{1fb2b}' | '\u{1fb2c}' | '\u{1fb2f}' | '\u{1fb30}'
+ | '\u{1fb33}' | '\u{1fb34}' | '\u{1fb37}' | '\u{1fb38}' | '\u{1fb3b}' => {
+ (x_center, y_third)
+ },
+ _ => (0., 0.),
+ };
+ let (w_mid_left, h_mid_left) = match character {
+ '\u{1fb03}' | '\u{1fb04}' | '\u{1fb05}' | '\u{1fb06}' | '\u{1fb0b}'
+ | '\u{1fb0c}' | '\u{1fb0d}' | '\u{1fb0e}' | '\u{1fb13}' | '\u{1fb14}'
+ | '\u{1fb15}' | '\u{1fb1a}' | '\u{1fb1b}' | '\u{1fb1c}' | '\u{1fb1d}'
+ | '\u{1fb22}' | '\u{1fb23}' | '\u{1fb24}' | '\u{1fb25}' | '\u{1fb29}'
+ | '\u{1fb2a}' | '\u{1fb2b}' | '\u{1fb2c}' | '\u{1fb31}' | '\u{1fb32}'
+ | '\u{1fb33}' | '\u{1fb34}' | '\u{1fb39}' | '\u{1fb3a}' | '\u{1fb3b}' => {
+ (x_center, y_third)
+ },
+ _ => (0., 0.),
+ };
+ let (w_mid_right, h_mid_right) = match character {
+ '\u{1fb07}' | '\u{1fb08}' | '\u{1fb09}' | '\u{1fb0a}' | '\u{1fb0b}'
+ | '\u{1fb0c}' | '\u{1fb0d}' | '\u{1fb0e}' | '\u{1fb16}' | '\u{1fb17}'
+ | '\u{1fb18}' | '\u{1fb19}' | '\u{1fb1a}' | '\u{1fb1b}' | '\u{1fb1c}'
+ | '\u{1fb1d}' | '\u{1fb26}' | '\u{1fb27}' | '\u{1fb28}' | '\u{1fb29}'
+ | '\u{1fb2a}' | '\u{1fb2b}' | '\u{1fb2c}' | '\u{1fb35}' | '\u{1fb36}'
+ | '\u{1fb37}' | '\u{1fb38}' | '\u{1fb39}' | '\u{1fb3a}' | '\u{1fb3b}' => {
+ (x_center, y_third)
+ },
+ _ => (0., 0.),
+ };
+ let (w_bottom_left, h_bottom_left) = match character {
+ '\u{1fb0f}' | '\u{1fb10}' | '\u{1fb11}' | '\u{1fb12}' | '\u{1fb13}'
+ | '\u{1fb14}' | '\u{1fb15}' | '\u{1fb16}' | '\u{1fb17}' | '\u{1fb18}'
+ | '\u{1fb19}' | '\u{1fb1a}' | '\u{1fb1b}' | '\u{1fb1c}' | '\u{1fb1d}'
+ | '\u{1fb2d}' | '\u{1fb2e}' | '\u{1fb2f}' | '\u{1fb30}' | '\u{1fb31}'
+ | '\u{1fb32}' | '\u{1fb33}' | '\u{1fb34}' | '\u{1fb35}' | '\u{1fb36}'
+ | '\u{1fb37}' | '\u{1fb38}' | '\u{1fb39}' | '\u{1fb3a}' | '\u{1fb3b}' => {
+ (x_center, y_last_third)
+ },
+ _ => (0., 0.),
+ };
+ let (w_bottom_right, h_bottom_right) = match character {
+ '\u{1fb1e}' | '\u{1fb1f}' | '\u{1fb20}' | '\u{1fb21}' | '\u{1fb22}'
+ | '\u{1fb23}' | '\u{1fb24}' | '\u{1fb25}' | '\u{1fb26}' | '\u{1fb27}'
+ | '\u{1fb28}' | '\u{1fb29}' | '\u{1fb2a}' | '\u{1fb2b}' | '\u{1fb2c}'
+ | '\u{1fb2d}' | '\u{1fb2e}' | '\u{1fb2f}' | '\u{1fb30}' | '\u{1fb31}'
+ | '\u{1fb32}' | '\u{1fb33}' | '\u{1fb34}' | '\u{1fb35}' | '\u{1fb36}'
+ | '\u{1fb37}' | '\u{1fb38}' | '\u{1fb39}' | '\u{1fb3a}' | '\u{1fb3b}' => {
+ (x_center, y_last_third)
+ },
+ _ => (0., 0.),
+ };
+
+ canvas.draw_rect(0., 0., w_top_left, h_top_left, COLOR_FILL);
+ canvas.draw_rect(x_center, 0., w_top_right, h_top_right, COLOR_FILL);
+ canvas.draw_rect(0., y_third, w_mid_left, h_mid_left, COLOR_FILL);
+ canvas.draw_rect(x_center, y_third, w_mid_right, h_mid_right, COLOR_FILL);
+ canvas.draw_rect(0., y_third * 2., w_bottom_left, h_bottom_left, COLOR_FILL);
+ canvas.draw_rect(x_center, y_third * 2., w_bottom_right, h_bottom_right, COLOR_FILL);
+ },
_ => unreachable!(),
}
@@ -926,7 +1010,7 @@ mod tests {
let glyph_offset = Default::default();
// Test coverage of box drawing characters.
- for character in '\u{2500}'..='\u{259f}' {
+ for character in ('\u{2500}'..='\u{259f}').chain('\u{1fb00}'..='\u{1fb3b}') {
assert!(builtin_glyph(character, &METRICS, &offset, &glyph_offset).is_some());
}