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#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'? Date: Tue, 13 Sep 2022 14:19:01 +0300 Message-ID: <834jxb5xp6.fsf@gnu.org> References: <87v8pw1xyo.fsf@localhost> <83a678d5w6.fsf@gnu.org> <878rmr25tk.fsf@localhost> <83czc3bvbg.fsf@gnu.org> <87y1urybt6.fsf@localhost> <837d2bbr2s.fsf@gnu.org> <87edwjy77h.fsf@localhost> <831qsjboy0.fsf@gnu.org> <87v8puw945.fsf@localhost> <838rmq9rfr.fsf@gnu.org> <837d2a9qcu.fsf@gnu.org> <875yhtw3ed.fsf@localhost> <83ills9741.fsf@gnu.org> <878rmoujyx.fsf@localhost> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4301"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 57693@debbugs.gnu.org To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 13 13:20:40 2022 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 1oY3y4-0000x9-Ju for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 13 Sep 2022 13:20:40 +0200 Original-Received: from localhost ([::1]:51640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oY3y3-0001Kp-Ee for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 13 Sep 2022 07:20:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oY3xT-0001KR-2n for bug-gnu-emacs@gnu.org; Tue, 13 Sep 2022 07:20:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60342) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oY3xS-0006SX-Pd for bug-gnu-emacs@gnu.org; Tue, 13 Sep 2022 07:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oY3xS-0002MJ-6m for bug-gnu-emacs@gnu.org; Tue, 13 Sep 2022 07:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 13 Sep 2022 11:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57693 X-GNU-PR-Package: emacs Original-Received: via spool by 57693-submit@debbugs.gnu.org id=B57693.16630679799027 (code B ref 57693); Tue, 13 Sep 2022 11:20:02 +0000 Original-Received: (at 57693) by debbugs.gnu.org; 13 Sep 2022 11:19:39 +0000 Original-Received: from localhost ([127.0.0.1]:49040 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oY3x5-0002LX-Bg for submit@debbugs.gnu.org; Tue, 13 Sep 2022 07:19:39 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:48538) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oY3x0-0002LF-OJ for 57693@debbugs.gnu.org; Tue, 13 Sep 2022 07:19:38 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:53432) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oY3wv-0006PG-HY; Tue, 13 Sep 2022 07:19:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=Cw4z3cet3ZL9hZNvaBVPABdYpX8BdzOde30qY1ssrVI=; b=jZsnl3+xQiid VcBrqKSyrpQW2rPKL8fyYYNlg5xbRpj0GQ4pbBhTmRZElO5vTN8nnwhW/vflwSmmLlZUA4ofXdl11 BrM850FFxBEC0c6DsUfheGYhRSAyZDCVfhSHYJ27uYNbTJtxfnOMNRqG5uzVWk5FDK7suJUaQNxGz bAXUMaNdP+pnSYQfZ10JBEinat8zagbGVwYtlIH1Ayq1M/LTlefUAR9YDwtdTarhtFTlrvuxoWAUm m5Zv8MucoXqGTVnheVHw3+YSmMa8ukvqI5kW3qAvxl7kM3UNA/px6icgh9b/1/+WDxWoRHlnIV2KM ahykIqmhUPtVIIeuYoidaA==; Original-Received: from [87.69.77.57] (port=3454 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oY3wf-0001FZ-Qp; Tue, 13 Sep 2022 07:19:23 -0400 In-Reply-To: <878rmoujyx.fsf@localhost> (message from Ihor Radchenko on Tue, 13 Sep 2022 09:44:06 +0800) 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" Xref: news.gmane.io gmane.emacs.bugs:242336 Archived-At: > From: Ihor Radchenko > Cc: 57693@debbugs.gnu.org > Date: Tue, 13 Sep 2022 09:44:06 +0800 > > Eli Zaretskii writes: > > > If the terminal's encoding is UTF-8, and it doesn't support the method > > we use to query about individual glyphs, char-displayable-p may return > > non-nil when the character cannot be displayed, i.e. will show as an > > empty box or something. Otherwise, char-displayable-p does provide > > the correct answer for TTY frames. > > Do I understand correctly that: > 1. `font-at' is not sufficient for terminals, and we also need to use > `char-displayable-p' > 2. `char-displayable-p' works on many terminals but may be inaccurate in some More or less. More accurately: . font-at is not useful on text-mode frames . char-displayable-p, when invoked on text-mode frames, in most cases reports only whether the character can be safely encoded by terminal-coding-system . if terminal-coding-system is UTF-8, char-displayable-p will generally trivially return non-nil, unless the terminal supports queries about glyphs that it has for specific characters . the only terminal I know of that supports the above queries is the Linux console, which I think is not very popular among Emacs users . for terminals that do support such queries, you can use this: (internal-char-font nil CHAR) which will return a positive number if CHAR can be displayed, negative number if it cannot, or nil if the query is not supported. So an efficient method of testing this for terminal would be: . if terminal-coding-system is UTF-8, call internal-char-font to see if the character is supported, and if it returns a number, consider the character supported if the number is positive, not supported otherwise . otherwise, if terminal-coding-system is UTF-8, consider character supported (and pray) . otherwise call char-displayable-p and judge by its value This is more efficient than calling char-displayable-p because I expect most terminals these days to use UTF-8 encoding, and for them the above is optimized.