@@ -505,7 +505,7 @@ def createFontDict(fontfiles, fontext='ttf'):
505
505
for fpath in fontfiles :
506
506
verbose .report ('createFontDict: %s' % (fpath ), 'debug' )
507
507
fname = os .path .split (fpath )[1 ]
508
- if seen . has_key ( fname ) : continue
508
+ if fname in seen : continue
509
509
else : seen [fname ] = 1
510
510
if fontext == 'afm' :
511
511
try :
@@ -552,33 +552,33 @@ def setWeights(font):
552
552
for j in range (100 , 1000 , 100 ):
553
553
font [j ] = temp [wgt ]
554
554
555
- if temp . has_key ( 400 ) :
555
+ if 400 in temp :
556
556
for j in range (100 , 1000 , 100 ):
557
557
font [j ] = temp [400 ]
558
- if temp . has_key ( 500 ) :
559
- if temp . has_key ( 400 ) :
558
+ if 500 in temp :
559
+ if 400 in temp :
560
560
for j in range (500 , 1000 , 100 ):
561
561
font [j ] = temp [500 ]
562
562
else :
563
563
for j in range (100 , 1000 , 100 ):
564
564
font [j ] = temp [500 ]
565
565
566
- if temp . has_key ( 300 ) :
566
+ if 300 in temp :
567
567
for j in [100 , 200 , 300 ]:
568
568
font [j ] = temp [300 ]
569
- if temp . has_key ( 200 ) :
570
- if temp . has_key ( 300 ) :
569
+ if 200 in temp :
570
+ if 300 in temp :
571
571
for j in [100 , 200 ]:
572
572
font [j ] = temp [200 ]
573
573
else :
574
574
for j in [100 , 200 , 300 ]:
575
575
font [j ] = temp [200 ]
576
576
577
- if temp . has_key ( 800 ) :
577
+ if 800 in temp :
578
578
for j in [600 , 700 , 800 , 900 ]:
579
579
font [j ] = temp [800 ]
580
- if temp . has_key ( 700 ) :
581
- if temp . has_key ( 800 ) :
580
+ if 700 in temp :
581
+ if 800 in temp :
582
582
for j in [600 , 700 ]:
583
583
font [j ] = temp [700 ]
584
584
else :
@@ -872,7 +872,7 @@ def __init__(self, size=None, weight='normal'):
872
872
# Create list of font paths
873
873
874
874
for pathname in ['TTFPATH' , 'AFMPATH' ]:
875
- if os .environ . has_key ( pathname ) :
875
+ if pathname in os .environ :
876
876
ttfpath = os .environ [pathname ]
877
877
if ttfpath .find (';' ) >= 0 : #win32 style
878
878
paths .extend (ttfpath .split (';' ))
@@ -983,50 +983,50 @@ def lookup_name(name):
983
983
984
984
fname = None
985
985
font = fontdict
986
- if font . has_key ( name ) :
986
+ if name in font :
987
987
font = font [name ]
988
988
else :
989
989
verbose .report ('\t findfont failed %(name)s' % locals (), 'debug' )
990
990
return None
991
991
992
- if font . has_key ( style ) :
992
+ if style in font :
993
993
font = font [style ]
994
- elif style == 'italic' and font . has_key ( 'oblique' ) :
994
+ elif style == 'italic' and 'oblique' in font :
995
995
font = font ['oblique' ]
996
- elif style == 'oblique' and font . has_key ( 'italic' ) :
996
+ elif style == 'oblique' and 'italic' in font :
997
997
font = font ['italic' ]
998
998
else :
999
999
verbose .report ('\t findfont failed %(name)s, %(style)s' % locals (), 'debug' )
1000
1000
return None
1001
1001
1002
- if font . has_key ( variant ) :
1002
+ if variant in font :
1003
1003
font = font [variant ]
1004
1004
else :
1005
1005
verbose .report ('\t findfont failed %(name)s, %(style)s, %(variant)s' % locals (), 'debug' )
1006
1006
return None
1007
1007
1008
- if not font . has_key ( weight ) :
1008
+ if weight in font :
1009
1009
setWeights (font )
1010
- if not font . has_key ( weight ) :
1010
+ if weight not in font :
1011
1011
return None
1012
1012
font = font [weight ]
1013
1013
1014
- if font . has_key ( stretch ) :
1014
+ if stretch in font :
1015
1015
stretch_font = font [stretch ]
1016
- if stretch_font . has_key ( 'scalable' ) :
1016
+ if 'scalable' in stretch_font :
1017
1017
fname = stretch_font ['scalable' ]
1018
- elif stretch_font . has_key ( size ) :
1018
+ elif size in stretch_font :
1019
1019
fname = stretch_font [size ]
1020
1020
1021
1021
if fname is None :
1022
1022
for val in font .values ():
1023
- if val . has_key ( 'scalable' ) :
1023
+ if 'scalable' in val :
1024
1024
fname = val ['scalable' ]
1025
1025
break
1026
1026
1027
1027
if fname is None :
1028
1028
for val in font .values ():
1029
- if val . has_key ( size ) :
1029
+ if size in val :
1030
1030
fname = val [size ]
1031
1031
break
1032
1032
0 commit comments