aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alacritty.yml5
-rw-r--r--alacritty_macos.yml5
-rw-r--r--font/src/darwin/mod.rs14
-rw-r--r--font/src/ft/mod.rs2
-rw-r--r--font/src/lib.rs2
-rw-r--r--src/config.rs11
-rw-r--r--src/display.rs2
7 files changed, 32 insertions, 9 deletions
diff --git a/alacritty.yml b/alacritty.yml
index 14fea928..fb52e0f5 100644
--- a/alacritty.yml
+++ b/alacritty.yml
@@ -40,6 +40,11 @@ font:
x: 2.0
y: -7.0
+ # OS X only: use thin stroke font rendering. Thin strokes are suitable
+ # for retina displays, but for non-retina you probably want this set to
+ # false.
+ use_thin_strokes: true
+
# Should display the render timer
render_timer: false
diff --git a/alacritty_macos.yml b/alacritty_macos.yml
index 7a533e56..bceae75d 100644
--- a/alacritty_macos.yml
+++ b/alacritty_macos.yml
@@ -40,6 +40,11 @@ font:
x: 0.0
y: 0.0
+ # OS X only: use thin stroke font rendering. Thin strokes are suitable
+ # for retina displays, but for non-retina you probably want this set to
+ # false.
+ use_thin_strokes: true
+
# Should display the render timer
render_timer: false
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);
diff --git a/font/src/ft/mod.rs b/font/src/ft/mod.rs
index 0ffecf03..f9170ed3 100644
--- a/font/src/ft/mod.rs
+++ b/font/src/ft/mod.rs
@@ -41,7 +41,7 @@ fn to_freetype_26_6(f: f32) -> isize {
impl ::Rasterize for FreeTypeRasterizer {
type Err = Error;
- fn new(dpi_x: f32, dpi_y: f32, device_pixel_ratio: f32) -> Result<FreeTypeRasterizer, Error> {
+ fn new(dpi_x: f32, dpi_y: f32, device_pixel_ratio: f32, _: bool) -> Result<FreeTypeRasterizer, Error> {
let library = Library::init()?;
Ok(FreeTypeRasterizer {
diff --git a/font/src/lib.rs b/font/src/lib.rs
index bc4a2006..cf697c8a 100644
--- a/font/src/lib.rs
+++ b/font/src/lib.rs
@@ -199,7 +199,7 @@ pub trait Rasterize {
type Err: ::std::error::Error + Send + Sync + 'static;
/// Create a new Rasterize
- fn new(dpi_x: f32, dpi_y: f32, device_pixel_ratio: f32) -> Result<Self, Self::Err>
+ fn new(dpi_x: f32, dpi_y: f32, device_pixel_ratio: f32, use_thin_strokes: bool) -> Result<Self, Self::Err>
where Self: Sized;
/// Get `Metrics` for the given `FontKey` and `Size`
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)?;