text zoom: Put a limit on the min and max zoom (#137)
Text zoom: Put a limit on the min and max zoom
This commit is contained in:
committed by
Clement Lefebvre
parent
87eb14e9dc
commit
9376dc72da
@@ -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:
|
||||
|
Reference in New Issue
Block a user