On Mon, Sep 27, 2021 at 03:49:16PM +0200, Nicolas P. Rougier
(inria) wrote:
Note that there is still a pending bug with text size for some
users (see
https://github.com/rougier/svg-tag-mode/pull/14. This is a
different project
but the problem is the same). Any help appreciated.
Hi Nicolas,
I had my own go at matching SVG images and Emacs's text
rendering at
one time and my code is here:
https://gist.github.com/alanthird/7b86dc66df1ed3b9006bcd3fddd7350f
I was really just messing about, though, so it's probably not
much
use.
Reading through that bug report I'm not 100% sure what is going
on,
but I do suspect there may be some confusion as the behaviour of
SVG
rendering has changed between Emacs 27 and Emacs 28.
For the most part Emacs 28 _should_ do the right thing. i.e. 1em
matches the exact font size used at the insertion point and the
default font family should also match the font at the insertion
point.
Emacs 28 also adds the ability to set image sizes with '(1
. em), to
make it easier to make images scale with the font (we're using
that to
display checkboxes in customize, and so on).
It also should set the DPI accurately so that 1cm == 1 real
world cm,
except possibly on Macs where Apple's recommended DPI behaviour
is...
Strange.
Unfortunately I guess you still have to support Emacs 27 (and
below?)
so perhaps none of that really helps you.
When generating images I'd suggest always setting the image
scale to
1, as that avoids any strange resizing behaviour that may be
caused by
the image creation code attempting to rescale images to match
the font
size.
Finally we have a bug open about screen DPIs (bug#49937)
although it
probably has nothing to do with the problems you're seeing.