<p dir="auto">I am trying to use Chinese text in my plot. There are some pre-installed font on the system which support Chinese (using <code class="notranslate">fc-list :lang=zh</code>), for example "WenQuanYi Zen Hei". But I find that these fonts can not be found by matplotlib. I checked some of the code of font_manager. I find that font_manger seems intentionally avoid finding font files in ttc extensions.</p>
<p dir="auto">In order to use these font, I have to explicitly give the path of the font, like the following example code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
import matplotlib.font_manager as mfm
ch_font = mfm.FontProperties(fname=&quot;/usr/share/fonts/wqy-zenhei/wqy-zenhei.ttc&quot;)
plt.annotate(xy=(0.5, 0.5), s=u'测试', xycoords='axes fraction', fontproperties=ch_font)
plt.show()"><pre class="notranslate"><code class="notranslate">import matplotlib.pyplot as plt
import matplotlib.font_manager as mfm
ch_font = mfm.FontProperties(fname="/usr/share/fonts/wqy-zenhei/wqy-zenhei.ttc")
plt.annotate(xy=(0.5, 0.5), s=u'测试', xycoords='axes fraction', fontproperties=ch_font)
plt.show()
</code></pre></div>
<p dir="auto">What is the reason behind this ?</p>
<p dir="auto"><strong>Matplotlib version</strong></p>
<ul dir="auto">
<li>Operating System: CentOS 7.2</li>
<li>Matplotlib Version:  2.0.1</li>
<li>Python Version: 3.6</li>
</ul>
<p dir="auto">The code posted below will return the following:  <em>RuntimeError: TrueType font is missing table</em>  .  It looks like TTC files have replaced TTF files for many fonts in Windows 8.  Please consider adding support.  Thanks so much,</p>
<p dir="auto">MJ</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="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 = &quot;r&quot;, linestyle = &quot;-&quot;)
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()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-v">PLT</span>
<span class="pl-k">import</span> <span class="pl-s1">pylab</span> <span class="pl-k">as</span> <span class="pl-v">PYLAB</span>
<span class="pl-k">from</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">backends</span>.<span class="pl-s1">backend_pdf</span> <span class="pl-k">import</span> <span class="pl-v">PdfPages</span> <span class="pl-k">as</span> <span class="pl-v">PDF</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">font_manager</span> <span class="pl-k">as</span> <span class="pl-s1">fm</span>

<span class="pl-s1">fontFile</span> <span class="pl-c1">=</span> <span class="pl-s">r'C:\Windows\Fonts\msyh.ttc'</span>
<span class="pl-s1">fp1</span> <span class="pl-c1">=</span> <span class="pl-s1">fm</span>.<span class="pl-v">FontProperties</span>(<span class="pl-s1">fname</span><span class="pl-c1">=</span><span class="pl-s1">fontFile</span>)

<span class="pl-s1">reportFile</span> <span class="pl-c1">=</span> <span class="pl-s">r'C:\Temp\TestUnicodeJA.pdf'</span>
<span class="pl-s1">pdfOutput</span> <span class="pl-c1">=</span> <span class="pl-v">PDF</span>(<span class="pl-s1">reportFile</span>)
<span class="pl-s1">vals</span> <span class="pl-c1">=</span> <span class="pl-en">range</span>(<span class="pl-c1">100</span>)

<span class="pl-v">PLT</span>.<span class="pl-en">plot</span>(<span class="pl-s1">vals</span>, <span class="pl-s1">vals</span>, <span class="pl-s1">color</span> <span class="pl-c1">=</span> <span class="pl-s">"r"</span>, <span class="pl-s1">linestyle</span> <span class="pl-c1">=</span> <span class="pl-s">"-"</span>)
<span class="pl-s1">mess</span> <span class="pl-c1">=</span> <span class="pl-s">u'<span class="pl-cce">\u30c7</span><span class="pl-cce">\u30fc</span><span class="pl-cce">\u30bf</span><span class="pl-cce">\u3092</span><span class="pl-cce">\u8aad</span><span class="pl-cce">\u307f</span><span class="pl-cce">\u8fbc</span><span class="pl-cce">\u3093</span><span class="pl-cce">\u3067</span><span class="pl-cce">\u3044</span><span class="pl-cce">\u307e</span><span class="pl-cce">\u3059</span>....'</span>
<span class="pl-v">PYLAB</span>.<span class="pl-en">xlabel</span>(<span class="pl-s1">mess</span>, <span class="pl-s1">fontproperties</span> <span class="pl-c1">=</span> <span class="pl-s1">fp1</span>)
<span class="pl-v">PLT</span>.<span class="pl-en">savefig</span>(<span class="pl-s1">pdfOutput</span>, <span class="pl-s1">format</span><span class="pl-c1">=</span><span class="pl-s">'pdf'</span>)
<span class="pl-v">PLT</span>.<span class="pl-en">close</span>()
<span class="pl-s1">pdfOutput</span>.<span class="pl-en">close</span>()</pre></div>