diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2015-08-01 18:57:33 -0400 |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2015-08-01 18:57:33 -0400 |
commit | d87d16826ac55f260b706cb63d8ee0a7d3c6d893 (patch) | |
tree | cf6b3f446a0225d092116e897f68043a2f0f8e55 /Lib/idlelib/configHandler.py | |
parent | 231007fe142975ee5e468929af5ed69705e7547e (diff) | |
download | cpython-git-d87d16826ac55f260b706cb63d8ee0a7d3c6d893.tar.gz |
Issue 24745: Switch from Courier to platform-sensitive TkFixedFont as default
editor font. This should not affect current customized font selections.
Patch by Mark Roseman.
Diffstat (limited to 'Lib/idlelib/configHandler.py')
-rw-r--r-- | Lib/idlelib/configHandler.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py index b94b8f1808..db3bcbc438 100644 --- a/Lib/idlelib/configHandler.py +++ b/Lib/idlelib/configHandler.py @@ -22,6 +22,7 @@ import os import sys from configparser import ConfigParser +from tkinter.font import Font, nametofont class InvalidConfigType(Exception): pass class InvalidConfigSet(Exception): pass @@ -670,6 +671,32 @@ class IdleConf: self.GetExtraHelpSourceList('user') ) return allHelpSources + def GetFont(self, root, configType, section): + """Retrieve a font from configuration (font, font-size, font-bold) + Intercept the special value 'TkFixedFont' and substitute + the actual font, factoring in some tweaks if needed for + appearance sakes. + + The 'root' parameter can normally be any valid Tkinter widget. + + Return a tuple (family, size, weight) suitable for passing + to tkinter.Font + """ + family = self.GetOption(configType, section, 'font', default='courier') + size = self.GetOption(configType, section, 'font-size', type='int', + default='10') + bold = self.GetOption(configType, section, 'font-bold', default=0, + type='bool') + if (family == 'TkFixedFont'): + f = Font(name='TkFixedFont', exists=True, root=root) + actualFont = Font.actual(f) + family = actualFont['family'] + size = actualFont['size'] + if size < 0: + size = 10 # if font in pixels, ignore actual size + bold = actualFont['weight']=='bold' + return (family, size, 'bold' if bold else 'normal') + def LoadCfgFiles(self): "Load all configuration files." for key in self.defaultCfg: |