From 8d7ebaff5db98340d4aa198430976864b466b774 Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 6 Jun 2015 17:21:39 +0800 Subject: [PATCH] add external font dir option for Android --- base | 2 +- defaults.lua | 3 +++ frontend/ui/font.lua | 13 +++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/base b/base index cd68f482e..12ed26473 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit cd68f482e00f26402ea8116ef813df08162a39cb +Subproject commit 12ed264734bfad1b34620877cd2753e63436356c diff --git a/defaults.lua b/defaults.lua index 210cc6c1a..f608898ed 100644 --- a/defaults.lua +++ b/defaults.lua @@ -186,6 +186,9 @@ NETWORK_PROXY = nil -- Use turbo library to handle async HTTP request DUSE_TURBO_LIB = false +-- Custom font dir for Android +ANDROID_FONT_DIR = "/system/fonts;/sdcard/koreader/fonts" + -- #################################################################### -- following features are not supported right now -- #################################################################### diff --git a/frontend/ui/font.lua b/frontend/ui/font.lua index 90adbf9c7..5181018a6 100644 --- a/frontend/ui/font.lua +++ b/frontend/ui/font.lua @@ -1,6 +1,7 @@ local lfs = require("libs/libkoreader-lfs") local Freetype = require("ffi/freetype") local Screen = require("device").screen +local Device = require("device") local DEBUG = require("dbg") local Font = { @@ -94,11 +95,19 @@ function Font:_readList(target, dir) end end +function Font:_getExternalFontDir() + if Device:isAndroid() then + return ANDROID_FONT_DIR + else + return os.getenv("EXT_FONT_DIR") + end +end + function Font:getFontList() 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("EXT_FONT_DIR") or "", "([^;]+)") do + -- multiple paths should be joined with semicolon + for dir in string.gmatch(self:_getExternalFontDir() or "", "([^;]+)") do self:_readList(fontlist, dir) end table.sort(fontlist)