From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: Enclosing text in a box Date: Wed, 16 Nov 2022 21:55:29 +0700 Message-ID: References: <_AODCZ2cNjiSAkIvdrGzDgeSNSWqJoJ9xfXn-zFenyY-yTUYx-Ijx0k4-Lq46rN4CjdkyIrzIBD1h4YY23BAP089R0Tg0kzM9MOUnaEOFrs=@protonmail.com> <835yffgfwp.fsf@gnu.org> <83y1sbez2r.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4881"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Eli Zaretskii Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 16 15:56:22 2022 Return-path: Envelope-to: geh-help-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 1ovJpt-00016N-DD for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 16 Nov 2022 15:56:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJpO-00031N-Sw; Wed, 16 Nov 2022 09:55:50 -0500 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 1ovJpK-0002zu-7B for help-gnu-emacs@gnu.org; Wed, 16 Nov 2022 09:55:46 -0500 Original-Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ovJpG-0003xi-TT; Wed, 16 Nov 2022 09:55:45 -0500 Original-Received: by mail-wm1-x335.google.com with SMTP id t1so12082472wmi.4; Wed, 16 Nov 2022 06:55:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=G6N1TJF2yKptZjmWfEVff8kRVSjV75Yii850ptkLLFg=; b=ikQ7Eze9v9Q30ZmfGDkgahJ3X2bX4/9y2DQcC2bA+GdnMrczrACP0o2dAT+qFwcgrc 2nZVSS/nfVURfUSNxoR0Shw4LvNzoyLxGjLloHe3ZP9RtCprrX7OPleaE+o+2wzgFwAy he1+4zM+vb0v0X5fE9Ud3LFYt1wzEegYKnhi5JC7ZK728IACQVT7RfUl9XGDi0KdZRAo VGyXvmRwUEhvRP9yT+qoSKup74/HIvz83uuKkWOl0ME2y1gGdgzLa4CRCw675+wU1WU+ YZ8bOoTJ6VcGqDLuhhMn31+e92mpv2WOlxUh6Me7ub4/qEn0ElQO/NlKJsk5mneQFK8R /Wng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G6N1TJF2yKptZjmWfEVff8kRVSjV75Yii850ptkLLFg=; b=n7yW5Y5Z+QOKV+4WTnyhVjxrVFup63FwvxKaIsXh/4nDk4ppgn6qmn5wHT3Biizn8S sgrbMFR3jhewlGFcpIbVRfiJL3bAtsw/Z4WUJH47CbFgsTWLnN7bxztofSNlgM1GM6xS F+OnUiDmWa7Ij9QD+o3n+BFujoHgY8DpJ0o+zFxJ2Ybx4fmwq2BRYmanAJcFhyZ6Nt8S mwZtafU9P0qIbKHmMNZUNIt7G6Vlm5PfvtJM7t6ji2MbGY03zrtG1k5CskykI/NqAdoU nv6g0qcIffFemy0JDMPdTJmOWTjAHF2dwuv+b0c+x8muqTXKliuWVJVVnbhS1TCAQKO8 JURQ== X-Gm-Message-State: ANoB5pmB7yJR15rP7+utqnaVrmzj/01zpXE1NzSrhIW6lnQF910R5bfO 2pLXFalFDc4YriL+NeHmOjJWtaSvDJeu3rwJWKE82uoYvmQ= X-Google-Smtp-Source: AA0mqf4WrCS2gsJQ9Hk6Ega/nEAo+BQEYpxi3U+i3pf2hQGy3vnklTdCUpWYmgm+YXopJsc99V/rHmmbaWZW/1v5mBA= X-Received: by 2002:a05:600c:2216:b0:3c6:cb54:ef66 with SMTP id z22-20020a05600c221600b003c6cb54ef66mr2436459wml.90.1668610540636; Wed, 16 Nov 2022 06:55:40 -0800 (PST) In-Reply-To: <83y1sbez2r.fsf@gnu.org> Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=yurivkhan@gmail.com; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:141004 Archived-At: On Wed, 16 Nov 2022 at 21:48, Eli Zaretskii wrote: > > > Using 'length' to measure the width of text on display is not > > > reliable, because there are characters of different width. It is > > > better to use 'string-width' or 'string-pixel-width' instead. > > > > The next stumbling point is going to be =E2=80=9Cmake-string does the w= rong > > thing when passed 17.237 as the count=E2=80=9D, without an explanation = as to > > what the right thing would be. (I don=E2=80=99t know either.) > > Why would sane code call make-string with such an argument? My train of thought was: * OP uses =E2=80=98length=E2=80=99 to measure the text, and =E2=80=98make-s= tring=E2=80=99 to build a box. * You point out that this fails for non-monospace fonts, and suggest measuring with =E2=80=98string-width=E2=80=99 or =E2=80=98string-pixel-widt= h=E2=80=99. * OP tries to measure in pixels, realizes one has to divide by the width of a box drawing character. The division result turns out fractional.