Re: [PATCH -perfbook 0/8] Use rsvg-convert for SVG --> PDF conversion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Subject: [PATCH -perfbook 1/8] Makefile: Add rules to use rsvg-convert for SVG --> PDF conversion

Recently, Inkscape has had a number of stability issues in both of
its GUI- and CLI- modes.  We have experienced crashes of CLI-mode
Inkscape caused by a change in glib, which can been resolved
by an update in the GTK3 library now released in GTK 3.24.39.
Commit f307e19f2be0 ("Prevent inkscape from interacting with desktop
manager") was an ugly hack for mitigating such crashes.

There is an alternative converter called rsvg-convert.
It is a light-weight CLI-only converter.

Up until Ubuntu 20.04 LTS, rsvg-convert's coverage of SVG features
was not good enough for some of the figures in perfbook drawn by
using Inkscape.

rsvg-convert has improved since, and version 2.52.5, which is the
version on Ubuntu 22.04 LTS, and later versions do fairly good jobs
in this respect.

So let's use rsvg-convert when it is available.

For Ubuntu and Debian, rsvg-convert belongs to the librsvg2-bin
package.  For Fedora, it is provided in the librsvg2-tools package.

Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx>
---
 Makefile | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 424a166c..f869862c 100644
--- a/Makefile
+++ b/Makefile
@@ -103,6 +103,8 @@ PDFTARGETS_OF_EPSOTHER := $(filter-out $(PDFTARGETS_OF_EPSORIG) $(PDFTARGETS_OF_
 BIBSOURCES := bib/*.bib alphapf.bst
 
 # required commands
+SED ?= sed
+
 LATEX_CMD := $(shell $(WHICH) $(LATEX) 2>/dev/null)
 DOT := $(shell $(WHICH) dot 2>/dev/null)
 FIG2EPS := $(shell $(WHICH) fig2eps 2>/dev/null)
@@ -111,6 +113,13 @@ INKSCAPE := $(shell $(WHICH) inkscape 2>/dev/null)
 ifdef INKSCAPE
   INKSCAPE_ONE := $(shell inkscape --version 2>/dev/null | grep -c "Inkscape 1")
 endif
+# rsvg-convert is preferred to inkscape in SVG --> PDF conversion
+RSVG_CONVERT := $(shell $(WHICH) rsvg-convert 2>/dev/null)
+ifdef RSVG_CONVERT
+  SVG_PDF_CONVERTER = (rsvg-convert)
+else
+  SVG_PDF_CONVERTER = (inkscape)
+endif
 LATEXPAND := $(shell $(WHICH) latexpand 2>/dev/null)
 QPDF := $(shell $(WHICH) qpdf 2>/dev/null)
 
@@ -455,12 +464,14 @@ ISOLATE_INKSCAPE ?= XDG_RUNTIME_DIR=na DBUS_SESSION_BUS_ADDRESS=na
 
 $(PDFTARGETS_OF_SVG): $(FIXSVGFONTS)
 $(PDFTARGETS_OF_SVG): %.pdf: %.svg
-	@echo "$< --> $(suffix $@)"
+	@echo "$< --> $(suffix $@) $(SVG_PDF_CONVERTER)"
 ifeq ($(STEELFONT),0)
 	$(error "Steel City Comic" font not found. See #1 in FAQ.txt)
 endif
-ifndef INKSCAPE
-	$(error $< --> $@ inkscape not found. Please install it)
+ifndef RSVG_CONVERT
+  ifndef INKSCAPE
+	$(error $< --> $@ inkscape nor rsvg-convert not found. Please install either one)
+  endif
 endif
 ifeq ($(STEELFONTID),0)
 	@sh $(FIXSVGFONTS) < $< | sed -e 's/Steel City Comic/Test/g' > $<i
@@ -483,10 +494,14 @@ ifeq ($(RECOMMEND_LIBERATIONMONO),1)
 	$(info Nice-to-have font family 'Liberation Mono' not found. See #9 in FAQ-BUILD.txt)
 endif
 
-ifeq ($(INKSCAPE_ONE),0)
-	@inkscape --export-pdf=$@ $<i > /dev/null 2>&1
+ifdef RSVG_CONVERT
+	@cat $<i | rsvg-convert --format=pdf > $@
 else
+  ifeq ($(INKSCAPE_ONE),0)
+	@inkscape --export-pdf=$@ $<i > /dev/null 2>&1
+  else
 	@$(ISOLATE_INKSCAPE) inkscape -o $@ $<i > /dev/null 2>&1
+  endif
 endif
 	@rm -f $<i
 ifeq ($(chkpagegroup),on)
-- 
2.34.1





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux