CreDocument: disable fancy formatting by default

It does significantly more harm than good. It can be reenabled with a `txt_preformatted` setting if desired. Fixes #1607.
pull/2708/head
Frans de Jonge 7 years ago committed by Qingping Hou
parent 10132d1c59
commit e5a3ecd3e5

@ -50,6 +50,11 @@ function ReaderTypeset:onReadSettings(config)
self.floating_punctuation = config:readSetting("floating_punctuation") or
G_reader_settings:readSetting("floating_punctuation") or 1
self:toggleFloatingPunctuation(self.floating_punctuation)
-- default to disable txt formatting as it does more harm than good
self.txt_preformatted = config:readSetting("txt_preformatted") or
G_reader_settings:readSetting("txt_preformatted") or 1
self:toggleTxtPreFormatted(self.txt_preformatted)
end
function ReaderTypeset:onSaveSettings()
@ -140,6 +145,11 @@ function ReaderTypeset:toggleFloatingPunctuation(toggle)
self.ui:handleEvent(Event:new("UpdatePos"))
end
function ReaderTypeset:toggleTxtPreFormatted(toggle)
self.ui.document:setTxtPreFormatted(toggle)
self.ui:handleEvent(Event:new("UpdatePos"))
end
function ReaderTypeset:addToMainMenu(menu_items)
-- insert table to main reader menu
menu_items.set_render_style = {

@ -427,6 +427,13 @@ function CreDocument:setFloatingPunctuation(enabled)
self._document:setIntProperty("crengine.style.floating.punctuation.enabled", enabled)
end
function CreDocument:setTxtPreFormatted(enabled)
logger.dbg("CreDocument: set txt preformatted", enabled)
self._document:setIntProperty("crengine.file.txt.preformatted", enabled)
-- monospace is really kind of ugly for this...
self._document:setStringProperty("styles.pre.font-face", "font-family: \"" .. self.default_font .. "\"")
end
function CreDocument:getVisiblePageCount()
return self._document:getVisiblePageCount()
end
@ -458,8 +465,8 @@ function CreDocument:findText(pattern, origin, reverse, caseInsensitive)
end
function CreDocument:register(registry)
registry:addProvider("txt", "application/txt", self)
registry:addProvider("log", "application/txt", self)
registry:addProvider("txt", "text/plain", self)
registry:addProvider("log", "text/plain", self)
registry:addProvider("txt.zip", "application/zip", self)
registry:addProvider("log.zip", "application/zip", self)
registry:addProvider("epub", "application/epub", self)

Loading…
Cancel
Save