From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#37159: 26.1; svg images in eww Date: Thu, 19 Sep 2019 12:02:56 +0100 Message-ID: References: <87r259hdhr.fsf@is.umk.pl> <83sgpphd06.fsf@gnu.org> <877e707cdh.fsf@gnus.org> <83v9ukfjum.fsf@gnu.org> <87sgpo4b80.fsf@gnus.org> <83r258fj6o.fsf@gnu.org> <87zhjv2iwn.fsf@gnus.org> <20190914085951.GA37515@breton.holly.idiocy.org> <87v9tv84m2.fsf@gnus.org> <87r24j6igj.fsf@gnus.org> <20190914155406.GA2686@breton.holly.idiocy.org> <87muf5ycrh.fsf@gnus.org> <87h85c8wax.fsf@potas.fizyka.umk.pl> <87ef0gv327.fsf@gnus.org> <87blvkmi0u.fsf@potas.fizyka.umk.pl> <87ef0gt7iu.fsf@gnus.org> <87woe6dqdn.fsf@host-4-22.fizyka.umk.pl> <87d0fxlnxo.fsf@gnus.org> <875zloofx3.fsf@host-4-42.fizyka.umk.pl> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000016991e0592e5e626" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="243568"; mail-complaints-to="usenet@blaine.gmane.org" Cc: Lars Magne Ingebrigtsen , 37159@debbugs.gnu.org To: Tomasz Piotrowski Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Sep 19 13:05:52 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iAuFz-0011Di-Iz for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Sep 2019 13:05:51 +0200 Original-Received: from localhost ([::1]:42444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAuFy-0006z1-Cg for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Sep 2019 07:05:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57118) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAuEG-0005bJ-0J for bug-gnu-emacs@gnu.org; Thu, 19 Sep 2019 07:04:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAuEE-0007u7-M8 for bug-gnu-emacs@gnu.org; Thu, 19 Sep 2019 07:04:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46364) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iAuEE-0007u1-Jc for bug-gnu-emacs@gnu.org; Thu, 19 Sep 2019 07:04:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iAuEE-0000UW-CL for bug-gnu-emacs@gnu.org; Thu, 19 Sep 2019 07:04:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Sep 2019 11:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37159 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 37159-submit@debbugs.gnu.org id=B37159.15688909991826 (code B ref 37159); Thu, 19 Sep 2019 11:04:02 +0000 Original-Received: (at 37159) by debbugs.gnu.org; 19 Sep 2019 11:03:19 +0000 Original-Received: from localhost ([127.0.0.1]:55185 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAuDW-0000TN-Lv for submit@debbugs.gnu.org; Thu, 19 Sep 2019 07:03:18 -0400 Original-Received: from mail-io1-f44.google.com ([209.85.166.44]:45822) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAuDS-0000T7-QT for 37159@debbugs.gnu.org; Thu, 19 Sep 2019 07:03:17 -0400 Original-Received: by mail-io1-f44.google.com with SMTP id f12so6547855iog.12 for <37159@debbugs.gnu.org>; Thu, 19 Sep 2019 04:03:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pQvEWgf19lKRv26IEc7+ROTITHME1OG6gVaBjSdMS4o=; b=GO1nBSmhrU24vAYBWleJwcSXQiV8HSTUGydEs2UIhjcY1wzTieAuxcL8/XrNq6T1Pe H/qHNAEMTIMCtrpZ+9+oTEKaHphzCjVscBpB7QO3v1C7QDBsqP9QX91xXPMpJ2i9VEYf CqQw0d/QncRbq+hOm6p20ZEbDtak2JLbZKLAJMMfNH2vFPipg5CfYMxlG0suN3ou94Yl AQftAEOy3nose2Zv6J76WkG0AUgHHBttu1qXFpTRxodmMGW6fJXi6DfKLqWdmc1SN9Ix TWjNq9vJlcgfd3xgFveCPS2IcVf04CVaGQb6zOqk58llGd8oJKwXm4LdmIphqDfba9UL OSVg== X-Gm-Message-State: APjAAAW8mnHYxBGLe93WGtY4FqvmU1tjgIEYuZEmrNBPZCRi7kTC1+Pd YVLTwLRBKOJkLZTv7oft/Si8IOqHbaU9AntrkME= X-Google-Smtp-Source: APXvYqzw7kTs5EnxN2hlK8M6GdI1E65A5O9oRdctwhzxSunFotu/wfObHrDQrKOyZaPb7LMVaovvCPd2dxKHcZEMUOY= X-Received: by 2002:a6b:ec0c:: with SMTP id c12mr9462098ioh.138.1568890988958; Thu, 19 Sep 2019 04:03:08 -0700 (PDT) In-Reply-To: <875zloofx3.fsf@host-4-42.fizyka.umk.pl> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:166707 Archived-At: --00000000000016991e0592e5e626 Content-Type: text/plain; charset="UTF-8" On Thu, 19 Sep 2019, 09:21 Tomasz Piotrowski, wrote: > >>> Looks like whatever library Emacs is using for the svgs are saying that > >>> they're shorter than they should be: > >>> > >>> (image-size (create-image "/tmp/d.svg" nil nil :scale 1) t) > >>> => (12 . 13) > >> What would be a solution to this? > > > > I do not know. > If the patch lines are commented out in shr.el: > > ;; SVG images often do not have a specified foreground/background > ;; color, so wrap them in styles. > ;; (when (eq content-type 'image/svg+xml) > ;; (setq data (svg--wrap-svg data))) > (list data content-type))) > > (defun svg--wrap-svg (data)) > ;; "Add a default foreground colour to SVG images." > ;; (with-temp-buffer > ;; (insert " ;; "xmlns:xi=\"http://www.w3.org/2001/XInclude\" " > ;; "style=\"color: " > ;; (face-foreground 'default) ";\">" > ;; " ;; (base64-encode-string data t) > ;; "\">") > ;; (buffer-string))) > > then the equations (SVG images) are not overlapping with surrounding > text. > Hmm, it looks like GTK explicitly sets the width and height of the wrapper to match the SVG file. I don't know how practical that is for us, does it mean loading the file twice: once to get the size and once to wrap it? > --00000000000016991e0592e5e626 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Thu, 19 Sep 2019, 09:21 Tomasz Piotrowski, <tpiotrowski@is.umk.pl> wrote:
>>> Looks like whatever lib= rary Emacs is using for the svgs are saying that
>>> they're shorter than they should be:
>>>
>>> (image-size (create-image "/tmp/d.svg" nil nil :scal= e 1) t)
>>> =3D> (12 . 13)
>> What would be a solution to this?
>
> I do not know.
If the patch lines are commented out in shr.el:

