From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id +NcfOFVPjmBBXwAAgWs5BA (envelope-from ) for ; Sun, 02 May 2021 09:05:57 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id yDLCM1VPjmAhcQAA1q6Kng (envelope-from ) for ; Sun, 02 May 2021 07:05:57 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 63E671FE7C for ; Sun, 2 May 2021 09:05:57 +0200 (CEST) Received: from localhost ([::1]:59938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ld6Au-0008Kb-3g for larch@yhetil.org; Sun, 02 May 2021 03:05:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ld6A2-0008KR-Kx for emacs-orgmode@gnu.org; Sun, 02 May 2021 03:05:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:57668) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ld6A2-0000SW-DC for emacs-orgmode@gnu.org; Sun, 02 May 2021 03:05:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ld6A2-0004zI-7v for emacs-orgmode@gnu.org; Sun, 02 May 2021 03:05:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: emacs-orgmode@gnu.org Resent-Date: Sun, 02 May 2021 07:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48148 X-GNU-PR-Package: org-mode X-GNU-PR-Keywords: To: Shingo Tanaka Received: via spool by 48148-submit@debbugs.gnu.org id=B48148.161993904419156 (code B ref 48148); Sun, 02 May 2021 07:05:02 +0000 Received: (at 48148) by debbugs.gnu.org; 2 May 2021 07:04:04 +0000 Received: from localhost ([127.0.0.1]:40978 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ld696-0004yu-7m for submit@debbugs.gnu.org; Sun, 02 May 2021 03:04:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43304) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ld693-0004yJ-RN for 48148@debbugs.gnu.org; Sun, 02 May 2021 03:04:02 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57126) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ld68y-0008F6-MW; Sun, 02 May 2021 03:03:56 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1554 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ld68x-0007i3-Of; Sun, 02 May 2021 03:03:56 -0400 Date: Sun, 02 May 2021 10:03:36 +0300 Message-Id: <83bl9t8vnb.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87h7jm2es2.wl-shingo.fg8@gmail.com> (message from Shingo Tanaka on Sun, 02 May 2021 08:52:13 +0900) References: <87h7jm2es2.wl-shingo.fg8@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: emacs-orgmode@gnu.org List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 48148@debbugs.gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1619939157; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=lTSVDC/YbHiVuT+dB7KD0JuauSMGkQeYMagtMTaXHjQ=; b=FYRzuxwcq6UH0JmeoWzLkUDkf2twhaOLCg9X4/sbL9BGVi6HakgA8N62yd798TbkiR5VyZ HDkPCb7aPym4EZvLZytrYGWB9TvSPmleW3MGbsWApU2SCQlzpHY9xqXqJMhmpvk7fYwj5k tK236Z65ZpiM/PsMw0uudM0WfYog+jRGOwwlF7NN+3VBoa6JKZ+Rmgg9PRRfr/wF4ers35 1LjXalRy0aql5pSuom0eXikfIwW57ZI1kKP6W13FK7ew7SgA9qM6c3YfLU09HH4h8vJFgE oW/LU6IncPDLB96p5bQtTXGusqPhswpq6bblub6b2X7W8pKQMTEWFDHihZh0BQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1619939157; a=rsa-sha256; cv=none; b=btguIjRRbMghZ5VdF7JpoIzxtqglskYG+k30XPs9Sb1TIYeFNxz4l6UVLJbJDF0SzFug9D c2i2jgyn/68K1qtS7+gXeU0P5MrF+EMXgL6qZODYW0rjSxC9gSzL8BB9CO878u5DcUho8y a+wT2myBOJ64roeOIi9A/2z1vJpDlztg/BFNCLkyycZRTtvcvedRwbQXdVqfJnWQstDfZ4 RgiYfnr/gkY/ho8MosoEv6KAI3KZS/beNzRIDWcVSGHuVk4f1tQzr4gWa17VuuSx7OpC24 KZAN5GyxvYu+KzjE4k4zGSg8fb4RJ7908of66CnrxJ6MECzGSlAn2VFJxHlyuA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -2.96 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 63E671FE7C X-Spam-Score: -2.96 X-Migadu-Scanner: scn0.migadu.com X-TUID: wdg5hmw5uclD > Date: Sun, 02 May 2021 08:52:13 +0900 > From: Shingo Tanaka > > For example, when the title is "ABCDEF" (each character has width of > 2), expected title would be like: > > ━━━━━━━━━━━━━━━ > ABCDEF > ━━━━━━━━━━━━━━━ > > However, the reality is: > > ━━━━━━━━━━━━━━━ > ABC > DEF > ━━━━━━━━━━━━━━━ > > This is because it uses `length' to detects the width, which only returns the > number of characters (6 in this case) but not the actual width displayed (12 > in this case), and it tries to fill the line with that half width. > `string-width' should be used instead. > > Here is a potential patch. > > --- ox-ascii.el.org 2021-03-26 09:28:44.000000000 +0900 > +++ ox-ascii.el 2021-05-02 08:11:57.657347150 +0900 > @@ -1033,7 +1033,7 @@ > ;; Format TITLE. It may be filled if it is too wide, > ;; that is wider than the two thirds of the total width. > (title-len (min (apply #'max > - (mapcar #'length > + (mapcar #'string-width > (org-split-string > (concat title "\n" subtitle) "\n"))) > (/ (* 2 text-width) 3))) Thanks, but the change you propose will not work reliably on GUI frames, because the actual width of double-width characters on display is not necessarily twice the width of a "normal" character. Especially if this is done in a non-CJK locale, where the default font is likely to be different from the font used for double-width characters. The accurate method of lining up in these cases is to use window-text-pixel-size instead. That function will return the exact width of a string as it will displayed, in pixels, because it uses the same code as the display engine.