diff --git a/src/pyj/read_book/iframe.pyj b/src/pyj/read_book/iframe.pyj index f72ca5dd63..08c60aa7c3 100644 --- a/src/pyj/read_book/iframe.pyj +++ b/src/pyj/read_book/iframe.pyj @@ -120,6 +120,8 @@ class IframeBoss: def handle_gesture(self, gesture): if gesture.type is 'show-chrome': self.send_message('show_chrome') + elif gesture.type is 'pinch': + self.send_message('bump_font_size', increase=gesture.direction is 'out') else: self._handle_gesture(gesture) diff --git a/src/pyj/read_book/prefs/font_size.pyj b/src/pyj/read_book/prefs/font_size.pyj index e1277cc938..c6a0b423c3 100644 --- a/src/pyj/read_book/prefs/font_size.pyj +++ b/src/pyj/read_book/prefs/font_size.pyj @@ -34,6 +34,13 @@ def set_custom_size(ev): sz = int(element(CONTAINER, 'input').value) change_font_size(sz) +def change_font_size_by(amt): + sd = get_session_data() + sz = sd.get('base_font_size') + nsz = sz + amt + nsz = max(8, min(nsz, 40)) + change_font_size(nsz) + def show_custom_size(ev): c = element(CONTAINER) for child in c.childNodes: diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj index db7d21ad9e..981fe09c20 100644 --- a/src/pyj/read_book/view.pyj +++ b/src/pyj/read_book/view.pyj @@ -10,6 +10,7 @@ from read_book.globals import messenger, iframe_id from read_book.resources import load_resources 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.touch import set_left_margin_handler, set_right_margin_handler from book_list.theme import get_color from utils import parse_url_params, username_key @@ -83,6 +84,7 @@ class View: 'update_cfi': self.on_update_cfi, 'content_loaded': self.on_content_loaded, 'show_chrome': self.show_chrome, + 'bump_font_size': self.bump_font_size, } self.currently_showing = {} @@ -108,6 +110,10 @@ class View: def forward_gesture(self, gesture): self.send_message('gesture_from_margin', gesture=gesture) + def bump_font_size(self, data): + delta = 2 if data.increase else -2 + change_font_size_by(delta) + def show_chrome(self): self.overlay.show()