emacs-devel
[Top][All Lists]
Advanced

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

Re: Testing font things


From: Eli Zaretskii
Subject: Re: Testing font things
Date: Mon, 21 Nov 2022 16:12:51 +0200

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Mon, 21 Nov 2022 08:42:01 -0500
> 
> I'm trying to write a test for our font choice code (bug#59347)

Is it useful?  This test will work only on your platform and maybe on a few
other lucky ones.  The list of fonts installed on any given system is
unpredictable.

I suggest to defer coding of the test until we fully understand the problem,
and then try to write the test in some generic way independent of specific
font families.

That said...

>       (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?

...why do you need to go to these obscure entities, when you have the font's
name as a string to begin with?  So you should be able to:

  . use face-font, which returns the font's name as a string
  . compare that string with what you wanted it to be
  . and/or use find-font to check whether the font is in fact installed on
    the system

If the above is not enough, what is missing?



reply via email to

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