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

vscode: don't round font sizes #691

Merged
merged 2 commits into from
Dec 21, 2024
Merged

vscode: don't round font sizes #691

merged 2 commits into from
Dec 21, 2024

Conversation

musjj
Copy link
Contributor

@musjj musjj commented Dec 21, 2024

The font sizes shouldn't be rounded when converting pt to px. For example, 13.333 will look bigger than 13 and smaller than 14

In my configuration, the rounding causes my editor fonts to look really small compared to my standalone terminal.

Copy link
Collaborator

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From 718be6c4d5661f3558597e4727d47df48354b36b Mon Sep 17 00:00:00 2001
From: musjj <[email protected]>
Date: Sat, 21 Dec 2024 19:49:30 +0700
Subject: [PATCH 1/2] vscode: don't round font sizes

---
 modules/vscode/hm.nix | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/modules/vscode/hm.nix b/modules/vscode/hm.nix
index e738b3c7..0e9bdda4 100644
--- a/modules/vscode/hm.nix
+++ b/modules/vscode/hm.nix
@@ -36,18 +36,18 @@ in {
         "chat.editor.fontFamily" = monospace.name;

         # 4/3 factor used for pt to px;
-        "editor.fontSize" = builtins.floor (sizes.terminal * 4 / 3 + 0.5);
-        "debug.console.fontSize" = builtins.floor (sizes.terminal * 4 / 3 + 0.5);
-        "markdown.preview.fontSize" = builtins.floor (sizes.terminal * 4 / 3 + 0.5);
-        "terminal.integrated.fontSize" = builtins.floor (sizes.terminal * 4 / 3 + 0.5);
-        "chat.editor.fontSize" = builtins.floor (sizes.terminal * 4 / 3 + 0.5);
+        "editor.fontSize" = sizes.terminal * 4 / 3;
+        "debug.console.fontSize" = sizes.terminal * 4 / 3;
+        "markdown.preview.fontSize" = sizes.terminal * 4 / 3;
+        "terminal.integrated.fontSize" = sizes.terminal * 4 / 3;
+        "chat.editor.fontSize" = sizes.terminal * 4 / 3;

         # other factors (9/14, 13/14, 56/14) based on default for given value
         # divided by default for `editor.fontSize` (14) from
         # https://code.visualstudio.com/docs/getstarted/settings#_default-settings.
-        "editor.minimap.sectionHeaderFontSize" = builtins.floor (sizes.terminal * 4 / 3 * 9 / 14 + 0.5);
-        "scm.inputFontSize" = builtins.floor (sizes.terminal * 4 / 3 * 13 / 14 + 0.5);
-        "screencastMode.fontSize" = builtins.floor (sizes.terminal * 4 / 3 * 56 / 14 + 0.5);
+        "editor.minimap.sectionHeaderFontSize" = sizes.terminal * 4 / 3 * 9 / 14;
+        "scm.inputFontSize" = sizes.terminal * 4 / 3 * 13 / 14;
+        "screencastMode.fontSize" = sizes.terminal * 4 / 3 * 56 / 14;
       };
     };
   };

LGTM.

From 98733a0eb38f19dddaa32093632553fbd10d1e1d Mon Sep 17 00:00:00 2001
From: musjj <[email protected]>
Date: Sat, 21 Dec 2024 20:27:44 +0700
Subject: [PATCH 2/2] vscode: coerce font sizes to floats

---
 modules/vscode/hm.nix | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/modules/vscode/hm.nix b/modules/vscode/hm.nix
index 0e9bdda4..590a4548 100644
--- a/modules/vscode/hm.nix
+++ b/modules/vscode/hm.nix
@@ -36,18 +36,18 @@ in {
         "chat.editor.fontFamily" = monospace.name;

         # 4/3 factor used for pt to px;
-        "editor.fontSize" = sizes.terminal * 4 / 3;
-        "debug.console.fontSize" = sizes.terminal * 4 / 3;
-        "markdown.preview.fontSize" = sizes.terminal * 4 / 3;
-        "terminal.integrated.fontSize" = sizes.terminal * 4 / 3;
-        "chat.editor.fontSize" = sizes.terminal * 4 / 3;
+        "editor.fontSize" = sizes.terminal * 4.0 / 3.0;
+        "debug.console.fontSize" = sizes.terminal * 4.0 / 3.0;
+        "markdown.preview.fontSize" = sizes.terminal * 4.0 / 3.0;
+        "terminal.integrated.fontSize" = sizes.terminal * 4.0 / 3.0;
+        "chat.editor.fontSize" = sizes.terminal * 4.0 / 3.0;

         # other factors (9/14, 13/14, 56/14) based on default for given value
         # divided by default for `editor.fontSize` (14) from
         # https://code.visualstudio.com/docs/getstarted/settings#_default-settings.
-        "editor.minimap.sectionHeaderFontSize" = sizes.terminal * 4 / 3 * 9 / 14;
-        "scm.inputFontSize" = sizes.terminal * 4 / 3 * 13 / 14;
-        "screencastMode.fontSize" = sizes.terminal * 4 / 3 * 56 / 14;
+        "editor.minimap.sectionHeaderFontSize" = sizes.terminal * 4.0 / 3.0 * 9.0 / 14.0;
+        "scm.inputFontSize" = sizes.terminal * 4.0 / 3.0 * 13.0 / 14.0;
+        "screencastMode.fontSize" = sizes.terminal * 4.0 / 3.0 * 56.0 / 14.0;
       };
     };
   };

Why this is necessary?

@musjj
Copy link
Contributor Author

musjj commented Dec 21, 2024

It's a nix thing:

nix-repl> 1 * 4 / 3
1

nix-repl> 1 * 4.0 / 3.0
1.33333

Technically, you only need to have one float, but I felt that it's clearer this way.

Copy link
Collaborator

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, you only need to have one float, but I felt that it's clearer this way.

Sounds good.

@trueNAHO trueNAHO merged commit 4f489c6 into danth:master Dec 21, 2024
12 checks passed
stylix-automation bot pushed a commit that referenced this pull request Jan 4, 2025
Link: #691

Reviewed-by: NAHO <[email protected]>
(cherry picked from commit 4f489c6)
@stylix-automation
Copy link

Successfully created backport PR for release-24.11:

trueNAHO pushed a commit that referenced this pull request Jan 4, 2025
Link: #691

Reviewed-by: NAHO <[email protected]>
(cherry picked from commit 4f489c6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants