mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
half done demo for crengine
This commit is contained in:
40
Makefile
40
Makefile
@@ -5,6 +5,7 @@ MUPDFDIR=mupdf
|
||||
MUPDFTARGET=build/debug
|
||||
MUPDFLIBDIR=$(MUPDFDIR)/$(MUPDFTARGET)
|
||||
DJVUDIR=djvulibre
|
||||
CRENGINEDIR=crengine
|
||||
|
||||
FREETYPEDIR=$(MUPDFDIR)/thirdparty/freetype-2.4.8
|
||||
LFSDIR=luafilesystem
|
||||
@@ -55,16 +56,26 @@ KPDFREADER_CFLAGS=$(CFLAGS) -I$(LUADIR)/src -I$(MUPDFDIR)/
|
||||
|
||||
MUPDFLIBS := $(MUPDFLIBDIR)/libfitz.a
|
||||
DJVULIBS := $(DJVUDIR)/build/libdjvu/.libs/libdjvulibre.a
|
||||
CRENGINELIBS := $(CRENGINEDIR)/crengine/libcrengine.a \
|
||||
$(CRENGINEDIR)/thirdparty/chmlib/libchmlib.a \
|
||||
$(CRENGINEDIR)/thirdparty/libpng/libpng.a \
|
||||
$(CRENGINEDIR)/thirdparty/libjpeg/libjpeg.a \
|
||||
$(CRENGINEDIR)/thirdparty/zlib/libz.a \
|
||||
$(CRENGINEDIR)/thirdparty/antiword/libantiword.a
|
||||
THIRDPARTYLIBS := $(MUPDFLIBDIR)/libfreetype.a \
|
||||
$(MUPDFLIBDIR)/libjpeg.a \
|
||||
$(MUPDFLIBDIR)/libopenjpeg.a \
|
||||
$(MUPDFLIBDIR)/libjbig2dec.a \
|
||||
$(MUPDFLIBDIR)/libz.a
|
||||
$(MUPDFLIBDIR)/libopenjpeg.a \
|
||||
$(MUPDFLIBDIR)/libjbig2dec.a \
|
||||
$(MUPDFLIBDIR)/libz.a
|
||||
|
||||
# @TODO the libjpeg used by mupdf is too new for crengine and will cause
|
||||
# a segment fault when decoding jpeg images in crengine, we need to fix
|
||||
# this. 28.03 2012 (houqp)
|
||||
#$(MUPDFLIBDIR)/libjpeg.a
|
||||
|
||||
LUALIB := $(LUADIR)/src/liblua.a
|
||||
|
||||
kpdfview: kpdfview.o einkfb.o pdf.o blitbuffer.o drawcontext.o input.o util.o ft.o lfs.o $(MUPDFLIBS) $(THIRDPARTYLIBS) $(LUALIB) $(DJVULIBS) djvu.o
|
||||
$(CC) -lm -ldl -lpthread $(EMU_LDFLAGS) -lstdc++ \
|
||||
kpdfview: kpdfview.o einkfb.o pdf.o blitbuffer.o drawcontext.o input.o util.o ft.o lfs.o $(MUPDFLIBS) $(THIRDPARTYLIBS) $(LUALIB) djvu.o $(DJVULIBS) cre.o $(CRENGINELIBS)
|
||||
$(CC) -lm -ldl -lpthread $(EMU_LDFLAGS) -lstdc++ \
|
||||
kpdfview.o \
|
||||
einkfb.o \
|
||||
pdf.o \
|
||||
@@ -79,6 +90,8 @@ kpdfview: kpdfview.o einkfb.o pdf.o blitbuffer.o drawcontext.o input.o util.o ft
|
||||
$(LUALIB) \
|
||||
djvu.o \
|
||||
$(DJVULIBS) \
|
||||
cre.o \
|
||||
$(CRENGINELIBS) \
|
||||
-o kpdfview
|
||||
|
||||
einkfb.o input.o: %.o: %.c
|
||||
@@ -93,6 +106,9 @@ kpdfview.o pdf.o blitbuffer.o util.o drawcontext.o: %.o: %.c
|
||||
djvu.o: %.o: %.c
|
||||
$(CC) -c $(KPDFREADER_CFLAGS) -I$(DJVUDIR)/ $< -o $@
|
||||
|
||||
cre.o: %.o: %.cpp
|
||||
$(CC) -c -I$(CRENGINEDIR)/crengine/include/ $< -o $@ -lstdc++
|
||||
|
||||
lfs.o: $(LFSDIR)/src/lfs.c
|
||||
$(CC) -c $(CFLAGS) -I$(LUADIR)/src -I$(LFSDIR)/src $(LFSDIR)/src/lfs.c -o $@
|
||||
|
||||
@@ -112,6 +128,7 @@ clean:
|
||||
cleanthirdparty:
|
||||
make -C $(LUADIR) clean
|
||||
make -C $(MUPDFDIR) clean
|
||||
make -C $(CRENGINEDIR) clean
|
||||
-rm -rf $(DJVUDIR)/build
|
||||
-rm -f $(MUPDFDIR)/fontdump.host
|
||||
-rm -f $(MUPDFDIR)/cmapdump.host
|
||||
@@ -139,10 +156,19 @@ else
|
||||
endif
|
||||
make -C $(DJVUDIR)/build
|
||||
|
||||
$(CRENGINELIBS):
|
||||
cd $(CRENGINEDIR) && cmake -D CR3_PNG=1 -D CR3_JPEG=1 .
|
||||
cd $(CRENGINEDIR)/crengine && make
|
||||
cd $(CRENGINEDIR)/thirdparty/libjpeg && make
|
||||
cd $(CRENGINEDIR)/thirdparty/chmlib && make
|
||||
cd $(CRENGINEDIR)/thirdparty/antiword && make
|
||||
cd $(CRENGINEDIR)/thirdparty/libpng && make
|
||||
cd $(CRENGINEDIR)/thirdparty/zlib && make
|
||||
|
||||
$(LUALIB):
|
||||
make -C lua/src CC="$(CC)" CFLAGS="$(CFLAGS)" MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E" liblua.a
|
||||
|
||||
thirdparty: $(MUPDFLIBS) $(THIRDPARTYLIBS) $(LUALIB) $(DJVULIBS)
|
||||
thirdparty: $(MUPDFLIBS) $(THIRDPARTYLIBS) $(LUALIB) $(DJVULIBS) $(CRENGINELIBS)
|
||||
|
||||
INSTALL_DIR=kindlepdfviewer
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ function FileChooser:readDir()
|
||||
table.insert(self.dirs, f)
|
||||
else
|
||||
local file_type = string.lower(string.match(f, ".+%.([^.]+)") or "")
|
||||
if file_type == "djvu" or file_type == "pdf" or file_type == "xps" or file_type == "cbz" then
|
||||
if file_type == "djvu" or file_type == "pdf" or file_type == "xps" or file_type == "cbz" or file_type == "epub" or file_type == "txt" or file_type == "rtf" or file_type == "htm" or file_type == "fb2" or file_type == "chm" then
|
||||
table.insert(self.files, f)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,10 +30,15 @@ function FileSearcher:readDir()
|
||||
for __, d in pairs(self.dirs) do
|
||||
-- handle files in d
|
||||
for f in lfs.dir(d) do
|
||||
local file_type = string.lower(string.match(f, ".+%.([^.]+)") or "")
|
||||
if lfs.attributes(d.."/"..f, "mode") == "directory"
|
||||
and f ~= "." and f~= ".." and not string.match(f, "^%.[^.]") then
|
||||
table.insert(new_dirs, d.."/"..f)
|
||||
elseif string.match(f, ".+%.[pP][dD][fF]$") or string.match(f, ".+%.[dD][jJ][vV][uU]$") then
|
||||
elseif file_type == "djvu" or file_type == "pdf"
|
||||
or file_type == "xps" or file_type == "cbz"
|
||||
or file_type == "epub" or file_type == "txt"
|
||||
or file_type == "rtf" or file_type == "htm"
|
||||
or file_type == "fb2" or file_type == "chm" then
|
||||
file_entry = {dir=d, name=f,}
|
||||
table.insert(self.files, file_entry)
|
||||
--print("file:"..d.."/"..f)
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "blitbuffer.h"
|
||||
#include "drawcontext.h"
|
||||
#include "pdf.h"
|
||||
#include "djvu.h"
|
||||
#include "cre.h"
|
||||
#include "einkfb.h"
|
||||
#include "input.h"
|
||||
#include "ft.h"
|
||||
@@ -53,6 +55,7 @@ int main(int argc, char **argv) {
|
||||
luaopen_einkfb(L);
|
||||
luaopen_pdf(L);
|
||||
luaopen_djvu(L);
|
||||
luaopen_cre(L);
|
||||
luaopen_input(L);
|
||||
luaopen_util(L);
|
||||
luaopen_ft(L);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
require "alt_getopt"
|
||||
require "pdfreader"
|
||||
require "djvureader"
|
||||
require "crereader"
|
||||
require "filechooser"
|
||||
require "settings"
|
||||
require "screen"
|
||||
@@ -42,6 +43,8 @@ function openFile(filename)
|
||||
reader = DJVUReader
|
||||
elseif file_type == "pdf" or file_type == "xps" or file_type == "cbz" then
|
||||
reader = PDFReader
|
||||
elseif file_type == "epub" or file_type == "txt" or file_type == "rtf" or file_type == "htm" or file_type == "fb2" or file_type == "chm" then
|
||||
reader = CREReader
|
||||
end
|
||||
if reader then
|
||||
local ok, err = reader:open(filename)
|
||||
@@ -133,6 +136,7 @@ UniReader:initGlobalSettings(reader_settings)
|
||||
-- initialize specific readers
|
||||
PDFReader:init()
|
||||
DJVUReader:init()
|
||||
CREReader:init()
|
||||
|
||||
-- display directory or open file
|
||||
local patharg = reader_settings:readSetting("lastfile")
|
||||
|
||||
@@ -493,7 +493,7 @@ function UniReader:addJump(pageno, notes)
|
||||
local notes_to_add = notes
|
||||
if not notes_to_add then
|
||||
-- no notes given, auto generate from TOC entry
|
||||
notes_to_add = self:getTOCTitleByPage(self.pageno)
|
||||
notes_to_add = self:getTocTitleByPage(self.pageno)
|
||||
if notes_to_add ~= "" then
|
||||
notes_to_add = "in "..notes_to_add
|
||||
end
|
||||
@@ -563,6 +563,10 @@ function UniReader:goto(no)
|
||||
end
|
||||
end
|
||||
|
||||
function UniReader:redrawCurrentPage()
|
||||
self:goto(self.pageno)
|
||||
end
|
||||
|
||||
function UniReader:nextView()
|
||||
local pageno = self.pageno
|
||||
|
||||
@@ -659,7 +663,7 @@ function UniReader:fillTOC()
|
||||
self.toc = self.doc:getTOC()
|
||||
end
|
||||
|
||||
function UniReader:getTOCTitleByPage(pageno)
|
||||
function UniReader:getTocTitleByPage(pageno)
|
||||
if not self.toc then
|
||||
-- build toc when needed.
|
||||
self:fillTOC()
|
||||
@@ -734,7 +738,7 @@ function UniReader:showMenu()
|
||||
|
||||
ypos = ypos + 15
|
||||
local face, fhash = Font:getFaceAndHash(22)
|
||||
local cur_section = self:getTOCTitleByPage(self.pageno)
|
||||
local cur_section = self:getTocTitleByPage(self.pageno)
|
||||
if cur_section ~= "" then
|
||||
cur_section = "Section: "..cur_section
|
||||
end
|
||||
@@ -1010,7 +1014,7 @@ function UniReader:addAllCommands()
|
||||
"open menu",
|
||||
function(unireader)
|
||||
unireader:showMenu()
|
||||
unireader:goto(unireader.pageno)
|
||||
unireader:redrawCurrentPage()
|
||||
end)
|
||||
-- panning
|
||||
local panning_keys = {Keydef:new(KEY_FW_LEFT,MOD_ANY),Keydef:new(KEY_FW_RIGHT,MOD_ANY),Keydef:new(KEY_FW_UP,MOD_ANY),Keydef:new(KEY_FW_DOWN,MOD_ANY),Keydef:new(KEY_FW_PRESS,MOD_ANY)}
|
||||
|
||||
Reference in New Issue
Block a user