all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Third <alan@idiocy.org>
To: "Nicolas P. Rougier (inria)" <nicolas.rougier@inria.fr>
Cc: emacs-devel@gnu.org
Subject: Re: ELPA: New package: svg-lib
Date: Mon, 27 Sep 2021 21:19:42 +0100	[thread overview]
Message-ID: <YVInXi8Q/Aaf4XV6@idiocy.org> (raw)
In-Reply-To: <m1tui53n7r.fsf@inria.fr>

On Mon, Sep 27, 2021 at 08:03:12PM +0200, Nicolas P. Rougier (inria) wrote:
> 
> Thanks for the information and the code. I did not know about the difference
> between Emacs 27 and 28. I did not have a change to test 28.
> 
> My problem can be tested with the code below. The goal is to output an "A"
> using SVG and compare it to a regular "A". Ideally, they would need to be
> the same with very minor differences (due to different aliasing). But for
> some users and for unknown reason, the svg text size is plainly wrong.
> 
> Can you confirm this code works as expected with emacs 28 ?
> 
> #+BEGIN_SRC emacs-lisp
> 
> ;; To adapt font weight:
> ;; '((thin       . 100) (ultralight . 200) (light      . 300)
> ;;   (regular    . 400) (medium     . 500) (semibold   . 600)
> ;;   (bold       . 700) (extrabold  . 800) (black      . 900))))
> 
> (let* ((w           (window-font-width))
>       (h           (window-font-height))
>       (font        (query-font (font-at (point-min))))
>       (font-family (face-attribute 'default :family))
>       (font-size   (elt font 2))
>       (descent     (elt font 4))
>       (svg (svg-create w h)))
>  ;; (svg-rectangle svg 0 0 w h :stroke "black" :fill "none")
>  (svg-text svg "A"
>            :x           0
>            :y           descent
>            :font-family font-family            :font-weight 300
>            :font-size   font-size
>            :fill        (face-attribute 'default :foreground))
>  (insert-image (svg-image svg :ascent 'center)))
> 
> #+END_SRC

It's very close. It looks almost completely identical under GNUstep,
but under GTK it looks like the SVG text is sometimes about one pixel
taller, which makes it look slightly different at the default size
(14, I think?) but at larger sizes it looks near identical.

I suspect the difference I'm seeing is simply down to different font
rendering backends.

I'm not using hi-dpi, but even setting GDK_SCALE=2 doesn't make any
difference.

FWIW, I believe that librsvg defaults to 96dpi, however I'm not sure
that it always did, I've a feeling it used to use something different,
so different versions of librsvg may use different default DPIs. Only
Emacs 28 explicitly sets a DPI, so Emacs 27 will use whatever is
default for librsvg.

I ended up using pixels for font sizes rather than trying to get point
sizes to match up. When I DID try to use point sizes, on macOS I had
to multiply every size by something like 72/96. That calculation would
vary with OS and GUI toolkit, and possibly monitor size too.

-- 
Alan Third



  reply	other threads:[~2021-09-27 20:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27 13:49 ELPA: New package: svg-lib Nicolas P. Rougier (inria)
2021-09-27 14:34 ` Stefan Kangas
2021-09-27 14:34 ` Stefan Kangas
2021-09-27 17:38 ` Alan Third
2021-09-27 18:03   ` Nicolas P. Rougier (inria)
2021-09-27 20:19     ` Alan Third [this message]
2021-09-27 20:43       ` Nicolas P. Rougier (inria)
2021-09-27 20:03 ` Stefan Monnier
2021-09-27 20:47   ` Nicolas P. Rougier (inria)
2021-09-27 20:59     ` Stefan Kangas
2021-09-28  5:32       ` Nicolas P. Rougier (inria)
2021-09-27 21:02     ` Stefan Monnier
2021-09-28  5:34       ` Nicolas P. Rougier (inria)
2021-09-28  4:29     ` Adam Porter

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=YVInXi8Q/Aaf4XV6@idiocy.org \
    --to=alan@idiocy.org \
    --cc=emacs-devel@gnu.org \
    --cc=nicolas.rougier@inria.fr \
    /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.