mirror of https://github.com/koreader/koreader
add: status bar in reading menu & font.lua
* Since fontchooser is replaced by selectmenu, it is no longer needed. So I rewrite it into font.lua module which can cache faces that shared among all UIs. * add progressBar method in graphics.lua to draw reading progress. * add reading progress information in reading menu. It is just a demo. Should be clean up in next release when the real reading menu is out. :)pull/2/merge
parent
d3c9062c7c
commit
f95231d789
@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
Font = {
|
||||||
|
-- default font for menu contents
|
||||||
|
cfont = "sans",
|
||||||
|
-- default font for title
|
||||||
|
tfont = "Helvetica-BoldOblique",
|
||||||
|
-- default font for footer
|
||||||
|
ffont = "sans",
|
||||||
|
|
||||||
|
-- built in fonts
|
||||||
|
fonts = {"sans", "cjk", "mono",
|
||||||
|
"Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique",
|
||||||
|
"Helvetica", "Helvetica-Oblique", "Helvetica-BoldOblique",
|
||||||
|
"Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic",},
|
||||||
|
|
||||||
|
-- face table
|
||||||
|
faces = {},
|
||||||
|
}
|
||||||
|
|
||||||
|
function Font:getFaceAndHash(size, font)
|
||||||
|
if not font then
|
||||||
|
-- default to content font
|
||||||
|
font = self.cfont
|
||||||
|
end
|
||||||
|
|
||||||
|
local face = self.faces[font..size]
|
||||||
|
-- build face if not found
|
||||||
|
if not face then
|
||||||
|
for _k,_v in ipairs(self.fonts) do
|
||||||
|
if font == _v then
|
||||||
|
face = freetype.newBuiltinFace(font, size)
|
||||||
|
self.faces[font..size] = face
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not face then
|
||||||
|
print("#! Font "..font.." not supported!!")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return face, font..size
|
||||||
|
end
|
||||||
|
|
||||||
|
function Font:update()
|
||||||
|
self.faces = {}
|
||||||
|
clearglyphcache()
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue