[PATCH -perfbook 3/6] epstopdf-rule.mk: Add alternative rules for .eps --> .pdf conversion

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

 



a2ping is convenient in that it accepts most eps/ps files (not
necessarily EPS conformant) and generates properly cropped
figures in most cases.

However, recent updates of Ghostscript have conflicted with a2ping's
internal postscript and perl code.

As a2ping has limited active users, it tends to lag behind
Ghostscript changes.

So this commit attempts to achieve the same effect by adding
rules using other similar tools that have larger user bases
in the hope of getting timely fixes to catch up changes in
Ghostscript.

It is enabled when NO_A2PING is defined, for example:

    make NO_A2PING=1

The pair of commands, eps2eps and epstopdf, work similarly as a2ping.

The alternative rules generate much larger .pdf files than those
with a2ping does as of this change.
Size reduction will be attempted in a later change.

Current maintainer of epstopdf is Karl Berry, who has been active in
TeX Live and CTAN communities.
eps2eps is a command in the Ghostscript bundle.

Notes:
  o On Fedora, epstopdf is in texlive-collection-fontutils,
    or just installing texlive-esptopdf should suffice.
  o On Ubuntu, it is covered by the existing list of dependent
    packages in FAQ-BUILD.txt, namely "texlive-pstricks".

Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx>
---
 Makefile         |  6 +++++-
 epstopdf-rule.mk | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100644 epstopdf-rule.mk

diff --git a/Makefile b/Makefile
index 5d9ef4b9..d3fcffca 100644
--- a/Makefile
+++ b/Makefile
@@ -408,7 +408,11 @@ endif
 	@sh $(FIXANEPSFONTS) $@
 
 # .eps --> .pdf rules
-include a2ping-rule.mk
+ifndef NO_A2PING
+  include a2ping-rule.mk
+else
+  include epstopdf-rule.mk
+endif
 
 $(PDFTARGETS_OF_SVG): %.pdf: %.svg
 	@echo "$< --> $@"
diff --git a/epstopdf-rule.mk b/epstopdf-rule.mk
new file mode 100644
index 00000000..51425972
--- /dev/null
+++ b/epstopdf-rule.mk
@@ -0,0 +1,42 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright (C) Akira Yokosawa, 2021
+#
+# Authors: Akira Yokosawa <akiyks@xxxxxxxxx>
+
+EPSTOPDF := $(shell which epstopdf 2>/dev/null)
+GS_953_OR_LATER := $(shell gs --version | grep -c -E "9\.5[3-9].?")
+
+$(PDFTARGETS_OF_EPSORIG): %.pdf: %.eps
+	@echo "$< --> $@"
+ifndef EPSTOPDF
+	$(error $< --> $@: epstopdf not found. Please install it)
+endif
+	@cp $< $(basename $<)__.eps
+	@sh $(FIXANEPSFONTS) $(basename $<)__.eps
+	@eps2eps $(basename $<)__.eps $(basename $<)___.eps
+	@epstopdf $(basename $<)___.eps $@
+	@rm -f $(basename $<)__.eps $(basename $<)___.eps
+
+$(PDFTARGETS_OF_TEX): %.pdf: %.eps
+	@echo "$< --> $@"
+ifndef EPSTOPDF
+	$(error $< --> $@: epstopdf not found. Please install it)
+endif
+ifeq ($(GS_953_OR_LATER),1)
+	@eps2eps -dALLOWPSTRANSPARENCY $< $(basename $<)__.eps
+	@epstopdf --gsopt=-dALLOWPSTRANSPARENCY $(basename $<)__.eps $@
+else
+	@eps2eps $< $(basename $<)__.eps
+	@epstopdf --nosafer $(basename $<)__.eps $@
+endif
+	@rm -f $(basename $<)__.eps
+
+$(PDFTARGETS_OF_EPSOTHER): %.pdf: %.eps
+	@echo "$< --> $@"
+ifndef EPSTOPDF
+	$(error $< --> $@: epstopdf not found. Please install it)
+endif
+	@eps2eps $< $(basename $<)__.eps
+	@epstopdf $(basename $<)__.eps $@
+	@rm -f $(basename $<)__.eps
-- 
2.17.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