bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#47074: Replace XPM icons with Unicode codepoints in customize/widget


From: Alan Third
Subject: bug#47074: Replace XPM icons with Unicode codepoints in customize/widgets
Date: Thu, 11 Mar 2021 23:49:54 +0000

On Thu, Mar 11, 2021 at 10:01:11PM +0200, Eli Zaretskii wrote:
> > 
> > I think SVG is obviously much preferable to XPM, but there is still the
> > problem that the images don't scale with the text.  Do we have a general
> > solution to that?  If not, should we have one?
> 
> With SVG, I believe we could.  (We can scale other kinds of images as
> well, but they don't look well when enlarged, AFAIK.)

I've been thinking about this, and assuming we can extract the font
name and size from the face in C then we can create a default CSS
stylesheet that should make 1em in an SVG equivalent to the actual
Emacs font height.

It might mean rewriting the code I recently rewrote to extract the
foreground and background colours to just reference the face id, but
that will probably result in even less good image caching than we have
at the moment.

In fact, it's possible to build an SVG within Emacs that contains the
correct font details that will display at the correct size.

Something like this:

(require 'svg)
(let* ((scale (cadr (assoc :height (assoc 'default face-remapping-alist))))
       (height (* (/ (face-attribute 'default :height) 10) (if scale scale 1)))
       (family (face-attribute 'default :family))
       (img (svg-create height height
                        :font-size height
                        :font-family family)))
  (svg-circle img "0.5em" "0.5em" "0.5em")
  (insert "XX")
  (insert-image (svg-image img :ascent 'center))
  (insert "XX"))

Alas it doesn't resize the image as you scale with C-x C-+.

Perhaps there is some way to mark certain SVGs as part of the UI and
regenerate them?

Yet another alternative is to define a different text property (or
whatever) that only draws SVGs, but on the fly so there's no caching
and we can put them anywhere in the frame. But that might not be a
good idea.
-- 
Alan Third





reply via email to

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