GramEditor/gram
37
982
Fork
You've already forked gram
88

UI font sizing mismatch #321

Open
opened 2026年05月31日 02:22:41 +02:00 by al20ov · 15 comments

Sorry to resurface this issue (related: #147, #69) and sorry to nitpick but I just installed Gram and configured everything exactly as I had it on Zed and couldn't help but notice that the UI font looks kind of janky (no offense) compared to Zed. I narrowed it down to PR #69, and tried reverting it to see if that was the source of the issue.

Gram on the left, Zed on the right

With PR #69:
Screenshot from 2026年05月31日 01-15-58

Reverted PR #69:
Screenshot from 2026年05月31日 01-46-48

That's with Adwaita Sans (basically Inter), ui_font_size = 16.0 and project_panel.entry_spacing at "Comfortable".
I agree that having mismatched UI and buffer font size is annoying but it leads to every entry_spacing and everything with padding being all wrong due to the UI font needing to be smaller to roughly match the previous font size. Here's me trying to match font sizes (2pt smaller):
Screenshot from 2026年05月31日 02-16-49
Element spacing in the project panel is smaller, the bar at the bottom is thinner, etc... Maybe spacing/padding could be adjusted accordingly to compensate?

EDIT: forgot to mention I'm on Wayland and it doesn't seem to be related to display scaling as I saw the same issue whether on 1x or 1.25x scaling

Sorry to resurface this issue (related: https://codeberg.org/GramEditor/gram/issues/147, https://codeberg.org/GramEditor/gram/pulls/69) and sorry to nitpick but I just installed Gram and configured everything exactly as I had it on Zed and couldn't help but notice that the UI font looks kind of janky (no offense) compared to Zed. I narrowed it down to PR #69, and tried reverting it to see if that was the source of the issue. Gram on the left, Zed on the right With PR #69: ![Screenshot from 2026年05月31日 01-15-58](/attachments/43bd7ab7-61cc-4f14-ac60-261f3bd099d6) Reverted PR #69: ![Screenshot from 2026年05月31日 01-46-48](/attachments/47732a2b-015a-4c22-a865-5fc465c2cfbb) That's with Adwaita Sans (basically Inter), `ui_font_size` = 16.0 and `project_panel.entry_spacing` at "Comfortable". I agree that having mismatched UI and buffer font size is annoying but it leads to every entry_spacing and everything with padding being all wrong due to the UI font needing to be smaller to roughly match the previous font size. Here's me trying to match font sizes (2pt smaller): ![Screenshot from 2026年05月31日 02-16-49](/attachments/17120aea-d988-4342-bd8f-2f9f54b65357) Element spacing in the project panel is smaller, the bar at the bottom is thinner, etc... Maybe spacing/padding could be adjusted accordingly to compensate? EDIT: forgot to mention I'm on Wayland and it doesn't seem to be related to display scaling as I saw the same issue whether on 1x or 1.25x scaling
Owner
Copy link

Hi!

I think main annoyance is that panel font size and buffer font size are not the same when set to the same point size. If we could fix that without changing the baseline the UI would probably look better..

Hi! I think main annoyance is that panel font size and buffer font size are not the same when set to the same point size. If we could fix that without changing the baseline the UI would probably look better..
Author
Copy link

I see, as I understand it, PR #69 fixed that mismatch correct? Now UI/panel and buffer font sizes are the same pt size. The remaining issue though is that the baseline (so line height?) is now wrong because it was based on the previous wrong assumption about font size?
I'm not too familiar with Rust but I could give it shot if I knew where to look.

Maybe in crates/ui/src/styles/spacing.rs, crates/project_panel/src/project_panel.rs or crates/ui/src/components/list/list_item.rs?

I see, as I understand it, PR #69 fixed that mismatch correct? Now UI/panel and buffer font sizes are the same pt size. The remaining issue though is that the baseline (so line height?) is now wrong because it was based on the previous wrong assumption about font size? I'm not too familiar with Rust but I could give it shot if I knew where to look. Maybe in `crates/ui/src/styles/spacing.rs`, `crates/project_panel/src/project_panel.rs` or `crates/ui/src/components/list/list_item.rs`?
Author
Copy link

Okay I'm onto something I think, the map(|this| match self.spacing) in crates/ui/src/components/list/list_item.rs has four mappings from ListItemSpacings to Y padding values and I believe the first one (Dense) corresponds to what I use which is "Comfortable" and by changing that from just this to this.py_0p5(), I get the exact same baseline with 14pt UI font size as I do on Zed on 16pt UI font size.

Without this change:
image

With this change:
image

This is probably not the exact change that needs to be made though because it just fixes it in list_items but not buttons, etc... which still look wrong:

image

vs.
image

Okay I'm onto something I think, the map(|this| match self.spacing) in `crates/ui/src/components/list/list_item.rs` has four mappings from ListItemSpacings to Y padding values and I believe the first one (Dense) corresponds to what I use which is "Comfortable" and by changing that from just `this` to `this.py_0p5()`, I get the exact same baseline with 14pt UI font size as I do on Zed on 16pt UI font size. Without this change: ![image](/attachments/b37f1f91-e581-4a27-be50-cf4e0a487e71) With this change: ![image](/attachments/50cff38f-8da0-4c9a-9af3-bd5c957f0352) This is probably not the exact change that needs to be made though because it just fixes it in `list_items` but not buttons, etc... which still look wrong: ![image](/attachments/679a2bd2-17e6-49de-b640-1efa0376916b) vs. ![image](/attachments/48762358-dc01-4264-95c1-acbbb5f1f348)
Owner
Copy link

I think it's probably crates/ui/src/styles/spacing.rs that needs to be adjusted. Will experiment and see if I can get it to look decent.

I think it's probably `crates/ui/src/styles/spacing.rs` that needs to be adjusted. Will experiment and see if I can get it to look decent.
Owner
Copy link

OK, I made some changes and feel like things look better now.

OK, I made some changes and feel like things look better now.
Author
Copy link

Thanks. I just checked it out, ran a build and it looks a bit more balanced but it's still pretty tight even on "entry_spacing": "comfortable":
image

I guess it's just personal preference though.

Thanks. I just checked it out, ran a build and it looks a bit more balanced but it's still pretty tight even on `"entry_spacing": "comfortable"`: ![image](/attachments/dfc991e5-4ba2-449b-9355-d173f8220a09) I guess it's just personal preference though.
Author
Copy link

I played around with crates/theme/src/settings.rs and crates/ui/src/styles/typography.rs by basing everything on units.rs's BASE_REM_SIZE_IN_PX of 16px, which gets scaled up or down as needed by window manager scaling factor, etc...:

diff --git a/crates/theme/src/settings.rs b/crates/theme/src/settings.rs
index de5bf3a136..9a37d1922b 100644
--- a/crates/theme/src/settings.rs
+++ b/crates/theme/src/settings.rs
@@ -580,13 +580,12 @@ pub fn reset_buffer_font_size(cx: &mut App) {
 // TODO: Make private, change usages to use `get_ui_font_size` instead.
 #[allow(missing_docs)]
 pub fn setup_ui_font(window: &mut Window, cx: &mut App) -> gpui::Font {
- let (ui_font, ui_font_size) = {
+ let ui_font = {
 let theme_settings = ThemeSettings::get_global(cx);
- let font = theme_settings.ui_font.clone();
- (font, theme_settings.ui_font_size(cx))
+ theme_settings.ui_font.clone()
 };
 
- window.set_rem_size(ui_font_size);
+ window.set_rem_size(px(16.));
 ui_font
 }
 
diff --git a/crates/ui/src/styles/typography.rs b/crates/ui/src/styles/typography.rs
index f8ee37f120..16a048a6fb 100644
--- a/crates/ui/src/styles/typography.rs
+++ b/crates/ui/src/styles/typography.rs
@@ -136,10 +136,10 @@ impl TextSize {
 let theme_settings = ThemeSettings::get_global(cx);
 
 match self {
- Self::Large => rems_from_px(18.),
- Self::Default => rems_from_px(16.),
- Self::Small => rems_from_px(14.),
- Self::XSmall => rems_from_px(12.),
+ Self::Large => rems_from_px(theme_settings.ui_font_size(cx) + px(2.)),
+ Self::Default => rems_from_px(theme_settings.ui_font_size(cx)),
+ Self::Small => rems_from_px(theme_settings.ui_font_size(cx) - px(2.)),
+ Self::XSmall => rems_from_px(theme_settings.ui_font_size(cx) - px(4.)),
 Self::Ui => rems_from_px(theme_settings.ui_font_size(cx)),
 Self::Editor => rems_from_px(theme_settings.buffer_font_size(cx)),
 }
@@ -149,10 +149,10 @@ impl TextSize {
 let theme_settings = ThemeSettings::get_global(cx);
 
 match self {
- Self::Large => px(16.),
- Self::Default => px(14.),
- Self::Small => px(12.),
- Self::XSmall => px(10.),
+ Self::Large => theme_settings.ui_font_size(cx) + px(2.),
+ Self::Default => theme_settings.ui_font_size(cx),
+ Self::Small => theme_settings.ui_font_size(cx) - px(2.),
+ Self::XSmall => theme_settings.ui_font_size(cx) - px(4.),
 Self::Ui => theme_settings.ui_font_size(cx),
 Self::Editor => theme_settings.buffer_font_size(cx),
 }

And ended up with something that looks like the way it did before #69, except now on a reasonable UI font size, which #69 fixed:

image

I played around with `crates/theme/src/settings.rs` and `crates/ui/src/styles/typography.rs` by basing everything on units.rs's BASE_REM_SIZE_IN_PX of 16px, which gets scaled up or down as needed by window manager scaling factor, etc...: ```diff diff --git a/crates/theme/src/settings.rs b/crates/theme/src/settings.rs index de5bf3a136..9a37d1922b 100644 --- a/crates/theme/src/settings.rs +++ b/crates/theme/src/settings.rs @@ -580,13 +580,12 @@ pub fn reset_buffer_font_size(cx: &mut App) { // TODO: Make private, change usages to use `get_ui_font_size` instead. #[allow(missing_docs)] pub fn setup_ui_font(window: &mut Window, cx: &mut App) -> gpui::Font { - let (ui_font, ui_font_size) = { + let ui_font = { let theme_settings = ThemeSettings::get_global(cx); - let font = theme_settings.ui_font.clone(); - (font, theme_settings.ui_font_size(cx)) + theme_settings.ui_font.clone() }; - window.set_rem_size(ui_font_size); + window.set_rem_size(px(16.)); ui_font } diff --git a/crates/ui/src/styles/typography.rs b/crates/ui/src/styles/typography.rs index f8ee37f120..16a048a6fb 100644 --- a/crates/ui/src/styles/typography.rs +++ b/crates/ui/src/styles/typography.rs @@ -136,10 +136,10 @@ impl TextSize { let theme_settings = ThemeSettings::get_global(cx); match self { - Self::Large => rems_from_px(18.), - Self::Default => rems_from_px(16.), - Self::Small => rems_from_px(14.), - Self::XSmall => rems_from_px(12.), + Self::Large => rems_from_px(theme_settings.ui_font_size(cx) + px(2.)), + Self::Default => rems_from_px(theme_settings.ui_font_size(cx)), + Self::Small => rems_from_px(theme_settings.ui_font_size(cx) - px(2.)), + Self::XSmall => rems_from_px(theme_settings.ui_font_size(cx) - px(4.)), Self::Ui => rems_from_px(theme_settings.ui_font_size(cx)), Self::Editor => rems_from_px(theme_settings.buffer_font_size(cx)), } @@ -149,10 +149,10 @@ impl TextSize { let theme_settings = ThemeSettings::get_global(cx); match self { - Self::Large => px(16.), - Self::Default => px(14.), - Self::Small => px(12.), - Self::XSmall => px(10.), + Self::Large => theme_settings.ui_font_size(cx) + px(2.), + Self::Default => theme_settings.ui_font_size(cx), + Self::Small => theme_settings.ui_font_size(cx) - px(2.), + Self::XSmall => theme_settings.ui_font_size(cx) - px(4.), Self::Ui => theme_settings.ui_font_size(cx), Self::Editor => theme_settings.buffer_font_size(cx), } ``` And ended up with something that looks like the way it did before #69, except now on a reasonable UI font size, which #69 fixed: ![image](/attachments/ae88c7b7-9bca-484b-8784-534d247c5546)
Owner
Copy link

@al20ov Nice! I think it's going to be a series of fixing things here and there to get it looking good everywhere, but that sounds good. I would merge a PR if you made one :)

@al20ov Nice! I think it's going to be a series of fixing things here and there to get it looking good everywhere, but that sounds good. I would merge a PR if you made one :)
Owner
Copy link

Interesting how that works, I would have thought your patch would cause a lot of breakage in other font sizes..

Interesting how that works, I would have thought your patch would cause a lot of breakage in other font sizes..
Owner
Copy link

Hmm yeah, at least trying to add your changes on top of the changes that I made just now results in a lot of brokenness. It's very airy, but some text becomes very large (in the settings UI in particular). I'll try and see if making the headline sizes relative to the ui font size as well fixes things.

Hmm yeah, at least trying to add your changes on top of the changes that I made just now results in a lot of brokenness. It's very airy, but some text becomes very large (in the settings UI in particular). I'll try and see if making the headline sizes relative to the ui font size as well fixes things.
Author
Copy link

Yes sorry I tried these changes before #321. I'm sure there's a way to reconcile though if you think these changes are worth something. Also I tried bringing in BASE_REM_SIZE_IN_PX (16px) by importing the ui crate inside the theme crate but there was a circular dependency

Yes sorry I tried these changes before #321. I'm sure there's a way to reconcile though if you think these changes are worth something. Also I tried bringing in `BASE_REM_SIZE_IN_PX` (16px) by importing the ui crate inside the theme crate but there was a circular dependency
Owner
Copy link

@al20ov No worries, I guess my changes interact badly with yours. I can try reverting mine and applying yours here and see how that looks..

@al20ov No worries, I guess my changes interact badly with yours. I can try reverting mine and applying yours here and see how that looks..
Owner
Copy link

Hm. So I have the same problem when I try reverting my changes and just applying your patch. Some font sizes seem to no longer change when the ui font size changes, like the search field in the settings window for example. I also feel like things get very airy in general. My guess is that the line height no longer adjusts to the ui font size..

Hm. So I have the same problem when I try reverting my changes and just applying your patch. Some font sizes seem to no longer change when the ui font size changes, like the search field in the settings window for example. I also feel like things get very airy in general. My guess is that the line height no longer adjusts to the ui font size..
Author
Copy link

I guess you're right, I just tried bumping the UI font size and the UI only looks correct at 14pt with my change but other sizes don't look right. I'll keep searching and tell you if I come up with anything. Thanks for taking the time to try it out

I guess you're right, I just tried bumping the UI font size and the UI only looks correct at 14pt with my change but other sizes don't look right. I'll keep searching and tell you if I come up with anything. Thanks for taking the time to try it out
Owner
Copy link

I guess the problem is that a lot of the spacing is based on the combination of the base size (16px) and the default UI font size (14px), and when changing one but not the other all those spacings get tighter. I suspect there's no easier fix to get it right than to go through the UI and adjust the spacings to bump them up a size..

I guess the problem is that a lot of the spacing is based on the combination of the base size (16px) and the default UI font size (14px), and when changing one but not the other all those spacings get tighter. I suspect there's no easier fix to get it right than to go through the UI and adjust the spacings to bump them up a size..
Sign in to join this conversation.
main
main
test/wgpu-on-mac
test-ci/failing-test-mac
test/failing-test-mac
test/build-on-22-04
test/wgpu-present-mode-mailbox
v2.1
test/altgr-fix-again
test/2.0.0-rc1
test/linux-build
test/objc2
v1.2.1
3.0.1
3.0.0
2.2.0
2.1.2
2.1.1
2.1.0
2.0.0
1.2.1
1.2.0
1.1.0
1.0.0
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
GramEditor/gram#321
Reference in a new issue
GramEditor/gram
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?