help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

The right way to use svg?


From: Zhiwei Chen
Subject: The right way to use svg?
Date: Thu, 09 Sep 2021 20:33:01 +0800

#+begin_src elisp
(require 'svg)

(let* ((text "Hello, world")
       (w (* (length text) (window-font-width)))
       (h (window-font-height))
       (svg (svg-create w h)))
  (svg-rectangle svg 0 0 w h :stroke "black" :fill "none")
  (svg-text svg text
            :x           0
            :y           (- h 4) ;; Why 4 here?
            :fill        "black")
  (insert-image (svg-image svg :scale 1 :ascent 'center)))
#+end_src

PNG image

My question is why it uses 4 rather than other number?

#+begin_src elisp
(list (window-font-width)
      (window-font-height))
;; => (10 21)
#+end_src

on my machine with 1920x1080 screen resolution.

-- 
Zhiwei Chen

reply via email to

[Prev in Thread] Current Thread [Next in Thread]