Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ae5e903

Browse files
committed
Merge pull request matplotlib#4522 from jkseppan/type1font
FIX: type1font.py and test case
2 parents 909311f + 2e421be commit ae5e903

File tree

4 files changed

+338
-52
lines changed

4 files changed

+338
-52
lines changed

LICENSE/LICENSE_AMSFONTS

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
The cmr10.pfb file is a Type-1 version of one of Knuth's Computer Modern fonts.
2+
It is included here as test data only, but the following license applies.
3+
4+
Copyright (c) 1997, 2009, American Mathematical Society (http://www.ams.org).
5+
All Rights Reserved.
6+
7+
"cmb10" is a Reserved Font Name for this Font Software.
8+
"cmbsy10" is a Reserved Font Name for this Font Software.
9+
"cmbsy5" is a Reserved Font Name for this Font Software.
10+
"cmbsy6" is a Reserved Font Name for this Font Software.
11+
"cmbsy7" is a Reserved Font Name for this Font Software.
12+
"cmbsy8" is a Reserved Font Name for this Font Software.
13+
"cmbsy9" is a Reserved Font Name for this Font Software.
14+
"cmbx10" is a Reserved Font Name for this Font Software.
15+
"cmbx12" is a Reserved Font Name for this Font Software.
16+
"cmbx5" is a Reserved Font Name for this Font Software.
17+
"cmbx6" is a Reserved Font Name for this Font Software.
18+
"cmbx7" is a Reserved Font Name for this Font Software.
19+
"cmbx8" is a Reserved Font Name for this Font Software.
20+
"cmbx9" is a Reserved Font Name for this Font Software.
21+
"cmbxsl10" is a Reserved Font Name for this Font Software.
22+
"cmbxti10" is a Reserved Font Name for this Font Software.
23+
"cmcsc10" is a Reserved Font Name for this Font Software.
24+
"cmcsc8" is a Reserved Font Name for this Font Software.
25+
"cmcsc9" is a Reserved Font Name for this Font Software.
26+
"cmdunh10" is a Reserved Font Name for this Font Software.
27+
"cmex10" is a Reserved Font Name for this Font Software.
28+
"cmex7" is a Reserved Font Name for this Font Software.
29+
"cmex8" is a Reserved Font Name for this Font Software.
30+
"cmex9" is a Reserved Font Name for this Font Software.
31+
"cmff10" is a Reserved Font Name for this Font Software.
32+
"cmfi10" is a Reserved Font Name for this Font Software.
33+
"cmfib8" is a Reserved Font Name for this Font Software.
34+
"cminch" is a Reserved Font Name for this Font Software.
35+
"cmitt10" is a Reserved Font Name for this Font Software.
36+
"cmmi10" is a Reserved Font Name for this Font Software.
37+
"cmmi12" is a Reserved Font Name for this Font Software.
38+
"cmmi5" is a Reserved Font Name for this Font Software.
39+
"cmmi6" is a Reserved Font Name for this Font Software.
40+
"cmmi7" is a Reserved Font Name for this Font Software.
41+
"cmmi8" is a Reserved Font Name for this Font Software.
42+
"cmmi9" is a Reserved Font Name for this Font Software.
43+
"cmmib10" is a Reserved Font Name for this Font Software.
44+
"cmmib5" is a Reserved Font Name for this Font Software.
45+
"cmmib6" is a Reserved Font Name for this Font Software.
46+
"cmmib7" is a Reserved Font Name for this Font Software.
47+
"cmmib8" is a Reserved Font Name for this Font Software.
48+
"cmmib9" is a Reserved Font Name for this Font Software.
49+
"cmr10" is a Reserved Font Name for this Font Software.
50+
"cmr12" is a Reserved Font Name for this Font Software.
51+
"cmr17" is a Reserved Font Name for this Font Software.
52+
"cmr5" is a Reserved Font Name for this Font Software.
53+
"cmr6" is a Reserved Font Name for this Font Software.
54+
"cmr7" is a Reserved Font Name for this Font Software.
55+
"cmr8" is a Reserved Font Name for this Font Software.
56+
"cmr9" is a Reserved Font Name for this Font Software.
57+
"cmsl10" is a Reserved Font Name for this Font Software.
58+
"cmsl12" is a Reserved Font Name for this Font Software.
59+
"cmsl8" is a Reserved Font Name for this Font Software.
60+
"cmsl9" is a Reserved Font Name for this Font Software.
61+
"cmsltt10" is a Reserved Font Name for this Font Software.
62+
"cmss10" is a Reserved Font Name for this Font Software.
63+
"cmss12" is a Reserved Font Name for this Font Software.
64+
"cmss17" is a Reserved Font Name for this Font Software.
65+
"cmss8" is a Reserved Font Name for this Font Software.
66+
"cmss9" is a Reserved Font Name for this Font Software.
67+
"cmssbx10" is a Reserved Font Name for this Font Software.
68+
"cmssdc10" is a Reserved Font Name for this Font Software.
69+
"cmssi10" is a Reserved Font Name for this Font Software.
70+
"cmssi12" is a Reserved Font Name for this Font Software.
71+
"cmssi17" is a Reserved Font Name for this Font Software.
72+
"cmssi8" is a Reserved Font Name for this Font Software.
73+
"cmssi9" is a Reserved Font Name for this Font Software.
74+
"cmssq8" is a Reserved Font Name for this Font Software.
75+
"cmssqi8" is a Reserved Font Name for this Font Software.
76+
"cmsy10" is a Reserved Font Name for this Font Software.
77+
"cmsy5" is a Reserved Font Name for this Font Software.
78+
"cmsy6" is a Reserved Font Name for this Font Software.
79+
"cmsy7" is a Reserved Font Name for this Font Software.
80+
"cmsy8" is a Reserved Font Name for this Font Software.
81+
"cmsy9" is a Reserved Font Name for this Font Software.
82+
"cmtcsc10" is a Reserved Font Name for this Font Software.
83+
"cmtex10" is a Reserved Font Name for this Font Software.
84+
"cmtex8" is a Reserved Font Name for this Font Software.
85+
"cmtex9" is a Reserved Font Name for this Font Software.
86+
"cmti10" is a Reserved Font Name for this Font Software.
87+
"cmti12" is a Reserved Font Name for this Font Software.
88+
"cmti7" is a Reserved Font Name for this Font Software.
89+
"cmti8" is a Reserved Font Name for this Font Software.
90+
"cmti9" is a Reserved Font Name for this Font Software.
91+
"cmtt10" is a Reserved Font Name for this Font Software.
92+
"cmtt12" is a Reserved Font Name for this Font Software.
93+
"cmtt8" is a Reserved Font Name for this Font Software.
94+
"cmtt9" is a Reserved Font Name for this Font Software.
95+
"cmu10" is a Reserved Font Name for this Font Software.
96+
"cmvtt10" is a Reserved Font Name for this Font Software.
97+
"euex10" is a Reserved Font Name for this Font Software.
98+
"euex7" is a Reserved Font Name for this Font Software.
99+
"euex8" is a Reserved Font Name for this Font Software.
100+
"euex9" is a Reserved Font Name for this Font Software.
101+
"eufb10" is a Reserved Font Name for this Font Software.
102+
"eufb5" is a Reserved Font Name for this Font Software.
103+
"eufb7" is a Reserved Font Name for this Font Software.
104+
"eufm10" is a Reserved Font Name for this Font Software.
105+
"eufm5" is a Reserved Font Name for this Font Software.
106+
"eufm7" is a Reserved Font Name for this Font Software.
107+
"eurb10" is a Reserved Font Name for this Font Software.
108+
"eurb5" is a Reserved Font Name for this Font Software.
109+
"eurb7" is a Reserved Font Name for this Font Software.
110+
"eurm10" is a Reserved Font Name for this Font Software.
111+
"eurm5" is a Reserved Font Name for this Font Software.
112+
"eurm7" is a Reserved Font Name for this Font Software.
113+
"eusb10" is a Reserved Font Name for this Font Software.
114+
"eusb5" is a Reserved Font Name for this Font Software.
115+
"eusb7" is a Reserved Font Name for this Font Software.
116+
"eusm10" is a Reserved Font Name for this Font Software.
117+
"eusm5" is a Reserved Font Name for this Font Software.
118+
"eusm7" is a Reserved Font Name for this Font Software.
119+
"lasy10" is a Reserved Font Name for this Font Software.
120+
"lasy5" is a Reserved Font Name for this Font Software.
121+
"lasy6" is a Reserved Font Name for this Font Software.
122+
"lasy7" is a Reserved Font Name for this Font Software.
123+
"lasy8" is a Reserved Font Name for this Font Software.
124+
"lasy9" is a Reserved Font Name for this Font Software.
125+
"lasyb10" is a Reserved Font Name for this Font Software.
126+
"lcircle1" is a Reserved Font Name for this Font Software.
127+
"lcirclew" is a Reserved Font Name for this Font Software.
128+
"lcmss8" is a Reserved Font Name for this Font Software.
129+
"lcmssb8" is a Reserved Font Name for this Font Software.
130+
"lcmssi8" is a Reserved Font Name for this Font Software.
131+
"line10" is a Reserved Font Name for this Font Software.
132+
"linew10" is a Reserved Font Name for this Font Software.
133+
"msam10" is a Reserved Font Name for this Font Software.
134+
"msam5" is a Reserved Font Name for this Font Software.
135+
"msam6" is a Reserved Font Name for this Font Software.
136+
"msam7" is a Reserved Font Name for this Font Software.
137+
"msam8" is a Reserved Font Name for this Font Software.
138+
"msam9" is a Reserved Font Name for this Font Software.
139+
"msbm10" is a Reserved Font Name for this Font Software.
140+
"msbm5" is a Reserved Font Name for this Font Software.
141+
"msbm6" is a Reserved Font Name for this Font Software.
142+
"msbm7" is a Reserved Font Name for this Font Software.
143+
"msbm8" is a Reserved Font Name for this Font Software.
144+
"msbm9" is a Reserved Font Name for this Font Software.
145+
"wncyb10" is a Reserved Font Name for this Font Software.
146+
"wncyi10" is a Reserved Font Name for this Font Software.
147+
"wncyr10" is a Reserved Font Name for this Font Software.
148+
"wncysc10" is a Reserved Font Name for this Font Software.
149+
"wncyss10" is a Reserved Font Name for this Font Software.
150+
151+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
152+
This license is copied below, and is also available with a FAQ at:
153+
http://scripts.sil.org/OFL
154+
155+
-----------------------------------------------------------
156+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
157+
-----------------------------------------------------------
158+
159+
PREAMBLE
160+
The goals of the Open Font License (OFL) are to stimulate worldwide
161+
development of collaborative font projects, to support the font creation
162+
efforts of academic and linguistic communities, and to provide a free and
163+
open framework in which fonts may be shared and improved in partnership
164+
with others.
165+
166+
The OFL allows the licensed fonts to be used, studied, modified and
167+
redistributed freely as long as they are not sold by themselves. The
168+
fonts, including any derivative works, can be bundled, embedded,
169+
redistributed and/or sold with any software provided that any reserved
170+
names are not used by derivative works. The fonts and derivatives,
171+
however, cannot be released under any other type of license. The
172+
requirement for fonts to remain under this license does not apply
173+
to any document created using the fonts or their derivatives.
174+
175+
DEFINITIONS
176+
"Font Software" refers to the set of files released by the Copyright
177+
Holder(s) under this license and clearly marked as such. This may
178+
include source files, build scripts and documentation.
179+
180+
"Reserved Font Name" refers to any names specified as such after the
181+
copyright statement(s).
182+
183+
"Original Version" refers to the collection of Font Software components as
184+
distributed by the Copyright Holder(s).
185+
186+
"Modified Version" refers to any derivative made by adding to, deleting,
187+
or substituting -- in part or in whole -- any of the components of the
188+
Original Version, by changing formats or by porting the Font Software to a
189+
new environment.
190+
191+
"Author" refers to any designer, engineer, programmer, technical
192+
writer or other person who contributed to the Font Software.
193+
194+
PERMISSION & CONDITIONS
195+
Permission is hereby granted, free of charge, to any person obtaining
196+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
197+
redistribute, and sell modified and unmodified copies of the Font
198+
Software, subject to the following conditions:
199+
200+
1) Neither the Font Software nor any of its individual components,
201+
in Original or Modified Versions, may be sold by itself.
202+
203+
2) Original or Modified Versions of the Font Software may be bundled,
204+
redistributed and/or sold with any software, provided that each copy
205+
contains the above copyright notice and this license. These can be
206+
included either as stand-alone text files, human-readable headers or
207+
in the appropriate machine-readable metadata fields within text or
208+
binary files as long as those fields can be easily viewed by the user.
209+
210+
3) No Modified Version of the Font Software may use the Reserved Font
211+
Name(s) unless explicit written permission is granted by the corresponding
212+
Copyright Holder. This restriction only applies to the primary font name as
213+
presented to the users.
214+
215+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
216+
Software shall not be used to promote, endorse or advertise any
217+
Modified Version, except to acknowledge the contribution(s) of the
218+
Copyright Holder(s) and the Author(s) or with their explicit written
219+
permission.
220+
221+
5) The Font Software, modified or unmodified, in part or in whole,
222+
must be distributed entirely under this license, and must not be
223+
distributed under any other license. The requirement for fonts to
224+
remain under this license does not apply to any document created
225+
using the Font Software.
226+
227+
TERMINATION
228+
This license becomes null and void if any of the above conditions are
229+
not met.
230+
231+
DISCLAIMER
232+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
233+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
234+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
235+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
236+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
237+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
238+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
239+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
240+
OTHER DEALINGS IN THE FONT SOFTWARE.

