diff --git a/Makefile b/Makefile index d58ac18d1..b1366924c 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,8 @@ MUPDFDIR=mupdf MUPDFTARGET=build/debug MUPDFLIBDIR=$(MUPDFDIR)/$(MUPDFTARGET) DJVUDIR=djvulibre -KPVCRLIGDIR=kpvcrlib -CRENGINEDIR=$(KPVCRLIGDIR)/crengine +KPVCRLIBDIR=kpvcrlib +CRENGINEDIR=$(KPVCRLIBDIR)/crengine FREETYPEDIR=$(MUPDFDIR)/thirdparty/freetype-2.4.9 LFSDIR=luafilesystem @@ -32,7 +32,7 @@ CXXFLAGS:=-O3 $(SYSROOT) LDFLAGS:= $(SYSROOT) ARM_CFLAGS:=-march=armv6 # use this for debugging: -#CFLAGS:=-O0 -g +#CFLAGS:=-O0 -g $(SYSROOT) DYNAMICLIBSTDCPP:=-lstdc++ ifdef STATICLIBSTDCPP @@ -53,6 +53,9 @@ ifdef EMULATE_READER -DEMULATE_READER_W=$(EMULATE_READER_W) \ -DEMULATE_READER_H=$(EMULATE_READER_H) EMU_LDFLAGS?=$(shell sdl-config --libs) + ifeq "$(shell uname -s -m)" "Darwin x86_64" + EMU_LDFLAGS += -pagezero_size 10000 -image_base 100000000 + endif else CFLAGS+= $(ARM_CFLAGS) endif @@ -121,7 +124,7 @@ djvu.o: %.o: %.c $(CC) -c $(KPDFREADER_CFLAGS) -I$(DJVUDIR)/ $< -o $@ cre.o: %.o: %.cpp - $(CC) -c -I$(CRENGINEDIR)/crengine/include/ -Ilua/src $< -o $@ -lstdc++ + $(CC) -c -I$(CRENGINEDIR)/crengine/include/ -I$(LUADIR)/src $< -o $@ -lstdc++ lfs.o: $(LFSDIR)/src/lfs.c $(CC) -c $(CFLAGS) -I$(LUADIR)/src -I$(LFSDIR)/src $(LFSDIR)/src/lfs.c -o $@ @@ -143,7 +146,11 @@ fetchthirdparty: cd kpvcrlib/crengine/crengine/src && \ patch -N -p0 < ../../../lvrend_node_type_face.patch || true unzip mupdf-thirdparty.zip -d mupdf - # dirty patch in MuPDF's thirdparty liby for CREngine + # 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 @@ -158,9 +165,9 @@ cleanthirdparty: -make -C $(MUPDFDIR) clean -make -C $(CRENGINEDIR)/thirdparty/antiword clean test -d $(CRENGINEDIR)/thirdparty/chmlib && make -C $(CRENGINEDIR)/thirdparty/chmlib clean || echo warn: chmlib folder not found - test -d $(CRENGINEDIR)/thirdparty/libpng && (make -C $(CRENGINEDIR)/thirdparty/libpng clean) || echo warn: chmlib folder not found - test -d $(CRENGINEDIR)/crengine && (make -C $(CRENGINEDIR)/crengine clean) || echo warn: chmlib folder not found - test -d $(KPVCRLIGDIR) && (make -C $(KPVCRLIGDIR) clean) || echo warn: chmlib folder not found + test -d $(CRENGINEDIR)/thirdparty/libpng && (make -C $(CRENGINEDIR)/thirdparty/libpng clean) || echo warn: libpng folder not found + test -d $(CRENGINEDIR)/crengine && (make -C $(CRENGINEDIR)/crengine clean) || echo warn: crengine folder not found + test -d $(KPVCRLIBDIR) && (make -C $(KPVCRLIBDIR) clean) || echo warn: kpvcrlib folder not found -rm -rf $(DJVUDIR)/build -rm -f $(MUPDFDIR)/fontdump.host -rm -f $(MUPDFDIR)/cmapdump.host @@ -189,7 +196,7 @@ endif make -C $(DJVUDIR)/build $(CRENGINELIBS): - cd $(KPVCRLIGDIR) && rm -rf CMakeCache.txt CMakeFiles && \ + cd $(KPVCRLIBDIR) && rm -rf CMakeCache.txt CMakeFiles && \ CFLAGS="$(CFLAGS)" CC="$(CC)" CXX="$(CXX)" cmake . && \ make @@ -217,7 +224,7 @@ customupdate: all cp -rpL data/*.css $(INSTALL_DIR)/data cp -rpL fonts $(INSTALL_DIR) cp -r resources $(INSTALL_DIR) - cp -r frontend $(INSTALL_DIR) + cp -rpL frontend $(INSTALL_DIR) mkdir $(INSTALL_DIR)/fonts/host zip -9 -r kindlepdfviewer-$(VERSION).zip $(INSTALL_DIR) launchpad/ kite/ rm -Rf $(INSTALL_DIR) diff --git a/djvu.c b/djvu.c index d99f34431..53b1298ab 100644 --- a/djvu.c +++ b/djvu.c @@ -44,7 +44,7 @@ static int handle(lua_State *L, ddjvu_context_t *ctx, int wait) { const ddjvu_message_t *msg; if (!ctx) - return; + return -1; if (wait) msg = ddjvu_message_wait(ctx); while ((msg = ddjvu_message_peek(ctx))) diff --git a/frontend/document/document.lua b/frontend/document/document.lua index abb434d49..89a365607 100644 --- a/frontend/document/document.lua +++ b/frontend/document/document.lua @@ -70,6 +70,10 @@ function Document:new(o) return o end +-- override this method to open a document +function Document:init() +end + -- this might be overridden by a document implementation function Document:unlock(password) -- return true instead when the password provided unlocked the document diff --git a/input.c b/input.c index 86e53ca3f..87a1123fd 100644 --- a/input.c +++ b/input.c @@ -20,7 +20,12 @@ #include #include #include +#ifdef EMULATE_READER +#include +#define EV_KEY 0x01 +#else #include +#endif #include "input.h" #include #include @@ -138,6 +143,7 @@ static int openInputDevice(lua_State *L) { } static int closeInputDevices(lua_State *L) { +#ifndef EMULATE_READER int i; for(i=0; i -#endif - #include #include #include diff --git a/kpvcrlib/cr3.css b/kpvcrlib/cr3.css new file mode 100644 index 000000000..4fd4e1d66 --- /dev/null +++ b/kpvcrlib/cr3.css @@ -0,0 +1,74 @@ +body { text-align: left; text-indent: 0px } +p { text-align: justify; text-indent: 2em; margin-top:0em; margin-bottom: 0em } + +empty-line { height: 1em } + +hr { height: 1px; /* background-color: #808080; */ margin-top: 0.5em; margin-bottom: 0.5em } + +sub { vertical-align: sub; font-size: 70% } +sup { vertical-align: super; font-size: 70% } +strong, b { font-weight: bold } +emphasis, i { font-style: italic } + +a { text-decoration: underline } +a[type="note"] { vertical-align: super; font-size: 70%; text-decoration: none } + +image { text-align: center; text-indent: 0px } +p image { display: inline } + +title p, subtitle p, h1 p, h2 p, h3 p, h4 p, h5 p, h6 p { text-align: center; text-indent: 0px } +cite p, epigraph p { text-align: left; text-indent: 0px } +v { text-align: left; text-indent: 0px } + +stanza + stanza { margin-top: 1em; } +stanza { margin-left: 30%; text-align: left; font-style: italic } +poem { margin-top: 1em; margin-bottom: 1em; text-indent: 0px } +text-author { font-weight: bold; font-style: italic; margin-left: 5%} +epigraph { margin-left: 25%; margin-right: 1em; text-align: left; text-indent: + 1px; font-style: italic; margin-top: 15px; margin-bottom: 25px } +cite { font-style: italic; margin-left: 5%; margin-right: 5%; text-align: justify; + margin-top: 20px; margin-bottom: 20px } + +title, h1, h2 { text-align: center; text-indent: 0px; font-weight: bold; hyphenate: none; + page-break-before: always; page-break-inside: avoid; page-break-after: avoid; } +subtitle, h3, h4, h5, h6 { text-align: center; text-indent: 0px; font-weight: bold; + hyphenate: none; page-break-inside: avoid; page-break-after: avoid; } +title { font-size: 110%; margin-top: 0.7em; margin-bottom: 0.5em } +subtitle { font-style: italic; margin-top: 0.3em; margin-bottom: 0.3em } +h1 { font-size: 150% } +h2 { font-size: 140% } +h3 { font-size: 130% } +h4 { font-size: 120% } +h5 { font-size: 110% } + + +table { font-size: 80% } +td, th { text-indent: 0px; padding: 3px } +th { font-weight: bold; /* background-color: #DDD */ } +table > caption { text-indent: 0px; padding: 4px; /* background-color: #EEE */ } + +code, pre { display: block; white-space: pre; text-align: left; + font-family: "Droid Sans Mono", monospace; text-align: left } + +body[name="notes"] { font-size: 70%; } +body[name="notes"] section title { display: run-in; text-align: left; font-size: 110%; + font-weight: bold; page-break-before: auto; page-break-inside: auto; + page-break-after: auto; } +body[name="notes"] section title p { display: inline } + +description { display: block; } +title-info { display: block; } +annotation { margin-left: 5%; margin-right: 5%; font-size: 80%; font-style: italic; + text-align: justify; text-indent: 2em } +date { display: block; font-size: 80%; font-style: italic; text-align: center } +genre { display: none; } +author { display: none; } +book-title { display: none; } +keywords { display: none; } +lang { display: none; } +src-lang { display: none; } +translator { display: none; } +document-info { display: none; } +publish-info { display: none; } +custom-info { display: none; } +coverpage { display: none } diff --git a/pdf.c b/pdf.c index 4d9b086cd..0de2150d9 100644 --- a/pdf.c +++ b/pdf.c @@ -567,7 +567,7 @@ static int drawPage(lua_State *L) { } static int getCacheSize(lua_State *L) { - printf("## mupdf getCacheSize = %d\n", msize); + printf("## mupdf getCacheSize = %zu\n", msize); lua_pushnumber(L, msize); return 1; }