rougier / nano-emacs

GNU Emacs / N Λ N O - Emacs made simple
GNU General Public License v3.0
2.5k stars 191 forks source link

face problem on windows #113

Open albreche opened 2 years ago

albreche commented 2 years ago

Hi there, on windows, i can't get the faces weight behaviour. Below an illustration of the problem : all fonts are medium

image

Note faces are correctly set (eg: header1 has face org-level-1 which inherits from nano-face-strong). Changing the nano-face-strong weight in nano-face.el to bold produce the expected result. I use roboto mono which defines the expected weight.

It seems the problem is a kind of interference with default fonlt as set from the gui.

Does anyone has a clue ?

Btw, awesome work here !

albreche commented 2 years ago

edit: the problem come from the ttfs. Using RobotoMono NF (from nerdfont, the windows compatible one), the face changes depending on structural info, which is the expected behavior. But using the Roboto Mono from google, it does not work. Hence, i believe i have a problem with emacs, fonts and Windows.
Consequently, this issue is not relevant regarding nano emacs.

rougier commented 2 years ago

Thanks for the report. If you get the problem, probably others will have the same. If you find the reason and fix, please post if here.

albreche commented 2 years ago

looking at variable 'font-weight-table', i see that 'medium' is an alias for 'normal'. In nano-faces.el, the nano-face-strong is set to 'medium' for graphic-display. Hence , nano-face-strong wheight is the same as default face .

a quick&dirty fix this is to set the weight attribute to , eg, semibold instead of medium in nano-faces.el in graphic mode

diff --git "a/nano-faces.el" "b/nano-faces.el"
index 8904cf5..3d02f64 100644
--- "a/nano-faces.el"
+++ "b/nano-faces.el"
@@ -204,7 +204,7 @@ background color that is barely perceptible."
   (if (display-graphic-p)
       (set-face-attribute 'nano-face-strong nil
                           :foreground (face-foreground 'nano-face-default)
-                          :weight 'medium)
+                          :weight 'semi-bold)
     (set-face-attribute 'nano-face-strong nil
                         :foreground (face-foreground 'nano-face-default)
                         :weight 'bold))
albreche commented 2 years ago

Now, it works better using static ttf files and updating nano-faces.el with familiy attributes corresponding to the correct ttf as for example :

--- "a/nano-faces.el"
+++ "b/nano-faces.el"
@@ -204,18 +204,24 @@ background color that is barely perceptible."
   (if (display-graphic-p)
       (set-face-attribute 'nano-face-strong nil
                           :foreground (face-foreground 'nano-face-default)
-                          :weight 'medium)
+                          :weight 'medium
+                          :family "Roboto Mono Medium")
rougier commented 2 years ago

Thanks. I'm not sure to understand why Emacs failq at settings the weight from the :weight property.

claudiusmueller commented 4 months ago

I just wanted to add that this is still a problem (Windows 10, Emacs 29.2). The solution provided above by @albreche still works.

rougier commented 4 months ago

On OSX, a patch for fixing weight has been recently merged but I don't think it will dod anything on Windows.