all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* The right way to use svg?
@ 2021-09-09 12:33 Zhiwei Chen
  2021-09-09 14:53 ` Lars Ingebrigtsen
  2021-09-09 22:31 ` Nick Dokos
  0 siblings, 2 replies; 4+ messages in thread
From: Zhiwei Chen @ 2021-09-09 12:33 UTC (permalink / raw)
  To: help-gnu-emacs

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


#+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


[-- Attachment #2: Screenshot --]
[-- Type: image/png, Size: 39779 bytes --]

[-- Attachment #3: Type: text/plain, Size: 219 bytes --]


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-09 22:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-09 12:33 The right way to use svg? Zhiwei Chen
2021-09-09 14:53 ` Lars Ingebrigtsen
2021-09-09 14:54   ` Lars Ingebrigtsen
2021-09-09 22:31 ` Nick Dokos

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.