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.bugs Subject: bug#64013: [PATCH] macfont.m: Fix values for font widths and weights on macOS Date: Thu, 01 Feb 2024 12:21:40 +0200 Message-ID: <86y1c4zdqj.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10705"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64013-done@debbugs.gnu.org To: Stanislav Yaglo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 01 11:23:26 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1rVUE9-0002Zh-Jb for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Feb 2024 11:23:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVUDi-0000Zh-7e; Thu, 01 Feb 2024 05:22:58 -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 1rVUDc-0000U2-JG for bug-gnu-emacs@gnu.org; Thu, 01 Feb 2024 05:22:53 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rVUDc-0002o7-AW for bug-gnu-emacs@gnu.org; Thu, 01 Feb 2024 05:22:52 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rVUDm-0005nU-0B for bug-gnu-emacs@gnu.org; Thu, 01 Feb 2024 05:23:02 -0500 Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Feb 2024 10:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 64013 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Mail-Followup-To: 64013@debbugs.gnu.org, eliz@gnu.org, yaglo@me.com Original-Received: via spool by 64013-done@debbugs.gnu.org id=D64013.170678292322212 (code D ref 64013); Thu, 01 Feb 2024 10:23:01 +0000 Original-Received: (at 64013-done) by debbugs.gnu.org; 1 Feb 2024 10:22:03 +0000 Original-Received: from localhost ([127.0.0.1]:40276 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rVUCp-0005mB-2o for submit@debbugs.gnu.org; Thu, 01 Feb 2024 05:22:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33494) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rVUCm-0005le-CF for 64013-done@debbugs.gnu.org; Thu, 01 Feb 2024 05:22:01 -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 1rVUCW-0002ax-Qt; Thu, 01 Feb 2024 05:21:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=ye01++y+h7jlgFGHve+ThTgnqFdgWdF3+i7NGUBQH58=; b=TKz58HcC/cD6sgbmz7Jv jrHPBXtK8Ka6anYRHXJRbPQo5wJbffq+LuBiBjJjRhcO5zSOS9Wbb+C73+e20Wzi4q7S/IcdahaMr ga72JVZFUWn0f5fJFnd1S3uhzSzpjgjAWnpTULEGAE655CmTUvCdIM/w2k82J9L96dSswYyarp/lw hlvytF3vNu/cadryMzl5JvGLWBI+OT5vj3p9d+Kp/9OaiH0i9j+ZHTUkXnH4GLOGg7RDc44nYU1of m2CX3bGpgrVTc85j/LFRVDMsWmPqMmGKWzRv3TN4NUPwdgJwkWKb3fC/pWrRvdBO7oRSeUuGjOq9W 6qC1089uLVtLXg==; In-Reply-To: (message from Stanislav Yaglo on Mon, 12 Jun 2023 11:42:53 -0000) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:279276 Archived-At: > From: Stanislav Yaglo > Date: Mon, 12 Jun 2023 11:42:53 -0000 > > Currently, on macOS, font weights are not handled correctly, which causes > Emacs to choose different font weights and widths than what you request. As > one example, if you want to choose "Cascadia Code:weight=semi-light", you > will get Cascadia Code Light instead. Same for font widths, what you specify > is not always what you get. > > There's some interpolation going on which I didn't remove as it's potentially > handy for in-between values, but the problem itself is that the corresponding > values are not correct for the majority of fonts, for example, > kCTFontWeightTrait is specified as -0.24 corresponding to 87.5 , but in > reality, it is usually 50 (light), and the same for the other values. As you > can see here, it won't work as we have 50 followed by 87.5 and then (a lower) > 80, and then 140: > > {-0.4, 50}, /* light */ > {-0.24, 87.5}, /* (semi-light + normal) / 2 */ > {0, 80}, /* normal */ > {0.24, 140}, /* (semi-bold + normal) / 2 */ > > It probably is a typo, as in the second (duplicate) table of values in the > code, 100 is treated as normal instead of 80, which also isn't correct, as > 100 is medium, not normal: > > {-0.4, 50}, /* light */ > {-0.24, 87.5}, /* (semi-light + normal) / 2 */ > {0, 100}, /* normal */ > {0.24, 140}, /* (semi-bold + normal) / 2 */ > > For font widths, there's only two kCTFontWidthTrait values in the range that > are handled currently — from 0 to 1, and they are handled as linear font > values from 100 to 200, which isn't correct either. For condensed fonts, > kCTFontWidthTrait is negative, which is not accounted for, and the slope is > linear only from -0.4 (50, ultra-condensed) until 0.2 (125, expanded), and > from there until ultra-expanded is much steeper. > > I've included all values that are listed in font.c for explicitness even if > some values can be calculated with the code that interpolates the values. > Also, I haven't refactored the duplication of the structs and code as I think > this is a different issue and should be done separately to keep this patch on > point of the issue being fixed, and I will probably submit a patch for this > later to avoid code duplication and potential issues in the future as with > the current 80/100 problem mentioned above. Thanks, installed on the master branch, and closing the bug.