From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.devel Subject: Re: "Fix" sag scaling for hidpi Date: Sun, 7 Feb 2021 21:58:43 +0000 Message-ID: References: <07D5E64D-DAD0-45B3-B272-627A73D7CBAE@gmail.com> <7308DB2C-27A5-4227-A1F9-9949EE558052@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40320"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , emacs-devel To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Feb 07 23:10:31 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 1l8sGF-000AOq-BB for ged-emacs-devel@m.gmane-mx.org; Sun, 07 Feb 2021 23:10:31 +0100 Original-Received: from localhost ([::1]:50338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8sGE-0004WF-Ci for ged-emacs-devel@m.gmane-mx.org; Sun, 07 Feb 2021 17:10:30 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8s5r-0006HI-Qz for emacs-devel@gnu.org; Sun, 07 Feb 2021 16:59:47 -0500 Original-Received: from [217.169.17.33] (port=52896 helo=breton.holly.idiocy.org) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8s5q-0008IM-9t for emacs-devel@gnu.org; Sun, 07 Feb 2021 16:59:47 -0500 Original-Received: by breton.holly.idiocy.org (Postfix, from userid 501) id 46A00202A3A7A2; Sun, 7 Feb 2021 21:58:43 +0000 (GMT) Mail-Followup-To: Alan Third , Yuan Fu , Stefan Monnier , emacs-devel Content-Disposition: inline In-Reply-To: <7308DB2C-27A5-4227-A1F9-9949EE558052@gmail.com> X-Host-Lookup-Failed: Reverse DNS lookup failed for 217.169.17.33 (failed) Received-SPF: none client-ip=217.169.17.33; envelope-from=alan@breton.holly.idiocy.org; helo=breton.holly.idiocy.org X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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:264141 Archived-At: On Thu, Feb 04, 2021 at 06:10:15PM -0500, Yuan Fu wrote: > > > > On Feb 4, 2021, at 5:07 PM, Stefan Monnier wrote: > > > >> And Emacs will display a crisp 100x100 image in the buffer. However, this doesn’t work for sag images. If I do > >> > >> (progn > >> (require 'svg) > >> (let ((svg (svg-create 200 200))) > >> (svg-text svg "test" > >> :font-size 100 > >> :y 150) > >> (insert-image (svg-image svg :scale 0.5)))) > >> > >> The image is still blurry: > > > > I think it's a bug, and that even > > > > (progn > > (require 'svg) > > (let ((svg (svg-create 100 100))) > > (svg-text svg "test" > > :font-size 100 > > :y 150) > > (insert-image (svg-image svg :scale 1.0)))) > > > > should insert a crisp image. > > Sorry, I should be more specific. This blurry problem only occurs on > nsterm with hidpi screens. (That’s because cocoa reports logical > pixel sizes instead of physical ones.) At one time I had a patch that fixed this for SVGs on NS, but I wasn't sure if it was "available" on other platforms (GTK is the only place I know of that lets you set default scaling) and it wasn't generalised to all images. The best solution I could find is to set the SVG dpi and size according to the real screen DPI, then when it comes to generating the transform matrix allow divide the sizes by the scale factor. It also wasn't clear to me what we should do about dpi on macOS. Apparently macOS pretends the dpi is 72 no matter what the real value is, and that meant keeping track of both the fake dpi and the real dpi. I wish I could find that patch now, but I guess it was deleted in a clean-up. -- Alan Third