-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
editor: Adjust how gutter width is calculated to work with proportional fonts #24009
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -838,7 +838,7 @@ impl EditorElement { | |
let font_size = style.text.font_size.to_pixels(window.rem_size()); | ||
let em_width = window | ||
.text_system() | ||
.typographic_bounds(font_id, font_size, 'm') | ||
.typographic_bounds(font_id, font_size, '0') | ||
.unwrap() | ||
.size | ||
.width; | ||
|
@@ -6400,7 +6400,7 @@ impl Element for EditorElement { | |
style.text.font_size.to_pixels(window.rem_size()); | ||
let em_width = window | ||
.text_system() | ||
.typographic_bounds(font_id, font_size, 'm') | ||
.typographic_bounds(font_id, font_size, '0') | ||
.unwrap() | ||
.size | ||
.width; | ||
|
@@ -6482,13 +6482,13 @@ impl Element for EditorElement { | |
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') | ||
.typographic_bounds(font_id, font_size, '0') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing the em values here seems incorrect, because while it will impact the gutter dimensions, we also use the em width down below when computing the editor width and the wrap, which needs to stay in ems. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we want to do this then I think we need to compute both an em and a ch and use the ch just for the gutter measurements and the em for everything else. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fairly new to rust. How would we calculate ch and em here? |
||
.unwrap() | ||
.size | ||
.width; | ||
let em_advance = window | ||
.text_system() | ||
.advance(font_id, font_size, 'm') | ||
.advance(font_id, font_size, '0') | ||
.unwrap() | ||
.width; | ||
|
||
|
@@ -8062,13 +8062,13 @@ fn compute_auto_height_layout( | |
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') | ||
.typographic_bounds(font_id, font_size, '0') | ||
.unwrap() | ||
.size | ||
.width; | ||
let em_advance = window | ||
.text_system() | ||
.advance(font_id, font_size, 'm') | ||
.advance(font_id, font_size, '0') | ||
.unwrap() | ||
.width; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're changing the measured glyph from an
m
to something else, it is no longer an "em width".We should rename the surrounding bindings to be named something else. Maybe
digit_width
ornumeral_width
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we change this for em_advance too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In CSS they refer to this as a
ch
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we would.
Let's go with
ch_width
andch_advance
.