From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: David Ponce via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#72198: 31.0.50; `svg-print' add useless and possibly wrong space in XML representation. Date: Fri, 19 Jul 2024 16:10:00 +0200 Message-ID: Reply-To: David Ponce Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------Eg3Aus0BQcIgj183hqVPPrQ0" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25976"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird To: 72198@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 19 20:24:31 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1sUsHP-0006Yt-8U for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 19 Jul 2024 20:24:31 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUsHI-0002a8-4Z; Fri, 19 Jul 2024 14:24:24 -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 1sUsG4-0005y0-2V for bug-gnu-emacs@gnu.org; Fri, 19 Jul 2024 14:23:08 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUsG3-0006po-Nc for bug-gnu-emacs@gnu.org; Fri, 19 Jul 2024 14:23:07 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sUsG2-00068a-RT for bug-gnu-emacs@gnu.org; Fri, 19 Jul 2024 14:23:06 -0400 X-Loop: help-debbugs@gnu.org Resent-From: David Ponce Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 19 Jul 2024 18:23:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 72198 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.172141335423114 (code B ref -1); Fri, 19 Jul 2024 18:23:06 +0000 Original-Received: (at submit) by debbugs.gnu.org; 19 Jul 2024 18:22:34 +0000 Original-Received: from localhost ([127.0.0.1]:50603 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sUsFW-00060h-1C for submit@debbugs.gnu.org; Fri, 19 Jul 2024 14:22:34 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:40058) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sUsBW-0005hy-LD for submit@debbugs.gnu.org; Fri, 19 Jul 2024 14:18:29 -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 1sUoJI-0002w8-3L for bug-gnu-emacs@gnu.org; Fri, 19 Jul 2024 10:10:12 -0400 Original-Received: from smtp-84.smtpout.orange.fr ([80.12.242.84] helo=msa.smtpout.orange.fr) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUoJF-0002xO-1d for bug-gnu-emacs@gnu.org; Fri, 19 Jul 2024 10:10:11 -0400 Original-Received: from [192.168.1.21] ([2.7.225.247]) by smtp.orange.fr with ESMTPA id UoJ7s7ByxwQ1TUoJ7swQHL; Fri, 19 Jul 2024 16:10:03 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1721398203; bh=kY9HYqaZVHsbMjeVBAWPOV+GrkC32MaN+iQYl/AL+mY=; h=Message-ID:Date:MIME-Version:To:From:Subject; b=IvH96DTjeqkzyQ+r7M0P5DvI7LmPQWNpcsoaHtmP7qvEDf/zVBSyGSuLzWOKLlYQe l4d3vncPXPZC4ervhEToW5TiKmkwTA8tuTd84e5JpYBv+2NJjBxihLzc8X4R7TwTTk 5mHGOC4ExFsvBRUWuU8qoDV23Pejyz9+O52Nmn21g0ER+62O+xBdqGacFdAoJ/9Fg1 CtQy7J68xCaYGpcMoTvOnVzRE2QuY689KzzK8wp4/Jgz2phEfRtK9nBfwYQ9ifBM0I gIunNaRRHYK7VIRUWqP6w9268saTCVkoDi/UjzFg8+w0n/n9ErUljaC0y2TqDc5Gu4 Kk/W7jK8TnK0Q== X-ME-Helo: [192.168.1.21] X-ME-Auth: ZGFfdmlkQHdhbmFkb28uZnI= X-ME-Date: Fri, 19 Jul 2024 16:10:03 +0200 X-ME-IP: 2.7.225.247 Content-Language: fr, en-US Received-SPF: pass client-ip=80.12.242.84; envelope-from=da_vid@orange.fr; helo=msa.smtpout.orange.fr X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:288995 Archived-At: This is a multi-part message in MIME format. --------------Eg3Aus0BQcIgj183hqVPPrQ0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hello, While working on generating SVG images from text, I discovered that the "svg-print" function adds extra space in front of the XML representation of each child node. This is usually not a problem because, by default, extra spaces are ignored. But this becomes a problem, especially for text nodes, when the `xml:space' attribute is set to "preserve" to indicate that spaces in texts are not ignored. Because, in this case, the XML representation of the text node no longer corresponds to the original definition, including unwanted additional spaces. Here are two examples which illustrate the problem to be evaluated in the *scratch* buffer (emacs -Q): (require 'svg) ;; Simple text with extra spaces between words. (let* ((text "This buffer is for text that is not saved.") (w (* (length text) (default-font-width))) (h (* 1.5 (default-font-height))) (xmlspace "preserve") ;; Rendering preserves spaces. (svg (svg-create w h :xml:space xmlspace :stroke-width 0))) (svg-rectangle svg 0 0 w h :fill "blue") (svg-text svg text :y "1em" :fill "white") (insert-image (svg-image svg :scale 1))) ;; Aggregate texts separated by 1 space. (let* ((texts '("This buffer is " "for text that " "is not saved.")) (w (* (apply #'+ (mapcar #'length texts)) (default-font-width))) (h (* 1.5 (default-font-height))) (xmlspace "preserve") ;; Rendering preserves spaces. (svg (svg-create w h :xml:space xmlspace :stroke-width 0))) (svg-rectangle svg 0 0 w h :fill "blue") (dom-append-child svg (apply #'dom-node 'text '((y . "1em") (fill . "white")) texts)) (insert-image (svg-image svg :scale 1))) Since the extra space in front of the XML representation of each child node is unnecessary according to the SVG 1.1 specification, the attached V0 patch resolves this issue by removing the offending statement. The attached V1 patch is a proposal to go a step further by improving the documentation and using the DOM API to access parts of dom node. Thanks. In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.42, cairo version 1.18.0) of 2024-07-17 Repository revision: 3a790abd869ddadc343710deb0c4368227ba6611 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12014000 System Description: Fedora Linux 40 (KDE Plasma) Configured using: 'configure --with-x-toolkit=gtk3 --with-cairo-xcb --with-native-compilation=no PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB Important settings: value of $LC_TIME: fr_FR.utf8 value of $LANG: fr_FR.UTF-8 locale-coding-system: utf-8-unix --------------Eg3Aus0BQcIgj183hqVPPrQ0 Content-Type: text/x-patch; charset=UTF-8; name="svg-print-V1.patch" Content-Disposition: attachment; filename="svg-print-V1.patch" Content-Transfer-Encoding: base64 MjAyNC0wNy0xOSAgRGF2aWQgUG9uY2UgIDxkYV92aWRAb3JhbmdlLmZyPgoKCSogc3ZnLmVs IChzdmctcHJpbnQpOiBSZW1vdmUgdXNlbGVzcyBleHRyYSBzcGFjZSBmcm9tIHRoZSBYTUwK CXJlcHJlc2VudGF0aW9uIG9mIFNWRyBub2RlLiAgVXNlIHRoZSBkb20gQVBJIHRvIGFjY2Vz cyBwYXJ0cyBvZgoJZG9tIG5vZGUuIEltcHJvdmUgZG9jIHN0cmluZy4KCmRpZmYgLS1naXQg YS9saXNwL3N2Zy5lbCBiL2xpc3Avc3ZnLmVsCmluZGV4IGYyZWIyZWM2NmRkLi4xZmVkNmM2 YjNiOCAxMDA2NDQKL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kb20tYXR0cmlidXRlcyBkb20pKQor ICAgICAgICA7OyBJZ25vcmUgYXR0cmlidXRlcyB0aGF0IHN0YXJ0IHdpdGggYSBjb2xvbi4K KyAgICAgICAgKHVubGVzcyAoPSAoYXJlZiAoZm9ybWF0ICIlcyIgKGNhciBhdHRyKSkgMCkg PzopCisgICAgICAgICAgKGluc2VydCAoZm9ybWF0ICIgJXM9XCIlc1wiIiAoY2FyIGF0dHIp IChjZHIgYXR0cikpKSkpCisgICAgICAoaW5zZXJ0ICI+IikKKyAgICAgIChkb2xpc3QgKGVs ZW0gKGRvbS1jaGlsZHJlbiBkb20pKQorICAgICAgICAoc3ZnLXByaW50IGVsZW0pKQorICAg ICAgKGluc2VydCAoZm9ybWF0ICI8LyVzPiIgdGFnKSkpKSkKIAogKGRlZnVuIHN2Zy1yZW1v dmUgKHN2ZyBpZCkKICAgIlJlbW92ZSB0aGUgZWxlbWVudCBpZGVudGlmaWVkIGJ5IElEIGZy b20gU1ZHLiIK --------------Eg3Aus0BQcIgj183hqVPPrQ0 Content-Type: text/x-patch; charset=UTF-8; name="svg-print-V0.patch" Content-Disposition: attachment; filename="svg-print-V0.patch" Content-Transfer-Encoding: base64 MjAyNC0wNy0xOSAgRGF2aWQgUG9uY2UgIDxkYV92aWRAb3JhbmdlLmZyPgoKCSogc3ZnLmVs IChzdmctcHJpbnQpOiBSZW1vdmUgdXNlbGVzcyBleHRyYSBzcGFjZSBmcm9tIHRoZSBYTUwK CXJlcHJlc2VudGF0aW9uIG9mIGNoaWxkIG5vZGUuCgpkaWZmIC0tZ2l0IGEvbGlzcC9zdmcu ZWwgYi9saXNwL3N2Zy5lbAppbmRleCBmMmViMmVjNjZkZC4uZjVjNzYxNDUxMzYgMTAwNjQ0 Ci0tLSBhL2xpc3Avc3ZnLmVsCisrKyBiL2xpc3Avc3ZnLmVsCkBAIC0zMzEsNyArMzMxLDYg QEAgc3ZnLXByaW50CiAgICAgICAgIChpbnNlcnQgKGZvcm1hdCAiICVzPVwiJXNcIiIgKGNh ciBhdHRyKSAoY2RyIGF0dHIpKSkpKQogICAgIChpbnNlcnQgIj4iKQogICAgIChkb2xpc3Qg KGVsZW0gKG50aGNkciAyIGRvbSkpCi0gICAgICAoaW5zZXJ0ICIgIikKICAgICAgIChzdmct cHJpbnQgZWxlbSkpCiAgICAgKGluc2VydCAoZm9ybWF0ICI8LyVzPiIgKGNhciBkb20pKSkp KQogCg== --------------Eg3Aus0BQcIgj183hqVPPrQ0--