From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Testing font things Date: Mon, 21 Nov 2022 16:12:51 +0200 Message-ID: <83tu2s2y70.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28510"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Nov 21 15:13:55 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ox7YY-0007Da-9s for ged-emacs-devel@m.gmane-mx.org; Mon, 21 Nov 2022 15:13:54 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ox7Xo-0005tp-E4; Mon, 21 Nov 2022 09:13:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox7Xn-0005tg-DR for emacs-devel@gnu.org; Mon, 21 Nov 2022 09:13:07 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox7Xb-00075u-7h; Mon, 21 Nov 2022 09:13:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=0kXLgEPIMet4N0SKUoz6lRnyS8d4zS2Vafrna0eui5o=; b=KF3/S8CAZWdl vfGFBbdcfdEp71RXfucjiFnVhOzJKNBVVU2AZtIQvY+aaHpA4VCx6+VVpX3rspbOWgEcsAZYwvLup PwAqU4jjjU0drLzQe32IkIs3QQt2BLTpHAU9PXTVc81bHlXy/6jw8yyxlkb+pZ1Sszsw3t5ZYZcGL iR/5c8pmw832ZlFnRdapoTzK63+e6xfwRezB1g+HRh4+RiXbbXMdteBJ3WnentrX5nHaXPGiPSOim zRejy8yxd+MRhqmwCgzNZOKbWpCsaOl4KmTwD4YQ6UegoG4tEuBlgTgRalhmU+Y+IFutBNjNlzzFB ZiUuzMkiagLqxXNenyUkDg==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox7XK-0003Zk-Ve; Mon, 21 Nov 2022 09:12:53 -0500 In-Reply-To: (message from Stefan Monnier on Mon, 21 Nov 2022 08:42:01 -0500) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300298 Archived-At: > From: Stefan Monnier > 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?