rougier / svg-lib

Emacs SVG libraries for creatings tags, icons and bars
GNU General Public License v3.0
343 stars 31 forks source link

Problem with icon scaling (200%, GTK3 build) #46

Open dgutov opened 5 months ago

dgutov commented 5 months ago

Like discussed in https://github.com/jdtsmith/kind-icon/issues/22#issuecomment-2189593792,

this recipe:

(insert-image (svg-lib-icon  "folder" kind-icon-default-style)) 

leads to the icon being twice as big as it should.

jdtsmith commented 4 months ago

Any ideas on this one @rougier? Some systems get icons that are roughly twice as large as expected, but I haven't figured out a pattern.

rougier commented 2 months ago

Sorry for the long delay. Do you know if your desktop has any kind of software scaling factor ?

jdtsmith commented 2 months ago

@jilen is that true in your case? I have HDPI on Mac but have never encountered this. From my recollection, it seems to be with some Linux HDPI systems.

dgutov commented 2 months ago

Do you know if your desktop has any kind of software scaling factor ?

200%, yes (that's the scaling I'm referring to in the title).

rougier commented 1 month ago

Very, very late sorry for that. Since your desktop has a 200% factor, I need to have access to this information to compute the right size but I'm not sure how to do that with GTK3. Do you know if it is accessible from within Emacs?

dgutov commented 1 month ago

Hi!

Since your desktop has a 200% factor, I need to have access to this information to compute the right size but I'm not sure how to do that with GTK3.

There might be a better answer, but the approach I went with in https://github.com/company-mode/company-mode/blob/master/company.el#L2013 is just specifying :width and :height in pixels without accounting for any scaling factors there. Seems to work fine in the cases I've tested (both GNU/Linux and macOS).

Emacs seems to return accurate line/window heights in pixels when you call default-font-height, frame-pixel-height or display-pixel-height, without adjustment for scaling. They return 34, 1990 and 2160 respectively in my current configuration.