From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id uCgKAcphjmDjhgAAgWs5BA (envelope-from ) for ; Sun, 02 May 2021 10:24:42 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id wAUMOMlhjmDEXwAAbx9fmQ (envelope-from ) for ; Sun, 02 May 2021 08:24:41 +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 3901020DF0 for ; Sun, 2 May 2021 10:24:41 +0200 (CEST) Received: from localhost ([::1]:47294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ld7P5-0004Vn-75 for larch@yhetil.org; Sun, 02 May 2021 04:24:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ld7OV-0004VV-CK for emacs-orgmode@gnu.org; Sun, 02 May 2021 04:24:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58119) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ld7OV-00074l-44 for emacs-orgmode@gnu.org; Sun, 02 May 2021 04:24:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ld7OU-00064t-VS for emacs-orgmode@gnu.org; Sun, 02 May 2021 04:24: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: Nicolas Goaziou Original-Sender: "Debbugs-submit" Resent-CC: emacs-orgmode@gnu.org Resent-Date: Sun, 02 May 2021 08:24: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: Eli Zaretskii Received: via spool by 48148-submit@debbugs.gnu.org id=B48148.161994382423346 (code B ref 48148); Sun, 02 May 2021 08:24:02 +0000 Received: (at 48148) by debbugs.gnu.org; 2 May 2021 08:23:44 +0000 Received: from localhost ([127.0.0.1]:41430 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ld7OC-00064U-DF for submit@debbugs.gnu.org; Sun, 02 May 2021 04:23:44 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:33359) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ld7O9-00064O-B9 for 48148@debbugs.gnu.org; Sun, 02 May 2021 04:23:43 -0400 X-Originating-IP: 185.131.40.67 Received: from localhost (40-67.ipv4.commingeshautdebit.fr [185.131.40.67]) (Authenticated sender: admin@nicolasgoaziou.fr) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 18C671C0004; Sun, 2 May 2021 08:23:34 +0000 (UTC) From: Nicolas Goaziou References: <87h7jm2es2.wl-shingo.fg8@gmail.com> <83bl9t8vnb.fsf@gnu.org> Date: Sun, 02 May 2021 10:23:34 +0200 In-Reply-To: <83bl9t8vnb.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 02 May 2021 10:03:36 +0300") Message-ID: <87h7jla6ih.fsf@nicolasgoaziou.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: Shingo Tanaka , 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=1619943881; 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=Atu2phnZfIJiEd+aOsZajnYLKvOhNhQ3c7UezBx5gQY=; b=RGZ+YrQ8tkdRmAHdFhnhqPprrzaavFoV1r8avGS4isM0iUmb0BVlFPDAhIuh+OIaKm9icZ Te5nGq4sOVS5dnAqbVKZb2CPVQWZfbwEJhB2/czmDF0SRqGbE4ktmkMtv7efp6c/B0iUaT RhnDGy7w5zKn9Xt3x1v66jLW/6wwwHyGKR/9OU2n/fDUuGP5UfQHxR4stuBV58YiGgZxv2 R3AMoi9iQP/r/jN9iZOLRRR3C8C28xk9urwaAedpWnn2/0byzxbTTiX9Nn3j0k/toHmdvo hiMoMManhcHrDNi6IsFHuourUyxJRxk3qQQhYVHB3oyixLoNcRlzeqHaF5vxMw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1619943881; a=rsa-sha256; cv=none; b=le/aKfHyKjO8m9HetQlZ6Yi8ufLIccB6rXk1615YBzqEoby9HPk7M/DAMs2ZOm0ITkTHSG +48xPUvoWNpXj88mfkOfqSCEj0QGhcSRJ2Mxz0VvDe3t7YFR6qIehHziCeckjW6xo7LcxJ y2409nHCpp2Oe9MOoaUKqonKYDpzNTjh0xNKtexYne6Fh0UR8lABNHhbUhVn27TRDlhfot SXNyZ9YWcEqoTmzdUhJTb+5VKr2N3o0JLOV/Rnka8zFEqqe05F8jfZMJ4PBIsxX0/Sy/Fx vZKuJ1dCaSns3FYbQTU5gU3Gu3WJcMHx37uX+2oKeFzwi0rsV3iiTvYiRvkbyA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=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.46 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=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-Queue-Id: 3901020DF0 X-Spam-Score: -2.46 X-Migadu-Scanner: scn0.migadu.com X-TUID: qonDqPUNBf7U Hello, Eli Zaretskii writes: >> Date: Sun, 02 May 2021 08:52:13 +0900 >> From: Shingo Tanaka >>=20 >> For example, when the title is "=EF=BC=A1=EF=BC=A2=EF=BC=A3=EF=BC=A4=EF= =BC=A5=EF=BC=A6" (each character has width of >> 2), expected title would be like: >>=20 >> =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81 >> =EF=BC=A1=EF=BC=A2=EF=BC=A3=EF=BC=A4=EF=BC= =A5=EF=BC=A6 >> =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81 >>=20 >> However, the reality is: >>=20 >> =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81 >> =EF=BC=A1=EF=BC=A2=EF=BC=A3 >> =EF=BC=A4=EF=BC=A5=EF=BC=A6 >> =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81 >>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 >> This is because it uses `length' to detects the width, which only return= s 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. >>=20 >> Here is a potential patch. >>=20 >> --- 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. Would you mind giving an example about `window-text-pixel-size' usage in this situation? AFAIU, `window-text-pixel-size' returns the size of the window, but I fail to see how it is relevant here. Note that `text-width' in the code above is not related to the width of the window, but is a maximum number of allowed characters on a line. Thank you! Regards, --=20 Nicolas Goaziou