jdtsmith / kind-icon

Completion kind text/icon prefix labelling for emacs in-region completion
GNU Affero General Public License v3.0
174 stars 4 forks source link

The last candidate will be cut when using svg-icons on Windows system #18

Closed Eason0210 closed 2 years ago

Eason0210 commented 2 years ago

Hi @jdtsmith

When I usekind-icon withCorfu on Windows system, the popup window can't show all the icons, the last candidate will be cut. This issue only happen on Windows system, but with different fonts will have different result. I only test these fonts: SF Mono , Cascadia Mono and Consolas

Using SF Mono, the last candidate is cut, and the candidates only have 9 lines, expected is 10:

image

UsingConsolas, the candidates have 10 lines, but the last candidate is cut:

image

UsingCascadia Mono, the result looks good , but the candidates only have 9 lines, expected is 10:

image

If I use the text-based icon, It works well.

Steps to reproduce:

  1. Create an init.el file in ~/.emacs.d/init.el
  2. Put the following code in theinit.el file
    
    ;;(add-to-list 'default-frame-alist (cons 'font "Consolas-11"))
    ;;(add-to-list 'default-frame-alist (cons 'font "Cascadia Mono-11"))
    (add-to-list 'default-frame-alist (cons 'font "SF Mono-11"))

;; Setup corfu (package-install 'corfu) (require 'corfu) (setq corfu-auto t) (global-corfu-mode 1)

;; Setup kind-icon (package-install 'kind-icon) (require 'kind-icon) (setq kind-icon-default-face 'corfu-default) (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter)


3. Start Emacs, It will install `Corfu` and `kind-icon` , aslo the dependency `svg-lib`
4. Try to input someting on` *scratch*` buffer, you will see the result.

Actually, I'm not sure if the problem is caused by`Kind-icon`, may be it is caused by`Corfu`.

Emacs 29.0.50 https://github.com/emacs-mirror/emacs/commit/aab560f0c1955bae57cc35a71be95b5bfa2ab525
jdtsmith commented 2 years ago

I don't have Windows to test, but one issue is that icons are rendered and cached. So if you change the font, you should M-x kind-icon-reset-cache to get an accurate idea. What this may do, however, is demonstrate that the problem happens for all fonts.

If that is the case, it's probably then a bug in svg-lib rendering of full height icons. Or, perhaps your Emacs is confused about its (window-font-height) (misleading svg-lib).

You should be able to work around this by reducing the :height in kind-icon-default-style to something smaller, like 0.8. Give that a try.

Eason0210 commented 2 years ago

You should be able to work around this by reducing the :height in kind-icon-default-style to something smaller, like 0.8. Give that a try.

Thanks for you advice. I tried to customize the :height to 0.9 and it works well now.

(custom-set-variables
 '(kind-icon-default-style
   '(:padding 0 :stroke 0 :margin 0 :radius 0 :height 0.9 :scale 1.0))
 '(package-selected-packages '(kind-icon corfu)))

Using the font SF Mono image