From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "yaglo@me.com" 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 14:28:12 +0000 Message-ID: References: <87zg54hko0.fsf@yahoo.com> Reply-To: "yaglo@me.com" Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_LO2P265MB06714CB2E2413D7A7CA31576F454ALO2P265MB0671GBRP_" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2854"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "64013@debbugs.gnu.org" <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 Mon Jun 12 18:10:19 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 1q8k7X-0000a8-3v for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 12 Jun 2023 18:10:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q8k7N-0006oF-P2; Mon, 12 Jun 2023 12:10:13 -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 1q8k7H-0006nt-Al for bug-gnu-emacs@gnu.org; Mon, 12 Jun 2023 12:10: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 1q8k7G-00033H-VU for bug-gnu-emacs@gnu.org; Mon, 12 Jun 2023 12:10:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q8k7G-0007ro-Pa for bug-gnu-emacs@gnu.org; Mon, 12 Jun 2023 12:10:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "yaglo@me.com" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 12 Jun 2023 16:10: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.168658616430162 (code B ref 64013); Mon, 12 Jun 2023 16:10:02 +0000 Original-Received: (at 64013) by debbugs.gnu.org; 12 Jun 2023 16:09:24 +0000 Original-Received: from localhost ([127.0.0.1]:40407 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q8k6c-0007qN-5U for submit@debbugs.gnu.org; Mon, 12 Jun 2023 12:09:24 -0400 Original-Received: from ci74p00im-qukt09081701.me.com ([17.57.156.6]:64169) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q8iWs-0004wv-5b for 64013@debbugs.gnu.org; Mon, 12 Jun 2023 10:28:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1686580096; bh=q8asRcWq4ZbANpl8EUG1tCcw4HU0BgKkwWpStbpIWEg=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=JzbfQWOiTYNFyBkO4RokiNrKVJ8xyymyfeK3G1PPqzBbNbceBrziV48dLuXNBxJp+ VetPH03CSRlf5W2XQFGTzVKjU3Sdq++VR9I/71696S2ml5f9x2XjQLJ9bWtBpSCt3+ QNosDcPoEuHu8k4rlMlHvZagL/ERvHED909hk3NbFewdX4+/kul/cUuJ37fpxe3dhr yKUD+NeNl4XgLLyNianXQu0mOK+pHiizbOsx+NS1aHM1vArcuqxHZlvi9+f8HmTJd0 bG6YBVpMrV0CU4Ar1aVBoXPgGOjlWbTCwa8BgXJTkSkVbs6Bzx12mjl85ACEbHW4bG yFCmw8Of0TGsw== Original-Received: from LO2P265MB0671.GBRP265.PROD.OUTLOOK.COM (ci77p00im-dlb-asmtp-mailmevip.me.com [17.57.156.26]) by ci74p00im-qukt09081701.me.com (Postfix) with ESMTPSA id 2FC4D46C01F1; Mon, 12 Jun 2023 14:28:15 +0000 (UTC) Thread-Topic: bug#64013: [PATCH] macfont.m: Fix values for font widths and weights on macOS Thread-Index: AWVkNDQ0fFr1+qOSU2g4iFLGxWN8pmVkNDQ0ZmYwazTiE7gnMw== X-MS-Exchange-MessageSentRepresentingType: 1 In-Reply-To: <87zg54hko0.fsf@yahoo.com> Accept-Language: en-US Content-Language: en-GB X-MS-Exchange-Organization-SCL: -1 X-MS-Exchange-Organization-RecordReviewCfmType: 0 X-Proofpoint-GUID: hAAhIyDbJpJUwaeLBiqw_7ePvuN24Ybm X-Proofpoint-ORIG-GUID: hAAhIyDbJpJUwaeLBiqw_7ePvuN24Ybm X-Proofpoint-Virus-Version: vendor=fsecure engine=1.1.170-22c6f66c430a71ce266a39bfe25bc2903e8d5c8f:6.0.425, 18.0.572, 17.11.62.513.0000000 definitions=2022-01-11_01:2022-01-11_01, 2020-02-14_11, 2021-12-02_01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 suspectscore=0 clxscore=1011 malwarescore=0 mlxlogscore=999 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2306120124 X-Mailman-Approved-At: Mon, 12 Jun 2023 12:09:20 -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:263286 Archived-At: --_000_LO2P265MB06714CB2E2413D7A7CA31576F454ALO2P265MB0671GBRP_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable I=92m in the process of sorting the paperwork with my employer as well. I w= ill send an update to this thread when it=92s confirmed and the copyright p= apers have been signed. Kind regards, Stanislav Yaglo ________________________________ From: bug-gnu-emacs-bounces+yaglo=3Dme.com@gnu.org on behalf of Po Lu via Bug reports for GNU Emacs, th= e Swiss army knife of text editors Sent: Monday, June 12, 2023 2:31:11 PM To: Stanislav Yaglo Cc: 64013@debbugs.gnu.org <64013@debbugs.gnu.org>; YAMAMOTO Mitsuharu Subject: bug#64013: [PATCH] macfont.m: Fix values for font widths and weigh= ts on macOS 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, a= s > 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 =97 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. --_000_LO2P265MB06714CB2E2413D7A7CA31576F454ALO2P265MB0671GBRP_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable
I=92m in the process of sorting the paperwork with my empl= oyer as well. I will send an update to this thread when it=92s confirmed an= d the copyright papers have been signed.

Kind regards,
Stanislav Yaglo

From: bug-gnu-emacs-bounces= +yaglo=3Dme.com@gnu.org <bug-gnu-emacs-bounces+yaglo=3Dme.com@gnu.org>= ; on behalf of Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors <bug-gnu-emacs@gnu.org>
Sent: Monday, June 12, 2023 2:31:11 PM
To: Stanislav Yaglo <yaglo@me.com>
Cc: 64013@debbugs.gnu.org <64013@debbugs.gnu.org>; YAMAMOTO Mi= tsuharu <mituharu@math.s.chiba-u.ac.jp>
Subject: bug#64013: [PATCH] macfont.m: Fix values for font widths an= d weights on macOS
 
Stanislav Yaglo <yaglo@me.com> writes:

> Hi everyone,
>
> Currently, on macOS, font weights are not handled correctly, which cau= ses Emacs to choose different font weights and widths than what you
> request. As one example, if you want to choose "Cascadia Code:wei= ght=3Dsemi-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 pote= ntially handy for in-between values, but the problem itself is that the
> corresponding values are not correct for the majority of fonts, for ex= ample, kCTFontWeightTrait is specified as -0.24 corresponding to 87.5 , but=
> in reality, it is usually 50 (light), and the same for the other value= s. As you can see here, it won't work as we have 50 followed by 87.5 and th= en
> (a lower) 80, and then 140:
>
> {-0.4, 50},      /* light */
> {-0.24, 87.5},   /* (semi-light + normal) / 2 */
> {0, 80},         /* normal */<= br> > {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 rang= e that are handled currently =97 from 0 to 1, and they are handled as
> linear font values from 100 to 200, which isn't correct either. For co= ndensed 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 ev= en if some values can be calculated with the code that interpolates the val= ues.
> 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 thi= s
> 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<= br> > 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 <mituharu@math.s.chiba-u.ac.jp>= ;,
who might have additional comments on this code.



--_000_LO2P265MB06714CB2E2413D7A7CA31576F454ALO2P265MB0671GBRP_--