forked from matplotlib/matplotlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix multiple-encodings issue in dviread.PsfontsMap
Also adds a test for that function.
- Loading branch information
Showing
3 changed files
with
77 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
% used by test_dviread.py | ||
TeXfont1 PSfont1 <font1.pfb <font1.enc | ||
TeXfont2 PSfont2 <font2.enc <font2.pfa | ||
TeXfont3 PSfont3 "1.23 UnknownEffect" <[enc3.foo <font3.pfa | ||
TeXfont4 PSfont4 "-0.1 SlantFont 2.2 ExtendFont" <font4.enc <font4.pfa | ||
TeXfont5 PSfont5 <encoding1.enc <encoding2.enc <font5.pfb | ||
TeXfont6 PSfont6 | ||
TeXfont7 PSfont7 <font7.enc | ||
TeXfont8 PSfont8 <font8.pfb | ||
TeXfont9 PSfont9 </absolute/font9.pfb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from nose.tools import assert_equal | ||
import matplotlib.dviread as dr | ||
import os.path | ||
|
||
original_find_tex_file = dr.find_tex_file | ||
|
||
def setup(): | ||
dr.find_tex_file = lambda x: x | ||
|
||
def teardown(): | ||
dr.find_tex_file = original_find_tex_file | ||
|
||
def test_PsfontsMap(): | ||
filename = os.path.join( | ||
os.path.dirname(__file__), | ||
'baseline_images', 'dviread', 'test.map') | ||
fontmap = dr.PsfontsMap(filename) | ||
# Check all properties of a few fonts | ||
for n in [1, 2, 3, 4, 5]: | ||
key = 'TeXfont%d' % n | ||
entry = fontmap[key] | ||
assert_equal(entry.texname, key) | ||
assert_equal(entry.psname, 'PSfont%d' % n) | ||
if n not in [3, 5]: | ||
assert_equal(entry.encoding, 'font%d.enc' % n) | ||
elif n == 3: | ||
assert_equal(entry.encoding, 'enc3.foo') | ||
# We don't care about the encoding of TeXfont5, which specifies | ||
# multiple encodings. | ||
if n not in [1, 5]: | ||
assert_equal(entry.filename, 'font%d.pfa' % n) | ||
else: | ||
assert_equal(entry.filename, 'font%d.pfb' % n) | ||
if n == 4: | ||
assert_equal(entry.effects, {'slant': -0.1, 'extend': 2.2}) | ||
else: | ||
assert_equal(entry.effects, {}) | ||
# Some special cases | ||
entry = fontmap['TeXfont6'] | ||
assert_equal(entry.filename, None) | ||
assert_equal(entry.encoding, None) | ||
entry = fontmap['TeXfont7'] | ||
assert_equal(entry.filename, None) | ||
assert_equal(entry.encoding, 'font7.enc') | ||
entry = fontmap['TeXfont8'] | ||
assert_equal(entry.filename, 'font8.pfb') | ||
assert_equal(entry.encoding, None) | ||
entry = fontmap['TeXfont9'] | ||
assert_equal(entry.filename, '/absolute/font9.pfb') | ||
|