emacs-devel
[Top][All Lists]
Advanced

[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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]