emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Testing font things


From: Po Lu
Subject: Re: Testing font things
Date: Tue, 22 Nov 2022 08:24:47 +0800
User-agent: Gnus/5.13 (Gnus v5.13)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>   The code in font-tests.el looks like:
>
>       (defvar font-tests--gui-frame
>         (unless noninteractive ;; I get "killed by SIGIO" in batch mode :-(
>           (with-demoted-errors "%S"
>             (make-frame-on-display
>              (getenv "DISPLAY")
>              '((visibility . nil)
>                ;; Tell the window manager not to ask the user to
>                ;; manually place the frame/window.
>                (user-position . t)
>                (left . 0)
>                (top . 0)
>                (no-other-frame . t))))))
>       
>       (defvar font-tests--dejavu-sans
>         (when font-tests--gui-frame
>           (list-fonts (font-spec :family "DejaVu Sans")
>                       font-tests--gui-frame)))
>       
>       (defvar font-tests--misc-fixed
>         (when font-tests--gui-frame
>           (list-fonts
>            (font-spec :name 
> "-misc-fixed-*-*-semicondensed-*-13-*-*-*-*-*-*-*")
>            font-tests--gui-frame)))
>       
>       (ert-deftest font-tests--bug59347 ()
>         (skip-unless (and font-tests--misc-fixed font-tests--dejavu-sans))
>         (face-spec-set
>          'default
>          '((t :font "-misc-fixed-*-*-semicondensed-*-13-*-*-*-*-*-*-*")))
>         (face-spec-set 'font-tests-dejavu '((t :family "DejaVu Sans")))
>         (with-temp-buffer
>           (let ((w (frame-root-window font-tests--gui-frame)))
>             (set-window-buffer w (current-buffer))
>             (insert "hello " (propertize "world" 'face 'font-tests-dejavu))
>             (should (member (font-at (1+ (point-min)) w)
>                             font-tests--misc-fixed))
>             (should (member (font-at (1- (point-max)) w)
>                             font-tests--dejavu-sans)))))
>
>   But this fails because `fonts-at` gets me a "font-object" whereas
>   `list-fonts` gets me "font entities".  How can I convert one to
>   the other?

You should resort to comparing font attributes with `font-get' instead.
I don't think what you want is reliably possible.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]