gpui: Add helper methods for em width and em advance (#24036)
This PR adds two helpers methods to the `TextSystem`: - `em_width` - `em_advance` These methods return the width and advance width for an `em`, respectively. We were using these definitions in a number of different spots, and by unifying them we better canonicalize that an `em` is based on the `m` character. Release Notes: - N/A
This commit is contained in:
parent
af6548c745
commit
990bdde5e8
4 changed files with 23 additions and 47 deletions
|
@ -14124,13 +14124,7 @@ impl Editor {
|
|||
let font_id = window.text_system().resolve_font(&style.text.font());
|
||||
let font_size = style.text.font_size.to_pixels(window.rem_size());
|
||||
let line_height = style.text.line_height_in_pixels(window.rem_size());
|
||||
|
||||
let em_width = window
|
||||
.text_system()
|
||||
.typographic_bounds(font_id, font_size, 'm')
|
||||
.unwrap()
|
||||
.size
|
||||
.width;
|
||||
let em_width = window.text_system().em_width(font_id, font_size).unwrap();
|
||||
|
||||
gpui::Point::new(em_width, line_height)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue