diff --git a/docs/changelog.md b/docs/changelog.md index 6bcbf39e4..6322ffc16 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -49,6 +49,7 @@ As features stabilize some brief notes about them will accumulate here. * Fixed: incorrect spacing for IDEOGRAPHIC SPACE. [#1161](https://github.com/wez/wezterm/issues/1161) * Fixed: italic fonts weren't always recognized as being italic, resulting in italic variants being used instead of the non-italic variants in some cases! [#1162](https://github.com/wez/wezterm/issues/1162) * New: [bell](config/lua/window-events/bell.md) event allows you to trigger lua code when the bell is run. [#3](https://github.com/wez/wezterm/issues/3) +* Fixed: Ask freetype for cell metrics in bitmap-only fonts, rather than simply taking the bitmap width. [#1165](https://github.com/wez/wezterm/issues/1165) ### 20210814-124438-54e29167 diff --git a/wezterm-font/src/ftwrap.rs b/wezterm-font/src/ftwrap.rs index 4b4d7d36e..275ad8c29 100644 --- a/wezterm-font/src/ftwrap.rs +++ b/wezterm-font/src/ftwrap.rs @@ -101,6 +101,7 @@ struct FaceSize { is_scaled: bool, } +#[derive(Debug)] pub struct SelectedFontSize { pub width: f64, pub height: f64, @@ -383,9 +384,16 @@ impl Face { } let best = best.unwrap(); self.select_size(best.idx)?; + // Compute the cell metrics at this size. + // This stuff is a bit weird; for GohuFont.otb, cell_metrics() + // returns (8.0, 0.0) when the selected bitmap strike is (4, 14). + // 4 pixels is too thin for this font, so we take the max of the + // known dimensions to produce the size. + // + let (m_width, m_height) = self.cell_metrics(); SelectedFontSize { - width: f64::from(best.width), - height: f64::from(best.height), + width: f64::from(best.width).max(m_width), + height: f64::from(best.height).max(m_height), is_scaled: false, } }