Merge pull request #1400 from chrox/fix_eink_optimization

Fix eink optimization and add custom font directory
pull/1402/head
Qingping Hou 9 years ago
commit a05001943d

1
.gitignore vendored

@ -33,4 +33,5 @@ koreader-arm-linux-gnueabihf
koreader-i686-w64-mingw32
koreader-x86_64-linux-gnu
koreader-x86_64-pc-linux-gnu
koreader-arm-obreey-linux-gnueabi

@ -25,6 +25,7 @@ local Device = {
-- (these are functions!)
isKindle = no,
isKobo = no,
isPocketBook = no,
isAndroid = no,
isEmulator = no,

@ -58,8 +58,8 @@ function CreDocument:engineInit()
-- we need to initialize the CRE font list
local fonts = Font:getFontList()
for _k, _v in ipairs(fonts) do
if _v:sub(1, 4) ~= "urw/" then
local ok, err = pcall(cre.registerFont, Font.fontdir..'/'.._v)
if not _v:find("/urw/") then
local ok, err = pcall(cre.registerFont, _v)
if not ok then
DEBUG(err)
end

@ -1,9 +1,6 @@
local _ = require("gettext")
local Screen = require("device").screen
local eink = G_reader_settings:readSetting("eink")
Screen.eink = (eink == nil) and true or eink
return {
text = _("E-ink optimization"),
checked_func = function() return Screen.eink end,

@ -41,7 +41,7 @@ local Font = {
[4] = "freefont/FreeSans.ttf",
},
fontdir = os.getenv("FONTDIR") or "./fonts",
fontdir = "./fonts",
-- face table
faces = {},
@ -77,23 +77,27 @@ function Font:getFace(font, size)
return { size = size, orig_size = orig_size, ftface = face, hash = font..size }
end
function Font:_readList(target, dir, effective_dir)
function Font:_readList(target, dir)
for f in lfs.dir(dir) do
if lfs.attributes(dir.."/"..f, "mode") == "directory" and f ~= "." and f ~= ".." then
self:_readList(target, dir.."/"..f, effective_dir..f.."/")
self:_readList(target, dir.."/"..f)
else
local file_type = string.lower(string.match(f, ".+%.([^.]+)") or "")
if file_type == "ttf" or file_type == "ttc"
or file_type == "cff" or file_type == "otf" then
table.insert(target, effective_dir..f)
table.insert(target, dir.."/"..f)
end
end
end
end
function Font:getFontList()
fontlist = {}
self:_readList(fontlist, self.fontdir, "")
local fontlist = {}
self:_readList(fontlist, self.fontdir)
-- multiple path should be joined with semicolon in FONTDIR env variable
for dir in string.gmatch(os.getenv("FONTDIR") or "", "([^;]+)") do
self:_readList(fontlist, dir)
end
table.sort(fontlist)
return fontlist
end

@ -1,2 +1,8 @@
-- compatibility wrapper
return require("device").screen
local Screen = require("device").screen
-- set eink flag for this screen
local is_eink = G_reader_settings:readSetting("eink")
Screen.eink = (is_eink == nil) and true or is_eink
return Screen

@ -115,6 +115,9 @@ export TESSDATA_PREFIX="data"
# export dict directory
export STARDICT_DATA_DIR="data/dict"
# export font directory
export FONTDIR="/mnt/us/fonts"
logmsg "Setting up IPTables rules . . ."
# accept input ports for zsync plugin
iptables -A INPUT -i wlan0 -p udp --dport 5670 -j ACCEPT

@ -21,6 +21,9 @@ export TESSDATA_PREFIX="data"
# export dict directory
export STARDICT_DATA_DIR="data/dict"
# export font directory
export FONTDIR="/mnt/onboard/fonts"
# fast and dirty way of check if we are called from nickel
# through fmon, or from another launcher (KSM or advboot)
from_nickel=`pidof nickel | wc -c`

@ -21,6 +21,9 @@ export TESSDATA_PREFIX="data"
# export dict directory
export STARDICT_DATA_DIR="data/dict"
# export font directory
export FONTDIR="/mnt/ext1/fonts"
if [ `echo $@ | wc -c` -eq 1 ]; then
args="/mnt/ext1/"
else

Loading…
Cancel
Save