Skip to content

Commit 5fead54

Browse files
feat(font): make :w parameter behave like a relative offset
1 parent bc180a6 commit 5fead54

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

src/renderer/fonts/caching_shaper.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ impl CachingShaper {
179179

180180
let bare_font_height = (metrics.ascent + metrics.descent + metrics.leading).ceil();
181181
let font_height = bare_font_height as i64 + self.linespace;
182-
let font_width =
183-
(glyph_advance + (self.options.width - self.options.size + 0.5)).floor() as u64;
182+
let font_width = (glyph_advance + self.options.width + 0.5).floor() as u64;
184183

185184
(
186185
font_width,

src/renderer/fonts/font_options.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ impl FontOptions {
3232
}
3333
}
3434

35-
let mut width_set = false;
36-
3735
for part in parts {
3836
if let Some(hinting_string) = part.strip_prefix("#h-") {
3937
font_options.hinting = FontHinting::parse(hinting_string);
@@ -45,16 +43,10 @@ impl FontOptions {
4543
}
4644
if let Ok(parsed_size) = part[1..].parse::<f32>() {
4745
font_options.size = points_to_pixels(parsed_size);
48-
49-
// if the width has not been set via "w" operator set it to the font size
50-
if !width_set {
51-
font_options.width = font_options.size;
52-
}
5346
}
5447
} else if part.starts_with('w') && part.len() > 1 {
5548
if let Ok(parsed_size) = part[1..].parse::<f32>() {
5649
font_options.width = points_to_pixels(parsed_size);
57-
width_set = true;
5850
}
5951
} else if part == "b" {
6052
font_options.bold = true;
@@ -79,7 +71,7 @@ impl Default for FontOptions {
7971
italic: false,
8072
allow_float_size: false,
8173
size: points_to_pixels(DEFAULT_FONT_SIZE),
82-
width: points_to_pixels(DEFAULT_FONT_SIZE),
74+
width: 0.0,
8375
hinting: FontHinting::default(),
8476
edging: FontEdging::default(),
8577
}

0 commit comments

Comments
 (0)