Skip to content

Style fixes for font_manager.py. #15069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ per-file-ignores =

lib/matplotlib/_cm.py: E202, E203, E302
lib/matplotlib/_mathtext_data.py: E203, E261
lib/matplotlib/font_manager.py: E203, E221, E251, E501
lib/matplotlib/font_manager.py: E221, E251, E501
lib/matplotlib/mathtext.py: E221, E251
lib/matplotlib/rcsetup.py: E501
lib/matplotlib/tests/test_mathtext.py: E501
Expand Down
97 changes: 48 additions & 49 deletions lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,58 +44,58 @@
_log = logging.getLogger(__name__)

font_scalings = {
'xx-small' : 0.579,
'x-small' : 0.694,
'small' : 0.833,
'medium' : 1.0,
'large' : 1.200,
'x-large' : 1.440,
'xx-large' : 1.728,
'larger' : 1.2,
'smaller' : 0.833,
None : 1.0}

'xx-small': 0.579,
'x-small': 0.694,
'small': 0.833,
'medium': 1.0,
'large': 1.200,
'x-large': 1.440,
'xx-large': 1.728,
'larger': 1.2,
'smaller': 0.833,
None: 1.0,
}
stretch_dict = {
'ultra-condensed' : 100,
'extra-condensed' : 200,
'condensed' : 300,
'semi-condensed' : 400,
'normal' : 500,
'semi-expanded' : 600,
'semi-extended' : 600,
'expanded' : 700,
'extended' : 700,
'extra-expanded' : 800,
'extra-extended' : 800,
'ultra-expanded' : 900,
'ultra-extended' : 900}

'ultra-condensed': 100,
'extra-condensed': 200,
'condensed': 300,
'semi-condensed': 400,
'normal': 500,
'semi-expanded': 600,
'semi-extended': 600,
'expanded': 700,
'extended': 700,
'extra-expanded': 800,
'extra-extended': 800,
'ultra-expanded': 900,
'ultra-extended': 900,
}
weight_dict = {
'ultralight' : 100,
'light' : 200,
'normal' : 400,
'regular' : 400,
'book' : 400,
'medium' : 500,
'roman' : 500,
'semibold' : 600,
'demibold' : 600,
'demi' : 600,
'bold' : 700,
'heavy' : 800,
'extra bold' : 800,
'black' : 900}

'ultralight': 100,
'light': 200,
'normal': 400,
'regular': 400,
'book': 400,
'medium': 500,
'roman': 500,
'semibold': 600,
'demibold': 600,
'demi': 600,
'bold': 700,
'heavy': 800,
'extra bold': 800,
'black': 900,
}
font_family_aliases = {
'serif',
'sans-serif',
'sans serif',
'cursive',
'fantasy',
'monospace',
'sans'}

# OS Font paths
'sans',
}
# OS Font paths
MSFolders = \
r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'
MSFontDirectories = [
Expand Down Expand Up @@ -411,12 +411,11 @@ def ttfFontProperty(font):
# Relative stretches are: wider, narrower
# Child value is: inherit

if (sfnt4.find('narrow') >= 0 or sfnt4.find('condensed') >= 0 or
sfnt4.find('cond') >= 0):
if any(word in sfnt4 for word in ['narrow', 'condensed', 'cond']):
stretch = 'condensed'
elif sfnt4.find('demi cond') >= 0:
elif 'demi cond' in sfnt4:
stretch = 'semi-condensed'
elif sfnt4.find('wide') >= 0 or sfnt4.find('expanded') >= 0 or sfnt4.find('extended') >= 0:
elif any(word in sfnt4 for word in ['wide', 'expanded', 'extended']):
stretch = 'expanded'
else:
stretch = 'normal'
Expand Down Expand Up @@ -482,9 +481,9 @@ def afmFontProperty(fontpath, font):
# Child value is: inherit
if 'demi cond' in fontname:
stretch = 'semi-condensed'
elif 'narrow' in fontname or 'cond' in fontname:
elif any(word in fontname for word in ['narrow', 'cond']):
stretch = 'condensed'
elif 'wide' in fontname or 'expanded' in fontname or 'extended' in fontname:
elif any(word in fontname for word in ['wide', 'expanded', 'extended']):
stretch = 'expanded'
else:
stretch = 'normal'
Expand Down