GNU bug report logs - #67533
SVG images confound position pixel measurements

Previous Next

Package: emacs;

Reported by: JD Smith <jdtsmith <at> gmail.com>

Date: Wed, 29 Nov 2023 20:33:01 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: JD Smith <jdtsmith <at> gmail.com>
Subject: bug#67533: closed (Re: bug#67533: SVG images confound position
 pixel measurements)
Date: Sat, 16 Dec 2023 15:24:03 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#67533: SVG images confound position pixel measurements

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 67533 <at> debbugs.gnu.org.

-- 
67533: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67533
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: JD Smith <jdtsmith <at> gmail.com>
Cc: 67533-done <at> debbugs.gnu.org, contact <at> karthinks.com
Subject: Re: bug#67533: SVG images confound position pixel measurements
Date: Sat, 16 Dec 2023 17:23:18 +0200
> From: JD Smith <jdtsmith <at> gmail.com>
> Date: Sat, 16 Dec 2023 10:07:33 -0500
> Cc: 67533 <at> debbugs.gnu.org,
>  contact <at> karthinks.com
> 
>  On Dec 16, 2023, at 4:32 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
>  Great, I just recompiled and it’s fixed here too. Will keep an eye out for any other
>  image-display issues.  Thanks for your work on this.
> 
>  Any further issues, or can this be closed now?
> 
> I haven’t encountered any, other than the possibly related motion issue with inline images in
> bug#67604.  I believe it can be closed.  

Done.

> Given the unexpected issue that cropped up with org-indent and displayed wide images, it may be
> worth stress-testing this fix in buffers with other unusual/wide images (copying Karthik since I know he
> often works on latex/org image preview).

Any issues with stuff other than window-text-pixel-size should be
submitted as separate bugs.  If there are still issues with
window-text-pixel-size, we can reopen this bug, or start a new one.

Thanks.

[Message part 3 (message/rfc822, inline)]
From: JD Smith <jdtsmith <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: SVG images confound position pixel measurements
Date: Wed, 29 Nov 2023 15:31:43 -0500
(As posted on emacs-devel)
++++++++++++++++++++++

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.  

This erroneous pixel size/position result occurs whether the image appears via an overlay or a text-property.

Tested in Emacs 29.1 NS and Mac ports.

Small update:  this only occurs when the image is at the start of the line.  And PNG images exhibit the same issue.

+++++++

;;; 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 (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)
   (message "PIXEL SIZE OF LINE ABOVE IMAGE: %S"
	     (window-text-pixel-size nil (cons (point) -1) (point) nil nil nil t))))


This bug report was last modified 1 year and 156 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.