Show More
@@ -19,7 +19,7 b' from IPython.external.qt import QtCore, QtGui' | |||||
19 | from IPython.config.configurable import Configurable |
|
19 | from IPython.config.configurable import Configurable | |
20 | from IPython.frontend.qt.rich_text import HtmlExporter |
|
20 | from IPython.frontend.qt.rich_text import HtmlExporter | |
21 | from IPython.frontend.qt.util import MetaQObjectHasTraits, get_font |
|
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 | from ansi_code_processor import QtAnsiCodeProcessor |
|
23 | from ansi_code_processor import QtAnsiCodeProcessor | |
24 | from completion_widget import CompletionWidget |
|
24 | from completion_widget import CompletionWidget | |
25 | from kill_ring import QtKillRing |
|
25 | from kill_ring import QtKillRing | |
@@ -89,6 +89,28 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
89 | 'none' : The text is written directly to the console. |
|
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 | # Whether to override ShortcutEvents for the keybindings defined by this |
|
114 | # Whether to override ShortcutEvents for the keybindings defined by this | |
93 | # widget (Ctrl+n, Ctrl+a, etc). Enable this if you want this widget to take |
|
115 | # widget (Ctrl+n, Ctrl+a, etc). Enable this if you want this widget to take | |
94 | # priority (when it has focus) over, e.g., window-level menu shortcuts. |
|
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 | if sys.platform == 'win32': |
|
620 | if sys.platform == 'win32': | |
599 | # Consolas ships with Vista/Win7, fallback to Courier if needed |
|
621 | # Consolas ships with Vista/Win7, fallback to Courier if needed | |
600 |
|
|
622 | fallback = 'Courier' | |
601 | elif sys.platform == 'darwin': |
|
623 | elif sys.platform == 'darwin': | |
602 |
# OSX always has Monaco |
|
624 | # OSX always has Monaco | |
603 |
|
|
625 | fallback = 'Monaco' | |
604 | else: |
|
626 | else: | |
605 | # FIXME: remove Consolas as a default on Linux once our font |
|
627 | # FIXME: remove Consolas as a default on Linux once our font | |
606 | # selections are configurable by the user. |
|
628 | # selections are configurable by the user. | |
607 |
|
|
629 | fallback = 'Monospace' | |
608 | font = get_font(family, fallback) |
|
630 | font = get_font(self.font_family, fallback) | |
|
631 | if self.font_size: | |||
|
632 | font.setPointSize(self.font_size) | |||
|
633 | else: | |||
609 | font.setPointSize(QtGui.qApp.font().pointSize()) |
|
634 | font.setPointSize(QtGui.qApp.font().pointSize()) | |
610 | font.setStyleHint(QtGui.QFont.TypeWriter) |
|
635 | font.setStyleHint(QtGui.QFont.TypeWriter) | |
611 | self._set_font(font) |
|
636 | self._set_font(font) |
General Comments 0
You need to be logged in to leave comments.
Login now