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: Incorrect font weight selected Date: Sat, 18 Dec 2021 13:41:52 +0200 Message-ID: <83ilvmb0n3.fsf@gnu.org> References: <87pmpv708h.fsf@wavexx.thregr.org> <83r1abcb93.fsf@gnu.org> <87y24jqahr.fsf@wavexx.thregr.org> <83ilvnc6z4.fsf@gnu.org> <875yrmyk8q.fsf@wavexx.thregr.org> <83ee6actjj.fsf@gnu.org> <87o85ef8rg.fsf@wavexx.thregr.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29515"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Yuri D'Elia Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Dec 18 12:43:01 2021 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 1myY7A-0007Rs-FI for ged-emacs-devel@m.gmane-mx.org; Sat, 18 Dec 2021 12:43:00 +0100 Original-Received: from localhost ([::1]:57926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1myY78-0004ke-JT for ged-emacs-devel@m.gmane-mx.org; Sat, 18 Dec 2021 06:42:58 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1myY6F-0003uD-Oa for emacs-devel@gnu.org; Sat, 18 Dec 2021 06:42:03 -0500 Original-Received: from [2001:470:142:3::e] (port=47956 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1myY6F-0007l4-4F; Sat, 18 Dec 2021 06:42:03 -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=znkXVVrRGfao/n7wx/N5OUy2C0oA2dQXGN35299U0JI=; b=Am6mH6+szJ0M ISFhQN3GsGrnd3cGYOrPNAIy0ILljS5r4mb4C/y71RNVWHPrlg+haam0JX2BH6HV4TrCHmdlLM8CM ojZ6pB1fa4J7/a4DsTSY49NnLbR+Bc0DGS827i2hIq6EN8ccfuSat2xFvI1AH/n2PveVFDbcAbi47 mXgiwLUtEWvnJx8lL+u9H/EfU9sOrOL1GMOfgxhi0cFVJkILb7uXiwihd2Lz4dn4dMpa6yK7lyjyR nzaZCQ9OC0mIG+0SLqy+Fi6YCS7USmMaGlLOIdjZSloXySgHOzMnXwm+qQ/uhP4I8qa15/XzEInlM V8cv0RKRPsPBcm53lEDJvQ==; Original-Received: from [87.69.77.57] (port=2672 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 1myY6E-0005n6-VU; Sat, 18 Dec 2021 06:42:03 -0500 In-Reply-To: <87o85ef8rg.fsf@wavexx.thregr.org> (message from Yuri D'Elia on Sat, 18 Dec 2021 11:43:25 +0100) 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" Xref: news.gmane.io gmane.emacs.devel:282285 Archived-At: > From: Yuri D'Elia > Cc: emacs-devel@gnu.org > Date: Sat, 18 Dec 2021 11:43:25 +0100 > > or it didn't set the correct resolution according to the current > fontconfig settings for example, but it does both correctly. > > Why would it change only the weight selection? I don't know. I don't have access to any system where this happens, so I cannot step through the code to see what happens there. You (or someone else) are welcome to do that and see what happens there. Maybe we will then be able to make this less surprising and confusing. > I assumed that when setting the default font (by calling > set-face-attribute with FRAME set to nil) the actual face selection > would be effectively delayed until frame creation time. I guess this is > incorrect - i/e font selection is done immediately? Yes. > Ideally I'd want nil (default). If I do that, it seems to work > correctly. However in such case I'd also need to ensure I call this hook > once, not for every frame (the main reason I didn't bother calling this > in a make-frame hook) and gets slower as I add frames. You could use a simple flag variable for that. > If I use "t" to set the current frame only, I get a completely different > font size: smaller in fact. However, this only holds if I _never_ set > the "default frame". > > If I evaluate instead: > > (set-face-attribute 'default nil ...) > (set-face-attribute 'default t ...) > > where "..." is the same face selection. In such case, setting the > default frame somewhat alters permanently what setting the current frame > will do. The second call to set-face-attribute doesn't give me the > smaller face, instead it gives me the same face twice. > > I'm totally confused as of why this happens. Welcome to the club. The code which selects fonts in Emacs is quite complex and notoriously under-documented. On top of that, we don't have any experts on board who are familiar with that code and can readily answer questions such as this one. The only way to investigate is to step through the code, starting in xfaces.c (where we process set-face-attribute), and following into font.c and fontset.c, where the font selection actually happens.