pitkali / pos-tip

Show tooltip at point
37 stars 14 forks source link

Pos-tip font has :height 0 in Emacs 28 due to find-font call in pos-tip-show #20

Closed cpitclaudel closed 1 year ago

cpitclaudel commented 1 year ago

The fix in https://github.com/pitkali/pos-tip/issues/10 breaks causes pos-tips to be displayed with height 0 in Emacs 28.

Here's a repro:

mkdir -p /tmp/emacs-repro
cd /tmp/emacs-repro
cat  > .emacs << EOF
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)

(package-initialize)
(unless (package-installed-p 'pos-tip)
  (package-refresh-contents)
  (package-install 'pos-tip))

(require 'pos-tip)
(run-with-timer
 1 1 #'pos-tip-show
 "This long string is barely visible, even though it spans more than 80 characters.")
EOF
HOME=$(pwd) emacs 

This is what I see:

image

This seems to be related to the fact that Emacs now respects the :height 0 parameter that pos-tip passes it:

ELISP> (font-face-attributes (find-font (font-spec :name (frame-parameter nil 'font))))
(:family "Ubuntu Mono" :height 0 :weight regular :slant normal :width normal)
pitkali commented 1 year ago

Well, the previous fix doesn't set height to 0, does it? The font object created from frame font string would have no height, which is different. Perhaps propertize needs explicit height these days or there's better way to get the frame font.

Either way, I'm on holiday without computer until end of June. I can take a look then.

cpitclaudel commented 1 year ago

Thanks for the reply!

Well, the previous fix doesn't set height to 0, does it?

I think it does, indirectly, due to the added find-font:

ELISP> (font-face-attributes (font-spec :name (frame-parameter nil 'font)))
(:family "Ubuntu Mono" :height 181 :weight normal :slant normal :width normal)

ELISP> (font-face-attributes (find-font (font-spec :name (frame-parameter nil 'font))))
(:family "Ubuntu Mono" :height 0 :weight normal :slant normal :width normal)
pitkali commented 1 year ago

This will be a busy week, it seems, so I will not look at it straight away.

cpitclaudel commented 1 year ago

Thanks for the update!

fredericgiquel commented 1 year ago

Same problem for me. But it appears only in Emacs 29 pretest (currently 29.0.92). It works well with Emacs 28 and I didn't test with master branch (future Emacs 30)

pitkali commented 1 year ago

It also does not reproduce on my Ubuntu with emacs 28, but does reproduce on pretest.

pitkali commented 1 year ago

It appears its find-font that breaks it somehow. Looking at it now, frame's font parameter corresponds to the default face. The test case works then if you just remove :font as a parameter altogether, but since the function takes it from a specific frame and different frames may have different defaults, that probably won't work under all circumstances.

However, you can just read the font object directly from the frame's default face, without find-font.