emacs-devel
[Top][All Lists]
Advanced

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

Re: High-res Customize icons


From: Yuan Fu
Subject: Re: High-res Customize icons
Date: Tue, 27 Oct 2020 15:17:37 -0400

> 
> The reason I said defcustom didn't sound like TRT was because I think
> Emacs should handle this automatically.  It should automatically load
> the high resolution images when appropriate.  Where it finds those
> images and by what logic is a secondary question.
> 

I dug a bit further and it seems to do with Cocoa on Mac. On other engines the 
resolution is simply the resolution of the monitor, but Cocoa add an 
abstraction layer and the resolution an applications detects aren’t the actual 
physical resolution.

So for high-res icons we want to simply use the @2x image on Linux and use @2x 
image but with :scale 0.5 on Cocoa. If we use normal image on high-res monitor, 
the image is too small on Linux, and if we are on Cocoa, the image is blurry.

To detect high-res screens on other platforms, we currently have a function 
that measures the pixel height of a default line: if it’s greater than 15 
pixels, we consider the screen high-res and find-image will scale the returned 
image by :scale 2.

Cocoa provides an API for querying the scaling factor, if it is 2, we should 
load the @2x image and add :scale 0.5.

It’s kind of a mess. What do you think?

How about exposing that Cocoa API to lisp and handle accordingly in find-image? 
Some thing like:

(let (img)
  (if (eq (window-system) 'ns)
      ;; Cocoa
      (let ((pixel-scaling-factor (ns-scaling-factor)))
        (if (> pixel-scaling-factor 1.0)
            (append (find-2x-image) '(:scale 0.5))
          (find-normal-image)))
    ;; Other
    (let ((image-scaling-factor (image-compute-scaling-factor
                                 image-scaling-factor)))
      (if (> image-scaling-factor 2)
          (append (find-2x-image) '(:scale 2))
        (find-normal-image)))))


Yuan


reply via email to

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