From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#64013: [PATCH] macfont.m: Fix values for font widths and weights on macOS Date: Mon, 12 Jun 2023 21:31:11 +0800 Message-ID: <87zg54hko0.fsf@yahoo.com> References: Reply-To: Po Lu Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13946"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 64013@debbugs.gnu.org, YAMAMOTO Mitsuharu To: Stanislav Yaglo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 12 15:32:25 2023 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 1q8hei-0003UA-PB for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 12 Jun 2023 15:32:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q8heW-0005gp-8C; Mon, 12 Jun 2023 09:32:14 -0400 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 1q8heN-0005Yx-1G for bug-gnu-emacs@gnu.org; Mon, 12 Jun 2023 09:32:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q8heM-0004S5-Oo for bug-gnu-emacs@gnu.org; Mon, 12 Jun 2023 09:32:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q8heM-0003C8-Ey for bug-gnu-emacs@gnu.org; Mon, 12 Jun 2023 09:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 12 Jun 2023 13:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64013 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 64013-submit@debbugs.gnu.org id=B64013.168657668812239 (code B ref 64013); Mon, 12 Jun 2023 13:32:02 +0000 Original-Received: (at 64013) by debbugs.gnu.org; 12 Jun 2023 13:31:28 +0000 Original-Received: from localhost ([127.0.0.1]:39208 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q8hdn-0003BJ-ST for submit@debbugs.gnu.org; Mon, 12 Jun 2023 09:31:28 -0400 Original-Received: from sonic310-23.consmr.mail.ne1.yahoo.com ([66.163.186.204]:40031) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q8hdl-0003B4-B3 for 64013@debbugs.gnu.org; Mon, 12 Jun 2023 09:31:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1686576679; bh=OLrpIm+1fHra9M34D79Cvo9YLCx+PRwxK53nGoUP/24=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=r9d3/Ut4If/gWPeN9t4Xmn29askIe+pTMTdgbdMWsDqLg/kweSGqmlQzBzp6EiYOm7oymsqTn1A3PrsIgacwIkTgCKS5lLvLV5ARhevpjen+TgA+058sC2+W5WyLFUjn98qUPqYkWzravTlgx1/u0nVin97Ot8qBVd1sjKwnmZaZiibS4bhQj2qLLMghbJ0xoX3VE5voR5YMJOKsNCqZeHTRajth2ljOBS+DDNGgLlEk4GOooeFBjAEyi06PSCFz0+954Yd9EvPmyiiT2Y6hkBrH4XAw74dg/JdrwWFfPTQa8/2g/68vx/lKZBTFpjP3+QNx+3S3otkhH2dd23daTQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1686576679; bh=GS6b77GiX0zRw8njEKDI1y7npzMH3DmDHoBCIg9264A=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=NWnCqbsKroKVv2xQIfYhP2FKdz5gTSg8/ptxCTR4twj34HK4alqw72UR56aRYINRIuL54XSA+TDb6HAgLpMAzAeZ8HwSQ1KRfmnmcaVe9oRaVMcqhr9U5SS7/8kUYKf/qvX6BO1/3f3EO7vvqOU+a61JkkC9HNB27ouENoi3fp7Is27ObK4/fr/OJ/oStBftT/d7xEr5MOgDBFY799fGjFEKIzNxk69gm9gu6ZLVq5vNeJKUEDO6FfRT0okcEBaDIwVXdMnvuCpr3EomCMJ8Ko+RjPy2aGQSiuTJFsQ+8QsL2kT7duFPpO4Kb3O5gRQbnNg7K5mmFWux3phJA7cjXw== X-YMail-OSG: 0lkGsp8VM1k3vaq8vKfKyit_2sUEFmxTTimkFCVckaD0Z06U_Ml2nU7Tz2LnWNO 69Z7nUmOEFnqX64kYq944WUG7UlD5ciiZWh.xxfUMGmoDQcHYZh4SFiRaEeRvnqfNKcfck6TnqhQ 3JSznNnUBDa6bPpulmkS8WqvmgbRaXwIcDkGlVE2zlTneUtdn40OyUbMc7Avv_13f0vzrIi9c1O6 h.a.ssYJzrI8SX4I0oIxQ36b0kUWYNpD3yHYEQ_Xu8P2CdZBHwXDJF8hKP6h7AejPe7ad4sJp376 9W3DBextoalnAfLQ9i743l2A1fFiongnj5HNR2VKAdwAncmolTtvs8326whZQ7wqFMwHX8UsNQDi se6A0O8PXWT4CIzTsO3LHCFNKBUXDZnRTeHk68hruDprr7zFCubJaSNgL1hHTZunGXZthlwDH8op xvcdq8wGxm9CUeDsE.BHe5NDATkNkBwR9hWcuemcJ0yW7vTN3ab4N0NMXUZMZATw.KMEaJEmXo9S Dpszi6axqrjMSDrUlnYnYj9p_5CCu_1rtwfzJW2Ph.CUwluyUE7fL2jzSQTDVcteXbMyCSl6zQOW nkCFUYuYpkbkgJTGeYlg_WO2zQWLAzmWv2aXE6YyQCnknxrkylUYQJEQfjOtGofn93P6YhZzDeuT qCjrLruBO2UZd9in7wNbUVrBRWIzCdPxcqw3E803Q7ps.e7i6pJbH_pN1cdNd2P0CyKFu28vkKXe 2NEHVL1Hql3nfWUjtTJZ051jI_hUyHOf6rzrd6OwC5LKtPmjksbZQuYAi4mEyHA8Sqr_XKNCkbGz 2Ssd5otlMsrW7LwApewPF7N3CnlrrHuKNQYiKgAN0I X-Sonic-MF: X-Sonic-ID: f4e514da-936c-419a-bdfc-5328146c1568 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.ne1.yahoo.com with HTTP; Mon, 12 Jun 2023 13:31:19 +0000 Original-Received: by hermes--production-sg3-748897c457-ncjl6 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID b34137f3662febe749256e4d2468fb30; Mon, 12 Jun 2023 13:31:16 +0000 (UTC) In-Reply-To: (Stanislav Yaglo's message of "Mon, 12 Jun 2023 11:42:53 -0000") X-Mailer: WebService/1.1.21516 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo 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:263272 Archived-At: Stanislav Yaglo writes: > Hi everyone, > > 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=3Dse= mi-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 potenti= ally handy for in-between values, but the problem itself is that the > corresponding values are not correct for the majority of fonts, for examp= le, 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 th= e 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 t= hat are handled currently =E2=80=94 from 0 to 1, and they are handled as > linear font values from 100 to 200, which isn't correct either. For conde= nsed fonts, kCTFontWidthTrait is negative, which is not accounted for, > and the slope is linear only from -0.4 (50, ultra-condensed) until 0.2 (1= 25, 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 t= hink 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 pat= ch for this later to avoid code duplication and potential issues in the > future as with the current 80/100 problem mentioned above. > > Kind regards, > Stanislav Yaglo Thanks. Have you signed copyright papers for this change? I've also copied in YAMAMOTO Mitsuharu , who might have additional comments on this code.