From f85cc353a68fa67b9ac7985c38412c103221e24d Mon Sep 17 00:00:00 2001 From: Tom Crayford Date: Tue, 10 Jan 2017 13:58:54 +0000 Subject: 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. --- src/config.rs | 11 +++++++++++ src/display.rs | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/config.rs b/src/config.rs index e9cd505a..2665c3b3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -890,6 +890,12 @@ impl Config { self.render_timer } + #[inline] + pub fn use_thin_strokes(&self) -> bool { + self.font.use_thin_strokes + } + + pub fn path(&self) -> Option<&Path> { self.config_path .as_ref() @@ -1034,6 +1040,9 @@ pub struct Font { /// Extra spacing per character offset: FontOffset, + + #[serde(default="true_bool")] + use_thin_strokes: bool } fn default_bold_desc() -> FontDescription { @@ -1082,6 +1091,7 @@ impl Default for Font { bold: FontDescription::new_with_family("Menlo"), italic: FontDescription::new_with_family("Menlo"), size: Size::new(11.0), + use_thin_strokes: true, offset: FontOffset { x: 0.0, y: 0.0 @@ -1098,6 +1108,7 @@ impl Default for Font { bold: FontDescription::new_with_family("monospace"), italic: FontDescription::new_with_family("monospace"), size: Size::new(11.0), + use_thin_strokes: false, offset: FontOffset { // TODO should improve freetype metrics... shouldn't need such // drastic offsets for the default! diff --git a/src/display.rs b/src/display.rs index 5aa3bac4..18ba33c5 100644 --- a/src/display.rs +++ b/src/display.rs @@ -148,7 +148,7 @@ impl Display { println!("device_pixel_ratio: {}", dpr); - let rasterizer = font::Rasterizer::new(dpi.x(), dpi.y(), dpr)?; + let rasterizer = font::Rasterizer::new(dpi.x(), dpi.y(), dpr, config.use_thin_strokes())?; // Create renderer let mut renderer = QuadRenderer::new(config, size)?; -- cgit