##// END OF EJS Templates
qt font family/size configurable
MinRK -
Show More
@@ -19,7 +19,7 b' from IPython.external.qt import QtCore, QtGui'
19 19 from IPython.config.configurable import Configurable
20 20 from IPython.frontend.qt.rich_text import HtmlExporter
21 21 from IPython.frontend.qt.util import MetaQObjectHasTraits, get_font
22 from IPython.utils.traitlets import Bool, Enum, Int
22 from IPython.utils.traitlets import Bool, Enum, Int, Unicode
23 23 from ansi_code_processor import QtAnsiCodeProcessor
24 24 from completion_widget import CompletionWidget
25 25 from kill_ring import QtKillRing
@@ -89,6 +89,28 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
89 89 'none' : The text is written directly to the console.
90 90 """)
91 91
92 font_family = Unicode(config=True,
93 help="""The font family to use for the console.
94 On OSX this defaults to Monaco, on Windows the default is
95 Consolas with fallback of Courier, and on other platforms
96 the default is Inconsolata with fallback of Monospace
97 """)
98 def _font_family_default(self):
99 if sys.platform == 'win32':
100 # Consolas ships with Vista/Win7, fallback to Courier if needed
101 return 'Consolas'
102 elif sys.platform == 'darwin':
103 # OSX always has Monaco, no need for a fallback
104 return 'Monaco'
105 else:
106 # A popular free mono font, will fallback to Monospace
107 return 'Anonymous Pro'
108
109 font_size = Int(config=True,
110 help="""The font size. If unconfigured, Qt will be entrusted
111 with the size of the font.
112 """)
113
92 114 # Whether to override ShortcutEvents for the keybindings defined by this
93 115 # widget (Ctrl+n, Ctrl+a, etc). Enable this if you want this widget to take
94 116 # priority (when it has focus) over, e.g., window-level menu shortcuts.
@@ -597,15 +619,18 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
597 619 """
598 620 if sys.platform == 'win32':
599 621 # Consolas ships with Vista/Win7, fallback to Courier if needed
600 family, fallback = 'Consolas', 'Courier'
622 fallback = 'Courier'
601 623 elif sys.platform == 'darwin':
602 # OSX always has Monaco, no need for a fallback
603 family, fallback = 'Monaco', None
624 # OSX always has Monaco
625 fallback = 'Monaco'
604 626 else:
605 627 # FIXME: remove Consolas as a default on Linux once our font
606 628 # selections are configurable by the user.
607 family, fallback = 'Consolas', 'Monospace'
608 font = get_font(family, fallback)
629 fallback = 'Monospace'
630 font = get_font(self.font_family, fallback)
631 if self.font_size:
632 font.setPointSize(self.font_size)
633 else:
609 634 font.setPointSize(QtGui.qApp.font().pointSize())
610 635 font.setStyleHint(QtGui.QFont.TypeWriter)
611 636 self._set_font(font)
General Comments 0
You need to be logged in to leave comments. Login now