1
1
"""
2
2
A class representing a Type 1 font.
3
3
4
- This version merely allows reading in pfa and pfb files, stores the
5
- data in pfa format, and allows reading the parts of the data in a
6
- format suitable for embedding in pdf files. A more complete class
7
- might support subsetting.
4
+ This version merely reads pfa and pfb files and splits them for
5
+ embedding in pdf files. There is no support yet for subsetting or
6
+ anything like that.
8
7
9
- Usage: font = Type1Font(filename)
10
- somefile.write(font.data) # writes out font in pfa format
11
- len1, len2, len3 = font.lengths() # needed for pdf embedding
8
+ Usage (subject to change):
9
+
10
+ font = Type1Font(filename)
11
+ clear_part, encrypted_part, finale = font.parts
12
12
13
13
Source: Adobe Technical Note #5040, Supporting Downloadable PostScript
14
14
Language Fonts.
@@ -32,8 +32,7 @@ def __init__(self, filename):
32
32
def _read (self , file ):
33
33
rawdata = file .read ()
34
34
if not rawdata .startswith (chr (128 )):
35
- self .data = rawdata
36
- return
35
+ return rawdata
37
36
38
37
data = ''
39
38
while len (rawdata ) > 0 :
@@ -101,4 +100,6 @@ def _split(self, data):
101
100
if __name__ == '__main__' :
102
101
import sys
103
102
font = Type1Font (sys .argv [1 ])
104
- sys .stdout .write (font .data )
103
+ parts = font .parts
104
+ print len (parts [0 ]), len (parts [1 ]), len (parts [2 ])
105
+
0 commit comments