emacs-devel
[Top][All Lists]
Advanced

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

Re: "Fix" sag scaling for hidpi


From: Yuan Fu
Subject: Re: "Fix" sag scaling for hidpi
Date: Wed, 10 Feb 2021 13:00:52 -0500

> 
> One of the main problems I've had with trying to find a solution is to
> work out what we want to actually happen.
> 
> If I open an image on an emacs frame it makes sense that the image
> should be displayed 1:1 with the physical pixels no matter what the
> scale factor is.
> 
> If that frame is then moved to another display with a different scale
> factor do we then resize the image according to the change in scale
> factor (so it's still 1:1 with the physical pixels), or keep it the
> same (logical) size?
> 
> I think we probably want to keep it the same (logical) size, so I
> think we need to, as described elsewhere, expose the scale factor to
> lisp so that create-image can calculate :scale rather than trying to
> calculate it on-the-fly in C code.

I agrees that we should keep the logical size, i.e., keep the size comparing 
against text. If we expose correct physical size, packages that generate 
bitmaps for display can generate crisp bitmaps with correct pixel size.

IIUC, a high-res image with :scale 0.5 should work across high and low-res 
displays. So ideally any package that wants to generate crisp bitmap can get 
the physical size and pixel-ratio from Emacs, generate the image and set :scale 
to 1/pixel-ratio. And this image works across different displays.

> 
> We'll probably have to do more fiddling with SVGs though, since they
> can define sizes in real-world units, like cm or inches, so the dpi
> has to match the physical pixels, and if we move to a different screen
> and regenerate the SVG the DPI will be different but the scale likely
> won't be recalculated and the image will change size.

To simplify things, maybe we can assume DPI is 96. I.e., assume 1 inch = 96 
logical pixels = 96 * pixel-ratio physical pixels.

Obviously, if we can get DPI information from all terminals, then we could use 
that information. But from your previous message it doesn’t seem easy.

> 
> Perhaps we need to let lisp set the DPI for an SVG (and other scalable
> image types) as well as the scale.
> 
> And this is further complicated by the fact macOS uses a "fake" DPI
> that has no relation to physical pixel size at all!
> 
> And, of course, none of this will help when the lisp code doesn't use
> create-image.
> 
> I hope this makes sense, I find this hard to describe.
> -- 
> Alan Third

For SVGs I think we should automatically handle the pixel ratio and dpi so the 
image is always crisp and lisp doesn’t need to do anything (don’t need to add 
the :scale attribute or anything).

For bitmap images I think we display them in their physical size and let lisp 
alter the size by the :scale attribute.

For :width and :height attributes, I think they should be in logical 
pixels.Because the ratio of logical pixels and other text in a buffer doesn’t 
change when you drag a frame across different displays. So if the user set an 
image to have certain :width and drag the frame to a different display, the 
image doesn’t change its size comparing to everything else in the buffer.

Yuan




reply via email to

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