nano-theme icon indicating copy to clipboard operation
nano-theme copied to clipboard

problems with setting custom-face for nano-mono (noticed with show-paren-mode)

Open krupan opened this issue 3 months ago • 9 comments

Parens no longer get highlighted by show-paren-mode when using nano-theme and nano-fonts-use is true. Nor do expressions if you enable show-parens-mode and do (setq show-paren-style 'expression).

Unmatched parens are still shown in yellow, but highlighting matching parens does not work.

krupan avatar Sep 02 '25 17:09 krupan

Thanks for the report. What is the face for show-paren in you congiuration?

rougier avatar Sep 08 '25 09:09 rougier

I have not customized the face. I just spent some time looking at the source code for show-paren-mode and I'm not sure what face it uses. I just know that when I'm not using nano fonts it "shows" the parens by making them more bold/bright.

krupan avatar Sep 15 '25 17:09 krupan

It uses show-paren-match (and show-paren-mismatch). Can you have a look a this face on your config?

rougier avatar Sep 15 '25 20:09 rougier

If I run describe-face for those two I get this:

Face: show-paren-match (sample) (customize this face)

Documentation:
Face used for a matching paren.

Defined in ‘faces.el’.


           Family: unspecified
          Foundry: unspecified
            Width: unspecified
           Height: unspecified
           Weight: unspecified
            Slant: unspecified
       Foreground: unspecified
DistantForeground: unspecified
       Background: unspecified
        Underline: unspecified
         Overline: unspecified
   Strike-through: unspecified
              Box: unspecified
          Inverse: unspecified
          Stipple: unspecified
             Font: unspecified
          Fontset: unspecified
           Extend: unspecified
          Inherit: nano-strong

Face: show-paren-mismatch (sample) (customize this face)

Documentation:
Face used for a mismatching paren.

Defined in ‘faces.el’.


           Family: unspecified
          Foundry: unspecified
            Width: unspecified
           Height: unspecified
           Weight: unspecified
            Slant: unspecified
       Foreground: unspecified
DistantForeground: unspecified
       Background: unspecified
        Underline: unspecified
         Overline: unspecified
   Strike-through: unspecified
              Box: unspecified
          Inverse: unspecified
          Stipple: unspecified
             Font: unspecified
          Fontset: unspecified
           Extend: unspecified
          Inherit: nano-critical

[back]

If I do describe-face for nano-strong and nano-critical I see:

Face: nano-strong (sample) (customize this face)

Documentation:
Strong face is used for information of a structural nature.
It has to be the same color as the default color and only the
weight differs by one level (e.g., light/regular or
regular/bold). IT is generally used for titles, keywords,
directory, etc.

Defined in ‘nano-theme-support.el’.


           Family: unspecified
          Foundry: unspecified
            Width: unspecified
           Height: unspecified
           Weight: normal
            Slant: unspecified
       Foreground: unspecified
DistantForeground: unspecified
       Background: unspecified
        Underline: unspecified
         Overline: unspecified
   Strike-through: unspecified
              Box: unspecified
          Inverse: unspecified
          Stipple: unspecified
             Font: unspecified
          Fontset: unspecified
           Extend: unspecified
          Inherit: unspecified

Face: nano-critical (sample) (customize this face)

Documentation:
Critical face is for information that requires immediate action.
It should be of high constrast when compared to other faces. This
can be realized (for example) by setting an intense background
color, typically a shade of red. It must be used scarcely.

Defined in ‘nano-theme-support.el’.


           Family: unspecified
          Foundry: unspecified
            Width: unspecified
           Height: unspecified
           Weight: normal
            Slant: unspecified
       Foreground: #EBCB8B
DistantForeground: unspecified
       Background: unspecified
        Underline: unspecified
         Overline: unspecified
   Strike-through: unspecified
              Box: unspecified
          Inverse: unspecified
          Stipple: unspecified
             Font: unspecified
          Fontset: unspecified
           Extend: unspecified
          Inherit: unspecified

krupan avatar Sep 17 '25 15:09 krupan

if I run describe-char on the l in the "sample" of show-matching-paren above, when I don't have nano-fonts-use set to true, I see this:

             position: 29 of 1451 (2%), column: 28
            character: l (displayed as l) (codepoint 108, #o154, #x6c)
              charset: ascii (ASCII (ISO646 IRV))
code point in charset: 0x6C
               script: latin
               syntax: w 	which means: word
             category: .:Base, L:Strong L2R, a:ASCII, l:Latin, r:Roman
             to input: type "C-x 8 RET 6c" or "C-x 8 RET LATIN SMALL LETTER L"
          buffer code: #x6C
            file code: #x6C (encoded by coding system utf-8-unix)
              display: by this font (glyph code):
    ftcrhb:-UKWN-Adwaita Mono-bold-normal-normal-*-12-*-*-*-m-0-iso10646-1 (#x4F)

Character code properties: customize what to show
  name: LATIN SMALL LETTER L
  general-category: Ll (Letter, Lowercase)
  decomposition: (108) ('l')

There are text properties here:
  font-lock-face       show-paren-match

[back]

And when nano-fonts-use is true I see this:

             position: 29 of 1451 (2%), column: 28
            character: l (displayed as l) (codepoint 108, #o154, #x6c)
              charset: ascii (ASCII (ISO646 IRV))
code point in charset: 0x6C
               script: latin
               syntax: w 	which means: word
             category: .:Base, L:Strong L2R, a:ASCII, l:Latin, r:Roman
             to input: type "C-x 8 RET 6c" or "C-x 8 RET LATIN SMALL LETTER L"
          buffer code: #x6C
            file code: #x6C (encoded by coding system utf-8-unix)
              display: by this font (glyph code):
    ftcrhb:-1ASC-Liberation Mono-regular-normal-normal-*-13-*-*-*-m-0-iso10646-1 (#x4F)

Character code properties: customize what to show
  name: LATIN SMALL LETTER L
  general-category: Ll (Letter, Lowercase)
  decomposition: (108) ('l')

There are text properties here:
  font-lock-face       show-paren-match

[back]

Note the lack of "bold" in the second. I have this in my config for loading nano-theme:

(use-package nano-theme
  :ensure t
  :custom
  (nano-fonts-use t)
  :custom-face
  ;; nano recommends roboto, but I can't easily tell ., and ;: apart
  ;; with it
  (nano-mono ((t (:weight light :height 100 :family "Liberation Mono"))))
  (nano-mono-alt ((t (:weight light :height 100 :family "Roboto Mono"))))
  (nano-sans ((t (:weight light :height 100 :family "DejaVu Sans"))))
  (nano-serif ((t (:weight light :height 100 :family "DejaVu Serif"))))
  ;; can't figure out why when org-mode uses italic it doesn't scale it
  (nano-italic  ((t (:slant italic :height 100 :family "DejaVu Sans"))))

If I remove the whole :custom-face section then the parens are bold as they should be. I really don't like Roboto Mono for the reason I wrote in my comment above, I can't tell ., and :; apart easily in that font.

krupan avatar Sep 17 '25 15:09 krupan

Experimenting more, it seems that by default nano-theme uses the "light" version of Roboto Mono for normal text and then "normal" for bold stuff like matching parens. But if I customize the font like above it just uses "normal" for both.

krupan avatar Sep 17 '25 15:09 krupan

I'm using the light version of Roboto Mono and this makes "bold" to be regular. Maybe you can set the nano-strong face with real bold weight

rougier avatar Sep 17 '25 18:09 rougier

Here's what I have as part of my init (using use-package)

(use-package nano-theme
  :ensure t
  :custom
  (nano-fonts-use t)
  :custom-face
  ;; nano recommends roboto, but I can't easily tell ., and ;: apart
  ;; with it
  (nano-mono ((t (:weight light :family "Liberation Mono"))))
  (nano-mono-alt ((t (:weight light :height 100 :family "Roboto Mono"))))
  (nano-sans ((t (:weight light :height 100 :family "DejaVu Sans"))))
  (nano-serif ((t (:weight light :height 100 :family "DejaVu Serif"))))
  ;; can't figure out why when org-mode uses italic it doesn't scale it
  (nano-italic ((t (:slant oblique :family "DejaVu Sans"))))
  (nano-strong ((t (:weight bold))))

That, however, makes any monospace text regular weight, not light, so I had to use "bold" for nano-strong. Incidentally, the nano-italic setting makes the font a fixed size (italic text does not change size when I change the overall font size). I was worried my highlighted parens would be stuck at a fixed size too, but they are not. If I'm customizing these fonts incorrectly please let me know.

krupan avatar Sep 19 '25 22:09 krupan

Thanks for the report. You need to inspect your Liberation Mono font to check if light is available. If not, you need to fallback to regular/bold combination. For italic, you can remove the :heigth 100 that fix the size of the font. I did this because in my case, there was a difference in size with Roboto and I never change the size.

rougier avatar Sep 24 '25 04:09 rougier