mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 21:32:13 +03:00
fonts: fix a spacing issue for Goho OTB font
This font is a bit funky; the bitmap strikes are only 4px wide: ``` ; ftdump gohufont.otb There is 1 face in this file. ----- Face number: 0 ----- font name entries family: Gohu GohuFont style: Regular postscript: UNAVAILABLE created: 1904-01-01 modified: 1904-01-01 revision: 1.00 glyph count: 1694 font type entries FreeType driver: truetype sfnt wrapped: yes type: fixed size direction: horizontal fixed width: no glyph names: no fixed size 0: height 11, width 3 size 11.000, x_ppem 11.000, y_ppem 11.000 1: height 14, width 4 size 14.000, x_ppem 14.000, y_ppem 14.000 charmaps (1) 0: format 4, platform 3, encoding 1 language 0 (active) ``` but using that the cell size isn't right. We draw from the metrics we compute via cell_metrics to get more information; we don't get a valid height from that (just 0!), but we do get the much more plausible width of 8 pixels. So we take the max of the two techniques for figuring the metrics. That appears to work out, and also doesn't appear to break emoji fonts. refs: #1165
This commit is contained in:
parent
f648d8a6a5
commit
e287474973
@ -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
|
||||
|
||||
|
@ -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.
|
||||
// <https://github.com/wez/wezterm/issues/1165>
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user