unofficial mirror of emacs-devel@gnu.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 20:10:59 +0100	[thread overview]
Message-ID: <CAKDRQS7MNQG5+cMi4kjd-zMxUg=U+xqBe4rP04w1-W39Pr3mrQ@mail.gmail.com> (raw)
In-Reply-To: <ZQiUzk6WCe7fHunQ@idiocy.org>

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

Ah, I was looking at
https://www.gnu.org/software/emacs/manual/html_node/elisp/Pixel-Specification.html,
this isn't documented but indeed it scales.

```elisp
#("" 0 1
  (face all-the-icons-lpurple font-lock-face all-the-icons-lpurple
fontified t display
        (image :type svg :data "<svg viewBox=\"0 0 512 512\" width=\"512\"
height=\"512\"> <path d=\"...snip...\"></path></svg>" :scale 1
:transform-smoothing t :width (1 . em) :ascent center :margin 1)
        front-sticky nil rear-nonsticky t))
```

But this doesn't seem to work, I suppose px is not a unit?

```elisp
#("" 0 1
  (face all-the-icons-lpurple font-lock-face all-the-icons-lpurple
fontified t display
        (image :type svg :data "<svg viewBox=\"0 0 512 512\" width=\"512\"
height=\"512\"> <path d=\"...snip...\"></path></svg>" :scale 1
:transform-smoothing t :width (- (1 . em) (1 . px)) :ascent center :margin
1)
        front-sticky nil rear-nonsticky t))
```

I like this approach a lot, but I do need pixel precision calculated on
demand because I need to add a 1px margin between icons. If I don't
subtract 2 px back from the dimensions, the icons will be wider than a
character.

Jimmy


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

> On Mon, Sep 18, 2023 at 06:42:33PM +0100, Jimmy Yuen Ho Wong wrote:
> > In the SVG branch in all-the-icons, all the icons are inserted with a
> > `:width` and `:height` properties set on the image, and the face is
> applied
> > to the propertized string. i.e.
> >
> > ```elisp
> > ELISP> (all-the-icons-icon-for-file "test.js")
> > #("" 0 1
> >   (face all-the-icons-lpurple font-lock-face all-the-icons-lpurple
> > fontified t display
> >         (image :type svg :data "<svg viewBox=\"0 0 512 512\"
> width=\"512\"
> > height=\"512\"> <path d=\"...snip...\"></path></svg>" :scale 1
> > :transform-smoothing t :width 14 :height 14 :ascent center :margin 1)
> >         front-sticky nil rear-nonsticky t))
> > ```
>
> Do you need to set the size in pixels? If you set the size in em's
> (from Emacs 28 up) then it will scale automatically.
>
> --
> Alan Third
>

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

  reply	other threads:[~2023-09-18 19:10 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 [this message]
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
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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='CAKDRQS7MNQG5+cMi4kjd-zMxUg=U+xqBe4rP04w1-W39Pr3mrQ@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).