Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add width to guifont settings #1227

Merged
merged 5 commits into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/renderer/fonts/caching_shaper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ impl CachingShaper {

pub fn font_base_dimensions(&mut self) -> (u64, u64) {
let (metrics, glyph_advance) = self.info();
let font_width = (glyph_advance + 0.5).floor() as u64;

let bare_font_height = (metrics.ascent + metrics.descent + metrics.leading).ceil();
let font_height = bare_font_height as i64 + self.linespace;
let font_width = (glyph_advance + self.options.width + 0.5).floor() as u64;

(
font_width,
Expand Down
8 changes: 7 additions & 1 deletion src/renderer/fonts/font_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const DEFAULT_FONT_SIZE: f32 = 14.0;
pub struct FontOptions {
pub font_list: Vec<String>,
pub size: f32,
pub width: f32,
pub bold: bool,
pub italic: bool,
pub allow_float_size: bool,
Expand Down Expand Up @@ -41,7 +42,11 @@ impl FontOptions {
font_options.allow_float_size = true;
}
if let Ok(parsed_size) = part[1..].parse::<f32>() {
font_options.size = points_to_pixels(parsed_size)
font_options.size = points_to_pixels(parsed_size);
}
} else if part.starts_with('w') && part.len() > 1 {
if let Ok(parsed_size) = part[1..].parse::<f32>() {
font_options.width = points_to_pixels(parsed_size);
}
} else if part == "b" {
font_options.bold = true;
Expand All @@ -66,6 +71,7 @@ impl Default for FontOptions {
italic: false,
allow_float_size: false,
size: points_to_pixels(DEFAULT_FONT_SIZE),
width: 0.0,
hinting: FontHinting::default(),
edging: FontEdging::default(),
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ as such it's also documented in `:h guifont`. But to sum it up and also add Neov
- are separated from the fonts and themselves through `:` (colons).
- can be one of the following:
- `hX` — Sets the font size to `X` points, while `X` can be any (even floating-point) number.
- `wX` — Sets the width **relative offset** to be `X` points, while `X` can be again any number.
Negative values shift characters closer together, positive values shift them further apart.
- `b` — Sets the font **bold**.
- `i` — Sets the font _italic_.
- `#e-X` (available since 0.10.2) — Sets edge pixels to be drawn opaquely or
Expand Down