From: Po Lu <luangruo@yahoo.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Testing font things
Date: Tue, 22 Nov 2022 08:24:47 +0800 [thread overview]
Message-ID: <87bkoz6dkg.fsf@yahoo.com> (raw)
In-Reply-To: <jwvy1s4zb2h.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 21 Nov 2022 08:42:01 -0500")
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.
next prev parent reply other threads:[~2022-11-22 0:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-21 13:42 Testing font things Stefan Monnier
2022-11-21 14:12 ` Eli Zaretskii
2022-11-30 3:31 ` Stefan Monnier
2022-11-30 5:06 ` Stefan Kangas
2022-11-30 13:36 ` Eli Zaretskii
2022-11-22 0:24 ` Po Lu [this message]
2022-11-30 3:48 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bkoz6dkg.fsf@yahoo.com \
--to=luangruo@yahoo.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).