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

Please add support for ttc font files (PDF/PS output) · Issue #3135 · matplotlib/matplotlib · GitHub

Repository navigation

Please add support for ttc font files (PDF/PS output) #3135

Closed

Description

The code posted below will return the following: RuntimeError: TrueType font is missing table . It looks like TTC files have replaced TTF files for many fonts in Windows 8. Please consider adding support. Thanks so much,

MJ

import matplotlib.pyplot as PLT
import pylab as PYLAB
from matplotlib.backends.backend_pdf import PdfPages as PDF
import matplotlib.font_manager as fm

fontFile = r'C:\Windows\Fonts\msyh.ttc'
fp1 = fm.FontProperties(fname=fontFile)

reportFile = r'C:\Temp\TestUnicodeJA.pdf'
pdfOutput = PDF(reportFile)
vals = range(100)

PLT.plot(vals, vals, color = "r", linestyle = "-")
mess = u'\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3044\u307e\u3059....'
PYLAB.xlabel(mess, fontproperties = fp1)
PLT.savefig(pdfOutput, format='pdf')
PLT.close()
pdfOutput.close()

Activity

  1. added this to the milestone on Jun 25, 2014
  2. petehuang commented on Dec 29, 2016

    Contributor

    Hi,

    This issue has been inactive for a while. Does this continue to represent a useful enhancement? I believe the PR associated with this has stalled a little. Thanks!

  3. modified the milestones: , on Oct 3, 2017
  4. spinicist commented on Sep 20, 2018

    A lot of the fonts I want to use on Mac (principally Gill Sans) are also TTC, so I would love to see #9787 merged.

  5. lukelbd commented on Jan 3, 2020

    Contributor

    Friendly ping. I ran into this issue when testing various sans-serif fonts. Who would have the expertise to address this?

  6. jklymak commented on Jan 3, 2020

    Member

    #9897 is in Matplotlib 3.1. Does it not go far enough? I take it there are some issues with pdf/ps.

  7. lukelbd commented on Jan 3, 2020

    Contributor

    I have matplotlib 3.1.1, issue is still present.

    In [1]: import matplotlib
    In [2]: matplotlib.__version__
    Out[2]: '3.1.1'

    This is an issue specifically with the PDF backend (not sure about PS). The title should probably be changed to reflect this.

  8. lukelbd commented on Jan 3, 2020

    Contributor

    Also, I am on macOS, not windows.

  9. jklymak commented on Jan 3, 2020

    Member

    In #9897 @anntzer (who is probably best suited to looking at this) said there were technical limitations to getting ttc files to work with pdf/ps. So probably someone who strongly needed this would need to dig into things, some of which may be quite arcane.

  10. changed the title [-]Please add support for ttc font files[/-] [+]Please add support for ttc font files (PDF/PS output)[/+] on Jan 3, 2020
  11. lukelbd commented on Jan 3, 2020

    Contributor

    In the meantime here is a working example for macOS:

    import matplotlib.font_manager as fm
    import matplotlib.pyplot as plt
    props = fm.FontProperties(fname='/System/Library/Fonts/Helvetica.ttc')
    f, ax = plt.subplots()
    ax.set_title('Title', fontproperties=props)
    f.savefig('tmp.pdf')

    Note that fontfamily='Helvetica' still seems to work on macOS (Catalina) because there are also Helvetica .ttf files in /Library/Fonts, and the OSXFontDirectories variable in font_manager.py gives these files the priority (this was on my system only!).

  12. 13 remaining items

  13. added
    keepItems to be ignored by the “Stale” Github Action
    on Jun 30, 2023
  14. dhyanKaro commented on Dec 27, 2023

    Emojis!

  15. Artoria2e5 commented on Feb 20, 2024

    Emojis in PDF might need to wait, since the color formats are also an issue beyond just TTC. I heard that Clerk Ma is doing something to XeTeX to allow them -- maybe we can use his work if the license and stuff works.

    The current PR works, but converting by splitting is, at the end of the day, less than perfect -- especially if you have something like a 35-in-one Source Han Sans SuperOTC installed (I used to have that. I probably still do, but I'm too lazy to check.). The ideal is to find an alternative to _ttconv somewhere -- the TeX people might have the answer, I don't know.

  16. moved this from Waiting for other PR to In Progress in Font and text overhaulon Jul 19, 2025
  17. self-assigned this
    on Sep 17, 2025
  18. removed
    keepItems to be ignored by the “Stale” Github Action
    on Apr 10, 2026
  19. QuLogic commented on Apr 10, 2026

    Member

    The text-overhaul branch is now merged to main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


Back | FazBrowse Home | New Git URL