diff --git a/src/calibre/gui2/viewer/web_view.py b/src/calibre/gui2/viewer/web_view.py index 08ed380b26..0237119beb 100644 --- a/src/calibre/gui2/viewer/web_view.py +++ b/src/calibre/gui2/viewer/web_view.py @@ -549,12 +549,6 @@ class WebView(RestartingWebEngineView): if ans is not None and not sip.isdeleted(ans): return ans - def change_zoom_by(self, steps=1): - # TODO: Add UI for this - ss = vprefs['session_data'].get('zoom_step_size') or 20 - amt = (ss / 100) * steps - self._page.setZoomFactor(max(0.25, min(self._page.zoomFactor() + amt, 5))) - def render_process_died(self): if self.dead_renderer_error_shown: return diff --git a/src/pyj/read_book/prefs/font_size.pyj b/src/pyj/read_book/prefs/font_size.pyj index 5970979aa7..fdd7c50234 100644 --- a/src/pyj/read_book/prefs/font_size.pyj +++ b/src/pyj/read_book/prefs/font_size.pyj @@ -37,9 +37,10 @@ def set_custom_size(ev): sz = int(element(CONTAINER, 'input').value) change_font_size(sz) -def change_font_size_by(amt): +def change_font_size_by(frac): sd = get_session_data() sz = sd.get('base_font_size') + amt = sz * frac nsz = sz + amt nsz = max(8, min(nsz, 80)) change_font_size(nsz) diff --git a/src/pyj/read_book/prefs/fonts.pyj b/src/pyj/read_book/prefs/fonts.pyj index 91b8d1efc0..31e3446ffe 100644 --- a/src/pyj/read_book/prefs/fonts.pyj +++ b/src/pyj/read_book/prefs/fonts.pyj @@ -16,6 +16,11 @@ DEFAULT_MINIMUM_FONT_SIZE = 8 DEFAULT_ZOOM_STEP_SIZE = 20 +def current_zoom_step_size(): + s = get_session_data().get('standalone_font_settings') + return s.zoom_step_size or DEFAULT_ZOOM_STEP_SIZE + + def font_select(name, settings): ans = E.select(name=name) ans.appendChild(E.option(_('— Choose a font —'), value='')) diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj index 334987fd33..dc69a3b62c 100644 --- a/src/pyj/read_book/view.pyj +++ b/src/pyj/read_book/view.pyj @@ -13,7 +13,9 @@ from dom import add_extra_css, build_rule, clear, set_css, svgicon, unique_id from iframe_comm import IframeWrapper from modals import error_dialog, warning_dialog from read_book.content_popup import ContentPopupOverlay -from read_book.create_annotation import AnnotationsManager, CreateAnnotation, ViewAnnotation +from read_book.create_annotation import ( + AnnotationsManager, CreateAnnotation, ViewAnnotation +) from read_book.globals import ( current_book, runtime, set_current_spine_item, ui_operations ) @@ -22,6 +24,7 @@ from read_book.open_book import add_book_to_recently_viewed from read_book.overlay import Overlay from read_book.prefs.colors import resolve_color_scheme from read_book.prefs.font_size import change_font_size_by +from read_book.prefs.fonts import current_zoom_step_size from read_book.prefs.head_foot import render_head_foot from read_book.prefs.scrolling import ( MIN_SCROLL_SPEED_AUTO as SCROLL_SPEED_STEP, change_scroll_speed @@ -570,8 +573,11 @@ class View: ) def bump_font_size(self, data): - delta = 2 if data.increase else -2 - change_font_size_by(delta) + mult = 1 if data.increase else -1 + frac = 0.2 + if runtime.is_standalone_viewer: + frac = current_zoom_step_size() / 100 + change_font_size_by(mult * frac) def on_show_footnote(self, data): self.show_content_popup()