From 9376dc72da4a4871a9d86662fd8d8810d77382fa Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Wed, 30 Aug 2017 03:14:43 -0700 Subject: [PATCH] text zoom: Put a limit on the min and max zoom (#137) Text zoom: Put a limit on the min and max zoom --- plugins/textsize/textsize/documenthelper.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugins/textsize/textsize/documenthelper.py b/plugins/textsize/textsize/documenthelper.py index 0fb580d..bd355fb 100644 --- a/plugins/textsize/textsize/documenthelper.py +++ b/plugins/textsize/textsize/documenthelper.py @@ -24,6 +24,9 @@ from .signals import Signals from gi.repository import Gtk, Gdk, Pango +MAX_FONT_SIZE = 30 +MIN_FONT_SIZE = 5 + class DocumentHelper(Signals): def __init__(self, view): Signals.__init__(self) @@ -94,6 +97,11 @@ class DocumentHelper(Signals): size = description.get_size() / Pango.SCALE if not bounds: + if size >= MAX_FONT_SIZE and amount == 1: + return; + if size <= MIN_FONT_SIZE and amount == -1: + return; + description.set_size(max(1, (size + amount)) * Pango.SCALE) self._view.override_font(description) @@ -117,6 +125,11 @@ class DocumentHelper(Signals): newsize = round(newsize / len(tags)) + if newsize >= MAX_FONT_SIZE and amount == 1: + return; + if newsize <= MIN_FONT_SIZE and amount == -1: + return; + newsize = int(max(1, newsize)) if not newsize in self._font_tags: