diff options
author | Tom Crayford <tcrayford@googlemail.com> | 2017-01-10 13:58:54 +0000 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2017-01-12 21:19:40 -0800 |
commit | f85cc353a68fa67b9ac7985c38412c103221e24d (patch) | |
tree | d51d411d1cd95fa5c8d30a15798a8e17b954089a /font/src/darwin/mod.rs | |
parent | 32cfca772798d13e9c96c5d66250f6ca5ae9baef (diff) | |
download | alacritty-f85cc353a68fa67b9ac7985c38412c103221e24d.tar.gz alacritty-f85cc353a68fa67b9ac7985c38412c103221e24d.zip |
make thin stroke rendering configurable
Makes thin stroke rendering for darwin configurable by a new toplevel
key under `font:` in the config file. Defaults to false, has no impact
on non macos.
Diffstat (limited to 'font/src/darwin/mod.rs')
-rw-r--r-- | font/src/darwin/mod.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/font/src/darwin/mod.rs b/font/src/darwin/mod.rs index 35336df9..69a9f29a 100644 --- a/font/src/darwin/mod.rs +++ b/font/src/darwin/mod.rs @@ -78,6 +78,7 @@ pub struct Rasterizer { fonts: HashMap<FontKey, Font>, keys: HashMap<(FontDesc, Size), FontKey>, device_pixel_ratio: f32, + use_thin_strokes: bool, } /// Errors occurring when using the core text rasterizer @@ -122,12 +123,13 @@ impl ::std::fmt::Display for Error { impl ::Rasterize for Rasterizer { type Err = Error; - fn new(_dpi_x: f32, _dpi_y: f32, device_pixel_ratio: f32) -> Result<Rasterizer, Error> { + fn new(_dpi_x: f32, _dpi_y: f32, device_pixel_ratio: f32, use_thin_strokes: bool) -> Result<Rasterizer, Error> { println!("device_pixel_ratio: {}", device_pixel_ratio); Ok(Rasterizer { fonts: HashMap::new(), keys: HashMap::new(), device_pixel_ratio: device_pixel_ratio, + use_thin_strokes: use_thin_strokes, }) } @@ -164,7 +166,7 @@ impl ::Rasterize for Rasterizer { self.fonts .get(&glyph.font_key) .ok_or(Error::FontNotLoaded)? - .get_glyph(glyph.c, scaled_size as _) + .get_glyph(glyph.c, scaled_size as _, self.use_thin_strokes) } } @@ -357,7 +359,7 @@ impl Font { ) } - pub fn get_glyph(&self, character: char, _size: f64) -> Result<RasterizedGlyph, Error> { + pub fn get_glyph(&self, character: char, _size: f64, use_thin_strokes: bool) -> Result<RasterizedGlyph, Error> { let glyph_index = self.glyph_index(character) .ok_or(Error::MissingGlyph(character))?; @@ -402,9 +404,9 @@ impl Font { cg_context.fill_rect(context_rect); - // Uses thin strokes - // TODO make this configurable since it's undesirable on non-retina displays. - cg_context.set_font_smoothing_style(16); + if use_thin_strokes { + cg_context.set_font_smoothing_style(16); + } cg_context.set_allows_font_smoothing(true); cg_context.set_should_smooth_fonts(true); |