mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
bump crengine: adds support for dpi-based css units (#4040)
Adds a new toggle to the bottom menu: Zoom (dpi), which allows for scaling CSS absolute units and image sizes.
This commit is contained in:
2
base
2
base
Submodule base updated: d741e83bbd...438014b1d9
@@ -49,6 +49,14 @@ function ReaderTypeset:onReadSettings(config)
|
||||
end
|
||||
self.ui.document:setEmbeddedStyleSheet(self.embedded_css and 1 or 0)
|
||||
|
||||
-- set render DPI
|
||||
self.render_dpi = config:readSetting("render_dpi") or
|
||||
G_reader_settings:readSetting("copt_render_dpi") or 96
|
||||
self:setRenderDPI(self.render_dpi)
|
||||
|
||||
-- uncomment if we want font size to follow DPI changes
|
||||
-- self.ui.document:setRenderScaleFontWithDPI(1)
|
||||
|
||||
-- set page margins
|
||||
self:onSetPageMargins(
|
||||
config:readSetting("copt_page_margins") or
|
||||
@@ -74,6 +82,7 @@ function ReaderTypeset:onSaveSettings()
|
||||
self.ui.doc_settings:saveSetting("embedded_css", self.embedded_css)
|
||||
self.ui.doc_settings:saveSetting("floating_punctuation", self.floating_punctuation)
|
||||
self.ui.doc_settings:saveSetting("embedded_fonts", self.embedded_fonts)
|
||||
self.ui.doc_settings:saveSetting("render_dpi", self.render_dpi)
|
||||
end
|
||||
|
||||
function ReaderTypeset:onToggleEmbeddedStyleSheet(toggle)
|
||||
@@ -102,6 +111,11 @@ local OBSOLETED_CSS = {
|
||||
"txt.css",
|
||||
}
|
||||
|
||||
function ReaderTypeset:onSetRenderDPI(dpi)
|
||||
self:setRenderDPI(dpi)
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderTypeset:genStyleSheetMenu()
|
||||
local getStyleMenuItem = function(text, css_file, separator)
|
||||
return {
|
||||
@@ -251,6 +265,12 @@ function ReaderTypeset:toggleTxtPreFormatted(toggle)
|
||||
self.ui:handleEvent(Event:new("UpdatePos"))
|
||||
end
|
||||
|
||||
function ReaderTypeset:setRenderDPI(dpi)
|
||||
self.render_dpi = dpi
|
||||
self.ui.document:setRenderDPI(dpi)
|
||||
self.ui:handleEvent(Event:new("UpdatePos"))
|
||||
end
|
||||
|
||||
function ReaderTypeset:addToMainMenu(menu_items)
|
||||
-- insert table to main reader menu
|
||||
menu_items.set_render_style = {
|
||||
|
||||
@@ -452,6 +452,21 @@ function CreDocument:setTrustSoftHyphens(toggle)
|
||||
self._document:setIntProperty("crengine.hyphenation.trust.soft.hyphens", toggle and 1 or 0)
|
||||
end
|
||||
|
||||
function CreDocument:setRenderDPI(value)
|
||||
-- set DPI used for scaling css units (with 96, 1 css px = 1 screen px)
|
||||
-- it can be different from KOReader screen DPI
|
||||
-- it has no relation to the default fontsize (which is already
|
||||
-- scaleBySize()'d when provided to crengine)
|
||||
logger.dbg("CreDocument: set render dpi", value or 96)
|
||||
self._document:setIntProperty("crengine.render.dpi", value or 96)
|
||||
end
|
||||
|
||||
function CreDocument:setRenderScaleFontWithDPI(toggle)
|
||||
-- wheter to scale font with DPI, or keep the current size
|
||||
logger.dbg("CreDocument: set render scale font with dpi", toggle)
|
||||
self._document:setIntProperty("crengine.render.scale.font.with.dpi", toggle)
|
||||
end
|
||||
|
||||
function CreDocument:clearSelection()
|
||||
logger.dbg("clear selection")
|
||||
self._document:clearSelection()
|
||||
|
||||
@@ -47,6 +47,16 @@ local CreOptions = {
|
||||
event = "SetViewMode",
|
||||
name_text_hold_callback = optionsutil.showValues,
|
||||
},
|
||||
{
|
||||
name = "render_dpi",
|
||||
name_text = S.ZOOM_DPI,
|
||||
toggle = {S.OFF, "48", "96¹’¹", "167", "212", "300"},
|
||||
values = {0, 48, 96, 167, 212, 300},
|
||||
default_value = 96,
|
||||
args = {0, 48, 96, 167, 212, 300},
|
||||
event = "SetRenderDPI",
|
||||
name_text_hold_callback = optionsutil.showValues,
|
||||
},
|
||||
{
|
||||
name = "line_spacing",
|
||||
name_text = S.LINE_SPACING,
|
||||
|
||||
@@ -6,6 +6,7 @@ S.SCREEN_MODE = _("Orientation")
|
||||
S.PAGE_CROP = _("Page Crop")
|
||||
S.FULL_SCREEN = _("Full Screen")
|
||||
S.SCROLL_MODE = _("Scroll Mode")
|
||||
S.ZOOM_DPI = _("Zoom (dpi)")
|
||||
S.PAGE_MARGIN = _("Margin")
|
||||
S.LINE_SPACING = _("Line Spacing")
|
||||
S.COLUMNS = _("Columns")
|
||||
|
||||
@@ -16,9 +16,9 @@ describe("ReaderLink module", function()
|
||||
local readerui = ReaderUI:new{
|
||||
document = DocumentRegistry:openDocument(sample_epub),
|
||||
}
|
||||
readerui.rolling:onGotoPage(4)
|
||||
readerui.link:onTap(nil, {pos = {x = 306, y = 710}})
|
||||
assert.is.same(37, readerui.rolling.current_page)
|
||||
readerui.rolling:onGotoPage(5)
|
||||
readerui.link:onTap(nil, {pos = {x = 326, y = 220}})
|
||||
assert.is.same(44, readerui.rolling.current_page)
|
||||
end)
|
||||
|
||||
it("should jump to links in pdf page mode", function()
|
||||
@@ -53,11 +53,11 @@ describe("ReaderLink module", function()
|
||||
local readerui = ReaderUI:new{
|
||||
document = DocumentRegistry:openDocument(sample_epub),
|
||||
}
|
||||
readerui.rolling:onGotoPage(4)
|
||||
readerui.link:onTap(nil, {pos = {x = 306, y = 710}})
|
||||
assert.is.same(37, readerui.rolling.current_page)
|
||||
readerui.rolling:onGotoPage(5)
|
||||
readerui.link:onTap(nil, {pos = {x = 326, y = 220}})
|
||||
assert.is.same(44, readerui.rolling.current_page)
|
||||
readerui.link:onGoBackLink()
|
||||
assert.is.same(4, readerui.rolling.current_page)
|
||||
assert.is.same(5, readerui.rolling.current_page)
|
||||
end)
|
||||
|
||||
it("should be able to go back after link jump in pdf page mode", function()
|
||||
|
||||
Reference in New Issue
Block a user