mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make base font size a setting
This commit is contained in:
parent
e3300f3123
commit
4d8786e4e9
@ -4,7 +4,6 @@ from __python__ import bound_methods, hash_literals
|
||||
|
||||
import traceback
|
||||
from aes import GCM
|
||||
from elementmaker import E
|
||||
from gettext import install, gettext as _
|
||||
from read_book.cfi import at_current, scroll_to as scroll_to_cfi
|
||||
from read_book.globals import set_boss, set_current_spine_item, current_layout_mode, current_spine_item, set_layout_mode
|
||||
@ -45,6 +44,7 @@ class IframeBoss:
|
||||
'display': self.display,
|
||||
'scroll_to_anchor': self.on_scroll_to_anchor,
|
||||
'next_screen': self.on_next_screen,
|
||||
'change_font_size': self.change_font_size,
|
||||
}
|
||||
self.last_window_ypos = 0
|
||||
|
||||
@ -135,11 +135,26 @@ class IframeBoss:
|
||||
else:
|
||||
paged_scroll_by_page(backwards, True)
|
||||
|
||||
def apply_font_size(self):
|
||||
document.documentElement.style.fontSize = document.body.style.fontSize = '{}px'.format(opts.base_font_size)
|
||||
|
||||
def apply_colors(self):
|
||||
for elem in (document.documentElement, document.body):
|
||||
elem.style.color = opts.color_scheme.foreground
|
||||
elem.style.backgroundColor = opts.color_scheme.background
|
||||
|
||||
def change_font_size(self, data):
|
||||
if data.base_font_size? and data.base_font_size != opts.base_font_size:
|
||||
opts.base_font_size = data.base_font_size
|
||||
self.apply_font_size()
|
||||
|
||||
def content_loaded(self):
|
||||
document.documentElement.style.overflow = 'hidden'
|
||||
document.body.appendChild(
|
||||
E.style(str.format('html, body {{ color: {} !important; background-color: {} !important }}', opts.color_scheme.foreground, opts.color_scheme.background))
|
||||
)
|
||||
# document.body.appendChild(
|
||||
# E.style() # TODO: User style sheet
|
||||
# )
|
||||
self.apply_colors()
|
||||
self.apply_font_size()
|
||||
self.do_layout()
|
||||
if self.mathjax:
|
||||
return apply_mathjax(self.mathjax, self.book.manifest.link_uid, self.content_loaded_stage2)
|
||||
|
@ -10,5 +10,6 @@ def apply_settings(settings):
|
||||
opts.margin_left = max(0, settings.margin_left or 0)
|
||||
opts.margin_right = max(0, settings.margin_right or 0)
|
||||
opts.color_scheme = settings.color_scheme
|
||||
opts.base_font_size = max(8, min(settings.base_font_size or 16, 64))
|
||||
|
||||
apply_settings()
|
||||
|
@ -248,6 +248,7 @@ class View:
|
||||
'read_mode': sd.get('read_mode'),
|
||||
'columns_per_screen': sd.get('columns_per_screen'),
|
||||
'color_scheme': self.get_color_scheme(True),
|
||||
'base_font_size': sd.get('base_font_size'),
|
||||
}
|
||||
initial_position = initial_position or {'replace_history':False}
|
||||
self.currently_showing = {'name':name, 'settings':settings, 'initial_position':initial_position, 'loading':True}
|
||||
@ -320,3 +321,6 @@ class View:
|
||||
def on_content_loaded(self):
|
||||
self.hide_loading()
|
||||
# self.overlay.show()
|
||||
|
||||
def update_font_size(self):
|
||||
self.send_message('change_font_size', base_font_size=get_session_data().get('base_font_size'))
|
||||
|
@ -28,6 +28,7 @@ defaults = {
|
||||
'columns_per_screen': {'portrait':0, 'landscape':0},
|
||||
'current_color_scheme': 'white',
|
||||
'user_color_schemes': {},
|
||||
'base_font_size': 16,
|
||||
}
|
||||
|
||||
is_local_setting = {
|
||||
@ -40,6 +41,7 @@ is_local_setting = {
|
||||
'max_text_width': True,
|
||||
'columns_per_screen': True,
|
||||
'current_color_scheme': True,
|
||||
'base_font_size': True,
|
||||
}
|
||||
|
||||
def storage_available(which):
|
||||
|
Loading…
x
Reference in New Issue
Block a user