aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src
diff options
context:
space:
mode:
authorChris Copeland <chris@chrisnc.net>2022-07-15 14:56:26 -0700
committerGitHub <noreply@github.com>2022-07-15 21:56:26 +0000
commit2a676dfad837d1784ed0911d314bc263804ef4ef (patch)
treef5ab5069dd71fc6c73c8d3f4dd5d409b5b37523a /alacritty/src
parent40bbdce6de8775b7bbc3f9a5731337d1dd05d195 (diff)
downloadr-alacritty-2a676dfad837d1784ed0911d314bc263804ef4ef.tar.gz
r-alacritty-2a676dfad837d1784ed0911d314bc263804ef4ef.tar.bz2
r-alacritty-2a676dfad837d1784ed0911d314bc263804ef4ef.zip
Fix thin strokes on macOS
Remove the `font.use_thin_strokes` config, which only did anything on macOS and only prior to Big Sur. Instead, we will enable or disable "font smoothing" on macOS based on the `AppleFontSmoothing` user default. These changes let users get the "thin strokes" behavior by setting `AppleFontSmoothing` to 0 with: ```sh $ defaults write -g AppleFontSmoothing -int 0 ``` (Or replace `-g` with `org.alacritty` to apply this setting only to Alacritty.app, rather than the whole system.) Add a `removed` config attribute to show helpful warnings to users who are using config options that don't do anything anymore, and apply this attribute to `font.use_thin_strokes`. Bump `crossfont` to 0.5.0 to pick up the new font smoothing behavior. This release also includes a fix for a crash when trying to load a disabled font. Fixes #4616. Fixes #6108.
Diffstat (limited to 'alacritty/src')
-rw-r--r--alacritty/src/config/font.rs3
-rw-r--r--alacritty/src/display/mod.rs6
-rw-r--r--alacritty/src/renderer/text/builtin_font.rs11
-rw-r--r--alacritty/src/window_context.rs4
4 files changed, 13 insertions, 11 deletions
diff --git a/alacritty/src/config/font.rs b/alacritty/src/config/font.rs
index cdd84ff9..d3431171 100644
--- a/alacritty/src/config/font.rs
+++ b/alacritty/src/config/font.rs
@@ -22,6 +22,7 @@ pub struct Font {
/// Glyph offset within character cell.
pub glyph_offset: Delta<i8>,
+ #[config(removed = "set the AppleFontSmoothing user default instead")]
pub use_thin_strokes: bool,
/// Normal font face.
@@ -79,8 +80,8 @@ impl Default for Font {
fn default() -> Font {
Self {
builtin_box_drawing: true,
- use_thin_strokes: Default::default(),
glyph_offset: Default::default(),
+ use_thin_strokes: Default::default(),
bold_italic: Default::default(),
italic: Default::default(),
offset: Default::default(),
diff --git a/alacritty/src/display/mod.rs b/alacritty/src/display/mod.rs
index f1f51ec7..79e57307 100644
--- a/alacritty/src/display/mod.rs
+++ b/alacritty/src/display/mod.rs
@@ -411,7 +411,7 @@ impl Display {
// Guess the target window dimensions.
debug!("Loading \"{}\" font", &config.font.normal().family);
let font = &config.font;
- let rasterizer = Rasterizer::new(estimated_scale_factor as f32, font.use_thin_strokes)?;
+ let rasterizer = Rasterizer::new(estimated_scale_factor as f32)?;
let mut glyph_cache = GlyphCache::new(rasterizer, font)?;
let metrics = glyph_cache.font_metrics();
let (cell_width, cell_height) = compute_cell_size(config, &metrics);
@@ -488,10 +488,6 @@ impl Display {
let background_color = config.colors.primary.background;
renderer.clear(background_color, config.window_opacity());
- // Set subpixel anti-aliasing.
- #[cfg(target_os = "macos")]
- crossfont::set_font_smoothing(config.font.use_thin_strokes);
-
// Disable shadows for transparent windows on macOS.
#[cfg(target_os = "macos")]
window.set_has_shadow(config.window_opacity() >= 1.0);
diff --git a/alacritty/src/renderer/text/builtin_font.rs b/alacritty/src/renderer/text/builtin_font.rs
index 36d1ccdc..a4bf65e3 100644
--- a/alacritty/src/renderer/text/builtin_font.rs
+++ b/alacritty/src/renderer/text/builtin_font.rs
@@ -90,6 +90,7 @@ fn box_drawing(character: char, metrics: &Metrics, offset: &Delta<i8>) -> Raster
left: 0,
height: height as i32,
width: width as i32,
+ advance: (0, 0),
buffer,
};
},
@@ -479,7 +480,15 @@ fn box_drawing(character: char, metrics: &Metrics, offset: &Delta<i8>) -> Raster
let top = height as i32 + metrics.descent as i32;
let buffer = BitmapBuffer::Rgb(canvas.into_raw());
- RasterizedGlyph { character, top, left: 0, height: height as i32, width: width as i32, buffer }
+ RasterizedGlyph {
+ character,
+ top,
+ left: 0,
+ height: height as i32,
+ width: width as i32,
+ advance: (0, 0),
+ buffer,
+ }
}
#[repr(packed)]
diff --git a/alacritty/src/window_context.rs b/alacritty/src/window_context.rs
index a45b9404..7fe33fd0 100644
--- a/alacritty/src/window_context.rs
+++ b/alacritty/src/window_context.rs
@@ -210,10 +210,6 @@ impl WindowContext {
self.display.window.set_title(config.window.identity.title.clone());
}
- // Set subpixel anti-aliasing.
- #[cfg(target_os = "macos")]
- crossfont::set_font_smoothing(config.font.use_thin_strokes);
-
// Disable shadows for transparent windows on macOS.
#[cfg(target_os = "macos")]
self.display.window.set_has_shadow(config.window_opacity() >= 1.0);