From 9b2a886652cb44f09229319b50b246675845bff9 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Mon, 11 Jul 2016 21:56:22 -0500 Subject: [PATCH] TST: add test for CFF / OTF files follow up to #6714 --- .travis.yml | 1 + lib/matplotlib/tests/test_font_manager.py | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 099e120c7a99..7f21018f7260 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ addons: - texlive-xetex - graphviz - libgeos-dev + - otf-freefont # - fonts-humor-sans # sources: # - debian-sid diff --git a/lib/matplotlib/tests/test_font_manager.py b/lib/matplotlib/tests/test_font_manager.py index ff13904c51cd..5a8bd2cf3091 100644 --- a/lib/matplotlib/tests/test_font_manager.py +++ b/lib/matplotlib/tests/test_font_manager.py @@ -5,8 +5,9 @@ import six import os - -from matplotlib.font_manager import (findfont, FontProperties, get_font) +import os.path +from matplotlib.font_manager import (findfont, FontProperties, get_font, + is_opentype_cff_font, fontManager as fm) from matplotlib import rc_context @@ -23,3 +24,15 @@ def test_font_priority(): cmap = font.get_charmap() assert len(cmap) == 131 assert cmap[8729] == 30 + + +def test_otf(): + fname = '/usr/share/fonts/opentype/freefont/FreeMono.otf' + if os.path.exists(fname): + assert is_opentype_cff_font(fname) + + otf_files = [f for f in fm.ttffiles if 'otf' in f] + for f in otf_files: + with open(f, 'rb') as fd: + res = fd.read(4) == b'OTTO' + assert res == is_opentype_cff_font(f)