all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
To: Alan Third <alan@idiocy.org>,
	Jimmy Yuen Ho Wong <wyuenho@gmail.com>,
	 Emacs-Devel devel <emacs-devel@gnu.org>
Subject: Re: Mechanism to scale SVG images when default face height changes?
Date: Mon, 18 Sep 2023 22:04:17 +0100	[thread overview]
Message-ID: <CAKDRQS6GQy5AnhH74qGdKAvccUA+X=dZ916fJ4wMy9164YZENg@mail.gmail.com> (raw)
In-Reply-To: <ZQi4zWFCWZPaFy7s@idiocy.org>

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

On Mon, Sep 18, 2023 at 9:53 PM Alan Third <alan@idiocy.org> wrote:

> On Mon, Sep 18, 2023 at 08:55:55PM +0100, Jimmy Yuen Ho Wong wrote:
> > On Mon, Sep 18, 2023 at 8:37 PM Alan Third <alan@idiocy.org> wrote:
> >
> > > On Mon, Sep 18, 2023 at 08:10:59PM +0100, Jimmy Yuen Ho Wong wrote:
> > > > Ah, I was looking at
> > > >
> > >
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Pixel-Specification.html
> > > ,
> <snip>
> > >
> > > I suppose you could calculate the number of ems required by
> > > doing something like...
> > >
> > >       ((/ (- font-px-size 1) font-px-size) . 'em)
> > >
> > > But while that would scale on demand, it wouldn't scale properly
> > > because the calculation is done before the user changes the font size.
> > >
> > > I can't think of any way round it, or even any practical way to extend
> > > the current mechanism.
> > >
> > >
> > Sad face :(. I suppose what I'm really looking for is to extend the pixel
> > specification mini language to support something like CSS' calc()
> > <https://developer.mozilla.org/en-US/docs/Web/CSS/calc> function, where
> it
> > can do arithmetic on both relative and absolute units.
> >
> > Is that possible?
>
> I didn't actually know about the pixel specification language before
> now. It seems to me like it would make sense to teach the image code
> to understand it too and add ems to it, but since I know nothing about
> it I can't say if that's practical or not.
>
> > For my specific purpose, having `:margin` to support
> > floating point em will also suffice, but that doesn't seem to work at the
> > moment.
>
> Indeed, this would actually be quite simple, but it won't help you now
> as it won't be available until Emacs 30.
>
> All I can suggest for compatibility with current versions of Emacs is
> to wrap the SVG's within other SVGs. We do this internally in Emacs to
> implement vector scaling and you could probably do something similar,
> although I'm not sure exactly how much control you could get from it.
>
> For example, you can do something like:
>
> <svg xmlns:xlink="http://www.w3.org/1999/xlink"
>  xmlns:xi="http://www.w3.org/2001/XInclude"
>  width="1em" height="1em" preserveAspectRatio="none">
>   <xi:include href="data:image/svg+xml;base64,<base64 encoded SVG data>">
>   </xi:include>
> </svg>
>
> It should be possible to scale down the embedded image to leave a gap
> around it, but I'd have to go and investigate how to do it.
>
> I recommend base64 encoding the SVG data as shown above, because
> directly embedding the SVG text can be problematic unless it's very
> simple.
> --
> Alan Third
>

Thank you! I'll report back once I've played around with SVG wrappers.

Thanks

[-- Attachment #2: Type: text/html, Size: 4008 bytes --]

  reply	other threads:[~2023-09-18 21:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-18 17:42 Mechanism to scale SVG images when default face height changes? Jimmy Yuen Ho Wong
2023-09-18 17:53 ` Eli Zaretskii
2023-09-18 19:16   ` Jimmy Yuen Ho Wong
2023-09-18 18:19 ` Alan Third
2023-09-18 19:10   ` Jimmy Yuen Ho Wong
2023-09-18 19:37     ` Alan Third
2023-09-18 19:55       ` Jimmy Yuen Ho Wong
2023-09-18 20:53         ` Alan Third
2023-09-18 21:04           ` Jimmy Yuen Ho Wong [this message]
2023-09-20 19:12             ` Alan Third

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='CAKDRQS6GQy5AnhH74qGdKAvccUA+X=dZ916fJ4wMy9164YZENg@mail.gmail.com' \
    --to=wyuenho@gmail.com \
    --cc=alan@idiocy.org \
    --cc=emacs-devel@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.