Skip to content

Commit

Permalink
Use builtin font for box drawing unicode characters
Browse files Browse the repository at this point in the history
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 alacritty#5485.
  • Loading branch information
kchibisov authored Jan 5, 2022
1 parent 2057ac2 commit f717710
Show file tree
Hide file tree
Showing 4 changed files with 770 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Display area keeps history position when viewport is cleared
- Commands spawn from the current directory of the foreground shell in Unix-like systems
- Remove trailing newline from strings taken from hints or simple/semantic selections
- Builtin font is now used for box drawing characters from `U+2500` to `U+259f`

### Fixed

Expand Down
10 changes: 5 additions & 5 deletions alacritty/src/display/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ impl Display {
lines.update(&cell);

// Draw the cell.
api.render_cell(cell, glyph_cache);
api.draw_cell(cell, glyph_cache);
}
});
}
Expand Down Expand Up @@ -606,7 +606,7 @@ impl Display {
for (i, message_text) in text.iter().enumerate() {
let point = Point::new(start_line + i, Column(0));
self.renderer.with_api(config, &size_info, |mut api| {
api.render_string(glyph_cache, point, fg, bg, message_text);
api.draw_string(glyph_cache, point, fg, bg, message_text);
});
}
} else {
Expand Down Expand Up @@ -756,7 +756,7 @@ impl Display {
let bg = config.colors.search_bar_background();

self.renderer.with_api(config, size_info, |mut api| {
api.render_string(glyph_cache, point, fg, bg, &text);
api.draw_string(glyph_cache, point, fg, bg, &text);
});
}

Expand All @@ -774,7 +774,7 @@ impl Display {
let bg = config.colors.normal.red;

self.renderer.with_api(config, size_info, |mut api| {
api.render_string(glyph_cache, point, fg, bg, &timing);
api.draw_string(glyph_cache, point, fg, bg, &timing);
});
}

Expand All @@ -797,7 +797,7 @@ impl Display {
if obstructed_column.map_or(true, |obstructed_column| obstructed_column < column) {
let glyph_cache = &mut self.glyph_cache;
self.renderer.with_api(config, size_info, |mut api| {
api.render_string(glyph_cache, Point::new(0, column), fg, bg, &text);
api.draw_string(glyph_cache, Point::new(0, column), fg, bg, &text);
});
}
}
Expand Down
Loading

0 comments on commit f717710

Please sign in to comment.