mirror of
https://github.com/koreader/koreader.git
synced 2025-12-18 12:02:09 +01:00
add CreDocument:engineInit() method
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
require "cache"
|
||||
require "ui/geometry"
|
||||
|
||||
CreDocument = Document:new{
|
||||
_document = false,
|
||||
engine_initilized = false,
|
||||
|
||||
line_space_percent = 100,
|
||||
--dc_null = DrawContext.new()
|
||||
default_font = "Droid Sans Fallback",
|
||||
}
|
||||
|
||||
-- NuPogodi, 20.05.12: inspect the zipfile content
|
||||
@@ -22,7 +23,8 @@ function CreDocument:zipContentExt(fname)
|
||||
return string.lower(string.match(s, ".+%.([^.]+)"))
|
||||
end
|
||||
|
||||
function CreDocument:init()
|
||||
function CreDocument:engineInit()
|
||||
if not engine_initilized then
|
||||
-- we need to initialize the CRE font list
|
||||
local fonts = Font:getFontList()
|
||||
for _k, _v in ipairs(fonts) do
|
||||
@@ -32,10 +34,17 @@ function CreDocument:init()
|
||||
end
|
||||
end
|
||||
|
||||
--local default_font = G_reader_settings:readSetting("cre_font")
|
||||
--if default_font then
|
||||
--self.default_font = default_font
|
||||
--end
|
||||
local default_font = G_reader_settings:readSetting("cre_font")
|
||||
if default_font then
|
||||
self.default_font = default_font
|
||||
end
|
||||
|
||||
engine_initilized = true
|
||||
end
|
||||
end
|
||||
|
||||
function CreDocument:init()
|
||||
self:engineInit()
|
||||
|
||||
local ok
|
||||
local file_type = string.lower(string.match(self.file, ".+%.([^.]+)"))
|
||||
|
||||
@@ -9,10 +9,6 @@ function DocumentRegistry:addProvider(extension, mimetype, provider)
|
||||
table.insert(self.providers, { extension = extension, mimetype = mimetype, provider = provider })
|
||||
end
|
||||
|
||||
function DocumentRegistry:openDocument(file)
|
||||
return self:getProvider(file):new{file = file}
|
||||
end
|
||||
|
||||
function DocumentRegistry:getProvider(file)
|
||||
-- TODO: some implementation based on mime types?
|
||||
local extension = string.lower(string.match(file, ".+%.([^.]+)"))
|
||||
@@ -23,6 +19,10 @@ function DocumentRegistry:getProvider(file)
|
||||
end
|
||||
end
|
||||
|
||||
function DocumentRegistry:openDocument(file)
|
||||
return self:getProvider(file):new{file = file}
|
||||
end
|
||||
|
||||
|
||||
--[[
|
||||
This is an abstract interface to a document
|
||||
|
||||
Reference in New Issue
Block a user