From d192d9086aa2cc64a10114e059a8487d5f68203c Mon Sep 17 00:00:00 2001 From: Qiang Luo Date: Fri, 12 Dec 2014 10:32:58 +0800 Subject: [PATCH 1/4] add ttc font support --- lib/matplotlib/font_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/font_manager.py b/lib/matplotlib/font_manager.py index 3d33a28ce923..d83b0f65028b 100644 --- a/lib/matplotlib/font_manager.py +++ b/lib/matplotlib/font_manager.py @@ -156,7 +156,7 @@ def get_fontext_synonyms(fontext): Return a list of file extensions extensions that are synonyms for the given file extension *fileext*. """ - return {'ttf': ('ttf', 'otf'), + return {'ttf': ('ttf', 'ttc', 'otf'), 'otf': ('ttf', 'otf'), 'afm': ('afm',)}[fontext] From 3b078d2ad0a62bb1cd85e2c31bbf787da34a34af Mon Sep 17 00:00:00 2001 From: Qiang Luo Date: Fri, 12 Dec 2014 12:42:19 +0800 Subject: [PATCH 2/4] test ttc font loading using wqy-zenhei.ttc --- lib/matplotlib/tests/test_font_manager.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/matplotlib/tests/test_font_manager.py b/lib/matplotlib/tests/test_font_manager.py index df2675219023..91ba30f4287d 100644 --- a/lib/matplotlib/tests/test_font_manager.py +++ b/lib/matplotlib/tests/test_font_manager.py @@ -17,3 +17,13 @@ def test_font_priority(): font = findfont( FontProperties(family=["sans-serif"])) assert_equal(os.path.basename(font), 'cmmi10.ttf') + +def test_font_ttc(): +# the font should be available(ttf-wqy-zenhei in ubuntu) + font = findfont( + FontProperties(family=["WenQuanYi Zen Hei"])) + assert_equal(os.path.basename(font), 'wqy-zenhei.ttc') + +if __name__=='__main__': + import nose + nose.runmodule(argv=['-s','--with-doctest'], exit=False) From c74b3ff833e30036da39bf3c4ea5722f333be2a3 Mon Sep 17 00:00:00 2001 From: Qiang Luo Date: Fri, 12 Dec 2014 13:28:54 +0800 Subject: [PATCH 3/4] install ttf-wqy-zenhei for travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 73a7997caebd..32a57cddef1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ matrix: install: - pip install -q --use-mirrors nose python-dateutil $NUMPY pep8 pyparsing pillow - - sudo apt-get update && sudo apt-get -qq install inkscape libav-tools gdb + - sudo apt-get update && sudo apt-get -qq install inkscape libav-tools gdb ttf-wqy-zenhei # We use --no-install-recommends to avoid pulling in additional large latex docs that we don't need - if [[ $BUILD_DOCS == true ]]; then sudo apt-get install -qq --no-install-recommends dvipng texlive-latex-base texlive-latex-extra texlive-fonts-recommended graphviz; fi - if [[ $BUILD_DOCS == true ]]; then pip install sphinx numpydoc linkchecker; fi From 0e0c1896667f057521de2b8db388c7f233bc64eb Mon Sep 17 00:00:00 2001 From: Qiang Luo Date: Fri, 12 Dec 2014 13:53:09 +0800 Subject: [PATCH 4/4] conform to pep8 --- lib/matplotlib/tests/test_font_manager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_font_manager.py b/lib/matplotlib/tests/test_font_manager.py index 91ba30f4287d..e7ca685f253a 100644 --- a/lib/matplotlib/tests/test_font_manager.py +++ b/lib/matplotlib/tests/test_font_manager.py @@ -18,12 +18,13 @@ def test_font_priority(): FontProperties(family=["sans-serif"])) assert_equal(os.path.basename(font), 'cmmi10.ttf') + def test_font_ttc(): -# the font should be available(ttf-wqy-zenhei in ubuntu) + # the font should be available(ttf-wqy-zenhei in ubuntu) font = findfont( FontProperties(family=["WenQuanYi Zen Hei"])) assert_equal(os.path.basename(font), 'wqy-zenhei.ttc') -if __name__=='__main__': +if __name__ == '__main__': import nose - nose.runmodule(argv=['-s','--with-doctest'], exit=False) + nose.runmodule(argv=['-s', '--with-doctest'], exit=False)