From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: "Fix" sag scaling for hidpi Date: Wed, 10 Feb 2021 21:01:35 -0500 Message-ID: <9C04F72C-1BB6-4308-AD8E-4A2B471CAC4E@gmail.com> References: <07D5E64D-DAD0-45B3-B272-627A73D7CBAE@gmail.com> <7308DB2C-27A5-4227-A1F9-9949EE558052@gmail.com> <87sg6alweo.fsf@gnus.org> <87pn1erewq.fsf@gmail.com> <87wnvlecrw.fsf@gnus.org> <83sg69o3av.fsf@gnu.org> <87mtwhctte.fsf@gnus.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2970"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , emacs-devel , Eli Zaretskii , monnier@iro.umontreal.ca, Robert Pluim To: Alan Third Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Feb 11 03:03:33 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lA1KO-0000bD-0m for ged-emacs-devel@m.gmane-mx.org; Thu, 11 Feb 2021 03:03:32 +0100 Original-Received: from localhost ([::1]:57496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lA1KM-0003Vd-WD for ged-emacs-devel@m.gmane-mx.org; Wed, 10 Feb 2021 21:03:31 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lA1Id-00030f-FI for emacs-devel@gnu.org; Wed, 10 Feb 2021 21:01:44 -0500 Original-Received: from mail-qv1-xf36.google.com ([2607:f8b0:4864:20::f36]:44298) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lA1IY-0004eF-VN; Wed, 10 Feb 2021 21:01:43 -0500 Original-Received: by mail-qv1-xf36.google.com with SMTP id r13so1891017qvm.11; Wed, 10 Feb 2021 18:01:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=LFePYFXqRZtWtXO6PbyW418jDCM/jozEAkuMb26g04U=; b=lJbUNQu3A4bhJS5HUoFEVY3dGS23YR8HITyronLvZqgv7ecThPgK9wnef8oEr5FAut wY5UKEJfFfdU5Kc7xDfUZh7Od1GQt7QnpArc9qJqtmK6ZmzHrxYURVRv4VvMod1tBvn8 VbBxPp1IbEsPVd8BGwuKG5ZFcCGh5hOIBlQa0m5EOxKC0ijVcbZWf40zugRLdJ4nLLdy 6PhphexFwU5gZ/JNKaKG8nJPYLKJL9zr9gNu3lpnctzMRe8xiozaJxygt+it2cslf+sl JvFcIX/AJF4g+gQhscdNAFwzD2jjwrHGSArU+NDPxuXo6o8SdJNdkaLKy0mK8vGsMBre Celg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=LFePYFXqRZtWtXO6PbyW418jDCM/jozEAkuMb26g04U=; b=H8ccSA6TptVlrY6VTv8eoePk8IqW80VTO5AJcZQzVixVgxrrRpvELsiNTHYI9OpOR3 OUifDxicDKbSZhUB1MU8LmLSCjeGmrnXRSsRsBDaQ8afTEcm/57AmvMXELzvdVO+N4pQ bBrHzomXPFXDq4Xy0Ofow9+Z08upSlxiu1WVapCryWFC6J1y+egRAdXi0HgSjHY0bvCa /CYuT32W0hfAuSYxSxVP1x+CqkSXtYPqC3bYynwzjfWaFyVyKK+lratvYAnSOBWuXmGD qsWWej+qR+QopCewWgwb5wlkgv0J5Mmox/1nJDWWLFq3tSjctLlMkOLkwmCDAVT9qRVl CM6g== X-Gm-Message-State: AOAM533MlINHRR1QjnY0hEVV1RlHTnbrMPaZ6J66ytNfvS61WjE2WJo/ V81I/Ioy8R465bkmDbZeA1w= X-Google-Smtp-Source: ABdhPJwqKhRgciPtVlAdDkAv1Z07ZA/v1DuwXUCzs26SF/DA3F0sqnl81vB0ceHnjVFJG5Z+olXzew== X-Received: by 2002:ad4:54ad:: with SMTP id r13mr5830498qvy.48.1613008896772; Wed, 10 Feb 2021 18:01:36 -0800 (PST) Original-Received: from ?IPv6:2601:98a:4102:3d80:1cab:85e9:2916:9018? ([2601:98a:4102:3d80:1cab:85e9:2916:9018]) by smtp.gmail.com with ESMTPSA id o12sm2963675qko.117.2021.02.10.18.01.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Feb 2021 18:01:36 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3654.60.0.2.21) Received-SPF: pass client-ip=2607:f8b0:4864:20::f36; envelope-from=casouri@gmail.com; helo=mail-qv1-xf36.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:264345 Archived-At: > On Feb 10, 2021, at 6:55 PM, Alan Third wrote: >=20 > On Wed, Feb 10, 2021 at 01:00:52PM -0500, Yuan Fu wrote: >> 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. >>=20 >> 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. >=20 > Yes, until the users drags the frame from a scale factor 1 screen to a > scale factor 2 screen, then it's blurry again. But I really don't > think there is a satisfactory solution to that. I think that=E2=80=99s fine. If the user don=E2=80=99t want his image to = be blurry, he should provide a high-enough-resolution image. >=20 >>> 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. >>=20 >> To simplify things, maybe we can assume DPI is 96. I.e., assume 1 >> inch =3D 96 logical pixels =3D 96 * pixel-ratio physical pixels. >>=20 >> Obviously, if we can get DPI information from all terminals, then we >> could use that information. But from your previous message it >> doesn=E2=80=99t seem easy. >=20 > After messing about a bit today, I think the DPI thing is a red > herring. If we calculate the logical size of the SVG, then just > multiply it by the scale factor, then when drawing scale it down by > the scale factor everything is the right size and we can forget about > modifying the dpi. >=20 >> For SVGs I think we should automatically handle the pixel ratio and >> dpi so the image is always crisp and lisp doesn=E2=80=99t need to do >> anything (don=E2=80=99t need to add the :scale attribute or = anything). >>=20 >> For bitmap images I think we display them in their physical size and >> let lisp alter the size by the :scale attribute. >>=20 >> 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=E2=80=99t 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=E2=80=99t = change its >> size comparing to everything else in the buffer. >=20 > Attached is a first go at this. I can't work out image.el and > image-mode.el, so I'll either need a lot more time or someone more > familiar with them can have a look. >=20 > The basic problem is that image-size returns physical pixels, and we > want to calculate logical pixels. I tried a few things and failed > miserably. I tried changing image-size to return logical pixels, but > that just seemed to make everything worse, and I don't think it's a > good idea to lie about the image size. I=E2=80=99m not sure what do you want to achieve here. Are you trying to = automatically size bitmap images when opening them, so that it is = displayed 1:1 to physical pixels? If can do something like this: (insert-image (create-image "~/d/Screen Shot 2021-02-09 at 10.11.56 = AM.png" nil nil :scale (/ 1 (frame-scale-factor)))) And the image inserted is displayed 1:1 to physical pixels. But :scale = is not really meant for controlling pixel ratio. Maybe we should add a = :pixel-ratio (or :scale-factor) attribute to control the default display = size of a bitmap image? > Anyway, SVGs will display nicely on macOS with the attached patch, and > frame-scale-factor returns a useful value. I didn't write the code for > GTK yet, but I guess it's probably not too hard. Yes, SVGs worked well! >=20 > I guess we also want to change the ghostscript code to do the same > thing as the SVG code too? I think so. Another question is what unit should :width and :height attributes use, = but I guess we can discuss them later. Yuan=