From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Steve Molitor Newsgroups: gmane.emacs.devel Subject: Re: How to use "smart kerning" font features in Emacs using composition-function-table Date: Sun, 26 Nov 2023 14:42:36 -0600 Message-ID: References: <83ttp89zbk.fsf@gnu.org> <83il5o9so6.fsf@gnu.org> 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="16499"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 26 21:43:11 2023 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 1r7LyB-00046p-34 for ged-emacs-devel@m.gmane-mx.org; Sun, 26 Nov 2023 21:43:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7Lxv-0008PT-NF; Sun, 26 Nov 2023 15:42:55 -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 1r7Lxu-0008Nv-5L for emacs-devel@gnu.org; Sun, 26 Nov 2023 15:42:54 -0500 Original-Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r7Lxq-0007f6-Go; Sun, 26 Nov 2023 15:42:52 -0500 Original-Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-6d64c1155a8so2447409a34.2; Sun, 26 Nov 2023 12:42:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701031368; x=1701636168; darn=gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ZvXAkxntoSgl9WLkUzbhTSQlDW5XmDeXROxznk7sPCw=; b=TveeW1Bw9mUAA3B//wt1SJz14JFfCAktd9VBUV6EDTwRJnlm6TX1Y+IL9igdP3mVGf FGvZNO06OSQrUKDruoOCTfdpNSEzdX5jb1vaMfpzWhvNTlgag1hKxHAgvxpG3KqySYk9 d4gIdbN8yFjFkYzmf8EAC9NmFUbhcGfKAFPjKHtdk8XveMueCeDv7IZ+CKmjzLpwRUYm N1ELkFD9ztpLGAkUhpgtSh4HSMBZ4/1DxbiuB3+HFvhMgYp4i2759iHsyiDefUE5ok2I FRPSc1YkZ1hT6uZ6mh3dObxOMGO4AnYckEjzJILwbs83sQoB9JPLsvhS9MKh9h+qERdd /i5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701031368; x=1701636168; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZvXAkxntoSgl9WLkUzbhTSQlDW5XmDeXROxznk7sPCw=; b=NpEbdhSBMMgi3lQoUaNjG7y1fLovxKgLkdOZKosfQeRwZmgc1B287t4NXCi8tT+L2Z yA093KR8tUfQhUTzZgjNguIQ6nvZhGOiw5ciriptn03r1c2jL1iVlfbwZ3TzlqWODzFF TAc1itf/mpzc9rK9dm1IUNVC/a9PHOlmVkwl7ObSp/0hwfs4IkUrQh/52n+5rkZexKRC pQMwJOOP25U8nLI43hGdu9z0/m81fcSX0wSTsDuah5NdvnZHeiYTPwd8+0weXFJZy8Cs 5HBgPVxe4/zO9x2egZ0tv8D8Y0M7AQ86Hnc4+uyKENeoicDWxtmj9zuh3nsZ5zMdRp9f GkhQ== X-Gm-Message-State: AOJu0Yz4xq/8wwsabsGSyUGeUoTcN9KTChnkZTN/EX6XnpqsKmcIPtIg y5UVgiu85Y9mFkrF39oBCsqBoCaVzE2HA2zMCdOnNI7sIpc= X-Google-Smtp-Source: AGHT+IF4EQ/9WuMvfebHQMtcH1yRLADJP7nCfKFv+2+iXy9A8h+IZubaBuwc5v93ihYzQhRl8mxsLLEqfStnlKg6qm4= X-Received: by 2002:a05:6830:1309:b0:6d8:28d1:755e with SMTP id p9-20020a056830130900b006d828d1755emr801539otq.5.1701031367929; Sun, 26 Nov 2023 12:42:47 -0800 (PST) In-Reply-To: <83il5o9so6.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::331; envelope-from=stevemolitor@gmail.com; helo=mail-ot1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:313253 Archived-At: > Do you really need the space character there? What happens if you omit > it? If I type: x mm Then the second "m" is supposed to get shifted away from the first m. If I take away the space character that stops working. Commit Mono looks at 3 character sequences to do the kerning. > And what about '?' and '!'? Commit Mono doesn't seem to take them into account when kerning. Other fonts like Github's Monaspace might, however. For ligature support, I do need something like this for Commit Mono: (set-char-table-range composition-function-table t `([" [,-.:;A-Z_a-z><=3D!&|+-?/\\]+" 0 font-shape-gstring])) (I'm probably missing some characters but common ligatures and the kerning work. I could finesse it to support mode-specific ligatures.) > Character composition in Emacs was never meant to be used for ASCII > characters, nor, more generally, for a significant fraction of buffer > text, except in several scripts (such as Arabic) where all the text > must be shaped to be legible. Does performance suffer a lot in those languages, like Arabic? Thanks again for the responses, I appreciate it. I have more understanding of how character composition works in Emacs now. On Sun, Nov 26, 2023 at 2:16=E2=80=AFPM Eli Zaretskii wrote: > > > From: Steve Molitor > > Date: Sun, 26 Nov 2023 13:49:13 -0600 > > Cc: emacs-devel@gnu.org > > > > Thanks. This indeed does work (matching against the characters Commit > > Mono applies its kerning effect to): > > > > (set-char-table-range > > composition-function-table > > t > > `(["[ ,-.:;A-Z_a-z]+" 0 font-shape-gstring])) > > Do you really need the space character there? What happens if you > omit it? > > And what about '?' and '!'? > > > > But -- and it's a very significant "but" -- displaying text via the > > > shaping engine is expensive -- it involves calls from the display > > > engine to Lisp, which then calls back into C. So rules that match any > > > sequence of ASCII letters will slow down redisplay of almost any text > > > in Emacs. This is why Emacs by default doesn't use the text-shaping > > > engine except for scripts that cannot be displayed without non-trivia= l > > > character compositions. > > > > Which scripts use the text-shaping engine? > > Arabic, Korean (Hangul), various Indian scripts (Devanagar, Bengali, > Gurmukhi), and some others. Grep for composition-function-table in > lisp/language/*.el, and you will see them all. > > Typically, only specific sequences of codepoints are composed, with > rare exceptions, even if a script needs compositions. This is again > for performance reasons. > > > Is it possible to optionally use the text-shaping engine and bypass > > Lisp in say the "English" script? > > No, not the way character composition was designed and implemented in > Emacs. Character composition in Emacs was never meant to be used for > ASCII characters, nor, more generally, for a significant fraction of > buffer text, except in several scripts (such as Arabic) where all the > text must be shaped to be legible. The calls to Lisp are so that > complex logic of composition and shaping required by some scripts > could be easily implemented and maintained.