From bab0cc27d534bed26ceefdb55769c6e234b0d7a1 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 13 Jul 2010 13:50:33 +0100 Subject: [PATCH] Make font antialiasing configurable --- terminatorlib/config.py | 1 + terminatorlib/preferences.glade | 23 ++++++++++++++++++----- terminatorlib/prefseditor.py | 8 ++++++++ terminatorlib/terminal.py | 17 +++++++++++++---- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index fd3804bf..61d964b9 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -154,6 +154,7 @@ DEFAULTS = { 'profiles': { 'default': { 'allow_bold' : True, + 'antialias' : True, 'audible_bell' : False, 'visible_bell' : False, 'urgent_bell' : False, diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index 79db6fa9..0f554010 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -884,6 +884,19 @@ 2 + + + Anti-alias text + True + True + False + True + + + + 3 + + Show titlebar @@ -896,7 +909,7 @@ False False - 3 + 4 @@ -909,7 +922,7 @@ - 4 + 5 @@ -945,7 +958,7 @@ False - 5 + 6 @@ -1079,7 +1092,7 @@ False False - 6 + 7 @@ -1180,7 +1193,7 @@ False False - 7 + 8 diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index f7f67949..c8edabda 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -311,6 +311,9 @@ class PrefsEditor: # Allow bold text widget = guiget('allow_bold_checkbutton') widget.set_active(self.config['allow_bold']) + # Anti-alias + widget = guiget('antialias_checkbutton') + widget.set_active(self.config['antialias']) # Icon terminal bell widget = guiget('icon_bell_checkbutton') widget.set_active(self.config['icon_bell']) @@ -545,6 +548,11 @@ class PrefsEditor: self.config['allow_bold'] = widget.get_active() self.config.save() + def on_antialias_checkbutton_toggled(self, widget): + """Anti-alias setting changed""" + self.config['antialias'] = widget.get_active() + self.config.save() + def on_show_titlebar_toggled(self, widget): """Show titlebar setting changed""" self.config['show_titlebar'] = widget.get_active() diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 85313a81..43908c8a 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -585,7 +585,7 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) font = self.config.get_system_font() else: font = self.config['font'] - self.vte.set_font(pango.FontDescription(font)) + self.set_font(pango.FontDescription(font)) except: pass self.vte.set_allow_bold(self.config['allow_bold']) @@ -1071,7 +1071,7 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) return new_font.set_size(new_size) dbg('setting new font: %s' % new_font) - self.vte.set_font(new_font) + self.set_font(new_font) def is_zoomed(self): """Determine if we are a zoomed terminal""" @@ -1270,7 +1270,7 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) fontsize += pango.SCALE pangodesc.set_size(fontsize) - self.vte.set_font(pangodesc) + self.set_font(pangodesc) self.custom_font_size = fontsize def zoom_orig(self): @@ -1280,9 +1280,18 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) else: font = self.config['font'] dbg("Terminal::zoom_orig: restoring font to: %s" % font) - self.vte.set_font(pango.FontDescription(font)) + self.set_font(pango.FontDescription(font)) self.custom_font_size = None + def set_font(self, fontdesc): + """Set the font we want in VTE""" + antialias = self.config['antialias'] + if antialias: + antialias = vte.ANTI_ALIAS_FORCE_ENABLE + else: + antialias = vte.ANTI_ALIAS_FORCE_DISABLE + self.vte.set_font_full(fontdesc, antialias) + def get_cursor_position(self): """Return the co-ordinates of our cursor""" # FIXME: THIS METHOD IS DEPRECATED AND UNUSED