GNU bug report logs -
#67533
SVG images confound position pixel measurements
Previous Next
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
Message #17 received at 67533 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: JD Smith <jdtsmith <at> gmail.com>
>> Date: Wed, 29 Nov 2023 15:31:43 -0500
>>
>> ;;; 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))))
>
> Does the patch below fix the issue? (It should fix the recipe you
> posted, but you hinted that this is just the simplest way of seeing a
> more general problem, so I wonder whether that more general problem is
> also fixed.)
Hi,
I have applied your patch to master and here are the results I get with
the recipe at the end of this message:
With a not large enough window:
FIRST LINE: (925 24 1); ABOVE IMAGE: (925 24 119)
With a large enough window (i.e., that can display the whole first
line):
FIRST LINE: (1053 24 1); ABOVE IMAGE: (1062 24 119)
--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
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.