emacs-svg-icon
emacs-svg-icon copied to clipboard
Icons Appear Very Small
My icons appear much smaller than those in the README, even when running emacs -q
.
Any idea why that might be?
Can you access the retrieved / cached SVG and check the size and viewport ? Is is the same for any icon?
Can you access the retrieved / cached SVG and check the size and viewport
Yeah, I believe this is the cached values:
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
Is is the same for any icon?
Yes, it's the same for every icon.
If you open the SVG directly with emacs, is it (approximately) the same size visually?
I may have been looking at the wrong cache actually, here's what the call returns:
(plist-get (cdr (svg-icon "material" "attachment")) :data)
;; => "<svg width=\"14\" height=\"15\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" fill=\"#d8dee9\" viewBox=\"0.000000 -4.000000 24.000000 32.000000\" stroke-width=\"0\"> <rect width=\"24\" height=\"32\" x=\"0\" y=\"-4\" fill=\"transparent\" stroke-width=\"0\"></rect> <path fill=\"#d8dee9\" d=\"M7.5,18A5.5,5.5 0 0,1 2,12.5A5.5,5.5 0 0,1 7.5,7H18A4,4 0 0,1 22,11A4,4 0 0,1 18,15H9.5A2.5,2.5 0 0,1 7,12.5A2.5,2.5 0 0,1 9.5,10H17V11.5H9.5A1,1 0 0,0 8.5,12.5A1,1 0 0,0 9.5,13.5H18A2.5,2.5 0 0,0 20.5,11A2.5,2.5 0 0,0 18,8.5H7.5A4,4 0 0,0 3.5,12.5A4,4 0 0,0 7.5,16.5H17V18H7.5Z\" stroke-width=\"0\"></path></svg>"
If you open the SVG directly with emacs, is it (approximately) the same size visually?
If I open that directly with Emacs it seems to be exactly the same size as the one inserted (which probably makes sense given I originally shared the wrong svg.
That's weird because from https://materialdesignicons.com/, the size should be 24x24 (see below). Can you try to clear the cache and retry?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24">
<path fill="#000000" d="M7.5,18A5.5,5.5 0 0,1 2,12.5A5.5,5.5 0 0,1 7.5,7H18A4,4 0 0,1 22,11A4,4 0 0,1 18,15H9.5A2.5,2.5 0 0,1 7,12.5A2.5,2.5 0 0,1 9.5,10H17V11.5H9.5A1,1 0 0,0 8.5,12.5A1,1 0 0,0 9.5,13.5H18A2.5,2.5 0 0,0 20.5,11A2.5,2.5 0 0,0 18,8.5H7.5A4,4 0 0,0 3.5,12.5A4,4 0 0,0 7.5,16.5H17V18H7.5Z" />
</svg>
You're right, that's actually what is in the cache. When I run svg-icon
, it then transforms it to the second set of dimensions I shared 14x15.
After playing with the code a bit, it all seems to come down the my text scale which is 7x15. Using a size 14 font which gives a scale of 8x18 makes things much clearer.
Thanks for going back and forth on this!
14x15 is the expected dimension since an icon is supposed to be 2 characters wide. There's a pending PR to have the possibility to zoom the icon inside (without changing the enclosing size). Hopefully, this could solve your problem.
This happens for me in Emacs 28.3 but not in Emacs 29.
@konrad1977 you mean it is working properly with Emacs 29?
@rougier yes, 29 and 30 works as expected, but its very small in 28.2
@konrad1977 that's interesting because this means something has changed in 29 in how svg are handled. I need to setup a debug function with all the different dimensions needed to check what is different from one version to the other. In the meantime, can you try the svg-lib which is on elpa and is supposed to be a bit more robust?