gui: refuse to scale to sizes where cell height would be < 2 pixels
refs: https://github.com/wez/wezterm/issues/428
This commit is contained in:
1 parent
db964a91a0
commit
4bbe67aac3
2 files changed
+20
-2
No files matched your search
@@ -2,7 +2,7 @@ use crate::db::FontDatabase;
|
||||
use crate::locator::{new_locator, FontDataHandle, FontLocator, FontLocatorSelection};
|
||||
use crate::rasterizer::{new_rasterizer, FontRasterizer};
|
||||
use crate::shaper::{new_shaper, FontShaper, FontShaperSelection};
|
||||
use anyhow::Error;
|
||||
use anyhow::{Context, Error};
|
||||
use config::{configuration, ConfigHandle, FontRasterizerSelection, TextStyle};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
@@ -290,7 +290,12 @@ impl FontConfigInner {
|
||||
let font_size = config.font_size * *self.font_scale.borrow();
|
||||
let dpi =
|
||||
*self.dpi_scale.borrow() as u32 * config.dpi.unwrap_or(::window::DEFAULT_DPI) as u32;
|
||||
let metrics = shaper.metrics(font_size, dpi)?;
|
||||
let metrics = shaper.metrics(font_size, dpi).with_context(|| {
|
||||
format!(
|
||||
"obtaining metrics for font_size={} @ dpi {}",
|
||||
font_size, dpi
|
||||
)
|
||||
})?;
|
||||
|
||||
let loaded = Rc::new(LoadedFont {
|
||||
rasterizers: RefCell::new(HashMap::new()),
|
||||
|
||||
@@ -2134,6 +2134,19 @@ impl TermWindow {
|
||||
}
|
||||
|
||||
fn apply_scale_change(&mut self, dimensions: &Dimensions, font_scale: f64) {
|
||||
let config = configuration();
|
||||
let font_size = config.font_size * font_scale;
|
||||
let theoretical_height = font_size * dimensions.dpi as f64 / 72.0;
|
||||
|
||||
if theoretical_height < 2.0 {
|
||||
log::warn!("refusing to go to an unreasonably small font scale {:?} "
|
||||
"font_scale={} would yield font_height {}",
|
||||
dimensions,
|
||||
font_scale,
|
||||
theoretical_height);
|
||||
return;
|
||||
}
|
||||
|
||||
let (prior_font, prior_dpi) = self
|
||||
.fonts
|
||||
.change_scaling(font_scale, dimensions.dpi as f64 / ::window::DEFAULT_DPI);
|
||||
|
||||
Reference in new issue
Block a user