copt deduplicate: line_spacing (#10768)

reviewable/pr10890/r1
hius07 8 months ago committed by GitHub
parent 5e74f29fba
commit 73378cd9d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -24,7 +24,6 @@ local optionsutil = require("ui/data/optionsutil")
local ReaderFont = InputContainer:extend{
font_face = nil,
font_size = nil,
line_space_percent = nil,
font_menu_title = _("Font"),
face_table = nil,
-- default gamma from crengine's lvfntman.cpp
@ -216,10 +215,7 @@ function ReaderFont:onReadSettings(config)
or 100
self.ui.document:setCJKWidthScaling(self.cjk_width_scaling)
self.line_space_percent = config:readSetting("line_space_percent")
or G_reader_settings:readSetting("copt_line_spacing")
or G_defaults:readSetting("DCREREADER_CONFIG_LINE_SPACE_PERCENT_MEDIUM")
self.ui.document:setInterlineSpacePercent(self.line_space_percent)
self.ui.document:setInterlineSpacePercent(self.configurable.line_spacing)
self.gamma_index = config:readSetting("gamma_index")
or G_reader_settings:readSetting("copt_font_gamma")
@ -287,10 +283,11 @@ function ReaderFont:onSetFontSize(new_size)
end
function ReaderFont:onSetLineSpace(space)
self.line_space_percent = math.min(200, math.max(50, space))
self.ui.document:setInterlineSpacePercent(self.line_space_percent)
space = math.max(50, math.min(space, 200))
self.configurable.line_spacing = space
self.ui.document:setInterlineSpacePercent(space)
self.ui:handleEvent(Event:new("UpdatePos"))
Notification:notify(T(_("Line spacing set to: %1%."), self.line_space_percent))
Notification:notify(T(_("Line spacing set to: %1%."), space))
return true
end
@ -361,7 +358,6 @@ function ReaderFont:onSaveSettings()
self.ui.doc_settings:saveSetting("word_spacing", self.word_spacing)
self.ui.doc_settings:saveSetting("word_expansion", self.word_expansion)
self.ui.doc_settings:saveSetting("cjk_width_scaling", self.cjk_width_scaling)
self.ui.doc_settings:saveSetting("line_space_percent", self.line_space_percent)
self.ui.doc_settings:saveSetting("gamma_index", self.gamma_index)
self.ui.doc_settings:saveSetting("font_family_fonts", self.font_family_fonts)
end

@ -835,7 +835,7 @@ function ReaderRolling:onGotoXPointer(xp, marker_xp)
-- where xpointer target is (and remove if after 1s)
local screen_y, screen_x = self.ui.document:getScreenPositionFromXPointer(marker_xp)
local doc_margins = self.ui.document:getPageMargins()
local marker_h = Screen:scaleBySize(self.ui.font.font_size * 1.1 * self.ui.font.line_space_percent * (1/100))
local marker_h = Screen:scaleBySize(self.ui.font.font_size * 1.1 * self.configurable.line_spacing * (1/100))
-- Make it 4/5 of left margin wide (and bigger when huge margin)
local marker_w = math.floor(math.max(doc_margins["left"] - Screen:scaleBySize(5), doc_margins["left"] * 4/5))
@ -933,7 +933,7 @@ function ReaderRolling:onGotoViewRel(diff)
local pan_diff = diff * page_visible_height
if self.view.page_overlap_enable then
local overlap_lines = G_reader_settings:readSetting("copt_overlap_lines") or 1
local overlap_h = Screen:scaleBySize(self.ui.font.font_size * 1.1 * self.ui.font.line_space_percent * (1/100)) * overlap_lines
local overlap_h = Screen:scaleBySize(self.ui.font.font_size * 1.1 * self.configurable.line_spacing * (1/100)) * overlap_lines
if pan_diff > overlap_h then
pan_diff = pan_diff - overlap_h
elseif pan_diff < -overlap_h then

@ -325,6 +325,7 @@ function ReaderUI:init()
})
-- font menu
self:registerModule("font", ReaderFont:new{
configurable = self.document.configurable,
dialog = self.dialog,
view = self.view,
ui = self
@ -343,6 +344,7 @@ function ReaderUI:init()
})
-- rolling controller
self:registerModule("rolling", ReaderRolling:new{
configurable = self.document.configurable,
pan_rate = pan_rate,
dialog = self.dialog,
view = self.view,

@ -29,7 +29,6 @@ local CreDocument = Document:extend{
_smooth_scaling = false,
_nightmode_images = true,
line_space_percent = 100,
default_font = "Noto Serif",
monospace_font = "Droid Sans Mono",
header_font = "Noto Sans",

@ -21,11 +21,11 @@ return {--do NOT change this line
},
["/mnt/onboard/smalltext"] = {
["font_size"] = 34,
["line_space_percent"] = 130,
["copt_line_spacing"] = 130,
},
["/sdcard/Books/smalltext"] = {
["font_size"] = 34,
["line_space_percent"] = 130,
["copt_line_spacing"] = 130,
},
--]]

Loading…
Cancel
Save