all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: JD Smith <jdtsmith@gmail.com>
To: Manuel Giraud <manuel@ledu-giraud.fr>
Cc: emacs-devel@gnu.org
Subject: Re: SVG images confound position pixel measurements
Date: Fri, 1 Dec 2023 09:11:56 -0500	[thread overview]
Message-ID: <EA045483-1CF9-4E1E-A62E-1EFC35EB3AB9@gmail.com> (raw)
In-Reply-To: <877clyb9q8.fsf@ledu-giraud.fr>

[-- Attachment #1: Type: text/plain, Size: 3267 bytes --]

Thanks for checking this, Manuel.  I’ve already filed a bug report and Eli has found a fix, but unfortunately only for this very specific case with line truncation.  The general issue remains.  We are seeking a self-contained reproducer for the more general case in other wrap modes (visual-line, normal wrapping).  

Please see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67533 to continue the discussion there.

> On Dec 1, 2023, at 3:36 AM, Manuel Giraud <manuel@ledu-giraud.fr> wrote:
> 
> JD Smith <jdtsmith@gmail.com <mailto:jdtsmith@gmail.com>> writes:
> 
>> In developing a new pixel-precise smooth scrolling mode, I’ve noticed
>> that inline SVG images confuse Emacs regarding pixel positions of
>> surrounding elements.  You sometimes also experience this while
>> visiting SVG image-rich files (think org-latex-preview) while in
>> visual line mode.  In this case, previous/next-line sometimes jump
>> from one side of the window to the other.
>> 
>> But it’s easiest to reproduce with line-truncation in effect.  Run the
>> snippet below with your frame either expanded wide enough to
>> accommodate the full width of the 1st line of text, or too narrow
>> (eliciting truncation).  While truly truncated and with point on the
>> SVG, pixel text measurements above are erroneous (reporting zero pixel
>> height above), as if it thinks it’s on the prior line.  At other
>> points in line 2, the pixel-size values are correct.
> 
> Hi, I can reproduce this on master.  Below I modified your example
> slightly and I also observe different pixel width for the same text
> line.
> 
> I think you should file a bug report with this issue.  Thanks.
> 
> --8<---------------cut here---------------start------------->8---
> ;;; test-svg-pixel-position --- test pixel position for SVG images
> 
> ;;; This small code creates a buffer with two lines, the first of
> ;;; which is long, and the second of which has an SVG image at start.
> ;;; Line truncation is turned on.  `window-text-pixel-size` returns
> ;;; differing results depending on whether truncation is actually in
> ;;; effect (alter the frame width to see this).
> 
> ;;; Code:
> (require 'svg)
> (let ((buf "svg-pixel-demo")
>      (svg (svg-create 50 25)))
>  (svg-circle svg 25 25 25 :stroke-color "green")
>  (with-current-buffer (get-buffer-create buf)
>    (erase-buffer)
>    (insert "Pellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna.\n")
>    (insert "Pellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna.\n")
>    (insert (propertize "THISISACIRCLE" 'display (svg-image svg)))
>    (insert " Aliquam posuere.\n")
>    (pop-to-buffer buf)
>    (goto-char (point-max))
>    (forward-line -1)
>    (toggle-truncate-lines 1)
>    (let ((above-image (window-text-pixel-size nil (cons (point) -1) (point) nil nil nil t)))
>      (forward-line -1)
>      (message "FIRST LINE: %S; ABOVE IMAGE: %S"
> 	       (window-text-pixel-size nil (cons (point) -1) (point) nil nil nil t)
> 	       above-image))))
> --8<---------------cut here---------------end--------------->8---
> -- 
> Manuel Giraud


[-- Attachment #2: Type: text/html, Size: 32164 bytes --]

      reply	other threads:[~2023-12-01 14:11 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29 19:02 SVG images confound position pixel measurements JD Smith
2023-11-29 20:31 ` bug#67533: " JD Smith
2023-11-30 17:32   ` Eli Zaretskii
2023-11-30 21:00     ` JD Smith
2023-12-01  7:08       ` Eli Zaretskii
2023-12-01 22:04         ` JD Smith
2023-12-02  7:30           ` Eli Zaretskii
2023-12-02 13:36             ` JD Smith
2023-12-02 14:18               ` Eli Zaretskii
2023-12-02 19:39                 ` Eli Zaretskii
2023-12-02 21:44                   ` JD Smith
2023-12-03  3:04                     ` JD Smith
2023-12-03 13:02                       ` Eli Zaretskii
2023-12-03 15:48                         ` JD Smith
2023-12-03 15:52                           ` Eli Zaretskii
2023-12-03 16:31                             ` Eli Zaretskii
2023-12-03 21:25                               ` JD Smith
2023-12-03 23:14                                 ` JD Smith
2023-12-04  3:27                                 ` Eli Zaretskii
2023-12-04  4:32                                   ` JD Smith
2023-12-04 13:11                                     ` Eli Zaretskii
2023-12-04 14:14                                       ` JD Smith
2023-12-16  9:32                                         ` Eli Zaretskii
2023-12-16 15:07                                           ` JD Smith
2023-12-16 15:23                                             ` Eli Zaretskii
2023-12-03 15:49                         ` JD Smith
2023-12-03 16:33                           ` Eli Zaretskii
2023-12-03 18:58                             ` JD Smith
2023-12-01 14:40     ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-01 14:55       ` Eli Zaretskii
2023-12-01 15:21         ` JD Smith
2023-12-01 15:36           ` Eli Zaretskii
2023-12-01 15:45             ` JD Smith
2023-12-01 15:59               ` Eli Zaretskii
2023-12-01 16:17                 ` JD Smith
2023-12-01 16:30                   ` Eli Zaretskii
2023-12-01 16:27         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-01 16:31           ` Eli Zaretskii
2023-12-01  8:36 ` Manuel Giraud via Emacs development discussions.
2023-12-01 14:11   ` JD Smith [this message]

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

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

  git send-email \
    --in-reply-to=EA045483-1CF9-4E1E-A62E-1EFC35EB3AB9@gmail.com \
    --to=jdtsmith@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=manuel@ledu-giraud.fr \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.