The atom-one-dark theme that I was using was the issue.

(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/atom-one-dark")
(load-theme 'atom-one-dark t)

My init.el:

(menu-bar-mode -1)
(scroll-bar-mode -1)
(tool-bar-mode -1)

(add-hook 'prog-mode-hook 'display-line-numbers-mode)

(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/atom-one-dark")
(load-theme 'atom-one-dark t)

 '(mode-line ((t (:box (:line-width 8 :color "#21252B")))))
 '(mode-line-inactive ((t (:box (:line-width 8 :color "#181A1F"))))))

I am new to Emacs, I've set up display-line-numbers-mode like so:

(add-hook 'prog-mode-hook 'display-line-numbers-mode)

This enables display-line-numbers-mode on all source code files (ex: .py, .js), and it works fine.

display-line-numbers-mode works perfectly

Now, my problem is that the font size is always constant, meaning that when I zoom in, this happens:

When I zoom in

And when I zoom out:

When I zoom out

Doom Emacs

Surprisingly enough, Doom Emacs uses display-line-numbers-mode, and has managed to fix this issue, I don't know how they did it:

Normal: Doom Emacs Normal

Zoom Out:

Doom Emacs Zoom Out

Zoom In:

Doom Emacs Zoom In

I don't exactly know how they managed to fix it, I found some of their code here

Why Did I Ask?

I am having this issue, and I didn't found anything regarding this issue on the Internet. Google (Startpage) is giving me irrelevant results, ex. linum-mode

How You Can Answer This Question


  • Correct any misinformation (comment), example: Doom Emacs doesn't use display-line-numbers-mode
  • Solve my issue (answer), please write elisp code blocks in the answer since I am new.
  • Refer to websites or answers that you think is helpful (comment or answer).
  • Show me how you did it in your config (answer)


  • Don't refer to linum-mode, I've already tried it, and it has many issues. + Doom Emacs did it right, despite them using display-line-numbers-mode.

2 Answers 2



I was using a theme called atom-one-dark:

(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/atom-one-dark-theme")
(load-theme 'atom-one-dark t)

The theme source code contained these two faulty lines:

`(line-number ((t (:foreground ,atom-one-dark-gutter :background ,atom-one-dark-bg))))
`(line-number-current-line ((t (:foreground ,atom-one-dark-fg :background ,atom-one-dark-bg))))

This is not only for atom-one-dark, but for many other themes that I've tried like catppuccin. I've commented the two lines and my problem is solved. But the line number colors reverted to the default grayish color, which I didn't like.

I wanted to change the color of the line numbers, I tried, and changed it to cyan, and it worked. But my problem is back again, the line numbers don't look right when I zoom in & out. When I reverted back to the normal foreground color for the line numbers, it worked and the issue was resolved. But I still wanted some bling to my line numbers.

I fired up Doom Emacs, and began to browse in the Customization Browser (M-x customize-browse), and began to look for the line-number face. This is what I found.

Doom Emacs

I fired up my own GNU Emacs and copied all the options, it worked perfectly even when I change the foreground color, the font, or the font style. I began to analyse the options, to know which one solved my problem, and it was the Inherit option. It was set to default, which is the default face which can be looked up in the Customization Browser in Faces > Basic Faces > Default.

I set the inherit option in my line-number face (Environment > Display > Display Line Numbers > Line Number) to default (The Default face) and everything worked, no matter how I customized the other options.


Set the inherit option to default. (This is how Doom Emacs does it)

  • Solved the problem for me on GNU Emacs 29.3. Commented Jun 4 at 10:00

What Emacs release are you using?

Do you see this when you start Emacs with emacs -Q (no init file). If so, bisect your init file to find the culprit. If not, provide a step-by-step recipe starting from emacs -Q to repro the problem.

I don't see what you describe - I see the line numbers zoom along with the text.

But you don't say how you are zooming. Are you using C-x C-= etc. (text-scale-adjust)? If not, try that.

Note that if you are using an Emacs 29 dev build, there is an outstanding bug with global-text-scale-adjust: Bug #59122.

  • Well actually, you are right, when running emacs -Q, it works seamlessly. My config is only in init.el, which is the file displayed in the images. And yes, I use C-x C-=
    – TechTycho
    Commented Nov 10, 2022 at 16:38
  • Bisect your init file, to see where/how you are shooting yourself in the foot, then don't do that. ;-)
    – Drew
    Commented Nov 10, 2022 at 16:54
  • Actually, the problem is when I set a foreground face to Display Line Numbers, for example: (custom-set-faces '(line-number ((t (:foreground "cyan"))))), why is that happening? (Emacs Version 28.2)
    – TechTycho
    Commented Nov 12, 2022 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.