zathura-pdf-mupdf: update to 0.3.2.

This commit is contained in:
lemmi 2017-12-31 10:30:20 +01:00
parent 35e371aede
commit fc86e98d98
2 changed files with 170 additions and 3 deletions

View File

@ -0,0 +1,167 @@
From b742d97f3d49b37d82aedcbe68e2fac2f3f9a58a Mon Sep 17 00:00:00 2001
From: lemmi <lemmi@nerd2nerd.org>
Date: Sun, 31 Dec 2017 10:23:53 +0100
Subject: [PATCH] Revert "Updated for MuPDF 1.12.0"
This reverts commit a3f703788f77b19bb986e14666fe0c47911adddc.
---
image.c | 18 ++++++++++--------
page.c | 9 +++++++++
plugin.h | 3 +--
render.c | 4 +---
select.c | 11 +++--------
utils.c | 8 ++++----
6 files changed, 28 insertions(+), 25 deletions(-)
diff --git image.c image.c
index 3de01ba..b938e5c 100644
--- image.c
+++ image.c
@@ -43,16 +43,18 @@ pdf_page_images_get(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_erro
/* Extract images */
mupdf_page_extract_text(mupdf_document, mupdf_page);
- fz_stext_block* block;
- for (block = mupdf_page->text->first_block; block; block = block->next) {
- if (block->type == FZ_STEXT_BLOCK_IMAGE) {
+ 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;
+
zathura_image_t* zathura_image = g_malloc(sizeof(zathura_image_t));
- 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;
+ 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;
girara_list_append(list, zathura_image);
}
diff --git page.c page.c
index c615efe..a563655 100644
--- page.c
+++ page.c
@@ -44,6 +44,11 @@ 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;
+ }
+
zathura_page_set_data(page, mupdf_page);
/* get page dimensions */
@@ -74,6 +79,10 @@ pdf_page_clear(zathura_page_t* page, mupdf_page_t* mupdf_page)
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 plugin.h plugin.h
index 09fb1de..35ff568 100644
--- plugin.h
+++ plugin.h
@@ -3,8 +3,6 @@
#ifndef PDF_H
#define PDF_H
-#include <stdlib.h>
-#include <string.h>
#include <stdbool.h>
#include <zathura/plugin-api.h>
#include <mupdf/fitz.h>
@@ -20,6 +18,7 @@ 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 render.c render.c
index d3bc177..5d70401 100644
--- render.c
+++ render.c
@@ -38,8 +38,7 @@ pdf_page_render_to_buffer(mupdf_document_t* mupdf_document, mupdf_page_t* mupdf_
fz_rect rect = { .x1 = page_width, .y1 = page_height };
fz_colorspace* colorspace = fz_device_bgr(mupdf_document->ctx);
- fz_separations* seps= fz_page_separations(mupdf_page->ctx, mupdf_page->page);
- fz_pixmap* pixmap = fz_new_pixmap_with_bbox_and_data(mupdf_page->ctx, colorspace, &irect, seps, 1, image);
+ fz_pixmap* pixmap = fz_new_pixmap_with_bbox_and_data(mupdf_page->ctx, colorspace, &irect, 1, image);
fz_clear_pixmap_with_value(mupdf_page->ctx, pixmap, 0xFF);
device = fz_new_draw_device(mupdf_page->ctx, NULL, pixmap);
@@ -49,7 +48,6 @@ pdf_page_render_to_buffer(mupdf_document_t* mupdf_document, mupdf_page_t* mupdf_
fz_drop_pixmap(mupdf_page->ctx, pixmap);
fz_drop_display_list(mupdf_page->ctx, display_list);
- fz_drop_separations(mupdf_page->ctx, seps);
return ZATHURA_ERROR_OK;
}
diff --git select.c select.c
index 427458e..c1e1437 100644
--- select.c
+++ select.c
@@ -24,14 +24,9 @@ pdf_page_get_text(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_rectan
mupdf_page_extract_text(mupdf_document, mupdf_page);
}
- fz_point a = { rectangle.x1, rectangle.y1 };
- fz_point b = { rectangle.x2, rectangle.y2 };
-
-#ifdef _WIN32
- return fz_copy_selection(mupdf_page->ctx, mupdf_page->text, a, b, 1);
-#else
- return fz_copy_selection(mupdf_page->ctx, mupdf_page->text, a, b, 0);
-#endif
+ fz_rect rect = { rectangle.x1, rectangle.y1, rectangle.x2, rectangle.y2 };
+
+ return fz_copy_selection(mupdf_page->ctx, mupdf_page->text, rect);
error_ret:
diff --git utils.c utils.c
index 923fb4b..5605783 100644
--- utils.c
+++ utils.c
@@ -7,17 +7,17 @@
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->text == NULL) {
+ mupdf_page->sheet == 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->text, NULL);
+ text_device = fz_new_stext_device(mupdf_page->ctx, mupdf_page->sheet, mupdf_page->text, NULL);
- /* Disable FZ_DONT_INTERPOLATE_IMAGES to collect image blocks */
- fz_disable_device_hints(mupdf_page->ctx, text_device, FZ_DONT_INTERPOLATE_IMAGES);
+ /* Disable FZ_IGNORE_IMAGE to collect image blocks */
+ fz_disable_device_hints(mupdf_page->ctx, text_device, FZ_IGNORE_IMAGE);
fz_matrix ctm;
fz_scale(&ctm, 1.0, 1.0);
--
2.15.1

View File

@ -1,7 +1,7 @@
# Template file for 'zathura-pdf-mupdf'
pkgname=zathura-pdf-mupdf
version=0.3.1
revision=5
version=0.3.2
revision=1
build_style=gnu-makefile
make_build_args="MUPDF_LIB=-lmupdf MUPDF_LIB+=-lmujs"
maintainer="lemmi <lemmi@nerd2nerd.org>"
@ -13,7 +13,7 @@ license="zlib"
homepage="http://pwmt.org/projects/zathura-pdf-mupdf/"
short_desc="PDF support for zathura (using mupdf)"
distfiles="http://pwmt.org/projects/${pkgname}/download/${pkgname}-${version}.tar.gz"
checksum=d9b9edc0297b9eddb53020976f287b4e8db33edef8cfa047d70e02653eb2f81b
checksum=931d88c4d1adc3be77a8fa9f28c25fc2aa9c9ffbabfaeac4aacc1e1d07936a76
pre_build() {
sed -i 's/^\(CFLAGS *+=\)/override \1/' config.mk