all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Zhiwei Chen <condy0919@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: The right way to use svg?
Date: Thu, 09 Sep 2021 20:33:01 +0800	[thread overview]
Message-ID: <87r1dyj5du.fsf@gmail.com> (raw)

[-- 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

             reply	other threads:[~2021-09-09 12:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09 12:33 Zhiwei Chen [this message]
2021-09-09 14:53 ` The right way to use svg? Lars Ingebrigtsen
2021-09-09 14:54   ` Lars Ingebrigtsen
2021-09-09 22:31 ` Nick Dokos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r1dyj5du.fsf@gmail.com \
    --to=condy0919@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.