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: Mechanism to scale SVG images when default face height changes? Date: Mon, 18 Sep 2023 21:53:33 +0100 Message-ID: References: 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="5485"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Emacs-Devel devel To: Jimmy Yuen Ho Wong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Sep 18 22:54:32 2023 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 1qiLGK-0001EW-0y for ged-emacs-devel@m.gmane-mx.org; Mon, 18 Sep 2023 22:54:32 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiLFY-0001to-U4; Mon, 18 Sep 2023 16:53:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiLFV-0001tf-BQ for emacs-devel@gnu.org; Mon, 18 Sep 2023 16:53:41 -0400 Original-Received: from dane.soverin.net ([2a10:de80:1:4091:b9e9:2218:0:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qiLFT-0003yZ-5M for emacs-devel@gnu.org; Mon, 18 Sep 2023 16:53:41 -0400 Original-Received: from smtp.soverin.net (c04smtp-lb01.int.sover.in [10.10.4.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dane.soverin.net (Postfix) with ESMTPS id 4RqH7x6VlQzybW; Mon, 18 Sep 2023 20:53:33 +0000 (UTC) Original-Received: from smtp.soverin.net (smtp.soverin.net [10.10.4.100]) by soverin.net (Postfix) with ESMTPSA id 4RqH7x3yCbzFv; Mon, 18 Sep 2023 20:53:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=idiocy.org; s=soverin; t=1695070413; bh=ZP5hk+3ZEHKMFcNL92OW9IfndHQQVZCB65k6/0VvQrE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=P6apKgfeyLtkO2SPADWaJXc0gX1qlbJmbtk3VVHIe9D6JVf883YT4xBT4w4h5yatT Rcy903ojFuNOvek5Oykseg2cNDdEwA3uhgWoUH7gpb5KoobPyMm5L6snI5mToU0jZQ /PJlAln4WTsFN67H55wWpCycvc4+oC4R6zfHulKaI8KBdaqtvv9MQpTqwkyeC+rCIg waKv3kTO7PxM7dloYQeVIqNFzZacdCQV2CGtraQurehncam3FlXqH5Am0tGN0aaC+/ 5dyCbLKJVMQ4n3lqxvPRhhAxhKBrGRuh2HhB8JQxQWG0EJUQjghZDbD5KQSuMSsUZF Gxyytyp+rOAsQ== Original-Received: from alan by faroe.holly.idiocy.org with local (Exim 4.96) (envelope-from ) id 1qiLFN-000Bzn-0I; Mon, 18 Sep 2023 21:53:33 +0100 X-Soverin-Authenticated: true Mail-Followup-To: Alan Third , Jimmy Yuen Ho Wong , Emacs-Devel devel Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=2a10:de80:1:4091:b9e9:2218:0:1; envelope-from=alan@idiocy.org; helo=dane.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_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.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:310726 Archived-At: On Mon, Sep 18, 2023 at 08:55:55PM +0100, Jimmy Yuen Ho Wong wrote: > On Mon, Sep 18, 2023 at 8:37 PM Alan Third wrote: > > > On Mon, Sep 18, 2023 at 08:10:59PM +0100, Jimmy Yuen Ho Wong wrote: > > > Ah, I was looking at > > > > > https://www.gnu.org/software/emacs/manual/html_node/elisp/Pixel-Specification.html > > , > > > > I suppose you could calculate the number of ems required by > > doing something like... > > > > ((/ (- font-px-size 1) font-px-size) . 'em) > > > > But while that would scale on demand, it wouldn't scale properly > > because the calculation is done before the user changes the font size. > > > > I can't think of any way round it, or even any practical way to extend > > the current mechanism. > > > > > Sad face :(. I suppose what I'm really looking for is to extend the pixel > specification mini language to support something like CSS' calc() > function, where it > can do arithmetic on both relative and absolute units. > > Is that possible? I didn't actually know about the pixel specification language before now. It seems to me like it would make sense to teach the image code to understand it too and add ems to it, but since I know nothing about it I can't say if that's practical or not. > For my specific purpose, having `:margin` to support > floating point em will also suffice, but that doesn't seem to work at the > moment. Indeed, this would actually be quite simple, but it won't help you now as it won't be available until Emacs 30. All I can suggest for compatibility with current versions of Emacs is to wrap the SVG's within other SVGs. We do this internally in Emacs to implement vector scaling and you could probably do something similar, although I'm not sure exactly how much control you could get from it. For example, you can do something like: It should be possible to scale down the embedded image to leave a gap around it, but I'd have to go and investigate how to do it. I recommend base64 encoding the SVG data as shown above, because directly embedding the SVG text can be problematic unless it's very simple. -- Alan Third