lib/matplotlib/tests/cmr10.pfb

34.9 KB
Binary file not shown.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from __future__ import (absolute_import, division, print_function,
2+
unicode_literals)
3+
4+
import six
5+
6+
from nose.tools import assert_equal, assert_in
7+
import matplotlib.type1font as t1f
8+
import os.path
9+
import difflib
10+
11+
12+
def test_Type1Font():
13+
filename = os.path.join(os.path.dirname(__file__), 'cmr10.pfb')
14+
font = t1f.Type1Font(filename)
15+
slanted = font.transform({'slant': 1})
16+
condensed = font.transform({'extend': 0.5})
17+
rawdata = open(filename, 'rb').read()
18+
assert_equal(font.parts[0], rawdata[0x0006:0x10c5])
19+
assert_equal(font.parts[1], rawdata[0x10cb:0x897f])
20+
assert_equal(font.parts[2], rawdata[0x8985:0x8ba6])
21+
assert_equal(font.parts[1:], slanted.parts[1:])
22+
assert_equal(font.parts[1:], condensed.parts[1:])
23+
24+
differ = difflib.Differ()
25+
diff = list(differ.compare(
26+
font.parts[0].decode('latin-1').splitlines(),
27+
slanted.parts[0].decode('latin-1').splitlines()))
28+
for line in (
29+
# Removes UniqueID
30+
'- FontDirectory/CMR10 known{/CMR10 findfont dup/UniqueID known{dup',
31+
'+ FontDirectory/CMR10 known{/CMR10 findfont dup',
32+
# Changes the font name
33+
'- /FontName /CMR10 def',
34+
'+ /FontName /CMR10_Slant_1000 def',
35+
# Alters FontMatrix
36+
'- /FontMatrix [0.001 0 0 0.001 0 0 ]readonly def',
37+
'+ /FontMatrix [0.001 0.0 0.001 0.001 0.0 0.0]readonly def',
38+
# Alters ItalicAngle
39+
'- /ItalicAngle 0 def',
40+
'+ /ItalicAngle -45.0 def'):
41+
assert_in(line, diff, 'diff to slanted font must contain %s' % line)
42+
43+
diff = list(differ.compare(font.parts[0].decode('latin-1').splitlines(),
44+
condensed.parts[0].decode('latin-1').splitlines()))
45+
for line in (
46+
# Removes UniqueID
47+
'- FontDirectory/CMR10 known{/CMR10 findfont dup/UniqueID known{dup',
48+
'+ FontDirectory/CMR10 known{/CMR10 findfont dup',
49+
# Changes the font name
50+
'- /FontName /CMR10 def',
51+
'+ /FontName /CMR10_Extend_500 def',
52+
# Alters FontMatrix
53+
'- /FontMatrix [0.001 0 0 0.001 0 0 ]readonly def',
54+
'+ /FontMatrix [0.0005 0.0 0.0 0.001 0.0 0.0]readonly def'):
55+
assert_in(line, diff, 'diff to condensed font must contain %s' % line)

0 commit comments

Comments
 (0)