mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
kopt: color support
Keep colors when reflowing documents.
This commit is contained in:
committed by
Frans de Jonge
parent
cb002f3d1f
commit
0c17941ffb
@@ -21,12 +21,6 @@ local PdfDocument = Document:extend{
|
||||
|
||||
function PdfDocument:init()
|
||||
if not pdf then pdf = require("ffi/mupdf") end
|
||||
-- mupdf.color has to stay false for kopt to work correctly
|
||||
-- and be accurate (including its job about showing highlight
|
||||
-- boxes). We will turn it on and off in PdfDocument:preRenderPage()
|
||||
-- and :postRenderPage() when mupdf is called without kopt involved.
|
||||
pdf.color = false
|
||||
self:updateColorRendering()
|
||||
self.koptinterface = require("document/koptinterface")
|
||||
self.koptinterface:setDefaultConfigurable(self.configurable)
|
||||
local ok
|
||||
@@ -34,6 +28,7 @@ function PdfDocument:init()
|
||||
if not ok then
|
||||
error(self._document) -- will contain error message
|
||||
end
|
||||
self:updateColorRendering()
|
||||
self.is_reflowable = self._document:isDocumentReflowable()
|
||||
self.reflowable_font_size = self:convertKoptToReflowableFontSize()
|
||||
-- no-op on PDF
|
||||
@@ -48,6 +43,13 @@ function PdfDocument:init()
|
||||
end
|
||||
end
|
||||
|
||||
function PdfDocument:updateColorRendering()
|
||||
Document.updateColorRendering(self) -- will set self.render_color
|
||||
if self._document then
|
||||
self._document:setColorRendering(self.render_color)
|
||||
end
|
||||
end
|
||||
|
||||
function PdfDocument:layoutDocument(font_size)
|
||||
if font_size then
|
||||
self.reflowable_font_size = font_size
|
||||
@@ -81,14 +83,6 @@ function PdfDocument:convertKoptToReflowableFontSize(font_size)
|
||||
end
|
||||
end
|
||||
|
||||
function PdfDocument:preRenderPage()
|
||||
pdf.color = self.render_color
|
||||
end
|
||||
|
||||
function PdfDocument:postRenderPage()
|
||||
pdf.color = false
|
||||
end
|
||||
|
||||
function PdfDocument:unlock(password)
|
||||
if not self._document:authenticatePassword(password) then
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user