From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stanislav Yaglo 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: Fri, 8 Sep 2023 10:34:08 +0100 Message-ID: <132F9964-D44D-4E49-80DD-F8939744A0A2@me.com> References: <87zg54hko0.fsf@yahoo.com> Reply-To: Stanislav Yaglo Mime-Version: 1.0 (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="31870"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64013@debbugs.gnu.org, YAMAMOTO Mitsuharu To: Po Lu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 08 14:45:06 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 1qearB-00085z-Ji for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 08 Sep 2023 14:45:05 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeaqj-0002Er-7z; Fri, 08 Sep 2023 08:44:37 -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 1qeaqJ-00029B-9U for bug-gnu-emacs@gnu.org; Fri, 08 Sep 2023 08:44:21 -0400 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 1qeaq8-0005qB-IV for bug-gnu-emacs@gnu.org; Fri, 08 Sep 2023 08:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qeaqA-0003nn-PJ for bug-gnu-emacs@gnu.org; Fri, 08 Sep 2023 08:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stanislav Yaglo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 08 Sep 2023 12:44: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 pending Original-Received: via spool by 64013-submit@debbugs.gnu.org id=B64013.169417700714552 (code B ref 64013); Fri, 08 Sep 2023 12:44:02 +0000 Original-Received: (at 64013) by debbugs.gnu.org; 8 Sep 2023 12:43:27 +0000 Original-Received: from localhost ([127.0.0.1]:42526 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeapa-0003mX-6k for submit@debbugs.gnu.org; Fri, 08 Sep 2023 08:43:26 -0400 Original-Received: from st43p00im-ztdg10073201.me.com ([17.58.63.177]:41426) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeXsi-0001rn-Vb for 64013@debbugs.gnu.org; Fri, 08 Sep 2023 05:34:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1694165661; bh=Ge61LBJBzD0oyhLcGc+MQkRZoHIfFP0YCbhI6YG8w8k=; h=Content-Type:From:Mime-Version:Subject:Date:Message-Id:To; b=oWm2+NZG5fGJ3pld+tsFZyTchwLU0/c38BxWv6CCsdv7/MDe5QtMRuhSBGLdbfnBq Fq3RDcJZ7zHymgQ933MD7lopag6xf9U3dFiEqo3I6X7cwVY+eZxbqWCe6+mqrkv0E+ 9gdGK80I0CN4L2ntLijyGZky4EhrFZx84TtY3NBnCZ5ajPMLKeqKnahtQgL9Z5BRoo dtRooNd1bRxyh+/m+vVW2auJvaQ4ZOl322Vb8tlMjqy0evmN5i5P3qN/I2hzHDOiwk 66x2BjU6cyGN1wuelD/A7PruJJA3LgnsN2B54ANpCPP6pAO3r2E0w0rSqTRGhD8XWp DxOHPMGo+Xzxg== Original-Received: from smtpclient.apple (st43p00im-dlb-asmtp-mailmevip.me.com [17.42.251.41]) by st43p00im-ztdg10073201.me.com (Postfix) with ESMTPSA id DA2C49A02CE; Fri, 8 Sep 2023 09:34:20 +0000 (UTC) In-Reply-To: <87zg54hko0.fsf@yahoo.com> X-Mailer: iPhone Mail (20D67) X-Proofpoint-GUID: aZmq43wU7EXMZt6MBo48j-9cczsK4qq0 X-Proofpoint-ORIG-GUID: aZmq43wU7EXMZt6MBo48j-9cczsK4qq0 X-Proofpoint-Virus-Version: vendor=fsecure engine=1.1.170-22c6f66c430a71ce266a39bfe25bc2903e8d5c8f:6.0.591, 18.0.572, 17.11.176.26.0000000 definitions=2023-07-31_02:2023-07-31_02, 2020-02-14_11, 2023-05-22_02 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2309080088 X-Mailman-Approved-At: Fri, 08 Sep 2023 08:43:23 -0400 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:269769 Archived-At: Hi, Update - I=E2=80=99ve sorted the copyright assignment docs, so everything sh= ould be good to move forward. Kind regards, Stanislav Yaglo > On 12 Jun 2023, at 14:31, Po Lu wrote: >=20 > =EF=BB=BFStanislav Yaglo writes: >=20 >> Hi everyone, >>=20 >> 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. >>=20 >> 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. A= s you can see here, it won't work as we have 50 followed by 87.5 and then >> (a lower) 80, and then 140: >>=20 >> {-0.4, 50}, /* light */ >> {-0.24, 87.5}, /* (semi-light + normal) / 2 */ >> {0, 80}, /* normal */ >> {0.24, 140}, /* (semi-bold + normal) / 2 */ >>=20 >> 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: >>=20 >> {-0.4, 50}, /* light */ >> {-0.24, 87.5}, /* (semi-light + normal) / 2 */ >> {0, 100}, /* normal */ >> {0.24, 140}, /* (semi-bold + normal) / 2 */ >>=20 >> 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. >>=20 >> I've included all values that are listed in font.c for explicitness even i= f 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. >>=20 >> Kind regards, >> Stanislav Yaglo >=20 > Thanks. Have you signed copyright papers for this change? > I've also copied in YAMAMOTO Mitsuharu , > who might have additional comments on this code.