MCPcopy Index your code
hub / github.com/python/cpython / GetFont

Method GetFont

Lib/idlelib/config.py:731–755  ·  view source on GitHub ↗

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.

(self, root, configType, section)

Source from the content-addressed store, hash-verified

729 return allHelpSources
730
731 def GetFont(self, root, configType, section):
732 """Retrieve a font from configuration (font, font-size, font-bold)
733 Intercept the special value 'TkFixedFont' and substitute
734 the actual font, factoring in some tweaks if needed for
735 appearance sakes.
736
737 The 'root' parameter can normally be any valid Tkinter widget.
738
739 Return a tuple (family, size, weight) suitable for passing
740 to tkinter.Font
741 """
742 family = self.GetOption(configType, section, 'font', default='courier')
743 size = self.GetOption(configType, section, 'font-size', type='int',
744 default='10')
745 bold = self.GetOption(configType, section, 'font-bold', default=0,
746 type='bool')
747 if (family == 'TkFixedFont'):
748 f = Font(name='TkFixedFont', exists=True, root=root)
749 actualFont = Font.actual(f)
750 family = actualFont['family']
751 size = actualFont['size']
752 if size <= 0:
753 size = 10 # if font in pixels, ignore actual size
754 bold = actualFont['weight'] == 'bold'
755 return (family, size, 'bold' if bold else 'normal')
756
757 def LoadCfgFiles(self):
758 "Load all configuration files."

Callers 9

update_fontMethod · 0.80
load_font_cfgMethod · 0.80
update_fontMethod · 0.80
update_fontMethod · 0.80
__init__Method · 0.80
ResetFontMethod · 0.80
test_font_setMethod · 0.80
test_get_fontMethod · 0.80

Calls 3

GetOptionMethod · 0.95
FontClass · 0.90
actualMethod · 0.80

Tested by 2

test_font_setMethod · 0.64
test_get_fontMethod · 0.64