On Mon, Sep 18, 2023 at 8:37 PM Alan Third 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 > , > > this isn't documented but indeed it scales. > > Ems are only available for images, afaik: > > > https://www.gnu.org/software/emacs/manual/html_node/elisp/Image-Descriptors.html > > > 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 " width=\"512\" > > height=\"512\"> " :scale 1 > > :transform-smoothing t :width (- (1 . em) (1 . px)) :ascent center > :margin > > 1) > > front-sticky nil rear-nonsticky t)) > > ``` > > Hmm, yeah it only supports ems in that format, and it's not clever > enough to be able to do arithmetic on it. The conversion from ems to > pixels is done when the image is to be displayed. > > > 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. > > 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() function, where it can do arithmetic on both relative and absolute units. Is that possible? For my specific purpose, having `:margin` to support floating point em will also suffice, but that doesn't seem to work at the moment. > -- > Alan Third >