From 15d6f7e85103995dc87d81a2e439c0072821e695 Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Sat, 3 Nov 2012 08:30:04 +0000 Subject: [PATCH 01/16] Add "-a author" option This option is useful when creating a PDF file with embedded collection by the same author. Then one can specify the author on the command line and it will be shown correctly instead of the email address in Amazon's Personal Documents area. --- utils/pdfattach | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/utils/pdfattach b/utils/pdfattach index a7ae4d76f..a4de38aa8 100755 --- a/utils/pdfattach +++ b/utils/pdfattach @@ -19,7 +19,7 @@ function escape_tex_specialchars() function usage() { - echo "Usage: $progname -o file.pdf file1.djvu [file2.mp3] ..." + echo "Usage: $progname -o file.pdf [-a author] file1.djvu [file2.mp3] ..." exit 1 } @@ -43,9 +43,13 @@ declare -a infiles=() declare -a infiles_texclean=() declare -a infilesize=() declare -i infcount=0 outfcount=0 totalsize=0 +declare author="" -while getopts ":o:" opt; do +while getopts ":o:a:" opt; do case $opt in + a) + author="$OPTARG" + ;; o) outfile=$(readlink -f "$OPTARG") ((outfcount++)) @@ -96,6 +100,9 @@ cd $workdir echo -E "\documentclass{book}" >> tmp.tex echo -E "\usepackage[margin={1mm},papersize={9cm,12cm}]{geometry}" >> tmp.tex echo -E "\usepackage{hyperref,attachfile}" >> tmp.tex +if [ ! -z "$author" ] ; then + echo -E "\AtBeginDocument{\hypersetup{pdfauthor={$author}}}" >> tmp.tex +fi echo -E "\begin{document}" >> tmp.tex echo -E "\tolerance=10000\pagestyle{empty}\fontsize{7}{13}\selectfont" >> tmp.tex From f073c232968414e2d90d480ed7b2a1622ae8b132 Mon Sep 17 00:00:00 2001 From: HW Date: Sat, 3 Nov 2012 16:08:13 +0100 Subject: [PATCH 02/16] Switched LuaJIT to shared library instead of static --- Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 68fb3d9cb..7bffb37da 100644 --- a/Makefile +++ b/Makefile @@ -109,7 +109,8 @@ THIRDPARTYLIBS := $(MUPDFLIBDIR)/libfreetype.a \ #$(MUPDFLIBDIR)/libjpeg.a \ #$(CRENGINEDIR)/thirdparty/libjpeg/libjpeg.a \ -LUALIB := $(LUADIR)/src/libluajit.a +#LUALIB := $(LUADIR)/src/libluajit.a +LUALIB := $(LIBDIR)/libluajit-5.1.so.2 POPENNSLIB := $(POPENNSDIR)/libpopen_noshell.a @@ -143,7 +144,7 @@ kpdfview: kpdfview.o einkfb.o pdf.o k2pdfopt.o blitbuffer.o drawcontext.o input. $(STATICLIBSTDCPP) \ $(LDFLAGS) \ -o $@ \ - -lm -ldl -lpthread -ldjvulibre -ljpeg -L$(MUPDFLIBDIR) -L$(LIBDIR)\ + -lm -ldl -lpthread -ldjvulibre -ljpeg -lluajit -L$(MUPDFLIBDIR) -L$(LIBDIR)\ $(EMU_LDFLAGS) \ $(DYNAMICLIBSTDCPP) @@ -264,11 +265,13 @@ $(CRENGINELIBS): $(LUALIB): ifdef EMULATE_READER - $(MAKE) -C $(LUADIR) BUILDMODE=static + $(MAKE) -C $(LUADIR) BUILDMODE=shared else # To recap: build its TARGET_CC from CROSS+CC, so we need HOSTCC in CC. Build its HOST/TARGET_CFLAGS based on CFLAGS, so we need a neutral CFLAGS without arch - $(MAKE) -C $(LUADIR) BUILDMODE=static CC="$(HOSTCC)" HOST_CC="$(HOSTCC) -m32" CFLAGS="$(BASE_CFLAGS)" HOST_CFLAGS="$(HOSTCFLAGS)" TARGET_CFLAGS="$(CFLAGS)" CROSS="$(CHOST)-" TARGET_FLAGS="-DLUAJIT_NO_LOG2 -DLUAJIT_NO_EXP2" + $(MAKE) -C $(LUADIR) BUILDMODE=shared CC="$(HOSTCC)" HOST_CC="$(HOSTCC) -m32" CFLAGS="$(BASE_CFLAGS)" HOST_CFLAGS="$(HOSTCFLAGS)" TARGET_CFLAGS="$(CFLAGS)" CROSS="$(CHOST)-" TARGET_FLAGS="-DLUAJIT_NO_LOG2 -DLUAJIT_NO_EXP2" endif + test -d $(LIBDIR) || mkdir $(LIBDIR) + cp -a $(LUADIR)/src/libluajit.so $(LUALIB) $(POPENNSLIB): $(MAKE) -C $(POPENNSDIR) CC="$(CC)" AR="$(AR)" @@ -290,6 +293,7 @@ customupdate: all cp -p README.md COPYING kpdfview extr kpdf.sh $(LUA_FILES) $(INSTALL_DIR) mkdir $(INSTALL_DIR)/data cp -L libs/libdjvulibre.so.21 $(INSTALL_DIR)/libs + cp -L $(LUALIB) $(INSTALL_DIR)/libs $(STRIP) --strip-unneeded $(INSTALL_DIR)/libs/* cp -rpL data/*.css $(INSTALL_DIR)/data cp -rpL fonts $(INSTALL_DIR) From f2f299cd099a024b1ec0d3fcf9c45405792968f0 Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Sun, 11 Nov 2012 21:44:16 +0000 Subject: [PATCH 03/16] Bugfix: link with the static libjpeg.a We should explicitly link with the libjpeg.a from mupdf/thirdparty and not with the shared libjpeg.so that may happen to be installed on the system. Conflicts: Makefile --- Makefile | 51 +++++++++++++++++---------------------------------- 1 file changed, 17 insertions(+), 34 deletions(-) diff --git a/Makefile b/Makefile index 5e50045b2..9be29b5e4 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,8 @@ DJVUDIR=djvulibre KPVCRLIBDIR=kpvcrlib CRENGINEDIR=$(KPVCRLIBDIR)/crengine -FREETYPEDIR=$(MUPDFDIR)/thirdparty/freetype-2.4.10 -JPEGDIR=$(MUPDFDIR)/thirdparty/jpeg-9 +FREETYPEDIR=$(MUPDFDIR)/thirdparty/freetype +JPEGDIR=$(MUPDFDIR)/thirdparty/jpeg LFSDIR=luafilesystem POPENNSDIR=popen-noshell @@ -111,7 +111,6 @@ THIRDPARTYLIBS := $(MUPDFLIBDIR)/libfreetype.a \ #$(MUPDFLIBDIR)/libjpeg.a \ #$(CRENGINEDIR)/thirdparty/libjpeg/libjpeg.a \ -#LUALIB := $(LUADIR)/src/libluajit.a LUALIB := $(LIBDIR)/libluajit-5.1.so.2 POPENNSLIB := $(POPENNSDIR)/libpopen_noshell.a @@ -137,18 +136,17 @@ kpdfview: kpdfview.o einkfb.o pdf.o blitbuffer.o drawcontext.o koptcontext.o inp ft.o \ lfs.o \ mupdfimg.o \ - $(MUPDFLIBS) \ - $(THIRDPARTYLIBS) \ - $(LUALIB) \ - djvu.o \ pic.o \ pic_jpeg.o \ + $(MUPDFLIBS) \ + $(THIRDPARTYLIBS) \ + djvu.o \ cre.o \ $(CRENGINELIBS) \ $(STATICLIBSTDCPP) \ $(LDFLAGS) \ -o $@ \ - -lm -ldl -lpthread -lk2pdfopt -ldjvulibre -lluajit -ljpeg -L$(MUPDFLIBDIR) -L$(LIBDIR)\ + -lm -ldl -lpthread -lk2pdfopt -ldjvulibre -lluajit-5.1 -L$(MUPDFLIBDIR) -L$(LIBDIR)\ $(EMU_LDFLAGS) \ $(DYNAMICLIBSTDCPP) @@ -199,21 +197,11 @@ fetchthirdparty: test -d fonts || ln -sf $(TTF_FONTS_DIR) fonts # CREngine patch: disable fontconfig grep USE_FONTCONFIG $(CRENGINEDIR)/crengine/include/crsetup.h && grep -v USE_FONTCONFIG $(CRENGINEDIR)/crengine/include/crsetup.h > /tmp/new && mv /tmp/new $(CRENGINEDIR)/crengine/include/crsetup.h || echo "USE_FONTCONFIG already disabled" - test -f mupdf-thirdparty.zip || wget http://www.mupdf.com/download/mupdf-thirdparty.zip # CREngine patch: change child nodes' type face # @TODO replace this dirty hack 24.04 2012 (houqp) cd kpvcrlib/crengine/crengine/src && \ patch -N -p0 < ../../../lvrend_node_type_face.patch && \ patch -N -p3 < ../../../lvdocview-getCurrentPageLinks.patch || true - unzip mupdf-thirdparty.zip -d mupdf - # check mupdf's thirdparty libs' version, if not matched, remove the old one - # run make fetchthirdparty again to get the latest thirdparty libs. - test -d $(FREETYPEDIR) || ( echo "error: mupdf's thirdparty libs' version not match" ; \ - rm -rf mupdf-thirdparty.zip ; exit 1 ) - # dirty patch in MuPDF's thirdparty lib for CREngine - cd mupdf/thirdparty/jpeg-*/ && \ - patch -N -p0 < ../../../kpvcrlib/jpeg_compress_struct_size.patch &&\ - patch -N -p0 < ../../../kpvcrlib/jpeg_decompress_struct_size.patch # MuPDF patch: use external fonts cd mupdf && patch -N -p1 < ../mupdf.patch test -f popen-noshell/popen_noshell.c || svn co http://popen-noshell.googlecode.com/svn/trunk/ popen-noshell @@ -233,24 +221,18 @@ cleanthirdparty: test -d $(CRENGINEDIR)/crengine && ($(MAKE) -C $(CRENGINEDIR)/crengine clean) || echo warn: chmlib folder not found test -d $(KPVCRLIBDIR) && ($(MAKE) -C $(KPVCRLIBDIR) clean) || echo warn: chmlib folder not found rm -rf $(DJVUDIR)/build - rm -f $(MUPDFDIR)/fontdump.host - rm -f $(MUPDFDIR)/cmapdump.host $(MAKE) -C $(POPENNSDIR) clean $(MAKE) -C $(K2PDFOPTLIBDIR) clean -$(MUPDFDIR)/fontdump.host: - CFLAGS="$(HOSTCFLAGS)" $(MAKE) -C mupdf build="release" CC="$(HOSTCC)" $(MUPDFTARGET)/fontdump - cp -a $(MUPDFLIBDIR)/fontdump $(MUPDFDIR)/fontdump.host - $(MAKE) -C mupdf clean - -$(MUPDFDIR)/cmapdump.host: - CFLAGS="$(HOSTCFLAGS)" $(MAKE) -C mupdf build="release" CC="$(HOSTCC)" $(MUPDFTARGET)/cmapdump - cp -a $(MUPDFLIBDIR)/cmapdump $(MUPDFDIR)/cmapdump.host - $(MAKE) -C mupdf clean - -$(MUPDFLIBS) $(THIRDPARTYLIBS): $(MUPDFDIR)/cmapdump.host $(MUPDFDIR)/fontdump.host +$(MUPDFLIBS) $(THIRDPARTYLIBS): # build only thirdparty libs, libfitz and pdf utils, which will care for libmupdf.a being built - CFLAGS="$(CFLAGS) -DNOBUILTINFONT" $(MAKE) -C mupdf build="release" CC="$(CC)" CMAPDUMP=cmapdump.host FONTDUMP=fontdump.host MUPDF= MU_APPS= BUSY_APP= XPS_APPS= verbose=1 +ifdef EMULATE_READER + $(MAKE) -C mupdf XCFLAGS="$(CFLAGS) -DNOBUILTINFONT" build="release" CC="$(CC)" MUPDF= MU_APPS= BUSY_APP= XPS_APPS= verbose=1 NOX11=yes +else + # generate data headers + $(MAKE) -C mupdf generate build="release" + $(MAKE) -C mupdf XCFLAGS="$(CFLAGS) -DNOBUILTINFONT" build="release" CC="$(CC)" MUPDF= MU_APPS= BUSY_APP= XPS_APPS= verbose=1 NOX11=yes CROSSCOMPILE=yes OS=Kindle +endif $(DJVULIBS): mkdir -p $(DJVUDIR)/build @@ -276,7 +258,8 @@ else $(MAKE) -C $(LUADIR) BUILDMODE=shared CC="$(HOSTCC)" HOST_CC="$(HOSTCC) -m32" CFLAGS="$(BASE_CFLAGS)" HOST_CFLAGS="$(HOSTCFLAGS)" TARGET_CFLAGS="$(CFLAGS)" CROSS="$(CHOST)-" TARGET_FLAGS="-DLUAJIT_NO_LOG2 -DLUAJIT_NO_EXP2" endif test -d $(LIBDIR) || mkdir $(LIBDIR) - cp -a $(LUADIR)/src/libluajit.so $(LUALIB) + cp -a $(LUADIR)/src/libluajit.so* $(LUALIB) + ln -s libluajit-5.1.so.2 $(LIBDIR)/libluajit-5.1.so $(POPENNSLIB): $(MAKE) -C $(POPENNSDIR) CC="$(CC)" AR="$(AR)" @@ -302,7 +285,7 @@ customupdate: all mkdir -p $(INSTALL_DIR)/{history,screenshots,clipboard,libs} cp -p README.md COPYING kpdfview extr kpdf.sh $(LUA_FILES) $(INSTALL_DIR) mkdir $(INSTALL_DIR)/data - cp -L $(LUALIB) libs/libdjvulibre.so.21 $(K2PDFOPTLIB) $(INSTALL_DIR)/libs + cp -L $(DJVULIB) $(LUALIB) $(K2PDFOPTLIB) $(INSTALL_DIR)/libs $(STRIP) --strip-unneeded $(INSTALL_DIR)/libs/* cp -rpL data/*.css $(INSTALL_DIR)/data cp -rpL fonts $(INSTALL_DIR) From 77a322f45f31b2f4d9571953596f3b7bd5ae59eb Mon Sep 17 00:00:00 2001 From: kai771 Date: Fri, 16 Nov 2012 22:21:59 +0100 Subject: [PATCH 04/16] Implements Kindle screen rotate on emulator Conflicts: einkfb.c --- einkfb.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/einkfb.c b/einkfb.c index c40863ec5..cdbc61658 100644 --- a/einkfb.c +++ b/einkfb.c @@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include #include #include #include @@ -24,6 +23,11 @@ #include "einkfb.h" +#ifdef EMULATE_READER + int emu_w = EMULATE_READER_W; + int emu_h = EMULATE_READER_H; +#endif + static int openFrameBuffer(lua_State *L) { const char *fb_device = luaL_checkstring(L, 1); FBInfo *fb = (FBInfo*) lua_newuserdata(L, sizeof(FBInfo)); @@ -114,14 +118,14 @@ static int openFrameBuffer(lua_State *L) { if(SDL_Init(SDL_INIT_VIDEO) < 0) { return luaL_error(L, "cannot initialize SDL."); } - if(!(fb->screen = SDL_SetVideoMode(EMULATE_READER_W, EMULATE_READER_H, 32, SDL_HWSURFACE))) { + if(!(fb->screen = SDL_SetVideoMode(emu_w, emu_h, 32, SDL_HWSURFACE))) { return luaL_error(L, "can't get video surface %dx%d for 32bpp.", - EMULATE_READER_W, EMULATE_READER_H); + emu_w, emu_h); } - fb->vinfo.xres = EMULATE_READER_W; - fb->vinfo.yres = EMULATE_READER_H; - fb->buf->pitch = (EMULATE_READER_W + 1) / 2; - fb->buf->data = calloc(fb->buf->pitch * EMULATE_READER_H, sizeof(char)); + fb->vinfo.xres = emu_w; + fb->vinfo.yres = emu_h; + fb->buf->pitch = (emu_w + 1) / 2; + fb->buf->data = calloc(fb->buf->pitch * emu_h, sizeof(char)); if(fb->buf->data == NULL) { return luaL_error(L, "cannot get framebuffer emu memory"); } @@ -342,7 +346,6 @@ static int einkUpdate(lua_State *L) { /* NOTICE!!! You must close and reopen framebuffer after called this method. * Otherwise, screen resolution will not be updated! */ static int einkSetOrientation(lua_State *L) { -#ifndef EMULATE_READER FBInfo *fb = (FBInfo*) luaL_checkudata(L, 1, "einkfb"); int mode = luaL_optint(L, 2, 0); @@ -367,12 +370,22 @@ static int einkSetOrientation(lua_State *L) { * +--------------+ * 0 * */ +#ifndef EMULATE_READER if (mode == 1) mode = 2; else if (mode == 2) mode = 1; ioctl(fb->fd, FBIO_EINK_SET_DISPLAY_ORIENTATION, mode); +#else + if (mode == 0 || mode == 2) { + emu_w = EMULATE_READER_W; + emu_h = EMULATE_READER_H; + } + else if (mode == 1 || mode == 3) { + emu_w = EMULATE_READER_H; + emu_h = EMULATE_READER_W; + } #endif return 0; } @@ -390,6 +403,9 @@ static int einkGetOrientation(lua_State *L) { mode = 1; else if (mode == 1) mode = 2; +#else + if (emu_w == EMULATE_READER_H || emu_h == EMULATE_READER_W) + mode = 1; #endif lua_pushinteger(L, mode); return 1; From 80fb6c21cc8a476660ea0f4f30d9b13f874399d1 Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Sun, 18 Nov 2012 19:12:57 +0000 Subject: [PATCH 05/16] Use the font DroidSansFallbackFull.ttf Conflicts: font.lua --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 9be29b5e4..75b27b932 100644 --- a/Makefile +++ b/Makefile @@ -289,6 +289,7 @@ customupdate: all $(STRIP) --strip-unneeded $(INSTALL_DIR)/libs/* cp -rpL data/*.css $(INSTALL_DIR)/data cp -rpL fonts $(INSTALL_DIR) + rm $(INSTALL_DIR)/fonts/droid/DroidSansFallback.ttf cp -r git-rev resources $(INSTALL_DIR) cp -rpL frontend $(INSTALL_DIR) mkdir $(INSTALL_DIR)/fonts/host From d57ac2e7569736dbb7f4a95fef01d5ff7174ed44 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Mon, 26 Nov 2012 13:39:09 -0500 Subject: [PATCH 06/16] Use the font DroidSansFallbackFull.ttf in font.lua --- frontend/ui/font.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/ui/font.lua b/frontend/ui/font.lua index b0c919114..c831fa079 100644 --- a/frontend/ui/font.lua +++ b/frontend/ui/font.lua @@ -3,7 +3,7 @@ require "settings" -- for DEBUG() Font = { fontmap = { -- default font for menu contents - cfont = "droid/DroidSans.ttf", + cfont = "droid/DroidSansFallbackFull.ttf", -- default font for title tfont = "NimbusSanL-BoldItal.cff", -- default font for footer From b3b3d04c98cc81f322c8b1b3687c9c31ab1732e9 Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Sun, 18 Nov 2012 21:03:42 +0000 Subject: [PATCH 07/16] Create history and clipboard dirs for the emulator --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 75b27b932..62fbc07da 100644 --- a/Makefile +++ b/Makefile @@ -195,6 +195,8 @@ fetchthirdparty: ln -sf kpvcrlib/crengine/cr3gui/data data test -e data/cr3.css || ln kpvcrlib/cr3.css data/ test -d fonts || ln -sf $(TTF_FONTS_DIR) fonts + test -d history || mkdir history + test -d clipboard || mkdir clipboard # CREngine patch: disable fontconfig grep USE_FONTCONFIG $(CRENGINEDIR)/crengine/include/crsetup.h && grep -v USE_FONTCONFIG $(CRENGINEDIR)/crengine/include/crsetup.h > /tmp/new && mv /tmp/new $(CRENGINEDIR)/crengine/include/crsetup.h || echo "USE_FONTCONFIG already disabled" # CREngine patch: change child nodes' type face From e26ae14bed4d1ce82034b5692211885427213546 Mon Sep 17 00:00:00 2001 From: HW Date: Sat, 3 Nov 2012 17:15:12 +0100 Subject: [PATCH 08/16] updated mupdf to latest version Conflicts: Makefile --- Makefile | 2 +- mupdf | 2 +- mupdf.patch | 48 +++++++++++++++++++++++------------------------- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 62fbc07da..6cdff35fd 100644 --- a/Makefile +++ b/Makefile @@ -188,7 +188,7 @@ lfs.o: $(LFSDIR)/src/lfs.c fetchthirdparty: rm -rf mupdf/thirdparty - test -d mupdf && (cd mupdf; git checkout .) || echo warn: mupdf folder not found + test -d mupdf && (cd mupdf; git checkout .; cd thirdparty; git submodule init; git submodule update) || echo warn: mupdf folder not found test -d $(LUADIR) && (cd $(LUADIR); git checkout .) || echo warn: $(LUADIR) folder not found git submodule init git submodule update diff --git a/mupdf b/mupdf index bdb6b688a..dd4f6ffd4 160000 --- a/mupdf +++ b/mupdf @@ -1 +1 @@ -Subproject commit bdb6b688a238df56b2cf47fa17a08a4dd4b7a122 +Subproject commit dd4f6ffd475b0e769ba6231cf24b050bcdc97814 diff --git a/mupdf.patch b/mupdf.patch index 348190f95..e6bf72bb1 100644 --- a/mupdf.patch +++ b/mupdf.patch @@ -1,62 +1,60 @@ diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c -index 5e54e0b..38bd1d8 100644 +index 33a1a65..c2fdee3 100644 --- a/pdf/pdf_font.c +++ b/pdf/pdf_font.c -@@ -182,8 +182,13 @@ pdf_load_builtin_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fontname) +@@ -185,7 +185,12 @@ pdf_load_builtin_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fontname) if (!data) fz_throw(ctx, "cannot find builtin font: '%s'", fontname); - + +#ifndef NOBUILTINFONT - fontdesc->font = fz_new_font_from_memory(ctx, data, len, 0, 1); - /* RJW: "cannot load freetype font from memory" */ + fontdesc->font = fz_new_font_from_memory(ctx, fontname, data, len, 0, 1); +#else -+ fontdesc->font = fz_new_font_from_file(ctx, data, 0, 1); ++ fontdesc->font = fz_new_font_from_file(ctx, fontname, data, 0, 1); + free(data); +#endif - + if (!strcmp(fontname, "Symbol") || !strcmp(fontname, "ZapfDingbats")) fontdesc->flags |= PDF_FD_SYMBOLIC; -@@ -199,8 +204,13 @@ pdf_load_substitute_font(fz_context *ctx, pdf_font_desc *fontdesc, int mono, int +@@ -201,7 +206,12 @@ pdf_load_substitute_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fontnam if (!data) fz_throw(ctx, "cannot find substitute font"); - + +#ifndef NOBUILTINFONT - fontdesc->font = fz_new_font_from_memory(ctx, data, len, 0, 1); - /* RJW: "cannot load freetype font from memory" */ + fontdesc->font = fz_new_font_from_memory(ctx, fontname, data, len, 0, 1); +#else -+ fontdesc->font = fz_new_font_from_file(ctx, data, 0, 1); ++ fontdesc->font = fz_new_font_from_file(ctx, fontname, data, 0, 1); + free(data); +#endif - + fontdesc->font->ft_substitute = 1; fontdesc->font->ft_bold = bold && !ft_is_bold(fontdesc->font->ft_face); -@@ -218,7 +228,12 @@ pdf_load_substitute_cjk_font(fz_context *ctx, pdf_font_desc *fontdesc, int ros, +@@ -219,7 +229,12 @@ pdf_load_substitute_cjk_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fon fz_throw(ctx, "cannot find builtin CJK font"); - + /* a glyph bbox cache is too big for droid sans fallback (51k glyphs!) */ +#ifndef NOBUILTINFONT - fontdesc->font = fz_new_font_from_memory(ctx, data, len, 0, 0); + fontdesc->font = fz_new_font_from_memory(ctx, fontname, data, len, 0, 0); +#else -+ fontdesc->font = fz_new_font_from_file(ctx, data, 0, 0); ++ fontdesc->font = fz_new_font_from_file(ctx, fontname, data, 0, 1); + free(data); +#endif - /* RJW: "cannot load builtin CJK font" */ - + fontdesc->font->ft_substitute = 1; + } diff --git a/pdf/pdf_fontfile.c b/pdf/pdf_fontfile.c -index 543ce76..a076033 100644 +index 99565da..a91380f 100644 --- a/pdf/pdf_fontfile.c +++ b/pdf/pdf_fontfile.c -@@ -1,6 +1,8 @@ - #include "fitz.h" - #include "mupdf.h" - +@@ -15,6 +15,8 @@ + Set NODROIDFONT to use the base 14 fonts as substitute fonts. + */ + +#ifndef NOBUILTINFONT + #ifdef NOCJK #define NOCJKFONT #endif -@@ -129,3 +131,112 @@ pdf_find_substitute_cjk_font(int ros, int serif, unsigned int *len) +@@ -152,3 +154,112 @@ pdf_lookup_substitute_cjk_font(int ros, int serif, unsigned int *len) return NULL; #endif } From 6d66c43a6f51e5b3a65a42d97c5fd7c219e12c85 Mon Sep 17 00:00:00 2001 From: HW Date: Sat, 3 Nov 2012 17:15:40 +0100 Subject: [PATCH 09/16] changes due to mupdf updates (third party libraries) --- kpvcrlib/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kpvcrlib/CMakeLists.txt b/kpvcrlib/CMakeLists.txt index d36200925..a430a42be 100644 --- a/kpvcrlib/CMakeLists.txt +++ b/kpvcrlib/CMakeLists.txt @@ -9,14 +9,14 @@ SET(CR_3RDPARTY_DIR crengine/thirdparty) SET(CR3_PNG 1) #SET(CR3_JPEG 1) -SET(FREETYPE_INCLUDE_DIRS ${MUPDF_3RDPARTY_DIR}/freetype-2.4.10/include) +SET(FREETYPE_INCLUDE_DIRS ${MUPDF_3RDPARTY_DIR}/freetype/include) #SET(FREETYPE_INCLUDE_DIRS ${CR_3RDPARTY_DIR}/freetype/include) SET(ANTIWORD_INCLUDE_DIR ${CR_3RDPARTY_DIR}/antiword) SET(CHM_INCLUDE_DIRS ${CR_3RDPARTY_DIR}/chmlib) SET(PNG_INCLUDE_DIR ${CR_3RDPARTY_DIR}/libpng) -SET(ZLIB_INCLUDE_DIR ${MUPDF_3RDPARTY_DIR}/zlib-1.2.7) +SET(ZLIB_INCLUDE_DIR ${MUPDF_3RDPARTY_DIR}/zlib) #SET(ZLIB_INCLUDE_DIR ${CR_3RDPARTY_DIR}/zlib) -SET(JPEGLIB_INCLUDE_DIR ${MUPDF_3RDPARTY_DIR}/jpeg-9) +SET(JPEGLIB_INCLUDE_DIR ${MUPDF_3RDPARTY_DIR}/jpeg) #SET(JPEGLIB_INCLUDE_DIR ${CR_3RDPARTY_DIR}/libjpeg) SET(JCONFIG_INCLUDE_DIR ${MUPDF_DIR}/scripts) From 77866a4bd47702a9ee67fa5352c468a601d6b12f Mon Sep 17 00:00:00 2001 From: HW Date: Sat, 3 Nov 2012 23:49:18 +0100 Subject: [PATCH 10/16] disabled patching of libjpeg, restructured everything for mupdf subrepos Conflicts: Makefile --- Makefile | 15 ++++++++++++++- kpvcrlib/jpeg_compress_struct_size.patch | 15 --------------- kpvcrlib/jpeg_decompress_struct_size.patch | 15 --------------- 3 files changed, 14 insertions(+), 31 deletions(-) delete mode 100644 kpvcrlib/jpeg_compress_struct_size.patch delete mode 100644 kpvcrlib/jpeg_decompress_struct_size.patch diff --git a/Makefile b/Makefile index 6cdff35fd..b728a4141 100644 --- a/Makefile +++ b/Makefile @@ -145,8 +145,13 @@ kpdfview: kpdfview.o einkfb.o pdf.o blitbuffer.o drawcontext.o koptcontext.o inp $(CRENGINELIBS) \ $(STATICLIBSTDCPP) \ $(LDFLAGS) \ + -Wl,-rpath=$(LIBDIR)/ \ -o $@ \ +<<<<<<< HEAD -lm -ldl -lpthread -lk2pdfopt -ldjvulibre -lluajit-5.1 -L$(MUPDFLIBDIR) -L$(LIBDIR)\ +======= + -lm -ldl -lpthread -ldjvulibre -ljpeg -lluajit-5.1 -L$(MUPDFLIBDIR) -L$(LIBDIR)\ +>>>>>>> 5c10908... disabled patching of libjpeg, restructured everything for mupdf subrepos $(EMU_LDFLAGS) \ $(DYNAMICLIBSTDCPP) @@ -188,7 +193,7 @@ lfs.o: $(LFSDIR)/src/lfs.c fetchthirdparty: rm -rf mupdf/thirdparty - test -d mupdf && (cd mupdf; git checkout .; cd thirdparty; git submodule init; git submodule update) || echo warn: mupdf folder not found + test -d mupdf && (cd mupdf; git checkout .; git submodule init; git submodule update) || echo warn: mupdf folder not found test -d $(LUADIR) && (cd $(LUADIR); git checkout .) || echo warn: $(LUADIR) folder not found git submodule init git submodule update @@ -204,6 +209,14 @@ fetchthirdparty: cd kpvcrlib/crengine/crengine/src && \ patch -N -p0 < ../../../lvrend_node_type_face.patch && \ patch -N -p3 < ../../../lvdocview-getCurrentPageLinks.patch || true +<<<<<<< HEAD +======= + # dirty patch in MuPDF's thirdparty liby for CREngine + # still needed? excluded for now since they do not apply out of the box + #cd mupdf/thirdparty/jpeg*/ && \ + # patch -N -p0 < ../../../kpvcrlib/jpeg_compress_struct_size.patch &&\ + # patch -N -p0 < ../../../kpvcrlib/jpeg_decompress_struct_size.patch +>>>>>>> 5c10908... disabled patching of libjpeg, restructured everything for mupdf subrepos # MuPDF patch: use external fonts cd mupdf && patch -N -p1 < ../mupdf.patch test -f popen-noshell/popen_noshell.c || svn co http://popen-noshell.googlecode.com/svn/trunk/ popen-noshell diff --git a/kpvcrlib/jpeg_compress_struct_size.patch b/kpvcrlib/jpeg_compress_struct_size.patch deleted file mode 100644 index e2da6de22..000000000 --- a/kpvcrlib/jpeg_compress_struct_size.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- jcapimin.c 2012-04-04 00:02:30.000000000 +0800 -+++ jcapimin-patched.c 2012-04-04 00:02:26.000000000 +0800 -@@ -36,9 +36,9 @@ - cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ - if (version != JPEG_LIB_VERSION) - ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); -- if (structsize != SIZEOF(struct jpeg_compress_struct)) -- ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, -- (int) SIZEOF(struct jpeg_compress_struct), (int) structsize); -+ /*if (structsize != SIZEOF(struct jpeg_compress_struct))*/ -+ /*ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, */ -+ /*(int) SIZEOF(struct jpeg_compress_struct), (int) structsize);*/ - - /* For debugging purposes, we zero the whole master structure. - * But the application has already set the err pointer, and may have set diff --git a/kpvcrlib/jpeg_decompress_struct_size.patch b/kpvcrlib/jpeg_decompress_struct_size.patch deleted file mode 100644 index deaf375a1..000000000 --- a/kpvcrlib/jpeg_decompress_struct_size.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- jdapimin.c 2012-04-04 01:09:00.000000000 +0800 -+++ jdapimin-patched.c 2012-04-04 01:42:44.000000000 +0800 -@@ -36,9 +36,9 @@ - cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ - if (version != JPEG_LIB_VERSION) - ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); -- if (structsize != SIZEOF(struct jpeg_decompress_struct)) -- ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, -- (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize); -+ /*if (structsize != SIZEOF(struct jpeg_decompress_struct))*/ -+ /*ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, */ -+ /*(int) SIZEOF(struct jpeg_decompress_struct), (int) structsize);*/ - - /* For debugging purposes, we zero the whole master structure. - * But the application has already set the err pointer, and may have set From 503fefe7ecdfed22877ee4b3fd95ef77ab4f51f5 Mon Sep 17 00:00:00 2001 From: HW Date: Sun, 4 Nov 2012 00:15:43 +0100 Subject: [PATCH 11/16] moved luajit-2.0 and mupdf to latest version - now really Conflicts: Makefile --- Makefile | 7 +++---- luajit-2.0 | 2 +- mupdf | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index b728a4141..2da1436f6 100644 --- a/Makefile +++ b/Makefile @@ -147,11 +147,7 @@ kpdfview: kpdfview.o einkfb.o pdf.o blitbuffer.o drawcontext.o koptcontext.o inp $(LDFLAGS) \ -Wl,-rpath=$(LIBDIR)/ \ -o $@ \ -<<<<<<< HEAD -lm -ldl -lpthread -lk2pdfopt -ldjvulibre -lluajit-5.1 -L$(MUPDFLIBDIR) -L$(LIBDIR)\ -======= - -lm -ldl -lpthread -ldjvulibre -ljpeg -lluajit-5.1 -L$(MUPDFLIBDIR) -L$(LIBDIR)\ ->>>>>>> 5c10908... disabled patching of libjpeg, restructured everything for mupdf subrepos $(EMU_LDFLAGS) \ $(DYNAMICLIBSTDCPP) @@ -210,6 +206,7 @@ fetchthirdparty: patch -N -p0 < ../../../lvrend_node_type_face.patch && \ patch -N -p3 < ../../../lvdocview-getCurrentPageLinks.patch || true <<<<<<< HEAD +<<<<<<< HEAD ======= # dirty patch in MuPDF's thirdparty liby for CREngine # still needed? excluded for now since they do not apply out of the box @@ -217,6 +214,8 @@ fetchthirdparty: # patch -N -p0 < ../../../kpvcrlib/jpeg_compress_struct_size.patch &&\ # patch -N -p0 < ../../../kpvcrlib/jpeg_decompress_struct_size.patch >>>>>>> 5c10908... disabled patching of libjpeg, restructured everything for mupdf subrepos +======= +>>>>>>> a048235... moved luajit-2.0 and mupdf to latest version - now really # MuPDF patch: use external fonts cd mupdf && patch -N -p1 < ../mupdf.patch test -f popen-noshell/popen_noshell.c || svn co http://popen-noshell.googlecode.com/svn/trunk/ popen-noshell diff --git a/luajit-2.0 b/luajit-2.0 index 5bd133d6c..eb6f890eb 160000 --- a/luajit-2.0 +++ b/luajit-2.0 @@ -1 +1 @@ -Subproject commit 5bd133d6c89fb9ef5c501eb27d2d6221ec44d11d +Subproject commit eb6f890ebd01ee4cf4f31a66d8a946bc8dccd885 diff --git a/mupdf b/mupdf index dd4f6ffd4..05219d086 160000 --- a/mupdf +++ b/mupdf @@ -1 +1 @@ -Subproject commit dd4f6ffd475b0e769ba6231cf24b050bcdc97814 +Subproject commit 05219d086a5136ee19f643cf062bd5c0d3aef5d3 From a123e5157f8f0a832abc42342031507036eda445 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Mon, 26 Nov 2012 14:02:42 -0500 Subject: [PATCH 12/16] remove comments --- Makefile | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/Makefile b/Makefile index 2da1436f6..b09165cea 100644 --- a/Makefile +++ b/Makefile @@ -205,17 +205,6 @@ fetchthirdparty: cd kpvcrlib/crengine/crengine/src && \ patch -N -p0 < ../../../lvrend_node_type_face.patch && \ patch -N -p3 < ../../../lvdocview-getCurrentPageLinks.patch || true -<<<<<<< HEAD -<<<<<<< HEAD -======= - # dirty patch in MuPDF's thirdparty liby for CREngine - # still needed? excluded for now since they do not apply out of the box - #cd mupdf/thirdparty/jpeg*/ && \ - # patch -N -p0 < ../../../kpvcrlib/jpeg_compress_struct_size.patch &&\ - # patch -N -p0 < ../../../kpvcrlib/jpeg_decompress_struct_size.patch ->>>>>>> 5c10908... disabled patching of libjpeg, restructured everything for mupdf subrepos -======= ->>>>>>> a048235... moved luajit-2.0 and mupdf to latest version - now really # MuPDF patch: use external fonts cd mupdf && patch -N -p1 < ../mupdf.patch test -f popen-noshell/popen_noshell.c || svn co http://popen-noshell.googlecode.com/svn/trunk/ popen-noshell From e129307c40e1daa8e06cadacae5c8633a23c372c Mon Sep 17 00:00:00 2001 From: HW Date: Sun, 4 Nov 2012 12:45:24 +0100 Subject: [PATCH 13/16] Fixed initialization/update of mupdf's submodules, build "release" version of build helpers --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b09165cea..99a3d57e9 100644 --- a/Makefile +++ b/Makefile @@ -189,10 +189,11 @@ lfs.o: $(LFSDIR)/src/lfs.c fetchthirdparty: rm -rf mupdf/thirdparty - test -d mupdf && (cd mupdf; git checkout .; git submodule init; git submodule update) || echo warn: mupdf folder not found + test -d mupdf && (cd mupdf; git checkout .) || echo warn: mupdf folder not found test -d $(LUADIR) && (cd $(LUADIR); git checkout .) || echo warn: $(LUADIR) folder not found git submodule init git submodule update + cd mupdf && (git submodule init; git submodule update) ln -sf kpvcrlib/crengine/cr3gui/data data test -e data/cr3.css || ln kpvcrlib/cr3.css data/ test -d fonts || ln -sf $(TTF_FONTS_DIR) fonts From 9d9100c5bf15570abd62e3f5e517a26d3ad906d5 Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Mon, 5 Nov 2012 09:29:32 +0000 Subject: [PATCH 14/16] No need to set LD_LIBRARY_PATH As we use -Wl,-rpath=$(LIBDIR)/ the RPATH is hardcoded in the kpdfview binary and so there is no need to help the linker find our libraries. --- kpdf.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/kpdf.sh b/kpdf.sh index 69be73d9f..3f5cffc43 100755 --- a/kpdf.sh +++ b/kpdf.sh @@ -21,7 +21,6 @@ fi # stop cvm killall -stop cvm -export LD_LIBRARY_PATH=`pwd`/libs # finally call reader ./reader.lua "$1" 2> /mnt/us/kindlepdfviewer/crash.log || cat /mnt/us/kindlepdfviewer/crash.log From 42a4c8042bf1ac31c725140f23ddd495ead016d9 Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Mon, 5 Nov 2012 09:30:40 +0000 Subject: [PATCH 15/16] Package defaults.lua and symlink libluajit-5.1.so 1. The file defaults.lua needs to be mentioned in LUA_FILES in order to be packaged by "make customupdate". 2. The problem with the linker not finding libluajit-5.1.so.2 can be fixed without specifying the shared library in the list of objects (and static libraries), simply by making a symbolic link. No need to copy a duplicate. Conflicts: Makefile --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 99a3d57e9..b3912e72d 100644 --- a/Makefile +++ b/Makefile @@ -96,6 +96,7 @@ K2PDFOPT_CFLAGS=-I$(K2PDFOPTLIBDIR)/willuslib -I$(K2PDFOPTLIBDIR)/k2pdfoptlib -I MUPDFLIBS := $(MUPDFLIBDIR)/libfitz.a DJVULIBS := $(DJVUDIR)/build/libdjvu/.libs/libdjvulibre.so \ $(LIBDIR)/libdjvulibre.so +DJVULIB := $(LIBDIR)/libdjvulibre.so.21 DJVULIBDIR := $(DJVUDIR)/build/libdjvu/.libs/ CRENGINELIBS := $(CRENGINEDIR)/crengine/libcrengine.a \ $(CRENGINEDIR)/thirdparty/chmlib/libchmlib.a \ From 0251a00cce18b29666ec0094c0a5c71e21abdaad Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Mon, 5 Nov 2012 11:39:58 +0000 Subject: [PATCH 16/16] No need to cat crash.log on crash. One cannot start kpdf.sh from a terminal anyway (try it and you will see that keyboard handling doesn't work), so there is no need to cat the content of crash.log (to a non-existent terminal) if reader.lua fails. --- kpdf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpdf.sh b/kpdf.sh index 3f5cffc43..a2b09ee4c 100755 --- a/kpdf.sh +++ b/kpdf.sh @@ -22,7 +22,7 @@ fi killall -stop cvm # finally call reader -./reader.lua "$1" 2> /mnt/us/kindlepdfviewer/crash.log || cat /mnt/us/kindlepdfviewer/crash.log +./reader.lua "$1" 2> crash.log # unmount system fonts if grep /mnt/us/kindlepdfviewer/fonts/host /proc/mounts; then