mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More robust line_height computation and settings init
This commit is contained in:
parent
1ecf881cb4
commit
b70ec30869
@ -12,7 +12,13 @@ from utils import document_height, viewport_to_document
|
|||||||
|
|
||||||
|
|
||||||
def line_height():
|
def line_height():
|
||||||
return parseFloat(line_height.doc_style.lineHeight)
|
try:
|
||||||
|
# will fail if line-height = "normal"
|
||||||
|
lh = parseFloat(line_height.doc_style.lineHeight)
|
||||||
|
except:
|
||||||
|
lh = 1.2 * parseFloat(line_height.doc_style.fontSize)
|
||||||
|
|
||||||
|
return lh
|
||||||
|
|
||||||
def flow_to_scroll_fraction(frac, on_initial_load):
|
def flow_to_scroll_fraction(frac, on_initial_load):
|
||||||
scroll_viewport.scroll_to(0, document_height() * frac)
|
scroll_viewport.scroll_to(0, document_height() * frac)
|
||||||
|
@ -9,7 +9,7 @@ from session import defaults
|
|||||||
opts = {}
|
opts = {}
|
||||||
|
|
||||||
def update_settings(settings):
|
def update_settings(settings):
|
||||||
settings = settings or defaults
|
settings = Object.assign({}, defaults, settings)
|
||||||
opts.base_font_size = max(8, min(settings.base_font_size, 64))
|
opts.base_font_size = max(8, min(settings.base_font_size, 64))
|
||||||
opts.bg_image_fade = settings.bg_image_fade or 'transparent'
|
opts.bg_image_fade = settings.bg_image_fade or 'transparent'
|
||||||
opts.color_scheme = settings.color_scheme
|
opts.color_scheme = settings.color_scheme
|
||||||
|
Loading…
x
Reference in New Issue
Block a user