mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
configurable default font for CREngine
when in CREngine mode, the current font can be made the default document font by pressing Shift-F in order to store this setting, the reader_settings variable was promoted to the declared global G_reader_settings close #184
This commit is contained in:
@@ -9,6 +9,7 @@ CREReader = UniReader:new{
|
||||
|
||||
gamma_index = 15,
|
||||
font_face = nil,
|
||||
default_font = "Droid Sans",
|
||||
font_zoom = 0,
|
||||
|
||||
line_space_percent = 100,
|
||||
@@ -31,6 +32,11 @@ function CREReader:init()
|
||||
debug(err)
|
||||
end
|
||||
end
|
||||
|
||||
local default_font = G_reader_settings:readSetting("cre_font")
|
||||
if default_font then
|
||||
self.default_font = default_font
|
||||
end
|
||||
end
|
||||
-- NuPogodi, 20.05.12: inspect the zipfile content
|
||||
function CREReader:ZipContentExt(fname)
|
||||
@@ -79,7 +85,10 @@ end
|
||||
----------------------------------------------------
|
||||
function CREReader:loadSpecialSettings()
|
||||
local font_face = self.settings:readSetting("font_face")
|
||||
self.font_face = font_face or "Droid Sans"
|
||||
if not font_face then
|
||||
font_face = self.default_font
|
||||
end
|
||||
self.font_face = font_face
|
||||
self.doc:setFontFace(self.font_face)
|
||||
|
||||
local gamma_index = self.settings:readSetting("gamma_index")
|
||||
@@ -456,6 +465,13 @@ function CREReader:adjustCreReaderCommands()
|
||||
self:fillToc()
|
||||
end
|
||||
)
|
||||
self.commands:add(KEY_F, MOD_SHIFT, "F",
|
||||
"use document font as default font",
|
||||
function(self)
|
||||
G_reader_settings:saveSetting("cre_font", self.font_face)
|
||||
showInfoMsgWithDelay("Default document font set", 2000, 1)
|
||||
end
|
||||
)
|
||||
self.commands:add(KEY_F, MOD_ALT, "F",
|
||||
"Toggle font bolder attribute",
|
||||
function(self)
|
||||
|
||||
14
reader.lua
14
reader.lua
@@ -51,7 +51,7 @@ function openFile(filename)
|
||||
reader:loadSettings(filename)
|
||||
page_num = reader:getLastPageOrPos()
|
||||
reader:goto(tonumber(page_num), true)
|
||||
reader_settings:saveSetting("lastfile", filename)
|
||||
G_reader_settings:saveSetting("lastfile", filename)
|
||||
return reader:inputLoop()
|
||||
else
|
||||
InfoMessage:show("Error opening document.", 0)
|
||||
@@ -120,21 +120,21 @@ Screen:updateRotationMode()
|
||||
Screen.native_rotation_mode = Screen.cur_rotation_mode
|
||||
|
||||
-- set up reader's setting: font
|
||||
reader_settings = DocSettings:open(".reader")
|
||||
fontmap = reader_settings:readSetting("fontmap")
|
||||
G_reader_settings = DocSettings:open(".reader")
|
||||
fontmap = G_reader_settings:readSetting("fontmap")
|
||||
if fontmap ~= nil then
|
||||
Font.fontmap = fontmap
|
||||
end
|
||||
|
||||
-- initialize global settings shared among all readers
|
||||
UniReader:initGlobalSettings(reader_settings)
|
||||
UniReader:initGlobalSettings(G_reader_settings)
|
||||
-- initialize specific readers
|
||||
PDFReader:init()
|
||||
DJVUReader:init()
|
||||
CREReader:init()
|
||||
|
||||
-- display directory or open file
|
||||
local patharg = reader_settings:readSetting("lastfile")
|
||||
local patharg = G_reader_settings:readSetting("lastfile")
|
||||
if ARGV[optind] and lfs.attributes(ARGV[optind], "mode") == "directory" then
|
||||
local running = true
|
||||
FileChooser:setPath(ARGV[optind])
|
||||
@@ -161,8 +161,8 @@ end
|
||||
|
||||
|
||||
-- save reader settings
|
||||
reader_settings:saveSetting("fontmap", Font.fontmap)
|
||||
reader_settings:close()
|
||||
G_reader_settings:saveSetting("fontmap", Font.fontmap)
|
||||
G_reader_settings:close()
|
||||
|
||||
-- @TODO dirty workaround, find a way to force native system poll
|
||||
-- screen orientation and upside down mode 09.03 2012
|
||||
|
||||
Reference in New Issue
Block a user