[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#48149: 27.2; Wrong underline width when the line char has a width of
From: |
Rudolf Schlatte |
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin) |
Eli Zaretskii <eliz@gnu.org> writes:
>> Date: Sun, 02 May 2021 10:12:43 +0900
>> From: Shingo Tanaka <shingo.fg8@gmail.com>
>>
>> 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.