FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Incorrect selection of Times New Roman Bold · Issue #5574 · matplotlib/matplotlib · GitHub

Repository navigation

Incorrect selection of Times New Roman Bold #5574

Closed

Description

On both my Mac and Linux setup (mpl 1.5.0) is appears that the bold version is selected over the regular one, as both are understood to have the same weight.

See this question on StackOverflow where I described the problem and the "solution".

http://stackoverflow.com/questions/33955900/matplotlib-times-new-roman-appears-bold/33962423#33962423

Please close this issue if this is an actual font problem unrelated to mpl.

Activity

  1. mdboom commented on Nov 27, 2015

    Member

    #5414, while not ready immediately, should address this by using font-config rather than our own homegrown code for font lookup. That's our long term solution to these sorts of problems, but won't be ready until at least matplotlib 2.1, maybe later.

    As for the actual problem at hand, I'm having trouble reproducing it. With the Times New Roman Bold that ships with Win8 (which has the filename timesbd.ttf and has the md5 hash 43a1861fb747438005fa1615b70798a4), the "style_flags" metadata is set correctly to indicate that it is bold. In the linked SO question the filename appears to be "Times New Roman Bold.ttf", so maybe that's a different font from a different source?

  2. added this to the milestone on Nov 30, 2015
  3. ferdinandvanwyk commented on Feb 22, 2017

    I recently started seeing this problem on OSX as well. The default Times fonts are named: Time New Roman.ttf, Time New Roman Bold.ttf, etc. The answer in the linked SO post seems to work, however, is there a better temporary solution to this?

  4. steffen-micdev commented on Apr 21, 2017

    I experienced the same problem. In font_manager.py the weight is set by scanning the font properties from sfnt4 = sfnt.get((1,0,0,4)) in the weight_dict.
    Since the sfnt4 is "Times New Roman Bold" and the weight dict contains also "roman" as a valid weight, all Fonts containing "Roman" in this string will be set to a weight of 500, regardless of the "bold".

    On simple solution is to remove "roman" from the weight_dict. Ideally would be a more sophisticated method to scan.

  5. jhrmnn commented on May 5, 2017

    Just encountered this problem as well. It can be fixed locally with

    del matplotlib.font_manager.weight_dict['roman']
    matplotlib.font_manager._rebuild()
  6. perwin commented on Jun 20, 2017

    I started seeing this same problem recently, when I upgraded from matplotlib 1.5 to 2.0
    (MacBook Pro 2012 with macOS 10.12.5, python.org's framework installation of Python 3.6.1)
    (azag0's fix works for me)

  7. modified the milestones: , on Oct 3, 2017
  8. Datseris commented on Oct 10, 2017

    Just chiming in to say that this is happening also to me, in Windows 10, with matplotlib 2.0 and anaconda, python 3.6

    Edit: I confirm that the answer by azag0 works, i.e.

    del matplotlib.font_manager.weight_dict['roman']
    matplotlib.font_manager._rebuild()
  9. xchank commented on Apr 2, 2018

    Windows 10 with matplotlib 2.1.2 and anaconda
    The answer by azag0 works like a charm

  10. austindowney commented on Aug 23, 2018

    This is happening for me with Matplotlib 2.2.2 on a Windows 10 machine. I assume there is no global fix to this solution other than the adding the local code provided by azag0.

    This code returns "KeyError: 'roman'"every time I run it and I would like to find a way to fit it without the error showing up.

  11. tcanders commented on Dec 10, 2018

    I upgraded from Python 3.5.4 with matplotlib 2.0.2 to Python 3.7.1 with matplotlib 3.0.2 and this was suddenly a problem. The local fix works. I'm on Windows 7.

  12. perwin commented on Mar 1, 2019

    This problem re-appeared when I upgraded to matplotlib 3.0.2 (macOS 10.13.6, Python.org's Python 3.7.2); azag0's fix worked again.

  13. JoElfner commented on Jun 7, 2019

    Same here when upgrading from 3.0.3 to 3.10.0.
    The answer

    del matplotlib.font_manager.weight_dict['roman']
    matplotlib.font_manager._rebuild()
    

    did NOT solve the problem. Instead it completely crashed my fontmanager, raising several errors. Unluckily I had a deadline pressuring me to get back to work asap, thus I did not have the time to write down everything.
    I had to re-install my whole anaconda dist, clearing all users/.matplotlib, users/.conda etc folders to make it work again. Additionally since then, the 'Times' font can't be found and instead of using 'Times New Roman', it is falling back to sans-serif DejaVu Sans...

  14. iTomxy commented on Jan 11, 2021

    I fixed this by changing importing :

    import matplotlib.font_manager
    del matplotlib.font_manager.weight_dict['roman']
    matplotlib.font_manager._rebuild()

    and it works


    when using jhrmnn's method, I got error :

    AttributeError: module 'matplotlib' has no attribute 'font_manager'
    • OS: win 10
    • matplotlib 3.1.1

    my codes:

    import matplotlib as mpl
    print(dir(mpl))
    del mpl.font_manager.weight_dict['roman']
    mpl.font_manager._rebuild()
    from matplotlib import rcParams
    rcParams['font.family'] = 'Times New Roman'
    # rcParams['font.sans-serif'] = ['Tahoma']
    import matplotlib.pyplot as plt
    
    fig, ax = plt.subplots()
    ax.plot([1, 2, 3], label='test')
    
    ax.legend()
    plt.show()

    any help ?

  15. removed this from the future releases milestone on Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL