From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.devel Subject: Re: Using more and/or better icons in Emacs Date: Fri, 9 Apr 2021 19:56:01 -0500 Message-ID: References: <2f0b4786-d569-27e6-fa8a-fb47bf08b166@yandex.ru> <0279fbc8-74c3-3766-2b26-b3eb933a501e@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37156"; mail-complaints-to="usenet@ciao.gmane.io" To: Alan Third , Dmitry Gutov , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Apr 10 02:57:13 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 1lV1w0-0009WV-WF for ged-emacs-devel@m.gmane-mx.org; Sat, 10 Apr 2021 02:57:13 +0200 Original-Received: from localhost ([::1]:48458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lV1w0-00039r-12 for ged-emacs-devel@m.gmane-mx.org; Fri, 09 Apr 2021 20:57:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lV1ux-0002Kb-Jt for emacs-devel@gnu.org; Fri, 09 Apr 2021 20:56:07 -0400 Original-Received: from mail-pf1-f179.google.com ([209.85.210.179]:41504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lV1ut-0002vH-OS for emacs-devel@gnu.org; Fri, 09 Apr 2021 20:56:06 -0400 Original-Received: by mail-pf1-f179.google.com with SMTP id l123so5313179pfl.8 for ; Fri, 09 Apr 2021 17:56:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:mime-version:date :message-id:subject:to; bh=m4jlmnHNfVcCLLw/ooKF7jrq8Fy2HIi3zPwXNyILiu8=; b=dO2rFMn2VddqHaRso7uQa5dH9eSddQ28jjVfrpE+g/M6I8Eds1tpqAYr1+tPaXQVpg 9k4OA0pslEp2KZNlToNXDOO9dqW9jhTVLewP1rKoowDgvXjM3SrpbNqlJr76bkvesh5b V7+tUw9NTUyJppC0jVztVIMn13HyjwV7OcuVGwaibXbK8+YDAdh9STJxpUbawyF2kd4P qBakjHv5oKsLmID/CdDNa9uTITcJv/6OJE7b+aiS8cdsBpVbPYB0nMacMF19DBR1oECg V2UyicZpeXl9dR8oyZ67P/SITJtuFuvxfJiyE0ZLNlA5REHufe4BvtDwU5Jo//C54krU jphw== X-Gm-Message-State: AOAM533XYk5MPRXJzSUaSSLNz7gQT6lpV783JQeZRsmnTnZlnMSINSyV StEmICnFrbayGNWY9uCjxLZq1XbGyRh09nqRifE= X-Google-Smtp-Source: ABdhPJzgJWmFYZ47i+cfLZ4oUWbVdEA9OFm4Q/wIRqkPTIFC/fonKa8M949w/q5Sz05dQjFaSRkLs26OMG/asa2TzJk= X-Received: by 2002:a65:4046:: with SMTP id h6mr15522372pgp.345.1618016161445; Fri, 09 Apr 2021 17:56:01 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Fri, 9 Apr 2021 19:56:01 -0500 In-Reply-To: Received-SPF: pass client-ip=209.85.210.179; envelope-from=stefankangas@gmail.com; helo=mail-pf1-f179.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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:267761 Archived-At: Alan Third writes: > On Fri, Apr 09, 2021 at 08:30:14PM +0100, Alan Third wrote: >> Something like >> >> (insert-image (create-image "my/svg/file.svg" 'svg nil >> :height (line-pixel-height) >> :ascent 'center)) >> >> Although it won't tie in quite as neatly as having the actual SVG >> height set to 1em or whatever. > > ... and if you want the actual text height instead of line height it's > more complex, have a look at scale and height in this: > > https://gist.github.com/alanthird/7b86dc66df1ed3b9006bcd3fddd7350f > > although there's probably a better way of doing it. Thanks! That is really useful. Basing myself on that I have ended up with the following fragment: (let* ((scale (cadr (assoc :height (assoc 'default face-remapping-alist)))) (family (face-attribute 'default :family)) (height (* (aref (font-info family) 2) (if scale scale 1))) (ascent (* (aref (font-info family) 8) (if scale scale 1)))) (insert-image (create-image "material/action/ic_search_24px.svg" 'svg nil :height height :ascent 'center))) Unfortunately, the SVG image doesn't change size when I use `text-scale-adjust'. But in our recent work on `customize' that is not the case, so I feel like I must be overlooking something here. > BTW, looking at those icons all you should have to do is set the width > and height to "1em". I had to insert the viewBox on the other ones > because they didn't have one to begin with, just the width and height. The above fragment seems to work the same way whether or not I use 24px or 1em as width and height in the SVG file. IOW, it doesn't make a difference. Is that expected? I can't understand why it wouldn't matter.