summaryrefslogtreecommitdiff
path: root/src/display.rs
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2018-01-05 03:22:58 +0000
committerGitHub <noreply@github.com>2018-01-05 03:22:58 +0000
commit228400a6c24bf651ecd74996d1fa68c3d92c9ff9 (patch)
tree5f7022854988b37592c8c47ef0215e62ce69c5b8 /src/display.rs
parent7b4ba80bb195b862f50c16263405a9507f99bb82 (diff)
downloadalacritty-228400a6c24bf651ecd74996d1fa68c3d92c9ff9.tar.gz
alacritty-228400a6c24bf651ecd74996d1fa68c3d92c9ff9.zip
Prevent font_size_modifier from sinking too low (#994)
This replaces the `font_size_modifier` stored on the `Term` struct with a `font_size` field. With this change it is not necessary anymore to calculate the new font size from a delta but the current font size is always stored directly on the `Term` struct. As a result of this it is now possible to increase the font size by more than 127 steps at runtime. It also limits the minimum font size to 1, so issues with the `font_size_modifier` dropping far below font size 1 are resolved with this change. This fixes #955.
Diffstat (limited to 'src/display.rs')
-rw-r--r--src/display.rs25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/display.rs b/src/display.rs
index 89403194..5ca2abb5 100644
--- a/src/display.rs
+++ b/src/display.rs
@@ -96,7 +96,7 @@ pub struct Display {
rx: mpsc::Receiver<(u32, u32)>,
tx: mpsc::Sender<(u32, u32)>,
meter: Meter,
- font_size_modifier: i8,
+ font_size: font::Size,
size_info: SizeInfo,
last_background_color: Rgb,
}
@@ -150,7 +150,7 @@ impl Display {
let mut renderer = QuadRenderer::new(config, viewport_size)?;
let (glyph_cache, cell_width, cell_height) =
- Self::new_glyph_cache(&window, &mut renderer, config, 0)?;
+ Self::new_glyph_cache(&window, &mut renderer, config)?;
let dimensions = options.dimensions()
@@ -205,17 +205,16 @@ impl Display {
tx: tx,
rx: rx,
meter: Meter::new(),
- font_size_modifier: 0,
+ font_size: font::Size::new(0.),
size_info: size_info,
last_background_color: background_color,
})
}
- fn new_glyph_cache(window : &Window, renderer : &mut QuadRenderer,
- config: &Config, font_size_delta: i8)
+ fn new_glyph_cache(window : &Window, renderer : &mut QuadRenderer, config: &Config)
-> Result<(GlyphCache, f32, f32), Error>
{
- let font = config.font().clone().with_size_delta(font_size_delta as f32);
+ let font = config.font().clone();
let dpr = window.hidpi_factor();
let rasterizer = font::Rasterizer::new(dpr, config.use_thin_strokes())?;
@@ -245,10 +244,11 @@ impl Display {
Ok((glyph_cache, cell_width as f32, cell_height as f32))
}
- pub fn update_glyph_cache(&mut self, config: &Config, font_size_delta: i8) {
+ pub fn update_glyph_cache(&mut self, config: &Config) {
let cache = &mut self.glyph_cache;
+ let size = self.font_size;
self.renderer.with_loader(|mut api| {
- let _ = cache.update_font_size(config.font(), font_size_delta, &mut api);
+ let _ = cache.update_font_size(config.font(), size, &mut api);
});
let metrics = cache.font_metrics();
@@ -282,11 +282,10 @@ impl Display {
new_size = Some(sz);
}
- if terminal.font_size_modifier != self.font_size_modifier {
- // Font size modification detected
-
- self.font_size_modifier = terminal.font_size_modifier;
- self.update_glyph_cache(config, terminal.font_size_modifier);
+ // Font size modification detected
+ if terminal.font_size != self.font_size {
+ self.font_size = terminal.font_size;
+ self.update_glyph_cache(config);
if new_size == None {
// Force a resize to refresh things