8000 Can't specify integer `font.weight` in custom style sheet any more · Issue #15240 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
< 8000 div class="clearfix new-discussion-timeline js-check-all-container container-xl px-3 px-md-4 px-lg-5 mt-4" data-pjax="" data-turbo-frame="">

Can't specify integer font.weight in custom style sheet any more #15240

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

Closed
fpavogt opened this issue Sep 10, 2019 · 3 comments · Fixed by #15271
Closed

Can't specify integer font.weight in custom style sheet any more #15240

fpavogt opened this issue Sep 10, 2019 · 3 comments · Fixed by #15271
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Milestone

Comments

@fpavogt
Copy link
fpavogt commented Sep 10, 2019

Bug report

In matplotlib v3.1.1, the font_manager.FontManager.score_weight function was made more robust, and now issues an exception if a integer value is passed as a string (e.g. '500').

This, however, causes havoc with my custom style sheet, in which I define font.weight: 500, which then appears to be converted to '500' by the time it reaches the score_weight function.

Expected outcome

Specifying font.weight: 500 used to work in earlier versions. The doc still suggests (indirectly) that this should work.

Question
What is the proper way to specify integer font weights in style sheets ? Should they be banned (and the doc clarified) in favor of name-based strings (e.g. normal) ? Or the score_weight function modified to handle them?

Matplotlib version

  • Operating system: OS X 10.13.6
  • Matplotlib version: 3.1.1
  • Python version: 3.7.3
@afvincent
Copy link
Contributor

'font.weight': ['normal', validate_string],

indeed seems to convert an int argument an str.

@anntzer
Copy link
Contributor
anntzer commented Sep 10, 2019

it should indeed be replaced by something like

def validate_int_or_string(s):
    if isinstance(s, str):
        try: return int(s)
        except ValueError: return s
    elif isinstance(s, numbers.Number):  # also numpy ints
        return s
    else: fail

@timhoffm timhoffm added this to the v3.2.0 milestone Sep 10, 2019
@timhoffm timhoffm added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Sep 10, 2019
@tacaswell tacaswell modified the milestones: v3.2.0, v3.1.2 Sep 10, 2019
@PatrickFeiring
Copy link
Contributor
PatrickFeiring commented Sep 11, 2019

Also mentioned in #15170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
0