Hi @ports,

The attached diff changes two aspects of the productivity/impressive
port:

1. Replace print/poppler,-utils with textproc/mupdf as dependency to
   render pages (and make textproc/mupdf work). Patch taken from:
   
http://pkgs.fedoraproject.org/cgit/rpms/impressive.git/commit/impressive-0.11.1-mudraw-1.7.patch?id=cdfeed75274505550cb7ecd0251c7b21ee386506
   
http://pkgs.fedoraproject.org/cgit/rpms/impressive.git/commit/impressive-0.11.1-mutool-info.patch?id=cdfeed75274505550cb7ecd0251c7b21ee386506

2. Drop the textproc/pdftk dependency. With the attached patch
   impressive(1) runs and displays fine. If print/poppler,-utils is used
   instead of textproc/mupdf, textproc/pdftk appears to be needed to
   render pdf 1.5 (and higher).

I have been using this for a while without problems on amd64.

Comments? Thoughts? Should this (if anything) be a FLAVOR instead?

Best

Gerrit


Index: Makefile
===================================================================
RCS file: /cvs/ports/productivity/impressive/Makefile,v
retrieving revision 1.17
diff -u -p -r1.17 Makefile
--- Makefile    8 Apr 2016 09:23:13 -0000       1.17
+++ Makefile    10 Apr 2017 17:26:06 -0000
@@ -5,6 +5,7 @@ COMMENT =               stylish PDF presentation gene
 MODPY_EGG_VERSION =    0.11.1
 DISTNAME =             Impressive-${MODPY_EGG_VERSION}
 PKGNAME =              impressive-${MODPY_EGG_VERSION}
+REVISION =             0
 
 CATEGORIES =           productivity
 HOMEPAGE =             http://impressive.sourceforge.net/
@@ -21,8 +22,7 @@ RUN_DEPENDS =         devel/pygame \
                        devel/xdg-utils \
                        graphics/py-Pillow \
                        graphics/py-opengl \
-                       print/poppler,-utils \
-                       textproc/pdftk
+                       textproc/mupdf
 
 MODPY_ADJ_FILES =      impressive.py
 
Index: patches/patch-impressive_py
===================================================================
RCS file: patches/patch-impressive_py
diff -N patches/patch-impressive_py
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-impressive_py 10 Apr 2017 17:26:06 -0000
@@ -0,0 +1,81 @@
+--- impressive.py.orig Sat Feb 18 14:43:47 2017
++++ impressive.py      Sat Feb 18 14:51:28 2017
+@@ -148,6 +148,7 @@ if os.name == "nt":
+                 return path
+         return binary  # fall-back if not found
+     pdftkPath = FindBinary("pdftk.exe")
++    mutoolPath = FindBinary("mutool.exe")
+     GhostScriptPlatformOptions = ["-I" + os.path.join(root, "gs")]
+     try:
+         import win32api
+@@ -173,6 +174,7 @@ else:
+     MPlayerPlatformOptions = [ "-vo", "gl" ]
+     MPlayerColorKey = False
+     pdftkPath = "pdftk"
++    mutoolPath = "mutool"
+     FontPath = ["/usr/share/fonts", "/usr/local/share/fonts", 
"/usr/X11R6/lib/X11/fonts/TTF"]
+     FontList = ["DejaVuSans.ttf", "Vera.ttf", "Verdana.ttf"]
+     Nice = ["nice", "-n", "7"]
+@@ -781,18 +783,6 @@ def b2s(b):
+     if b: return "Y"
+     return "N"
+ 
+-# extract a number at the beginning of a string
+-def num(s):
+-    s = s.strip()
+-    r = ""
+-    while s[0] in "0123456789":
+-        r += s[0]
+-        s = s[1:]
+-    try:
+-        return int(r)
+-    except ValueError:
+-        return -1
+-
+ # linearly interpolate between two floating-point RGB colors represented as 
tuples
+ def lerpColor(a, b, t):
+     return tuple([min(1.0, max(0.0, x + t * (y - x))) for x, y in zip(a, b)])
+@@ -807,11 +797,22 @@ def my_stat(filename):
+ 
+ # determine (pagecount,width,height) of a PDF file
+ def analyze_pdf(filename):
+-    f = file(filename,"rb")
++    t = TempFileName + ".txt"
++    f = file(t, "w")
++    try:
++      assert 0 == subprocess.Popen([mutoolPath, "info", filename], 
stdout=f).wait()
++    except OSError:
++      print >>sys.stderr, "Note: mutool not found, cannot determine output 
size."
++      return
++    except AssertionError:
++      print >>sys.stderr, "Note: mutool failed, cannot determine output size."
++      return
++    f.close()
++    f = file(t, "r")
+     pdf = f.read()
+     f.close()
+-    box = map(float, 
pdf.split("/MediaBox",1)[1].split("]",1)[0].split("[",1)[1].strip().split())
+-    return (max(map(num, pdf.split("/Count")[1:])), box[2]-box[0], 
box[3]-box[1])
++    box = map(float, 
pdf.split("Mediaboxes",1)[1].split("]",1)[0].split("[",1)[1].strip().split())
++    return (int(pdf.split("Pages:")[1].split()[0]), box[2]-box[0], 
box[3]-box[1])
+ 
+ # unescape { literals in PDF files
+ re_unescape = re.compile(r'&#[0-9]+;')
+@@ -2973,7 +2974,7 @@ class MuPDFRenderer(PDFRendererBase):
+     name = "MuPDF"
+     binaries = ["mudraw", "pdfdraw"]
+     test_run_args = []
+-    required_options = ["o", "r", "b"]
++    required_options = ["o", "r", "A"]
+ 
+     # helper object for communication with the reader thread
+     class ThreadComm(object):
+@@ -3016,7 +3017,7 @@ class MuPDFRenderer(PDFRendererBase):
+             except (OSError, IOError, AttributeError):
+                 pass
+         if not antialias:
+-            aa_opts = ["-b", "0"]
++            aa_opts = ["-A", "0"]
+         else:
+             aa_opts = []
+         try:

Reply via email to