unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Need `truncate-string-to-pixel-width` and `glyph-pixel-width` functions in C
Date: Wed, 23 Oct 2024 20:39:29 +0300	[thread overview]
Message-ID: <86ed46en1q.fsf@gnu.org> (raw)
In-Reply-To: <CAKDRQS4d4OaFpqO+2uJgm-X1URJ7SDs-Kt5s1=fPrJ0aduz_Ew@mail.gmail.com> (message from Jimmy Yuen Ho Wong on Wed, 23 Oct 2024 14:52:53 +0100)

> From: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
> Date: Wed, 23 Oct 2024 14:52:53 +0100
> Cc: emacs-devel@gnu.org
> 
> On Wed, Oct 23, 2024 at 9:01 AM Eli Zaretskii <eliz@gnu.org> wrote:
> 
>  I know next to nothing about Corfu, so I have hard time understanding
>  what you are trying to do and why.  Basically, the Emacs display
>  engine already truncates stuff it displays, so it is completely
>  unclear to me why you'd need to do that in Lisp.
> 
> Corfu is like Company, it's a completion frontend that formats a list of completion candidates to fit inside a
> confined pop up box.

Thanks, but that doesn't explain enough.  Please tell more about the
need to truncate completion candidates "inside a confined pop up box".
If that box is displayed, why doesn't Emacs truncate the text
automatically?  Or maybe I don't understand how this "pop up box",
whatever it is, is displayed?

> A `truncate-string-to-pixel-width` function is needed because propertized strings may consist of display space
> text properties, images, emojis in a different font, and faces in variable fonts, which all affect glyph widths, you
> can't simply assume every glyph will take up 1 column. As a result, when you calculate some `end-column`
> and whether it has reached the width constraint in pixels, one would necessarily need to know the exact width
> in pixels for each glyph. Converting the width constraint in pixels to columns in order to supply it as the second
> parameter to a correctly implemented `truncate-string-to-width` amounts to the exact same procedure.
> Therefore, either a `truncate-string-to-pixel-width` or `glyph-pixel-width` function is needed, because
> `string-pixel-width` is very expensive.

So the issue is not "pixel-wise truncation", the issue is to take
variable-width display elements into account when truncating, is that
right?



  reply	other threads:[~2024-10-23 17:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-23  5:01 Need `truncate-string-to-pixel-width` and `glyph-pixel-width` functions in C Jimmy Yuen Ho Wong
2024-10-23  8:01 ` Eli Zaretskii
2024-10-23 13:52   ` Jimmy Yuen Ho Wong
2024-10-23 17:39     ` Eli Zaretskii [this message]
2024-10-23 20:03       ` Jimmy Yuen Ho Wong
2024-10-24  9:55         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86ed46en1q.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=wyuenho@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).