Skip to content

Instantly share code, notes, and snippets.

@jdtsmith
Last active December 3, 2023 15:24
Show Gist options
  • Save jdtsmith/ad765047a6afe20f353de573d8c07da9 to your computer and use it in GitHub Desktop.
Save jdtsmith/ad765047a6afe20f353de573d8c07da9 to your computer and use it in GitHub Desktop.
Testing Emacs SVG layout positioning
;;; test-svg-wrapped --- test pixel position for SVG images -*- lexical-binding: t; -*-
;; This small code creates a buffer with a couple long lines with
;; several SVG images of varying height interspersed. It also
;; includes a tool to check if the pixel height information one pixel
;; above each character agrees with expectations. To use:
;; M-x my/test-svg-positions
;; (use a C-u prefix to create SVG overlays instead of text properties)
;;
;; A test buffer will be created; see svg-pixel-demo-report. Resize
;; the frame containing the text with images narrower and narrower, and
;; re-run the report from that buffer:
;;
;; M-x my/check-buffer-pixel-values
;;; Code:
(require 'svg)
(eval-when-compile (require 'cl-lib))
(defun my/check-buffer-pixel-values ()
(interactive)
(goto-char (point-min))
(let ((line-heights (vconcat (save-excursion
(cl-loop while (< (point) (point-max))
collect (line-pixel-height)
do (vertical-motion 1)))))
(line 0)
vmax)
(with-output-to-temp-buffer "svg-pixel-demo-report"
(princ (format "SVG Position analysis for %s (width %d, %s)\n\n"
(current-buffer) (window-width)
(if (next-single-property-change (point-min) 'display)
"text-properties" "overlays")))
(while (not (eobp))
(beginning-of-visual-line)
(vertical-motion 1)
(setq vmax (save-excursion (end-of-visual-line) (point)))
(save-excursion
(while (and (<= (point) vmax) (not (eobp)))
(let* ((ps (window-text-pixel-size nil (cons (point) -1)
(point) nil nil nil t))
(h (nth 1 ps)))
(unless (= h (aref line-heights line))
(princ
(format "Incorrect at point=%3d: line %2d at %12S (%5s): expected %2d got %2d\n"
(point) (+ line 2) (posn-x-y (posn-at-point))
(if (or (overlays-at (point))
(get-text-property (point) 'display))
"image"
(char-to-string (char-after (point))))
(aref line-heights line) h))))
(forward-char)))
(cl-incf line)))))
(defun my/test-svg-positions (arg)
(interactive "P")
(let ((buf "svg-pixel-demo")
(default-height (frame-char-height)))
(with-current-buffer (get-buffer-create buf)
(erase-buffer)
(insert "\nPellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna.\nEtiam vel tortor sodales tellus ultricies commodo. Curabitur vulputate vestibulum lorem. Nam euismod tellus id erat.\n\nNullam tristique diam non turpis.\n")
(goto-char (point-min))
(cl-loop for i from 1
for p = (point) then (progn (forward-word) (point))
while (< p (point-max))
if (zerop (% i 5)) do
(let* ((word-start (save-excursion (backward-word) (point)))
(r0 (/ (float i) 11))
(r (round (* 10 (- r0 (floor r0))))) ; some psuedo-randoms
(r2 (round (* 10 (- (* r0 10) (floor (* r0 10))))))
(h (+ default-height (* 3 r2)))
(w (+ 142 (* 2 (round (expt (1+ r) 1.25)))))
(m (/ w 2))
(svg (svg-create w h)))
(svg-circle svg m m m
:fill-color (face-foreground 'default)
:stroke-width 3
:stroke-color (if (zerop (% i 2)) "green" "red"))
(if arg
(let ((ov (make-overlay word-start p)))
(overlay-put ov 'evaporate t)
(overlay-put ov 'display
(svg-image svg :ascent 'center)))
(put-text-property word-start p 'display
(svg-image svg :ascent 'center)))))
(pop-to-buffer buf)
(visual-line-mode 1)
(my/check-buffer-pixel-values))))
Display the source blob
Display the rendered blob
Raw
<?xml version='1.0' encoding='UTF-8'?>
<!-- This file was generated by dvisvgm 3.0.3 -->
<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='156.375649pt' height='28.945305pt' viewBox='-23.475918 11.921308 156.375649 28.945305'>
<defs>
<path id='g1-40' d='M3.297634 2.391034C3.297634 2.361146 3.297634 2.34122 3.128269 2.171856C1.882939 .916563 1.564134-.966376 1.564134-2.49066C1.564134-4.224159 1.942715-5.957659 3.16812-7.202989C3.297634-7.32254 3.297634-7.342466 3.297634-7.372354C3.297634-7.442092 3.257783-7.47198 3.198007-7.47198C3.098381-7.47198 2.201743-6.794521 1.613948-5.529265C1.105853-4.433375 .986301-3.327522 .986301-2.49066C.986301-1.713574 1.09589-.508095 1.643836 .617684C2.241594 1.843088 3.098381 2.49066 3.198007 2.49066C3.257783 2.49066 3.297634 2.460772 3.297634 2.391034Z'/>
<path id='g1-41' d='M2.879203-2.49066C2.879203-3.267746 2.769614-4.473225 2.221669-5.599004C1.62391-6.824408 .767123-7.47198 .667497-7.47198C.607721-7.47198 .56787-7.43213 .56787-7.372354C.56787-7.342466 .56787-7.32254 .757161-7.143213C1.733499-6.156912 2.30137-4.572852 2.30137-2.49066C2.30137-.787049 1.932752 .966376 .697385 2.221669C.56787 2.34122 .56787 2.361146 .56787 2.391034C.56787 2.450809 .607721 2.49066 .667497 2.49066C.767123 2.49066 1.663761 1.8132 2.251557 .547945C2.759651-.547945 2.879203-1.653798 2.879203-2.49066Z'/>
<path id='g1-61' d='M6.844334-3.257783C6.993773-3.257783 7.183064-3.257783 7.183064-3.457036S6.993773-3.656289 6.854296-3.656289H.886675C.747198-3.656289 .557908-3.656289 .557908-3.457036S.747198-3.257783 .896638-3.257783H6.844334ZM6.854296-1.325031C6.993773-1.325031 7.183064-1.325031 7.183064-1.524284S6.993773-1.723537 6.844334-1.723537H.896638C.747198-1.723537 .557908-1.723537 .557908-1.524284S.747198-1.325031 .886675-1.325031H6.854296Z'/>
<path id='g1-97' d='M3.317559-.757161C3.35741-.358655 3.626401 .059776 4.094645 .059776C4.303861 .059776 4.911582-.079701 4.911582-.886675V-1.444583H4.662516V-.886675C4.662516-.308842 4.41345-.249066 4.303861-.249066C3.975093-.249066 3.935243-.697385 3.935243-.747198V-2.739726C3.935243-3.158157 3.935243-3.5467 3.576588-3.915318C3.188045-4.303861 2.689913-4.463263 2.211706-4.463263C1.39477-4.463263 .707347-3.995019 .707347-3.337484C.707347-3.038605 .9066-2.86924 1.165629-2.86924C1.444583-2.86924 1.62391-3.068493 1.62391-3.327522C1.62391-3.447073 1.574097-3.775841 1.115816-3.785803C1.384807-4.134496 1.872976-4.244085 2.191781-4.244085C2.67995-4.244085 3.247821-3.855542 3.247821-2.968867V-2.600249C2.739726-2.570361 2.042341-2.540473 1.414695-2.241594C.667497-1.902864 .418431-1.384807 .418431-.946451C.418431-.139477 1.384807 .109589 2.012453 .109589C2.669988 .109589 3.128269-.288917 3.317559-.757161ZM3.247821-2.391034V-1.39477C3.247821-.448319 2.530511-.109589 2.082192-.109589C1.594022-.109589 1.185554-.458281 1.185554-.956413C1.185554-1.504359 1.603985-2.331258 3.247821-2.391034Z'/>
<path id='g1-101' d='M1.115816-2.510585C1.175592-3.995019 2.012453-4.244085 2.351183-4.244085C3.377335-4.244085 3.476961-2.899128 3.476961-2.510585H1.115816ZM1.105853-2.30137H3.88543C4.104608-2.30137 4.134496-2.30137 4.134496-2.510585C4.134496-3.496887 3.596513-4.463263 2.351183-4.463263C1.195517-4.463263 .278954-3.437111 .278954-2.191781C.278954-.856787 1.325031 .109589 2.470735 .109589C3.686177 .109589 4.134496-.996264 4.134496-1.185554C4.134496-1.285181 4.054795-1.305106 4.004981-1.305106C3.915318-1.305106 3.895392-1.24533 3.875467-1.165629C3.526775-.139477 2.630137-.139477 2.530511-.139477C2.032379-.139477 1.633873-.438356 1.404732-.806974C1.105853-1.285181 1.105853-1.942715 1.105853-2.30137Z'/>
<path id='g1-110' d='M1.09589-3.427148V-.757161C1.09589-.308842 .986301-.308842 .318804-.308842V0C.667497-.009963 1.175592-.029888 1.444583-.029888C1.703611-.029888 2.221669-.009963 2.560399 0V-.308842C1.892902-.308842 1.783313-.308842 1.783313-.757161V-2.590286C1.783313-3.626401 2.49066-4.184309 3.128269-4.184309C3.755915-4.184309 3.865504-3.646326 3.865504-3.078456V-.757161C3.865504-.308842 3.755915-.308842 3.088418-.308842V0C3.437111-.009963 3.945205-.029888 4.214197-.029888C4.473225-.029888 4.991283-.009963 5.330012 0V-.308842C4.811955-.308842 4.562889-.308842 4.552927-.607721V-2.510585C4.552927-3.367372 4.552927-3.676214 4.244085-4.034869C4.104608-4.204234 3.775841-4.403487 3.198007-4.403487C2.470735-4.403487 2.002491-3.975093 1.723537-3.35741V-4.403487L.318804-4.293898V-3.985056C1.016189-3.985056 1.09589-3.915318 1.09589-3.427148Z'/>
<path id='g1-112' d='M1.713574-3.745953V-4.403487L.278954-4.293898V-3.985056C.986301-3.985056 1.05604-3.92528 1.05604-3.486924V1.175592C1.05604 1.62391 .946451 1.62391 .278954 1.62391V1.932752C.617684 1.92279 1.135741 1.902864 1.39477 1.902864C1.663761 1.902864 2.171856 1.92279 2.520548 1.932752V1.62391C1.853051 1.62391 1.743462 1.62391 1.743462 1.175592V-.498132V-.587796C1.793275-.428394 2.211706 .109589 2.968867 .109589C4.154421 .109589 5.190535-.86675 5.190535-2.15193C5.190535-3.417186 4.224159-4.403487 3.108344-4.403487C2.331258-4.403487 1.912827-3.965131 1.713574-3.745953ZM1.743462-1.135741V-3.35741C2.032379-3.865504 2.520548-4.154421 3.028643-4.154421C3.755915-4.154421 4.363636-3.277709 4.363636-2.15193C4.363636-.946451 3.666252-.109589 2.929016-.109589C2.530511-.109589 2.15193-.308842 1.882939-.71731C1.743462-.926526 1.743462-.936488 1.743462-1.135741Z'/>
<path id='g1-116' d='M1.723537-3.985056H3.148194V-4.293898H1.723537V-6.127024H1.474471C1.464508-5.310087 1.165629-4.244085 .18929-4.204234V-3.985056H1.036115V-1.235367C1.036115-.009963 1.96264 .109589 2.321295 .109589C3.028643 .109589 3.307597-.597758 3.307597-1.235367V-1.803238H3.058531V-1.255293C3.058531-.518057 2.759651-.139477 2.391034-.139477C1.723537-.139477 1.723537-1.046077 1.723537-1.215442V-3.985056Z'/>
<path id='g1-120' d='M2.859278-2.34122C3.158157-2.719801 3.536737-3.20797 3.775841-3.466999C4.084682-3.825654 4.493151-3.975093 4.961395-3.985056V-4.293898C4.702366-4.273973 4.403487-4.26401 4.144458-4.26401C3.845579-4.26401 3.317559-4.283935 3.188045-4.293898V-3.985056C3.39726-3.965131 3.476961-3.835616 3.476961-3.676214S3.377335-3.387298 3.327522-3.327522L2.709838-2.550436L1.932752-3.556663C1.843088-3.656289 1.843088-3.676214 1.843088-3.73599C1.843088-3.88543 1.992528-3.975093 2.191781-3.985056V-4.293898C1.932752-4.283935 1.275218-4.26401 1.115816-4.26401C.9066-4.26401 .438356-4.273973 .169365-4.293898V-3.985056C.86675-3.985056 .876712-3.975093 1.344956-3.377335L2.331258-2.092154L1.39477-.9066C.916563-.328767 .328767-.308842 .119552-.308842V0C.37858-.019925 .687422-.029888 .946451-.029888C1.235367-.029888 1.653798-.009963 1.892902 0V-.308842C1.673724-.33873 1.603985-.468244 1.603985-.617684C1.603985-.836862 1.892902-1.165629 2.500623-1.882939L3.257783-.886675C3.337484-.777086 3.466999-.617684 3.466999-.557908C3.466999-.468244 3.377335-.318804 3.108344-.308842V0C3.407223-.009963 3.965131-.029888 4.184309-.029888C4.4533-.029888 4.841843-.019925 5.140722 0V-.308842C4.60274-.308842 4.423412-.328767 4.194271-.617684L2.859278-2.34122Z'/>
<path id='g2-16' d='M5.13076 17.414695C5.150685 17.424658 5.240349 17.524284 5.250311 17.524284H5.469489C5.499377 17.524284 5.579078 17.514321 5.579078 17.424658C5.579078 17.384807 5.559153 17.364882 5.539228 17.334994C5.180573 16.976339 4.64259 16.428394 4.024907 15.332503C2.948941 13.419676 2.550436 10.958904 2.550436 8.56787C2.550436 4.144458 3.805729 1.544209 5.549191-.219178C5.579078-.249066 5.579078-.278954 5.579078-.298879C5.579078-.398506 5.50934-.398506 5.389788-.398506C5.260274-.398506 5.240349-.398506 5.150685-.318804C4.204234 .498132 3.138232 1.882939 2.450809 3.985056C2.022416 5.300125 1.793275 6.90411 1.793275 8.557908C1.793275 10.919054 2.221669 13.589041 3.785803 15.900374C4.054795 16.288917 4.423412 16.697385 4.423412 16.707347C4.523039 16.826899 4.662516 16.986301 4.742217 17.05604L5.13076 17.414695Z'/>
<path id='g2-17' d='M4.144458 8.557908C4.144458 5.69863 3.476961 2.660025 1.514321 .418431C1.374844 .259029 1.006227-.129514 .767123-.33873C.697385-.398506 .67746-.398506 .547945-.398506C.448319-.398506 .358655-.398506 .358655-.298879C.358655-.259029 .398506-.219178 .418431-.199253C.757161 .14944 1.295143 .697385 1.912827 1.793275C2.988792 3.706102 3.387298 6.166874 3.387298 8.557908C3.387298 12.881694 2.191781 15.521793 .398506 17.344956C.37858 17.364882 .358655 17.39477 .358655 17.424658C.358655 17.524284 .448319 17.524284 .547945 17.524284C.67746 17.524284 .697385 17.524284 .787049 17.444583C1.733499 16.627646 2.799502 15.242839 3.486924 13.140722C3.92528 11.775841 4.144458 10.161893 4.144458 8.557908Z'/>
<path id='g2-112' d='M4.224159 11.556663C4.533001 11.556663 4.542964 11.5467 4.64259 11.35741L10.092154-.019925C10.161893-.14944 10.161893-.169365 10.161893-.199253C10.161893-.308842 10.082192-.398506 9.96264-.398506C9.833126-.398506 9.793275-.308842 9.743462-.199253L4.60274 10.520548L2.480697 5.579078L1.09589 6.645081L1.24533 6.804483L1.952677 6.266501L4.224159 11.556663Z'/>
<path id='g0-31' d='M5.808219-4.014944C5.917808-4.124533 5.917808-4.144458 5.917808-4.174346C5.917808-4.234122 5.877958-4.293898 5.798257-4.293898C5.738481-4.293898 5.69863-4.244085 5.638854-4.174346L3.35741-1.633873C2.958904-2.899128 2.879203-3.148194 2.650062-3.676214C2.540473-3.905355 2.321295-4.403487 1.444583-4.403487C.86675-4.403487 .607721-3.88543 .607721-3.745953C.607721-3.73599 .607721-3.646326 .727273-3.646326C.816936-3.646326 .836862-3.706102 .856787-3.755915C1.006227-4.144458 1.325031-4.184309 1.384807-4.184309C1.683686-4.184309 1.982565-3.427148 2.15193-2.988792C2.470735-2.201743 2.789539-1.046077 2.789539-1.016189C2.789539-1.006227 2.789539-.986301 2.709838-.9066L.418431 1.653798C.308842 1.763387 .308842 1.783313 .308842 1.8132C.308842 1.872976 .368618 1.932752 .428394 1.932752C.498132 1.932752 .547945 1.863014 .587796 1.823163L2.86924-.737235C3.188045 .298879 3.307597 .687422 3.5467 1.24533C3.676214 1.544209 3.895392 2.042341 4.782067 2.042341C5.3599 2.042341 5.628892 1.524284 5.628892 1.39477C5.628892 1.344956 5.608966 1.285181 5.50934 1.285181S5.399751 1.325031 5.369863 1.424658C5.280199 1.663761 5.031133 1.823163 4.841843 1.823163C4.333748 1.823163 3.656289-.587796 3.437111-1.354919L5.808219-4.014944Z'/>
<path id='g0-121' d='M4.841843-3.795766C4.881694-3.935243 4.881694-3.955168 4.881694-4.024907C4.881694-4.204234 4.742217-4.293898 4.592777-4.293898C4.493151-4.293898 4.333748-4.234122 4.244085-4.084682C4.224159-4.034869 4.144458-3.726027 4.104608-3.5467C4.034869-3.287671 3.965131-3.01868 3.905355-2.749689L3.457036-.956413C3.417186-.806974 2.988792-.109589 2.331258-.109589C1.823163-.109589 1.713574-.547945 1.713574-.916563C1.713574-1.374844 1.882939-1.992528 2.221669-2.86924C2.381071-3.277709 2.420922-3.387298 2.420922-3.58655C2.420922-4.034869 2.102117-4.403487 1.603985-4.403487C.657534-4.403487 .288917-2.958904 .288917-2.86924C.288917-2.769614 .388543-2.769614 .408468-2.769614C.508095-2.769614 .518057-2.789539 .56787-2.948941C.836862-3.88543 1.235367-4.184309 1.574097-4.184309C1.653798-4.184309 1.823163-4.184309 1.823163-3.865504C1.823163-3.616438 1.723537-3.35741 1.653798-3.16812C1.255293-2.11208 1.075965-1.544209 1.075965-1.075965C1.075965-.18929 1.703611 .109589 2.291407 .109589C2.67995 .109589 3.01868-.059776 3.297634-.33873C3.16812 .179328 3.048568 .667497 2.650062 1.195517C2.391034 1.534247 2.012453 1.823163 1.554172 1.823163C1.414695 1.823163 .966376 1.793275 .797011 1.404732C.956413 1.404732 1.085928 1.404732 1.225405 1.285181C1.325031 1.195517 1.424658 1.066002 1.424658 .876712C1.424658 .56787 1.155666 .52802 1.05604 .52802C.826899 .52802 .498132 .687422 .498132 1.175592C.498132 1.673724 .936488 2.042341 1.554172 2.042341C2.580324 2.042341 3.606476 1.135741 3.88543 .009963L4.841843-3.795766Z'/>
</defs>
<g id='page1' transform='matrix(1.615 0 0 1.615 0 0)'>
<use x='-14.536172' y='18.838748' xlink:href='#g0-31'/>
<use x='-8.302624' y='18.838748' xlink:href='#g1-40'/>
<use x='-4.428251' y='18.838748' xlink:href='#g0-121'/>
<use x='.813693' y='18.838748' xlink:href='#g1-41'/>
<use x='7.455399' y='18.838748' xlink:href='#g1-61'/>
<use x='17.971479' y='18.838748' xlink:href='#g1-101'/>
<use x='22.39933' y='18.838748' xlink:href='#g1-120'/>
<use x='27.657418' y='18.838748' xlink:href='#g1-112'/>
<use x='34.852617' y='7.78012' xlink:href='#g2-16'/>
<use x='40.802534' y='10.320642' xlink:href='#g2-112'/>
<rect x='50.765189' y='9.922158' height='.398484' width='27.381207'/>
<use x='50.765189' y='18.838748' xlink:href='#g1-116'/>
<use x='54.639563' y='18.838748' xlink:href='#g1-97'/>
<use x='59.620902' y='18.838748' xlink:href='#g1-110'/>
<use x='65.155713' y='18.838748' xlink:href='#g1-40'/>
<use x='69.030087' y='18.838748' xlink:href='#g0-121'/>
<use x='74.27203' y='18.838748' xlink:href='#g1-41'/>
<use x='78.146397' y='7.78012' xlink:href='#g2-17'/>
</g>
</svg>
;;; test-svg-wrapped --- test pixel position for SVG images -*- lexical-binding: t; -*-
;; This small code creates a buffer with a couple long lines with
;; several SVG images of varying height interspersed. It also
;; includes a tool to check if the pixel height information one pixel
;; above each character agrees with expectations. To use:
;; M-x my/test-svg-positions
;; (use a C-u prefix to create SVG overlays instead of text properties)
;;
;; A test buffer will be created; see svg-pixel-demo-report. Resize
;; the frame containing the text with images narrower and narrower, and
;; re-run the report from that buffer:
;;
;; M-x my/check-buffer-pixel-values
;;; Code:
(require 'svg)
(eval-when-compile (require 'cl-lib))
(defun my/check-buffer-pixel-values ()
(interactive)
(goto-char (point-min))
(let ((line-heights (vconcat (save-excursion
(cl-loop while (< (point) (point-max))
collect (line-pixel-height)
do (vertical-motion 1)))))
(line 0)
vmax)
(with-output-to-temp-buffer "svg-pixel-demo-report"
(princ (format "SVG Position analysis for %s (width %d, %s)\n\n"
(current-buffer) (window-width)
(if (next-single-property-change (point-min) 'display)
"text-properties" "overlays")))
(while (not (eobp))
(beginning-of-visual-line)
(vertical-motion 1)
(setq vmax (save-excursion (end-of-visual-line) (point)))
(save-excursion
(while (and (<= (point) vmax) (not (eobp)))
(let* ((ps (window-text-pixel-size nil (cons (point) -1)
(point) nil nil nil t))
(h (nth 1 ps)))
(unless (= h (aref line-heights line))
(princ
(format "Incorrect at point=%3d: line %2d at %12S (%5s): expected %2d got %2d\n"
(point) (+ line 2) (posn-x-y (posn-at-point))
(if (or (overlays-at (point))
(get-text-property (point) 'display))
"image"
(char-to-string (char-after (point))))
(aref line-heights line) h))))
(forward-char)))
(cl-incf line)))))
(defun my/test-svg-positions (arg)
(interactive "P")
(let ((buf "svg-pixel-demo")
(default-height (frame-char-height)))
(with-current-buffer (get-buffer-create buf)
(erase-buffer)
(insert "\nPellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna.\nEtiam vel tortor sodales tellus ultricies commodo. Curabitur vulputate vestibulum lorem. Nam euismod tellus id erat.\n\nNullam tristique diam non turpis.\n")
(goto-char (point-min))
(cl-loop for i from 1
for p = (point) then (progn (forward-word) (point))
while (< p (point-max))
if (zerop (% i 5)) do
(let* ((word-start (save-excursion (backward-word) (point)))
(r0 (/ (float i) 11))
(r (round (* 10 (- r0 (floor r0))))) ; some psuedo-randoms
(r2 (round (* 10 (- (* r0 10) (floor (* r0 10))))))
(h (+ default-height (* 3 r2)))
(w (+ 40 (* 2 (round (expt (1+ r) 1.25)))))
(m (/ w 2))
(svg (svg-create w h)))
(svg-circle svg m m m
:fill-color (face-foreground 'default)
:stroke-width 3
:stroke-color (if (zerop (% i 2)) "green" "red"))
(if arg
(let ((ov (make-overlay word-start p)))
(overlay-put ov 'evaporate t)
(overlay-put ov 'display
(svg-image svg :ascent 'center)))
(put-text-property word-start p 'display
(svg-image svg :ascent 'center)))))
(pop-to-buffer buf)
(visual-line-mode 1)
(my/check-buffer-pixel-values))))
@jdtsmith
Copy link
Author

jdtsmith commented Dec 3, 2023

See Emacs Bug#67533. Updated to create wider SVGs to trigger the "wider than 1/4 the default frame width" bug.

@jdtsmith
Copy link
Author

jdtsmith commented Dec 3, 2023

The patch Eli developed on 3 Dec fixes all the pixel computation issues I've experienced, even in a large/complex file with many images.

One final, perhaps related, issue remains with inline images and visual-line-mode: navigation (including vertical-motion and next/previous-line) gets confused by images on the first column, quite rarely.

Here's a short video of this happening, in which I invoke next-line repeatedly. You can see the short wrapped line pulvinar nibh. gets skipped with next-line, but not previous-line. The same is true with vertical-motion. I'm working on a reproduction for this rare navigation-with-inline-images bug, but it has been elusive.

svg_image_navigation_bug.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment