Skip to content

Commit

Permalink
mupdf: update to 1.25.2 (#2017)
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit-pierre authored Jan 11, 2025
1 parent 5854014 commit 0c1985d
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 72 deletions.
2 changes: 1 addition & 1 deletion ffi/mupdf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ local mupdf = {
}
-- this cannot get adapted by the cdecl file because it is a
-- string constant. Must match the actual mupdf API:
local FZ_VERSION = "1.24.11"
local FZ_VERSION = "1.25.2"

local document_mt = { __index = {} }
local page_mt = { __index = {} }
Expand Down
24 changes: 19 additions & 5 deletions ffi/mupdf_h.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ extern const fz_rect fz_empty_rect;
typedef struct fz_context fz_context;
typedef struct fz_font fz_font;
void fz_install_external_font_funcs(fz_context *);
typedef struct fz_archive fz_archive;
fz_archive *mupdf_open_directory(fz_context *, const char *);
void *mupdf_drop_archive(fz_context *, fz_archive *);
typedef struct {
int refs;
unsigned char *data;
Expand Down Expand Up @@ -94,7 +97,6 @@ typedef struct {
int errors;
int incomplete;
} fz_cookie;
typedef struct fz_archive fz_archive;
typedef struct fz_separations fz_separations;
typedef struct fz_page fz_page;
typedef struct fz_document fz_document;
Expand Down Expand Up @@ -128,15 +130,14 @@ int mupdf_fz_page_number_from_location(fz_context *, fz_document *, fz_location
void *mupdf_fz_location_from_page_number(fz_context *, fz_document *, fz_location *, int);
fz_outline *mupdf_load_outline(fz_context *, fz_document *);
void fz_drop_outline(fz_context *, fz_outline *);
fz_archive *mupdf_open_directory(fz_context *, const char *);
void mupdf_drop_archive(fz_context *, fz_archive *);
void *mupdf_drop_stream(fz_context *, fz_stream *);
fz_stream *mupdf_open_memory(fz_context *, const unsigned char *, size_t);
typedef struct fz_stext_char fz_stext_char;
struct fz_stext_char {
int c;
int bidi;
int color;
uint16_t bidi;
uint16_t flags;
uint32_t argb;
fz_point origin;
fz_quad quad;
float size;
Expand Down Expand Up @@ -166,6 +167,18 @@ struct fz_stext_block {
fz_matrix transform;
fz_image *image;
} i;
struct {
struct fz_stext_struct *down;
int index;
} s;
struct {
uint8_t stroked;
uint32_t argb;
} v;
struct {
struct fz_stext_grid_positions *xs;
struct fz_stext_grid_positions *ys;
} b;
} u;
fz_stext_block *prev;
fz_stext_block *next;
Expand All @@ -179,6 +192,7 @@ typedef struct {
fz_rect mediabox;
fz_stext_block *first_block;
fz_stext_block *last_block;
struct fz_stext_struct *last_struct;
} fz_stext_page;
fz_stext_page *mupdf_new_stext_page_from_page(fz_context *, fz_page *, const fz_stext_options *);
void fz_drop_stext_page(fz_context *, fz_stext_page *);
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/mupdf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ list(APPEND BUILD_CMD COMMAND ${MAKE_CMD} libs)
list(APPEND INSTALL_CMD COMMAND ${MAKE_CMD} DESTDIR=${STAGING_DIR} prefix=/ install-libs)

external_project(
DOWNLOAD URL 7f02c87260948160e2e21f9685bdcda0
https://mupdf.com/downloads/archive/mupdf-1.24.11-source.tar.lz
DOWNLOAD URL 7d2da9958a7eebd49bdf326affe89af4
https://mupdf.com/downloads/archive/mupdf-1.25.2-source.tar.lz
PATCH_FILES ${PATCH_FILES}
PATCH_COMMAND ${PATCH_CMD}
BUILD_COMMAND ${BUILD_CMD}
Expand Down
18 changes: 10 additions & 8 deletions thirdparty/mupdf/css_color_names.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
diff --git a/source/html/css-apply.c b/source/html/css-apply.c
index 93839ccc..858bd588 100644
--- a/source/html/css-apply.c
+++ b/source/html/css-apply.c
@@ -48,24 +48,307 @@
@@ -48,24 +48,307 @@ static const char *border_style_kw[] = {
};

static const char *color_kw[] = {
Expand Down Expand Up @@ -308,7 +310,7 @@
};

static const char *list_style_type_kw[] = {
@@ -106,7 +387,7 @@
@@ -159,7 +442,7 @@ keyword_in_list(const char *name, const char **list, int n)
else if (c > 0)
l = m + 1;
else
Expand All @@ -317,17 +319,12 @@
}
return 0;
}
@@ -1116,43 +1397,12 @@
@@ -1237,43 +1520,12 @@ hex_color:

if (value->type == CSS_KEYWORD)
{
- if (!strcmp(value->data, "transparent"))
- return make_color(0, 0, 0, 0);
+ int n = keyword_in_list(value->data, color_kw, nelem(color_kw));
+ if (!n)
+ goto hex_color; /* last ditch attempt: maybe it's a #XXXXXX color without the # */
+ if (--n == 141)
+ return make_color(0, 0, 0, 0); // transparent
- if (!strcmp(value->data, "maroon"))
- return make_color(0x80, 0x00, 0x00, 255);
- if (!strcmp(value->data, "red"))
Expand Down Expand Up @@ -363,6 +360,11 @@
- if (!strcmp(value->data, "gray"))
- return make_color(0x80, 0x80, 0x80, 255);
- goto hex_color; /* last ditch attempt: maybe it's a #XXXXXX color without the # */
+ int n = keyword_in_list(value->data, color_kw, nelem(color_kw));
+ if (!n)
+ goto hex_color; /* last ditch attempt: maybe it's a #XXXXXX color without the # */
+ if (--n == 141)
+ return make_color(0, 0, 0, 0); // transparent
+ return make_color(color_rgb[n][0], color_rgb[n][1], color_rgb[n][2], 255);
}
return initial;
Expand Down
5 changes: 4 additions & 1 deletion thirdparty/mupdf/encrypted_zip.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
diff --git a/include/mupdf/fitz/archive.h b/include/mupdf/fitz/archive.h
index b169a88e..e5fd4207 100644
--- a/include/mupdf/fitz/archive.h
+++ b/include/mupdf/fitz/archive.h
@@ -314,6 +314,9 @@ fz_archive *fz_open_zip_archive(fz_context *ctx, const char *path);
Expand All @@ -12,6 +13,7 @@ diff --git a/include/mupdf/fitz/archive.h b/include/mupdf/fitz/archive.h
fz_zip_writer offers methods for creating and writing zip files.
It can be seen as the reverse of the fz_archive zip
diff --git a/source/cbz/mucbz.c b/source/cbz/mucbz.c
index 6d1b1b24..e2f99530 100644
--- a/source/cbz/mucbz.c
+++ b/source/cbz/mucbz.c
@@ -266,6 +266,20 @@ cbz_load_page(fz_context *ctx, fz_document *doc_, int chapter, int number)
Expand All @@ -35,7 +37,7 @@ diff --git a/source/cbz/mucbz.c b/source/cbz/mucbz.c
static int
cbz_lookup_metadata(fz_context *ctx, fz_document *doc_, const char *key, char *buf, size_t size)
{
@@ -284,6 +298,8 @@ cbz_open_document(fz_context *ctx, fz_stream *file, fz_stream *accel, fz_archive
@@ -284,6 +298,8 @@ cbz_open_document(fz_context *ctx, const fz_document_handler *handler, fz_stream
doc->super.count_pages = cbz_count_pages;
doc->super.load_page = cbz_load_page;
doc->super.lookup_metadata = cbz_lookup_metadata;
Expand All @@ -45,6 +47,7 @@ diff --git a/source/cbz/mucbz.c b/source/cbz/mucbz.c
fz_try(ctx)
{
diff --git a/source/fitz/unzip.c b/source/fitz/unzip.c
index 4b138ccc..a79db423 100644
--- a/source/fitz/unzip.c
+++ b/source/fitz/unzip.c
@@ -43,10 +43,33 @@
Expand Down
60 changes: 37 additions & 23 deletions thirdparty/mupdf/external_fonts.patch
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
--- i/Makefile
+++ w/Makefile
@@ -242,6 +242,7 @@ generated/%.otf.c : %.otf $(HEXDUMP_SH) ; $(QUIET_GEN) $(MKTGTDIR) ; bash $(HEXD
diff --git a/Makefile b/Makefile
index d18e557d..e806b39a 100644
--- a/Makefile
+++ b/Makefile
@@ -250,6 +250,7 @@ generated/%.otf.c : %.otf $(HEXDUMP_SH) ; $(QUIET_GEN) $(MKTGTDIR) ; bash $(HEXD
generated/%.ttf.c : %.ttf $(HEXDUMP_SH) ; $(QUIET_GEN) $(MKTGTDIR) ; bash $(HEXDUMP_SH) > $@ $<
generated/%.ttc.c : %.ttc $(HEXDUMP_SH) ; $(QUIET_GEN) $(MKTGTDIR) ; bash $(HEXDUMP_SH) > $@ $<

+ifneq (,)
ifeq ($(HAVE_OBJCOPY),yes)
MUPDF_OBJ += $(FONT_BIN:%=$(OUT)/%.o)
$(OUT)/%.cff.o : %.cff ; $(OBJCOPY_CMD)
@@ -253,6 +254,7 @@ else
@@ -261,6 +262,7 @@ else
endif

generate: $(FONT_GEN)
+endif

# --- Generated ICC profiles ---

--- i/include/mupdf/fitz/font.h
+++ w/include/mupdf/fitz/font.h
@@ -812,4 +812,9 @@ fz_buffer *fz_subset_ttf_for_gids(fz_context *ctx, fz_buffer *orig, int *gids, i
diff --git a/include/mupdf/fitz/font.h b/include/mupdf/fitz/font.h
index 7b3d1ccb..6d6b96cc 100644
--- a/include/mupdf/fitz/font.h
+++ b/include/mupdf/fitz/font.h
@@ -825,4 +825,9 @@ fz_buffer *fz_subset_ttf_for_gids(fz_context *ctx, fz_buffer *orig, int *gids, i
*/
fz_buffer *fz_subset_cff_for_gids(fz_context *ctx, fz_buffer *orig, int *gids, int num_gids, int symbolic, int cidfont);

Expand All @@ -28,9 +32,11 @@
+void fz_install_external_font_funcs(fz_context *ctx);
+
#endif
--- i/source/fitz/font.c
+++ w/source/fitz/font.c
@@ -572,6 +572,8 @@ fz_font *fz_load_fallback_font(fz_context *ctx, int script, int language, int se
diff --git a/source/fitz/font.c b/source/fitz/font.c
index b9de4396..edb316b2 100644
--- a/source/fitz/font.c
+++ b/source/fitz/font.c
@@ -556,6 +556,8 @@ fz_font *fz_load_fallback_font(fz_context *ctx, int script, int language, int se
return *fontp;
}

Expand All @@ -39,7 +45,7 @@
static fz_font *fz_load_fallback_math_font(fz_context *ctx)
{
const unsigned char *data;
@@ -650,6 +652,8 @@ static fz_font *fz_load_fallback_boxes_font(fz_context *ctx)
@@ -634,6 +636,8 @@ static fz_font *fz_load_fallback_boxes_font(fz_context *ctx)
return ctx->font->boxes;
}

Expand All @@ -48,7 +54,7 @@
static const struct ft_error ft_errors[] =
{
#include FT_ERRORS_H
@@ -908,13 +912,18 @@ find_base14_index(const char *name)
@@ -902,13 +906,18 @@ find_base14_index(const char *name)
fz_font *
fz_new_base14_font(fz_context *ctx, const char *name)
{
Expand All @@ -67,7 +73,7 @@
data = fz_lookup_base14_font(ctx, name, &size);
if (data)
{
@@ -926,6 +935,16 @@ fz_new_base14_font(fz_context *ctx, const char *name)
@@ -920,6 +929,16 @@ fz_new_base14_font(fz_context *ctx, const char *name)
fz_set_font_embedding(ctx, ctx->font->base14[x], 1);
return fz_keep_font(ctx, ctx->font->base14[x]);
}
Expand All @@ -84,15 +90,15 @@
}
fz_throw(ctx, FZ_ERROR_ARGUMENT, "cannot find builtin font with name '%s'", name);
}
@@ -2106,6 +2125,7 @@ fz_encode_character_with_fallback(fz_context *ctx, fz_font *user_font, int unico
@@ -2100,6 +2119,7 @@ fz_encode_character_with_fallback(fz_context *ctx, fz_font *user_font, int unico
}
#endif

+#ifndef NOBUILTINFONT
font = fz_load_fallback_math_font(ctx);
if (font)
{
@@ -2147,6 +2167,15 @@ fz_encode_character_with_fallback(fz_context *ctx, fz_font *user_font, int unico
@@ -2141,6 +2161,15 @@ fz_encode_character_with_fallback(fz_context *ctx, fz_font *user_font, int unico
}

font = fz_load_fallback_boxes_font(ctx);
Expand All @@ -108,8 +114,10 @@
if (font)
{
gid = fz_encode_character(ctx, font, unicode);
--- i/source/fitz/noto.c
+++ w/source/fitz/noto.c
diff --git a/source/fitz/noto.c b/source/fitz/noto.c
index 5c1aebf3..1ce86b54 100644
--- a/source/fitz/noto.c
+++ b/source/fitz/noto.c
@@ -23,8 +23,12 @@
#include "mupdf/fitz.h"
#include "mupdf/ucdn.h"
Expand Down Expand Up @@ -255,8 +263,10 @@
+}
+
+#endif
--- i/source/html/html-font.c
+++ w/source/html/html-font.c
diff --git a/source/html/html-font.c b/source/html/html-font.c
index 87511f9d..0f325748 100644
--- a/source/html/html-font.c
+++ b/source/html/html-font.c
@@ -23,18 +23,63 @@
#include "mupdf/fitz.h"
#include "html-imp.h"
Expand Down Expand Up @@ -349,8 +359,10 @@
return fz_load_html_default_font(ctx, set, family, is_bold, is_italic);

return NULL;
--- i/source/pdf/pdf-font-add.c
+++ w/source/pdf/pdf-font-add.c
diff --git a/source/pdf/pdf-font-add.c b/source/pdf/pdf-font-add.c
index d05d6019..39e98209 100644
--- a/source/pdf/pdf-font-add.c
+++ b/source/pdf/pdf-font-add.c
@@ -73,12 +73,16 @@ static int is_postscript(fz_context *ctx, FT_Face face)

static int is_builtin_font(fz_context *ctx, fz_font *font)
Expand All @@ -368,8 +380,10 @@
}

static pdf_obj*
--- i/source/pdf/pdf-font.c
+++ w/source/pdf/pdf-font.c
diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c
index 7406487a..c2f4d808 100644
--- a/source/pdf/pdf-font.c
+++ b/source/pdf/pdf-font.c
@@ -93,6 +93,8 @@ static const char *base_font_names[][10] =
{ "ZapfDingbats", NULL }
};
Expand Down
1 change: 1 addition & 0 deletions thirdparty/mupdf/free-html-doc-fonts-on-close.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
diff --git a/source/html/html-doc.c b/source/html/html-doc.c
index 46e0860e..24b10dfb 100644
--- a/source/html/html-doc.c
+++ b/source/html/html-doc.c
@@ -49,6 +49,11 @@ static void
Expand Down
3 changes: 2 additions & 1 deletion thirdparty/mupdf/honor_cflags.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
diff --git a/Makerules b/Makerules
index f582dc06..ac2fc56d 100644
--- a/Makerules
+++ b/Makerules
@@ -105,10 +105,10 @@
@@ -111,10 +111,10 @@ else
endif

ifeq ($(build),debug)
Expand Down
8 changes: 4 additions & 4 deletions thirdparty/mupdf/mupdf_cbz_chapter_support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Date: Sun Nov 13 22:10:06 2022 +0100
a comic book archive.

diff --git a/source/cbz/mucbz.c b/source/cbz/mucbz.c
index 0c93aa458..05540ff47 100644
index e877490b..a096648a 100644
--- a/source/cbz/mucbz.c
+++ b/source/cbz/mucbz.c
@@ -233,6 +233,110 @@ cbz_lookup_metadata(fz_context *ctx, fz_document *doc_, const char *key, char *b
@@ -290,6 +290,110 @@ cbz_lookup_metadata(fz_context *ctx, fz_document *doc_, const char *key, char *b
return -1;
}

Expand Down Expand Up @@ -124,9 +124,9 @@ index 0c93aa458..05540ff47 100644
+}
+
static fz_document *
cbz_open_document_with_stream(fz_context *ctx, fz_stream *file)
cbz_open_document(fz_context *ctx, const fz_document_handler *handler, fz_stream *file, fz_stream *accel, fz_archive *dir, void *state)
{
@@ -246,6 +349,7 @@ cbz_open_document_with_stream(fz_context *ctx, fz_stream *file)
@@ -301,6 +405,7 @@ cbz_open_document(fz_context *ctx, const fz_document_handler *handler, fz_stream
doc->super.lookup_metadata = cbz_lookup_metadata;
doc->super.needs_password = cbz_needs_password;
doc->super.authenticate_password = cbz_authenticate_password;
Expand Down
14 changes: 7 additions & 7 deletions thirdparty/mupdf/no_arm_asm.patch
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
diff --git a/include/mupdf/fitz/system.h b/include/mupdf/fitz/system.h
index c480bd7c..8190fc36 100644
index c5c32469..07e2254b 100644
--- a/include/mupdf/fitz/system.h
+++ b/include/mupdf/fitz/system.h
@@ -47,11 +47,13 @@ typedef unsigned __int64 uint64_t;
Spot architectures where we have optimisations.
@@ -77,11 +77,13 @@ typedef unsigned __int64 uint64_t;
*/

+/*
/* ARCH_ARM is only used for 32bit ARM stuff. */
+#if 0
#if defined(__arm__) || defined(__thumb__)
#ifndef ARCH_ARM
#define ARCH_ARM
#endif
#endif
+*/
+#endif

/*
Some differences in libc can be smoothed over
/* Detect NEON */
#ifndef ARCH_HAS_NEON
4 changes: 2 additions & 2 deletions thirdparty/mupdf/relink_on_xlibs_change.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
diff --git a/Makefile b/Makefile
index e806b39a..571f61aa 100644
--- a/Makefile
+++ b/Makefile
@@ -97,7 +97,7 @@
@@ -102,7 +102,7 @@ $(OUT)/%.a :
$(OUT)/%.exe: %.c
$(LINK_CMD)

Expand All @@ -10,4 +11,3 @@ diff --git a/Makefile b/Makefile
ifeq ($(SO_VERSION_LINUX),yes)
$(LINK_CMD) -Wl,-soname,$(notdir $@) $(LIB_LDFLAGS) $(THIRD_LIBS) $(LIBCRYPTO_LIBS)
ln -sf $(notdir $@) $(patsubst %$(SO_VERSION), %, $@)

Loading

0 comments on commit 0c1985d

Please sign in to comment.