def _font_initialise(root
, size
=None, fontScheme
= None):
if fontScheme
in ('pmw1', 'pmw2'):
defaultFont
= logicalfont('Helvetica')
menuFont
= logicalfont('Helvetica', weight
='bold', slant
='italic')
scaleFont
= logicalfont('Helvetica', slant
='italic')
root
.option_add('*Font', defaultFont
, 'userDefault')
root
.option_add('*Menu*Font', menuFont
, 'userDefault')
root
.option_add('*Menubutton*Font', menuFont
, 'userDefault')
root
.option_add('*Scale.*Font', scaleFont
, 'userDefault')
balloonFont
= logicalfont('Helvetica', -6, pixel
= '12')
else: # fontScheme == 'pmw2'
balloonFont
= logicalfont('Helvetica', -2)
root
.option_add('*Balloon.*Font', balloonFont
, 'userDefault')
defaultFont
= logicalfont('Helvetica')
root
.option_add('*Font', defaultFont
, 'userDefault')
elif fontScheme
== 'default':
defaultFont
= ('Helvetica', '-%d' % (_fontSize
,), 'bold')
entryFont
= ('Helvetica', '-%d' % (_fontSize
,))
textFont
= ('Courier', '-%d' % (_fontSize
,))
root
.option_add('*Font', defaultFont
, 'userDefault')
root
.option_add('*Entry*Font', entryFont
, 'userDefault')
root
.option_add('*Text*Font', textFont
, 'userDefault')
def logicalfont(name
='Helvetica', sizeIncr
= 0, **kw
):
if not _fontInfo
.has_key(name
):
raise ValueError, 'font %s does not exist' % name
for field
in _fontFields
:
elif _fontInfo
[name
].has_key(field
):
logicalValue
= _fontInfo
[name
][field
]
if _propertyAliases
[name
].has_key((field
, logicalValue
)):
realValue
= _propertyAliases
[name
][(field
, logicalValue
)]
elif _propertyAliases
[name
].has_key((field
, None)):
realValue
= _propertyAliases
[name
][(field
, None)]
elif _propertyAliases
[None].has_key((field
, logicalValue
)):
realValue
= _propertyAliases
[None][(field
, logicalValue
)]
elif _propertyAliases
[None].has_key((field
, None)):
realValue
= _propertyAliases
[None][(field
, None)]
realValue
= str((realValue
+ sizeIncr
) * 10)
return string
.join(rtn
, '-')
'registry', 'foundry', 'family', 'weight', 'slant', 'width', 'style',
'pixel', 'size', 'xres', 'yres', 'spacing', 'avgwidth', 'charset', 'encoding')
# <_propertyAliases> defines other names for which property values may
# be known by. This is required because italics in adobe-helvetica
# are specified by 'o', while other fonts use 'i'.
_propertyAliases
[None] = {
('slant', 'italic') : 'i',
('slant', 'normal') : 'r',
('weight', 'light') : 'normal',
('width', 'wide') : 'normal',
('width', 'condensed') : 'normal',
# <_fontInfo> describes a 'logical' font, giving the default values of
# some of its properties.
_fontInfo
['Helvetica'] = {
_propertyAliases
['Helvetica'] = {
('slant', 'italic') : 'o',
('weight', 'normal') : 'medium',
('weight', 'light') : 'medium',
_propertyAliases
['Times'] = {
('weight', 'normal') : 'medium',
('weight', 'light') : 'medium',
_propertyAliases
['Fixed'] = {
('weight', 'normal') : 'medium',
('weight', 'light') : 'medium',
('width', 'condensed') : 'semicondensed',
_propertyAliases
['Courier'] = {
('weight', 'normal') : 'medium',
('weight', 'light') : 'medium',
_fontInfo
['Typewriter'] = {
'family' : 'lucidatypewriter',
_propertyAliases
['Typewriter'] = {
('weight', 'normal') : 'medium',
('weight', 'light') : 'medium',
# For some reason 'fixed' fonts on NT aren't.
_fontInfo
['Fixed'] = _fontInfo
['Courier']
_propertyAliases
['Fixed'] = _propertyAliases
['Courier']