From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Rudolf Schlatte Newsgroups: gmane.emacs.bugs Subject: bug#48149: 27.2; Wrong underline width when the line char has a width of 2 Date: Sun, 02 May 2021 10:36:14 +0200 Message-ID: References: <87fsz62b1w.wl-shingo.fg8@gmail.com> <837dkh8uzi.fsf__22492.4155323365$1619940077$gmane$org@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30722"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin) To: 48149@debbugs.gnu.org Cancel-Lock: sha1:A9/Fs2ExA5c5KofSF+d0kMFXOac= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 02 10:41:00 2021 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 1ld7et-0007th-Tk for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 02 May 2021 10:40:59 +0200 Original-Received: from localhost ([::1]:54626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ld7et-0008GL-0U for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 02 May 2021 04:40:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ld7dy-0008Fu-UC; Sun, 02 May 2021 04:40:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58200) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ld7dx-0007XP-Ow; Sun, 02 May 2021 04:40:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ld7dx-0008Ox-Lo; Sun, 02 May 2021 04:40:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87fsz62b1w.wl-shingo.fg8@gmail.com> Resent-From: Rudolf Schlatte Original-Sender: "Debbugs-submit" Resent-CC: emacs-orgmode@gnu.org, bug-gnu-emacs@gnu.org Resent-Date: Sun, 02 May 2021 08:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48149 X-GNU-PR-Package: org-mode,emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.161994475032266 (code B ref -1); Sun, 02 May 2021 08:40:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 2 May 2021 08:39:10 +0000 Original-Received: from localhost ([127.0.0.1]:41510 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ld7d7-0008OL-NG for submit@debbugs.gnu.org; Sun, 02 May 2021 04:39:10 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:55412) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ld7d5-0008OE-Cp for submit@debbugs.gnu.org; Sun, 02 May 2021 04:39:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ld7d5-0007se-3I for bug-gnu-emacs@gnu.org; Sun, 02 May 2021 04:39:07 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]:55592) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ld7d3-000759-8n for bug-gnu-emacs@gnu.org; Sun, 02 May 2021 04:39:06 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1ld7cz-0005lJ-Ah for bug-gnu-emacs@gnu.org; Sun, 02 May 2021 10:39:01 +0200 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=geb-bug-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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:205404 Archived-At: Eli Zaretskii writes: >> Date: Sun, 02 May 2021 10:12:43 +0900 >> From: Shingo Tanaka >> >> When exporting org-mode document to plain text (either ascii/unicode/utf-8) >> with `org-export-dispatch', Emacs inserts lines under headlines, inline >> tasks, table rows and titles of the document, TOC, list of listings, list of >> tables and footnotes. The problem is it inserts too long (double width) line >> when the line character has a width of 2. >> >> Those lines are made of 3 types of characters below (in ox-ascii.el): >> 1) org-ascii-underline >> 2) (if (eq (plist-get info :ascii-charset) 'utf-8) ?─ ?_) >> 3) (if utf8p ?━ ?_) >> >> In case of 1), it correctly takes account of the case in which the character >> has a width of 2 in `org-ascii--build-title', by dividing the line width by >> `(char-width under-char)' (line 700-701), maybe because the character is user >> configurable and its width in unknown. However, in case of 2) and >> 3), maybe because the characters is embedded in the code, it looks like only >> considering the character always has a width of 1. But the reality is >> character ?─ or ?━ can have a width of 2 in the screen displayed with some >> fonts (ex. "Noto Sans Mono CJK JP"), and in that case the line width gets >> doubled of the expected width. >> >> Attached one is a potential patch. The basic concepts are: >> >> a) Do the same in case of 2) and 3) as in case of 1) >> (dividing the line width by `(char-width under-char)', >> assuming `char-width-table' is correctly set) >> >> b) Prefer the longer line width if the width is odd, even in case of 1) >> (adding `(1- (char-width under-char))' to dividend, >> just because it should be more beautiful ;-) ) > > You reported a similar bug already, and I replied there that TRT in > these cases is to use window-text-pixel-size, which will automatically > account for the actual width on display of any characters and any > fonts specified for displaying them. char-width is an approximation, > and is accurate only on TTY frames. Isn't the primary result of org-export a plain (UTF-8) text file, instead of an emacs buffer to be displayed in a GUI or TTY frame? If so, maybe the criterion for correctness should be that "cat filename.txt" looks as expected in a terminal, even if opening that file in Emacs shows lines of different lengths due to variable-pitch faces etc.