From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#64420: string-width of =?UTF-8?Q?=E2=80=A6?= is 2 in CJK environments Date: Fri, 7 Jul 2023 05:13:50 +0300 Message-ID: <39c8c0b0-070d-88c0-f074-a878a74ef780@gutov.dev> References: <961e5083-ccf3-9d39-175d-5c5957130d50@gutov.dev> <83cz1ao3x0.fsf@gnu.org> <83a5weo2dz.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27438"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cc: 64420@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 07 04:15:21 2023 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 1qHb0C-0006wA-AH for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 Jul 2023 04:15:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qHazx-0005BA-NY; Thu, 06 Jul 2023 22:15:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qHazv-0005Ax-0o for bug-gnu-emacs@gnu.org; Thu, 06 Jul 2023 22:15:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qHazu-0000Mq-P1 for bug-gnu-emacs@gnu.org; Thu, 06 Jul 2023 22:15:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qHazu-0000ov-Fm for bug-gnu-emacs@gnu.org; Thu, 06 Jul 2023 22:15:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 07 Jul 2023 02:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64420 X-GNU-PR-Package: emacs Original-Received: via spool by 64420-submit@debbugs.gnu.org id=B64420.16886960422997 (code B ref 64420); Fri, 07 Jul 2023 02:15:02 +0000 Original-Received: (at 64420) by debbugs.gnu.org; 7 Jul 2023 02:14:02 +0000 Original-Received: from localhost ([127.0.0.1]:42297 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qHayv-0000m5-Mg for submit@debbugs.gnu.org; Thu, 06 Jul 2023 22:14:02 -0400 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:60083) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qHayr-0000lr-Tq for 64420@debbugs.gnu.org; Thu, 06 Jul 2023 22:14:00 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id BC7655C00C3; Thu, 6 Jul 2023 22:13:52 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 06 Jul 2023 22:13:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1688696032; x=1688782432; bh=dfdVlicjziXVbaCOFbvZlJKFu2LgYMRMgTx nioEt7AY=; b=Lj5m/AMLCGlm8fbDzdVxXhKUdDQUBxjaBovkOtLnSalEIrURRp1 U8cdXDBGTZCiYQl/oUV+hN8/S31G75ixiV/MryNTgQt/YJTdemJM2MK7lWu9DcQZ d/AyZPhuCXEtQV5iGUsgwp5kA1S2BgpVaj4r0CPCURSwpFKUtzDI/6zQEbicd6TC GRGMvNdW8sOEHUJZ7HCyKXBRzi8epwgU2J3pMIJRCbz585yJQNjTUXSCpx0+5ljI pzcxlV7BGMCcHjUPrg9FbUe8ARo3i8hKB7fj4KtGCwCM0Vn7dNMmdKfKSmC4X0mz 1qgNaNFFtYEmywhlggozWwn+Uw3h7P+nN+Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1688696032; x=1688782432; bh=dfdVlicjziXVbaCOFbvZlJKFu2LgYMRMgTx nioEt7AY=; b=QfLXgbrBT6Du7/711gTj1ddQTHqn47bRTsNpWQMPDKwO5doc+f6 RrL2cUZGX+28XoK7eSmEU1ETvYKuS8Ra5xGTsFk+bwsbtl9OS2C3kC5u5tEjdQ0t rune79FBU91C83mVOiCemsTikj6DTEoYl2sU5pLkaUyX/bciWbR9Di4H+fIO7jEA e+QtI+sOSJZGop0ITKS/6BCdWR1ZEbtJCFpygu/p5Oq21TBg+ifB5uLvP/jvqVUI VBmk+E/hpDu/qsnpo1eKCC8Xw8FBBRBPWsGyxtGSafx2nRMMj73YeIcyHLJzD9wC nwLGL0SusXstMxOaG7RBC+UjlbkE+Z6eufw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrvddtgdehgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthekredttdefjeenucfhrhhomhepffhmihht rhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrghtth gvrhhnpefhffehleejffegffeugefhkeektdffgfehjedvgeejtedtudehueffgffgfeej heenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegumh hithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 6 Jul 2023 22:13:51 -0400 (EDT) Content-Language: en-US In-Reply-To: <83a5weo2dz.fsf@gnu.org> 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:264701 Archived-At: Hi Eli, On 02/07/2023 16:43, Eli Zaretskii wrote: >> Is there some inherent reason why string-width differs from the result >> of the above expression > Because string-width doesn't consult the actual metrics of the font. > It uses a char-table that we set "by hand". Would it be appropriate to fix the entry for … in that table either way? Or does that not match the principle with which those entries are done? >> and especially only does that on CJK? > In CJK locales, most characters are double-width because those locales > use fonts where the glyphs are wider. Or at least this is the theory. > string-pixel-width is free from these assumptions because it actually > measures the font glyphs. I'm guessing it's somewhat slower because of that too, but that doesn't seem like a problem so far. >> Since the overlay-based popup is used on both GUI and Terminal frames, >> are you suggesting I define my own string-width like this? >> >> (defun company--string-width (str) >> (if (display-graphic-p) >> (ceiling (/ (string-pixel-width str) >> (float (default-font-width)))) >> (string-width str))) > Yes, definitely. (Actually, display-multi-font-p is better than > display-graphic-p, but in practice they will return the same value.) Could you suggest a similar alternative to move-to-column? It's not 100% necessary, but we also have a piece of code where we take a width-aware substring from a buffer. And that logic uses 'move-to-column', which also has a problem with … in "Chinese-BIG5".