set menu font size according to screen dpi

pull/2/merge
chrox 11 years ago
parent ddfe5ca3a9
commit 25bcbfa53a

@ -99,7 +99,7 @@ KoptOptions = {
name_text = "Contrast",
name_align_right = 0.2,
item_text = {"lightest", "lighter", "default", "darker", "darkest"},
item_font_size = math.floor(18*Screen:getWidth()/600),
item_font_size = math.floor(18*Screen:getDPI()/167),
item_align_center = 0.8,
values = {2.0, 1.5, 1.0, 0.5, 0.2},
default_value = 1.0,

@ -1,7 +1,6 @@
require "cache"
require "ui/geometry"
require "ui/screen"
require "ui/device"
require "ui/reader/readerconfig"
require "document/koptinterface"
@ -11,7 +10,7 @@ PdfDocument = Document:new{
mupdf_cache_size = 5 * 1024 * 1024,
dc_null = DrawContext.new(),
screen_size = Screen:getSize(),
screen_dpi = Device:getModel() == "KindlePaperWhite" and 212 or 167,
screen_dpi = Screen:getDPI(),
options = KoptOptions,
configurable = Configurable,
koptinterface = KoptInterface,

@ -129,7 +129,7 @@ function ToggleSwitch:init()
self.position = nil
local label_font_face = "cfont"
local label_font_size = math.floor(20*Screen:getWidth()/600)
local label_font_size = math.floor(16*Screen:getDPI()/167)
self.toggle_frame = FrameContainer:new{background = 0, color = 7, radius = 7, bordersize = 1, padding = 2,}
self.toggle_content = HorizontalGroup:new{}
@ -260,18 +260,19 @@ end
ConfigOption = CenterContainer:new{}
function ConfigOption:init()
local default_name_font_size = math.floor(20*Screen:getWidth()/600)
local default_item_font_size = math.floor(20*Screen:getWidth()/600)
local default_items_spacing = math.floor(30*Screen:getWidth()/600)
local default_option_height = math.floor(50*Screen:getWidth()/600)
local default_option_padding = math.floor(30*Screen:getWidth()/600)
local mag_ratio = Screen:getDPI()/167
local default_name_font_size = math.floor(20*mag_ratio)
local default_item_font_size = math.floor(16*mag_ratio)
local default_items_spacing = math.floor(30*mag_ratio)
local default_option_height = math.floor(50*mag_ratio)
local default_option_padding = math.floor(30*mag_ratio)
local vertical_group = VerticalGroup:new{}
table.insert(vertical_group, VerticalSpan:new{ width = default_option_padding })
for c = 1, #self.options do
if self.options[c].show ~= false then
local name_align = self.options[c].name_align_right and self.options[c].name_align_right or 0.33
local item_align = self.options[c].item_align_center and self.options[c].item_align_center or 0.66
local name_font_face = self.options[c].name_font_face and self.options[c].name_font_face or "tfont"
local name_font_face = self.options[c].name_font_face and self.options[c].name_font_face or "cfont"
local name_font_size = self.options[c].name_font_size and self.options[c].name_font_size or default_name_font_size
local item_font_face = self.options[c].item_font_face and self.options[c].item_font_face or "cfont"
local item_font_size = self.options[c].item_font_size and self.options[c].item_font_size or default_item_font_size

@ -195,13 +195,13 @@ Widget that displays menu
--]]
Menu = FocusManager:new{
-- face for displaying item contents
cface = Font:getFace("cfont", 22),
cface = Font:getFace("cfont", math.floor(22*Screen:getDPI()/167)),
-- face for menu title
tface = Font:getFace("tfont", 25),
tface = Font:getFace("tfont", math.floor(25*Screen:getDPI()/167)),
-- face for paging info display
fface = Font:getFace("ffont", 16),
fface = Font:getFace("ffont", math.floor(16*Screen:getDPI()/167)),
-- font for item shortcut
sface = Font:getFace("scfont", 20),
sface = Font:getFace("scfont", math.floor(20*Screen:getDPI()/167)),
title = "No Title",
-- default width and height

@ -84,6 +84,10 @@ function Screen:getHeight()
return h
end
function Screen:getDPI()
return Device:getModel() == "KindlePaperWhite" and 212 or 167
end
function Screen:getPitch()
return self.fb:getPitch()
end

Loading…
Cancel
Save