[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using more and/or better icons in Emacs
From: |
Stefan Kangas |
Subject: |
Re: Using more and/or better icons in Emacs |
Date: |
Fri, 9 Apr 2021 19:56:01 -0500 |
Alan Third <alan@idiocy.org> writes:
> On Fri, Apr 09, 2021 at 08:30:14PM +0100, Alan Third wrote:
>> Something like
>>
>> (insert-image (create-image "my/svg/file.svg" 'svg nil
>> :height (line-pixel-height)
>> :ascent 'center))
>>
>> Although it won't tie in quite as neatly as having the actual SVG
>> height set to 1em or whatever.
>
> ... and if you want the actual text height instead of line height it's
> more complex, have a look at scale and height in this:
>
> https://gist.github.com/alanthird/7b86dc66df1ed3b9006bcd3fddd7350f
>
> although there's probably a better way of doing it.
Thanks! That is really useful.
Basing myself on that I have ended up with the following fragment:
(let* ((scale (cadr (assoc :height (assoc 'default face-remapping-alist))))
(family (face-attribute 'default :family))
(height (* (aref (font-info family) 2) (if scale scale 1)))
(ascent (* (aref (font-info family) 8) (if scale scale 1))))
(insert-image (create-image "material/action/ic_search_24px.svg" 'svg nil
:height height
:ascent 'center)))
Unfortunately, the SVG image doesn't change size when I use
`text-scale-adjust'. But in our recent work on `customize' that is not
the case, so I feel like I must be overlooking something here.
> BTW, looking at those icons all you should have to do is set the width
> and height to "1em". I had to insert the viewBox on the other ones
> because they didn't have one to begin with, just the width and height.
The above fragment seems to work the same way whether or not I use 24px
or 1em as width and height in the SVG file. IOW, it doesn't make a
difference.
Is that expected? I can't understand why it wouldn't matter.
- Re: Using more and/or better icons in Emacs, (continued)
- Re: Using more and/or better icons in Emacs, Dmitry Gutov, 2021/04/09
- Re: Using more and/or better icons in Emacs, Stefan Kangas, 2021/04/09
- Re: Using more and/or better icons in Emacs, Dmitry Gutov, 2021/04/09
- Re: Using more and/or better icons in Emacs, Stefan Kangas, 2021/04/09
- Re: Using more and/or better icons in Emacs, Eli Zaretskii, 2021/04/09
- Re: Using more and/or better icons in Emacs, Alan Third, 2021/04/09
- Re: Using more and/or better icons in Emacs, Alan Third, 2021/04/09
- Re: Using more and/or better icons in Emacs, Dmitry Gutov, 2021/04/09
- Re: Using more and/or better icons in Emacs,
Stefan Kangas <=
- Re: Using more and/or better icons in Emacs, Stefan Kangas, 2021/04/09
- Re: Using more and/or better icons in Emacs, Alan Third, 2021/04/10
- Re: Using more and/or better icons in Emacs, Stefan Kangas, 2021/04/10
- Re: Using more and/or better icons in Emacs, Alan Third, 2021/04/10
- Re: Using more and/or better icons in Emacs, Alan Third, 2021/04/12
- Re: Using more and/or better icons in Emacs, Stefan Kangas, 2021/04/12
- Re: Using more and/or better icons in Emacs, Alan Third, 2021/04/13
- Re: Using more and/or better icons in Emacs, Stefan Kangas, 2021/04/13
- Re: Using more and/or better icons in Emacs, Alan Third, 2021/04/13
- Re: Using more and/or better icons in Emacs, Stefan Kangas, 2021/04/13