add cell_width config to scale cell_width
This works similarly to line_height refs: #1979
This commit is contained in:
1 parent
94039c473b
commit
c04d831ee5
7 files changed
+61
-5
No files matched your search
@@ -47,6 +47,9 @@ pub struct Config {
|
||||
#[dynamic(default = "default_one_point_oh_f64")]
|
||||
pub line_height: f64,
|
||||
|
||||
#[dynamic(default = "default_one_point_oh_f64")]
|
||||
pub cell_width: f64,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub allow_square_glyphs_to_overflow_width: AllowSquareGlyphOverflow,
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
* Search Mode: key assignments are [now configurable](scrollback.md#configurable-key-assignments) [#993](https://github.com/wez/wezterm/issues/993)
|
||||
* Copy Mode and Search Mode can be toggled and remember search results and cursor positioning, making it easier to locate and select text without using the mouse [#1592](https://github.com/wez/wezterm/issues/1592)
|
||||
* In the Launcher Menu, you may now use `CTRL-G` to cancel/exit the launcher [#1977](https://github.com/wez/wezterm/issues/1977)
|
||||
* [cell_width](config/lua/config/cell_width.md) option to adjust the horizontal spacing when the availble font stretches are insufficient. [#1979](https://github.com/wez/wezterm/issues/1979)
|
||||
|
||||
|
||||
#### Updated
|
||||
* Bundled harfbuzz to 4.2.1
|
||||
|
||||
@@ -69,6 +69,7 @@ Additional options for configuring fonts can be found elsewhere in the docs:
|
||||
* [freetype_load_flags](lua/config/freetype_load_flags.md) - advanced hinting configuration
|
||||
* [freetype_load_target](lua/config/freetype_load_target.md) - configure hinting and anti-aliasing
|
||||
* [freetype_render_target](lua/config/freetype_render_target.md) - configure anti-aliasing
|
||||
* [cell_width](lua/config/cell_width.md) - scale the font-specified cell width
|
||||
* [line_height](lua/config/line_height.md) - scale the font-specified line height
|
||||
* [wezterm.font](lua/wezterm/font.md) - select a font based on family and style attributes
|
||||
* [wezterm.font_with_fallback](lua/wezterm/font_with_fallback.md) - select a font from a list of candidates
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
# `cell_width = 1.0`
|
||||
|
||||
*Since: nightly builds only*
|
||||
|
||||
Scales the computed cell width to adjust the spacing between successive cells
|
||||
of text.
|
||||
|
||||
If possible, you should prefer to specify the `stretch` parameter when
|
||||
selecting a font using [wezterm.font](../wezterm/font.md) or
|
||||
[wezterm.font_with_fallback](../wezterm/font_with_fallback.md) as that will
|
||||
generally look better and have fewer undesirable side effects.
|
||||
|
||||
If your preferred font doesn't have variations with different stretches, or
|
||||
if the font spacing still doesn't look right to you, then `cell_width` gives
|
||||
you a simple way to influence the spacing.
|
||||
|
||||
The default cell width is indirectly controlled by the [font](font.md) and
|
||||
[font_size](font_size.md) configuration options; the selected font and font
|
||||
size controls the height of the font, while the font designer controls the
|
||||
aspect ratio of the glyphs in the font. The base font (the first font resolved
|
||||
from your `font` configuration) defines the cell metrics for the terminal
|
||||
display grid, and those metrics are then used to place glyphs, regardless of
|
||||
which fallback font might be resolved for a given glyph.
|
||||
|
||||
If you feel that your chosen font feels too horizontally cramped then you can
|
||||
set `cell_width = 1.2` to increase the horizontal spacing by 20%. Conversely,
|
||||
setting `cell_width = 0.9` will decrease the horizontal spacing by 10%.
|
||||
|
||||
This option doesn't adjust the rasterized width of glyphs, it just changes what
|
||||
wezterm considers to be the cell boundaries. When rendering monospace, wezterm
|
||||
advances by the cell width to place successive glyphs.
|
||||
|
||||
If you set the scale less than `1.0` then the glyphs won't be truncated or
|
||||
squished, but will render over the top of each other. Conversely, if you set
|
||||
the scale to greater than `1.0`, the glyphs won't be stretched but will render
|
||||
further apart from each other.
|
||||
|
||||
Changing `cell_width` doesn't adjust the positioning of the glyph within the
|
||||
cell: it remains at its usual x-position. It is *not* centered within the
|
||||
adjusted space.
|
||||
|
||||
Changing `cell_width` may have undesirable consequences, especially for fonts
|
||||
that use ligatures: depending on the font, you may find that some ligatured
|
||||
sequences are misaligned or render strangely. This is not a bug: the font is
|
||||
designed to be rendered with a `cell_width = 1.0`, so running with a different
|
||||
value will have this sort of side effect.
|
||||
|
||||
See also: [line_height](line_height.md)
|
||||
|
||||
@@ -7,4 +7,4 @@ font feels too vertically cramped then you can set `line_height = 1.2` to
|
||||
increase the vertical spacing by 20%. Conversely, setting `line_height = 0.9`
|
||||
will decrease the vertical spacing by 10%.
|
||||
|
||||
|
||||
See also: [cell_width](cell_width.md)
|
||||
@@ -3695,7 +3695,7 @@ impl<T: Texture2d> GlyphCache<T> {
|
||||
return Ok(sprite.clone());
|
||||
}
|
||||
|
||||
let metrics = metrics.scale_cell_width(width);
|
||||
let metrics = metrics.scale_cell_width(width as f64);
|
||||
|
||||
let mut buffer = Image::new(
|
||||
metrics.cell_size.width as usize,
|
||||
|
||||
@@ -61,9 +61,9 @@ impl RenderMetrics {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn scale_cell_width(&self, scale: u8) -> Self {
|
||||
pub fn scale_cell_width(&self, scale: f64) -> Self {
|
||||
let mut scaled = self.clone();
|
||||
scaled.cell_size.width *= scale as isize;
|
||||
scaled.cell_size.width = (self.cell_size.width as f64 * scale) as isize;
|
||||
scaled
|
||||
}
|
||||
|
||||
@@ -73,10 +73,11 @@ impl RenderMetrics {
|
||||
.context("failed to get font metrics!?")?;
|
||||
|
||||
let line_height = fonts.config().line_height;
|
||||
let cell_width = fonts.config().cell_width;
|
||||
|
||||
let (cell_height, cell_width) = (
|
||||
(metrics.cell_height.get() * line_height).ceil() as usize,
|
||||
metrics.cell_width.get().ceil() as usize,
|
||||
(metrics.cell_width.get() * cell_width).ceil() as usize,
|
||||
);
|
||||
|
||||
// When line_height != 1.0, we want to adjust the baseline position
|
||||
|
||||
Reference in new issue
Block a user