=C2=A0 =C2=A0 ;; SVG images often do not have a specified foreground/backgr= ound
=C2=A0 =C2=A0 ;; color, so wrap them in styles.
=C2=A0 =C2=A0 ;; (when (eq content-type 'image/svg+xml)
=C2=A0 =C2=A0 ;;=C2=A0 =C2=A0(setq data (svg--wrap-svg data)))
=C2=A0 =C2=A0 (list data content-type)))

(defun svg--wrap-svg (data))
=C2=A0 ;; "Add a default foreground colour to SVG images."
=C2=A0 ;; (with-temp-buffer
=C2=A0 ;;=C2=A0 =C2=A0(insert "<svg xmlns:xlink=3D\"http://www.w3.org/1999/xlink\" "
=C2=A0 ;;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"xmlns:xi=3D\"<= a href=3D"http://www.w3.org/2001/XInclude%5C" rel=3D"noreferrer noreferrer"= target=3D"_blank">http://www.w3.org/2001/XInclude\" "
=C2=A0 ;;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"style=3D\"colo= r: "
=C2=A0 ;;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(face-foreground 'def= ault) ";\">"
=C2=A0 ;;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"<xi:include href= =3D\"data:image/svg+xml;base64,"
=C2=A0 ;;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(base64-encode-string dat= a t)
=C2=A0 ;;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"\"></xi:= include></svg>")
=C2=A0 ;;=C2=A0 =C2=A0(buffer-string)))

then the equations (SVG images) are not overlapping with surrounding
text.

Hmm, it looks like GTK explicitly sets the width and height of the wr= apper to match the SVG file. I don't know how practical that is for us,= does it mean loading the file twice: once to get the size and once to wrap= it?
--00000000000016991e0592e5e626--