emacs-lsp / lsp-ui

UI integrations for lsp-mode
https://emacs-lsp.github.io/lsp-ui
GNU General Public License v3.0
1.03k stars 141 forks source link

lsp-ui tooltip font is different from the default emacs setting #652

Closed drcxd closed 2 years ago

drcxd commented 2 years ago

image

As you can see in the picture, the font used in lsp-ui tooltip is different. Also, the information displayed at the bottom is using the same (different) font.

This is a windows specific issue, which cannot be found in a Linux environment.

Is there any way I can specify which font I want to use for lsp-ui?

cabins commented 2 years ago

image

I have the similar problem (Windows 10 too) , as shown in the picture, the code part is different as the default font, the rest is same as default.

drcxd commented 2 years ago

It turns out that lsp-ui-doc uses markdown-code-face to render part of the content in the tooltip. I am not sure why on Windows this face is displaying another font and rendering using GDI rather than harfbuzz. To fix this problem, I mean the annoying different font face, rather than the difference between OSes, I just manually customize the markdown-code-face.

(require 'markdown-mode)
(set-face-attribute 'markdown-code-face nil
                              :family "Cascadia Code")

@cabins Hope this could help you.

cabins commented 2 years ago

Yes ! It works! Thank you so much!

cabins commented 2 years ago

Another way, as I add these two line to my init file, each font looks great! No only the lsp-tooltip, but also the font in some other mode, such as org-mode, markdown-mode etc.

(set-face-attribute 'fixed-pitch nil :family "Cascadia Code")
(set-face-attribute 'variable-pitch nil :family "Cascadia Code")

Maybe this can give other people some hint.