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: ELPA: New package: svg-lib Date: Mon, 27 Sep 2021 21:19:42 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5116"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: "Nicolas P. Rougier (inria)" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Sep 27 22:22:49 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 1mUx9F-00019B-7R for ged-emacs-devel@m.gmane-mx.org; Mon, 27 Sep 2021 22:22:49 +0200 Original-Received: from localhost ([::1]:39998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mUx9D-00012c-DJ for ged-emacs-devel@m.gmane-mx.org; Mon, 27 Sep 2021 16:22:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUx6N-0006Ek-Si for emacs-devel@gnu.org; Mon, 27 Sep 2021 16:19:51 -0400 Original-Received: from outbound.soverin.net ([2a01:4f8:fff0:65::8:228]:50461) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUx6L-0000CX-EE for emacs-devel@gnu.org; Mon, 27 Sep 2021 16:19:51 -0400 Original-Received: from smtp.soverin.net (unknown [10.10.3.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by outbound.soverin.net (Postfix) with ESMTPS id 378FBD1; Mon, 27 Sep 2021 20:19:46 +0000 (UTC) Original-Received: from smtp.soverin.net (smtp.soverin.net [159.69.232.142]) by soverin.net DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=idiocy.org; s=soverin; t=1632773985; bh=IPTnd0jDQt0NzWpK5xlpYrjSQXhgKTG1RFXf49yJKIo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rINce650p/oLBKMVi/Re0Tus6jgAj1p/Hy+p5aTxzYs6VCT0GFl+mNbRC8x5+hIyN 73MD5sV4NsJQK4eTtV9UkM1Kp41tkxdBnZQv5Xc2em2MblPzml08o2vpWmR944dZrg anTo0dZia0WSiQ3bjA2u075tVEij2d1T5OMAGB9yk9s1SwtDd+Qb5wpfYYDcMNWICz D/DLtAspQKnnjLDZGjBrwkG7mIl+WXDcgPl6p9uZZt/Atzh8XV/K2pES7nLmvRpI97 oHhMET3MX8lRsRoMtBagHhAypWv43duQ4yLo1xuGAmB/dGWpLP3z7cvNgQ3HpxmILl +hrvF9dWslcNg== Original-Received: from alan by faroe.holly.idiocy.org with local (Exim 4.95-RC2) (envelope-from ) id 1mUx6E-000Ntu-SA; Mon, 27 Sep 2021 21:19:42 +0100 Mail-Followup-To: Alan Third , "Nicolas P. Rougier (inria)" , emacs-devel@gnu.org Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=2a01:4f8:fff0:65::8:228; envelope-from=alan@idiocy.org; helo=outbound.soverin.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-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:275615 Archived-At: On Mon, Sep 27, 2021 at 08:03:12PM +0200, Nicolas P. Rougier (inria) wrote: > > Thanks for the information and the code. I did not know about the difference > between Emacs 27 and 28. I did not have a change to test 28. > > My problem can be tested with the code below. The goal is to output an "A" > using SVG and compare it to a regular "A". Ideally, they would need to be > the same with very minor differences (due to different aliasing). But for > some users and for unknown reason, the svg text size is plainly wrong. > > Can you confirm this code works as expected with emacs 28 ? > > #+BEGIN_SRC emacs-lisp > > ;; To adapt font weight: > ;; '((thin . 100) (ultralight . 200) (light . 300) > ;; (regular . 400) (medium . 500) (semibold . 600) > ;; (bold . 700) (extrabold . 800) (black . 900)))) > > (let* ((w (window-font-width)) > (h (window-font-height)) > (font (query-font (font-at (point-min)))) > (font-family (face-attribute 'default :family)) > (font-size (elt font 2)) > (descent (elt font 4)) > (svg (svg-create w h))) > ;; (svg-rectangle svg 0 0 w h :stroke "black" :fill "none") > (svg-text svg "A" > :x 0 > :y descent > :font-family font-family :font-weight 300 > :font-size font-size > :fill (face-attribute 'default :foreground)) > (insert-image (svg-image svg :ascent 'center))) > > #+END_SRC It's very close. It looks almost completely identical under GNUstep, but under GTK it looks like the SVG text is sometimes about one pixel taller, which makes it look slightly different at the default size (14, I think?) but at larger sizes it looks near identical. I suspect the difference I'm seeing is simply down to different font rendering backends. I'm not using hi-dpi, but even setting GDK_SCALE=2 doesn't make any difference. FWIW, I believe that librsvg defaults to 96dpi, however I'm not sure that it always did, I've a feeling it used to use something different, so different versions of librsvg may use different default DPIs. Only Emacs 28 explicitly sets a DPI, so Emacs 27 will use whatever is default for librsvg. I ended up using pixels for font sizes rather than trying to get point sizes to match up. When I DID try to use point sizes, on macOS I had to multiply every size by something like 72/96. That calculation would vary with OS and GUI toolkit, and possibly monitor size too. -- Alan Third