pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
zathura-pdf-mupdf: Import zathura-pdf-mupdf--0.3.1nb7 as wip/zathura-pdf-mupdf
Module Name: pkgsrc-wip
Committed By: Leonardo Taccari <leot%NetBSD.org@localhost>
Pushed By: leot
Date: Mon Dec 18 10:18:05 2017 +0100
Changeset: 2e762943e61d1012eddd727ee8c89dca5dc0c269
Modified Files:
Makefile
Added Files:
zathura-pdf-mupdf/DESCR
zathura-pdf-mupdf/Makefile
zathura-pdf-mupdf/PLIST
zathura-pdf-mupdf/TODO
zathura-pdf-mupdf/distinfo
zathura-pdf-mupdf/patches/patch-document.c
zathura-pdf-mupdf/patches/patch-image.c
zathura-pdf-mupdf/patches/patch-index.c
zathura-pdf-mupdf/patches/patch-links.c
zathura-pdf-mupdf/patches/patch-page.c
zathura-pdf-mupdf/patches/patch-plugin.h
zathura-pdf-mupdf/patches/patch-render.c
zathura-pdf-mupdf/patches/patch-select.c
zathura-pdf-mupdf/patches/patch-utils.c
Log Message:
zathura-pdf-mupdf: Import zathura-pdf-mupdf--0.3.1nb7 as wip/zathura-pdf-mupdf
The zathura-pdf-mupdf plugin adds PDF support to zathura by using the
mupdf rendering library.
This package is intended as a WIP update to print/zathura-pdf-mupdf due API
changes in mupdf-1.12.0.
TODO: Still doesn't work properly and crashes on exit, patches to adjust to the
TODO: new API aren't commented and still need to be reviewed.
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=2e762943e61d1012eddd727ee8c89dca5dc0c269
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
Makefile | 1 +
zathura-pdf-mupdf/DESCR | 2 +
zathura-pdf-mupdf/Makefile | 28 ++++++++++++++
zathura-pdf-mupdf/PLIST | 3 ++
zathura-pdf-mupdf/TODO | 2 +
zathura-pdf-mupdf/distinfo | 15 ++++++++
zathura-pdf-mupdf/patches/patch-document.c | 21 +++++++++++
zathura-pdf-mupdf/patches/patch-image.c | 31 +++++++++++++++
zathura-pdf-mupdf/patches/patch-index.c | 58 +++++++++++++++++++++++++++++
zathura-pdf-mupdf/patches/patch-links.c | 60 ++++++++++++++++++++++++++++++
zathura-pdf-mupdf/patches/patch-page.c | 36 ++++++++++++++++++
zathura-pdf-mupdf/patches/patch-plugin.h | 12 ++++++
zathura-pdf-mupdf/patches/patch-render.c | 13 +++++++
zathura-pdf-mupdf/patches/patch-select.c | 17 +++++++++
zathura-pdf-mupdf/patches/patch-utils.c | 24 ++++++++++++
15 files changed, 323 insertions(+)
diffs:
diff --git a/Makefile b/Makefile
index 9601a63247..5be182b5f3 100644
--- a/Makefile
+++ b/Makefile
@@ -4674,6 +4674,7 @@ SUBDIR+= yp-tools
SUBDIR+= ypbind-mt
SUBDIR+= ypserv
SUBDIR+= zapping
+SUBDIR+= zathura-pdf-mupdf
SUBDIR+= zbackup
SUBDIR+= zbar
SUBDIR+= zenity
diff --git a/zathura-pdf-mupdf/DESCR b/zathura-pdf-mupdf/DESCR
new file mode 100644
index 0000000000..3c71cd55c5
--- /dev/null
+++ b/zathura-pdf-mupdf/DESCR
@@ -0,0 +1,2 @@
+The zathura-pdf-mupdf plugin adds PDF support to zathura by using the
+mupdf rendering library.
diff --git a/zathura-pdf-mupdf/Makefile b/zathura-pdf-mupdf/Makefile
new file mode 100644
index 0000000000..3a6a4b43f6
--- /dev/null
+++ b/zathura-pdf-mupdf/Makefile
@@ -0,0 +1,28 @@
+# $NetBSD: Makefile,v 1.19 2017/11/23 17:20:10 wiz Exp $
+#
+
+DISTNAME= zathura-pdf-mupdf-0.3.1
+PKGREVISION= 7
+CATEGORIES= print
+MASTER_SITES= https://pwmt.org/projects/zathura/plugins/download/
+
+MAINTAINER= leot%NetBSD.org@localhost
+HOMEPAGE= https://pwmt.org/projects/zathura-pdf-mupdf/
+COMMENT= Add PDF support to zathura using mupdf rendering engine
+LICENSE= zlib
+
+CONFLICTS+= zathura-pdf-poppler-[0-9]*
+
+USE_TOOLS+= pkg-config gmake
+USE_LIBTOOL= yes
+
+CPPFLAGS+= -D_XOPEN_SOURCE=600
+
+MAKE_ENV+= MUPDF_LIB="-lmupdf -lmupdfthird"
+
+.include "../../graphics/cairo/buildlink3.mk"
+.include "../../wip/mupdf/buildlink3.mk"
+.include "../../print/zathura/buildlink3.mk"
+.include "../../sysutils/desktop-file-utils/desktopdb.mk"
+.include "../../x11/gtk3/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/zathura-pdf-mupdf/PLIST b/zathura-pdf-mupdf/PLIST
new file mode 100644
index 0000000000..4ef2958705
--- /dev/null
+++ b/zathura-pdf-mupdf/PLIST
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.1 2016/02/14 14:01:49 leot Exp $
+lib/zathura/pdf.so
+share/applications/zathura-pdf-mupdf.desktop
diff --git a/zathura-pdf-mupdf/TODO b/zathura-pdf-mupdf/TODO
new file mode 100644
index 0000000000..f219235bfa
--- /dev/null
+++ b/zathura-pdf-mupdf/TODO
@@ -0,0 +1,2 @@
+- Comment all the new patches
+- Still not stable, the patches need to be revised and adjusted.
diff --git a/zathura-pdf-mupdf/distinfo b/zathura-pdf-mupdf/distinfo
new file mode 100644
index 0000000000..9dc73a97c1
--- /dev/null
+++ b/zathura-pdf-mupdf/distinfo
@@ -0,0 +1,15 @@
+$NetBSD: distinfo,v 1.6 2017/02/18 13:38:33 leot Exp $
+
+SHA1 (zathura-pdf-mupdf-0.3.1.tar.gz) = ef37a181de96d6fca36db3ac818f790dcf3627ae
+RMD160 (zathura-pdf-mupdf-0.3.1.tar.gz) = 7497475ba55d2e7f96d23f378cbefeddd56089e4
+SHA512 (zathura-pdf-mupdf-0.3.1.tar.gz) = 87b5b8a750a6911be37a0195b0f4bc3304350f9d29173091b3eeece40350b10cb98b009b2722a69ae1e617b4242292f3eba17fea97d5276e485069180f2bd67d
+Size (zathura-pdf-mupdf-0.3.1.tar.gz) = 9755 bytes
+SHA1 (patch-document.c) = dc12f3ec7d9cff6476e79540abbe9944cb280b4e
+SHA1 (patch-image.c) = b4afbd50638ed3738dd745a34659663fdfc22abd
+SHA1 (patch-index.c) = 87b67c5b9bbb2fbf184f966dc37e90d25978e10c
+SHA1 (patch-links.c) = ce2c1b3dfd5c6469bf64800c43bbdd15c75ddcbb
+SHA1 (patch-page.c) = d5e0125057bcc643e54ffdad64a6fdfbe062473f
+SHA1 (patch-plugin.h) = 686d313995cb29ba634f37cf969d8c3d3644700a
+SHA1 (patch-render.c) = f961f74b1daeca88a742c716fa7deed8c71d5ae8
+SHA1 (patch-select.c) = e3dbd7c8fc4d271fc1a9f159b35c34f874ff75a3
+SHA1 (patch-utils.c) = 511b1e7f648d5ed484d6c45d1ebb9af43a58b840
diff --git a/zathura-pdf-mupdf/patches/patch-document.c b/zathura-pdf-mupdf/patches/patch-document.c
new file mode 100644
index 0000000000..8bcd7bf4b3
--- /dev/null
+++ b/zathura-pdf-mupdf/patches/patch-document.c
@@ -0,0 +1,21 @@
+$NetBSD: patch-document.c,v 1.4 2017/01/31 10:12:02 leot Exp $
+
+Correct the glib-2.0 include header file path.
+
+--- document.c.orig 2017-01-11 21:21:14.000000000 +0000
++++ document.c
+@@ -2,10 +2,13 @@
+
+ #define _POSIX_C_SOURCE 1
+
++#include <stdlib.h>
++#include <string.h>
++
+ #include <mupdf/fitz.h>
+ #include <mupdf/pdf.h>
+
+-#include <glib-2.0/glib.h>
++#include <glib.h>
+
+ #include "plugin.h"
+
diff --git a/zathura-pdf-mupdf/patches/patch-image.c b/zathura-pdf-mupdf/patches/patch-image.c
new file mode 100644
index 0000000000..b4e8e7fba5
--- /dev/null
+++ b/zathura-pdf-mupdf/patches/patch-image.c
@@ -0,0 +1,31 @@
+$NetBSD$
+
+--- image.c.orig 2017-01-11 21:21:14.000000000 +0000
++++ image.c
+@@ -43,18 +43,16 @@ pdf_page_images_get(zathura_page_t* page
+ /* Extract images */
+ mupdf_page_extract_text(mupdf_document, mupdf_page);
+
+- fz_page_block* block;
+- for (block = mupdf_page->text->blocks; block < mupdf_page->text->blocks + mupdf_page->text->len; block++) {
+- if (block->type == FZ_PAGE_BLOCK_IMAGE) {
+- fz_image_block *image_block = block->u.image;
+-
++ fz_stext_block* block;
++ for (block = mupdf_page->text->first_block; block; block = block->next) {
++ if (block->type == FZ_STEXT_BLOCK_IMAGE) {
+ zathura_image_t* zathura_image = g_malloc(sizeof(zathura_image_t));
+
+- zathura_image->position.x1 = image_block->bbox.x0;
+- zathura_image->position.y1 = image_block->bbox.y0;
+- zathura_image->position.x2 = image_block->bbox.x1;
+- zathura_image->position.y2 = image_block->bbox.y1;
+- zathura_image->data = image_block->image;
++ zathura_image->position.x1 = block->bbox.x0;
++ zathura_image->position.y1 = block->bbox.y0;
++ zathura_image->position.x2 = block->bbox.x1;
++ zathura_image->position.y2 = block->bbox.y1;
++ zathura_image->data = block->u.i.image;
+
+ girara_list_append(list, zathura_image);
+ }
diff --git a/zathura-pdf-mupdf/patches/patch-index.c b/zathura-pdf-mupdf/patches/patch-index.c
new file mode 100644
index 0000000000..cf418a96f0
--- /dev/null
+++ b/zathura-pdf-mupdf/patches/patch-index.c
@@ -0,0 +1,58 @@
+$NetBSD: patch-index.c,v 1.3 2017/02/18 13:38:33 leot Exp $
+
+Avoid possible NULL-pointer dereference.
+
+--- index.c.orig 2017-01-11 21:21:14.000000000 +0000
++++ index.c
+@@ -2,6 +2,8 @@
+
+ #define _POSIX_C_SOURCE 1
+
++#include <string.h>
++
+ #include <girara/datastructures.h>
+
+ #include "plugin.h"
+@@ -51,24 +53,26 @@ build_index(fz_context* ctx, fz_document
+ zathura_link_type_t type = ZATHURA_LINK_INVALID;
+ zathura_rectangle_t rect = { .x1 = 0, .y1 = 0, .x2 = 0, .y2 = 0 };
+
+- if (fz_is_external_link(ctx, outline->uri) == 1) {
+- if (strstr(outline->uri, "file://") == outline->uri) {
+- type = ZATHURA_LINK_GOTO_REMOTE;
+- target.value = outline->uri;
++ if (outline->uri) {
++ if (fz_is_external_link(ctx, outline->uri) == 1) {
++ if (strstr(outline->uri, "file://") == outline->uri) {
++ type = ZATHURA_LINK_GOTO_REMOTE;
++ target.value = outline->uri;
++ } else {
++ type = ZATHURA_LINK_URI;
++ target.value = outline->uri;
++ }
+ } else {
+- type = ZATHURA_LINK_URI;
+- target.value = outline->uri;
++ float x = 0;
++ float y = 0;
++
++ type = ZATHURA_LINK_GOTO_DEST;
++ target.destination_type = ZATHURA_LINK_DESTINATION_XYZ;
++ target.page_number = fz_resolve_link(ctx, document, outline->uri, &x, &y);
++ target.left = x;
++ target.top = y;
++ target.scale = 0.0;
+ }
+- } else {
+- float x = 0;
+- float y = 0;
+-
+- type = ZATHURA_LINK_GOTO_DEST;
+- target.destination_type = ZATHURA_LINK_DESTINATION_XYZ;
+- target.page_number = fz_resolve_link(ctx, document, outline->uri, &x, &y);
+- target.left = x;
+- target.top = y;
+- target.scale = 0.0;
+ }
+
+ index_element->link = zathura_link_new(type, rect, target);
diff --git a/zathura-pdf-mupdf/patches/patch-links.c b/zathura-pdf-mupdf/patches/patch-links.c
new file mode 100644
index 0000000000..f9cdd83a4d
--- /dev/null
+++ b/zathura-pdf-mupdf/patches/patch-links.c
@@ -0,0 +1,60 @@
+$NetBSD: patch-links.c,v 1.3 2017/02/18 13:38:33 leot Exp $
+
+Avoid possible NULL-pointer dereference.
+
+--- links.c.orig 2017-01-11 21:21:14.000000000 +0000
++++ links.c
+@@ -2,6 +2,8 @@
+
+ #define _POSIX_C_SOURCE 1
+
++#include <string.h>
++
+ #include <glib.h>
+
+ #include "plugin.h"
+@@ -43,25 +45,27 @@ pdf_page_links_get(zathura_page_t* page,
+ zathura_link_type_t type = ZATHURA_LINK_INVALID;
+ zathura_link_target_t target = { 0 };
+
+- if (fz_is_external_link(mupdf_document->ctx, link->uri) == 1) {
+- if (strstr(link->uri, "file://") == link->uri) {
+- type = ZATHURA_LINK_GOTO_REMOTE;
+- target.value = link->uri;
++ if (link->uri) {
++ if (fz_is_external_link(mupdf_document->ctx, link->uri) == 1) {
++ if (strstr(link->uri, "file://") == link->uri) {
++ type = ZATHURA_LINK_GOTO_REMOTE;
++ target.value = link->uri;
++ } else {
++ type = ZATHURA_LINK_URI;
++ target.value = link->uri;
++ }
+ } else {
+- type = ZATHURA_LINK_URI;
+- target.value = link->uri;
++ float x = 0;
++ float y = 0;
++
++ type = ZATHURA_LINK_GOTO_DEST;
++ target.destination_type = ZATHURA_LINK_DESTINATION_XYZ;
++ target.page_number = fz_resolve_link(mupdf_document->ctx,
++ mupdf_document->document, link->uri, &x, &y);
++ target.left = x;
++ target.top = y;
++ target.scale = 0.0;
+ }
+- } else {
+- float x = 0;
+- float y = 0;
+-
+- type = ZATHURA_LINK_GOTO_DEST;
+- target.destination_type = ZATHURA_LINK_DESTINATION_XYZ;
+- target.page_number = fz_resolve_link(mupdf_document->ctx,
+- mupdf_document->document, link->uri, &x, &y);
+- target.left = x;
+- target.top = y;
+- target.scale = 0.0;
+ }
+
+ zathura_link_t* zathura_link = zathura_link_new(type, position, target);
diff --git a/zathura-pdf-mupdf/patches/patch-page.c b/zathura-pdf-mupdf/patches/patch-page.c
new file mode 100644
index 0000000000..1f99e39afc
--- /dev/null
+++ b/zathura-pdf-mupdf/patches/patch-page.c
@@ -0,0 +1,36 @@
+$NetBSD$
+
+--- page.c.orig 2017-01-11 21:21:14.000000000 +0000
++++ page.c
+@@ -2,6 +2,8 @@
+
+ #define _POSIX_C_SOURCE 1
+
++#include <stdlib.h>
++
+ #include "plugin.h"
+
+ zathura_error_t
+@@ -50,11 +52,6 @@ pdf_page_init(zathura_page_t* page)
+ goto error_free;
+ }
+
+- mupdf_page->sheet = fz_new_stext_sheet(mupdf_page->ctx);
+- if (mupdf_page->sheet == NULL) {
+- goto error_free;
+- }
+-
+ return ZATHURA_ERROR_OK;
+
+ error_free:
+@@ -79,10 +76,6 @@ pdf_page_clear(zathura_page_t* page, mup
+ fz_drop_stext_page(mupdf_page->ctx, mupdf_page->text);
+ }
+
+- if (mupdf_page->sheet != NULL) {
+- fz_drop_stext_sheet(mupdf_page->ctx, mupdf_page->sheet);
+- }
+-
+ if (mupdf_page->page != NULL) {
+ fz_drop_page(mupdf_document->ctx, mupdf_page->page);
+ }
diff --git a/zathura-pdf-mupdf/patches/patch-plugin.h b/zathura-pdf-mupdf/patches/patch-plugin.h
new file mode 100644
index 0000000000..eb902dadb0
--- /dev/null
+++ b/zathura-pdf-mupdf/patches/patch-plugin.h
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- plugin.h.orig 2017-01-11 21:21:14.000000000 +0000
++++ plugin.h
+@@ -21,7 +21,6 @@ typedef struct mupdf_page_s
+ {
+ fz_page* page; /**< Reference to the mupdf page */
+ fz_context* ctx; /**< Context */
+- fz_stext_sheet* sheet; /**< Text sheet */
+ fz_stext_page* text; /**< Page text */
+ fz_rect bbox; /**< Bbox */
+ bool extracted_text; /**< If text has already been extracted */
diff --git a/zathura-pdf-mupdf/patches/patch-render.c b/zathura-pdf-mupdf/patches/patch-render.c
new file mode 100644
index 0000000000..40707cc24c
--- /dev/null
+++ b/zathura-pdf-mupdf/patches/patch-render.c
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- render.c.orig 2017-01-11 21:21:14.000000000 +0000
++++ render.c
+@@ -37,7 +37,7 @@ pdf_page_render_to_buffer(mupdf_document
+ fz_rect rect = { .x1 = page_width, .y1 = page_height };
+
+ fz_colorspace* colorspace = fz_device_bgr(mupdf_document->ctx);
+- fz_pixmap* pixmap = fz_new_pixmap_with_bbox_and_data(mupdf_page->ctx, colorspace, &irect, 1, image);
++ fz_pixmap* pixmap = fz_new_pixmap_with_bbox_and_data(mupdf_page->ctx, colorspace, &irect, NULL, 1, image);
+ fz_clear_pixmap_with_value(mupdf_page->ctx, pixmap, 0xFF);
+
+ device = fz_new_draw_device(mupdf_page->ctx, NULL, pixmap);
diff --git a/zathura-pdf-mupdf/patches/patch-select.c b/zathura-pdf-mupdf/patches/patch-select.c
new file mode 100644
index 0000000000..9fda902db3
--- /dev/null
+++ b/zathura-pdf-mupdf/patches/patch-select.c
@@ -0,0 +1,17 @@
+$NetBSD$
+
+--- select.c.orig 2017-01-11 21:21:14.000000000 +0000
++++ select.c
+@@ -24,9 +24,10 @@ pdf_page_get_text(zathura_page_t* page,
+ mupdf_page_extract_text(mupdf_document, mupdf_page);
+ }
+
+- fz_rect rect = { rectangle.x1, rectangle.y1, rectangle.x2, rectangle.y2 };
++ fz_point a = { rectangle.x1, rectangle.y1 };
++ fz_point b = { rectangle.x2, rectangle.y2 };
+
+- return fz_copy_selection(mupdf_page->ctx, mupdf_page->text, rect);
++ return fz_copy_selection(mupdf_page->ctx, mupdf_page->text, a, b, 0);
+
+ error_ret:
+
diff --git a/zathura-pdf-mupdf/patches/patch-utils.c b/zathura-pdf-mupdf/patches/patch-utils.c
new file mode 100644
index 0000000000..7f0fcfa4a6
--- /dev/null
+++ b/zathura-pdf-mupdf/patches/patch-utils.c
@@ -0,0 +1,24 @@
+$NetBSD$
+
+--- utils.c.orig 2017-01-11 21:21:14.000000000 +0000
++++ utils.c
+@@ -7,17 +7,14 @@
+ void
+ mupdf_page_extract_text(mupdf_document_t* mupdf_document, mupdf_page_t* mupdf_page) {
+ if (mupdf_document == NULL || mupdf_document->ctx == NULL || mupdf_page == NULL ||
+- mupdf_page->sheet == NULL || mupdf_page->text == NULL) {
++ mupdf_page->text == NULL) {
+ return;
+ }
+
+ fz_device* text_device = NULL;
+
+ fz_try (mupdf_page->ctx) {
+- text_device = fz_new_stext_device(mupdf_page->ctx, mupdf_page->sheet, mupdf_page->text, NULL);
+-
+- /* Disable FZ_IGNORE_IMAGE to collect image blocks */
+- fz_disable_device_hints(mupdf_page->ctx, text_device, FZ_IGNORE_IMAGE);
++ text_device = fz_new_stext_device(mupdf_page->ctx, mupdf_page->text, NULL);
+
+ fz_matrix ctm;
+ fz_scale(&ctm, 1.0, 1.0);
Home |
Main Index |
Thread Index |
Old Index