Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b8677f3

Browse filesBrowse files
committed
Style fixes for font_manager.py.
1 parent b34c605 commit b8677f3
Copy full SHA for b8677f3

File tree

Expand file treeCollapse file tree

2 files changed

+49
-50
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+49
-50
lines changed

‎.flake8

Copy file name to clipboardExpand all lines: .flake8
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ per-file-ignores =
3333

3434
lib/matplotlib/_cm.py: E202, E203, E302
3535
lib/matplotlib/_mathtext_data.py: E203, E261
36-
lib/matplotlib/font_manager.py: E203, E221, E251, E501
36+
lib/matplotlib/font_manager.py: E221, E251, E501
3737
lib/matplotlib/mathtext.py: E221, E251
3838
lib/matplotlib/rcsetup.py: E501
3939
lib/matplotlib/tests/test_mathtext.py: E501

‎lib/matplotlib/font_manager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/font_manager.py
+48-49Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -44,58 +44,58 @@
4444
_log = logging.getLogger(__name__)
4545

4646
font_scalings = {
47-
'xx-small' : 0.579,
48-
'x-small' : 0.694,
49-
'small' : 0.833,
50-
'medium' : 1.0,
51-
'large' : 1.200,
52-
'x-large' : 1.440,
53-
'xx-large' : 1.728,
54-
'larger' : 1.2,
55-
'smaller' : 0.833,
56-
None : 1.0}
57-
47+
'xx-small': 0.579,
48+
'x-small': 0.694,
49+
'small': 0.833,
50+
'medium': 1.0,
51+
'large': 1.200,
52+
'x-large': 1.440,
53+
'xx-large': 1.728,
54+
'larger': 1.2,
55+
'smaller': 0.833,
56+
None: 1.0,
57+
}
5858
stretch_dict = {
59-
'ultra-condensed' : 100,
60-
'extra-condensed' : 200,
61-
'condensed' : 300,
62-
'semi-condensed' : 400,
63-
'normal' : 500,
64-
'semi-expanded' : 600,
65-
'semi-extended' : 600,
66-
'expanded' : 700,
67-
'extended' : 700,
68-
'extra-expanded' : 800,
69-
'extra-extended' : 800,
70-
'ultra-expanded' : 900,
71-
'ultra-extended' : 900}
72-
59+
'ultra-condensed': 100,
60+
'extra-condensed': 200,
61+
'condensed': 300,
62+
'semi-condensed': 400,
63+
'normal': 500,
64+
'semi-expanded': 600,
65+
'semi-extended': 600,
66+
'expanded': 700,
67+
'extended': 700,
68+
'extra-expanded': 800,
69+
'extra-extended': 800,
70+
'ultra-expanded': 900,
71+
'ultra-extended': 900,
72+
}
7373
weight_dict = {
74-
'ultralight' : 100,
75-
'light' : 200,
76-
'normal' : 400,
77-
'regular' : 400,
78-
'book' : 400,
79-
'medium' : 500,
80-
'roman' : 500,
81-
'semibold' : 600,
82-
'demibold' : 600,
83-
'demi' : 600,
84-
'bold' : 700,
85-
'heavy' : 800,
86-
'extra bold' : 800,
87-
'black' : 900}
88-
74+
'ultralight': 100,
75+
'light': 200,
76+
'normal': 400,
77+
'regular': 400,
78+
'book': 400,
79+
'medium': 500,
80+
'roman': 500,
81+
'semibold': 600,
82+
'demibold': 600,
83+
'demi': 600,
84+
'bold': 700,
85+
'heavy': 800,
86+
'extra bold': 800,
87+
'black': 900,
88+
}
8989
font_family_aliases = {
9090
'serif',
9191
'sans-serif',
9292
'sans serif',
9393
'cursive',
9494
'fantasy',
9595
'monospace',
96-
'sans'}
97-
98-
# OS Font paths
96+
'sans',
97+
}
98+
# OS Font paths
9999
MSFolders = \
100100
r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'
101101
MSFontDirectories = [
@@ -411,12 +411,11 @@ def ttfFontProperty(font):
411411
# Relative stretches are: wider, narrower
412412
# Child value is: inherit
413413

414-
if (sfnt4.find('narrow') >= 0 or sfnt4.find('condensed') >= 0 or
415-
sfnt4.find('cond') >= 0):
414+
if any(word in sfnt4 for word in ['narrow', 'condensed', 'cond']):
416415
stretch = 'condensed'
417-
elif sfnt4.find('demi cond') >= 0:
416+
elif 'demi cond' in sfnt4:
418417
stretch = 'semi-condensed'
419-
elif sfnt4.find('wide') >= 0 or sfnt4.find('expanded') >= 0 or sfnt4.find('extended') >= 0:
418+
elif any(word in sfnt4 for word in ['wide', 'expanded', 'extended']):
420419
stretch = 'expanded'
421420
else:
422421
stretch = 'normal'
@@ -482,9 +481,9 @@ def afmFontProperty(fontpath, font):
482481
# Child value is: inherit
483482
if 'demi cond' in fontname:
484483
stretch = 'semi-condensed'
485-
elif 'narrow' in fontname or 'cond' in fontname:
484+
elif any(word in fontname for word in ['narrow', 'cond']):
486485
stretch = 'condensed'
487-
elif 'wide' in fontname or 'expanded' in fontname or 'extended' in fontname:
486+
elif any(word in fontname for word in ['wide', 'expanded', 'extended']):
488487
stretch = 'expanded'
489488
else:
490489
stretch = 'normal'

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.