11"""
22A class representing a Type 1 font.
33
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.
87
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
1212
1313Source: Adobe Technical Note #5040, Supporting Downloadable PostScript
1414Language Fonts.
@@ -32,8 +32,7 @@ def __init__(self, filename):
3232 def _read (self , file ):
3333 rawdata = file .read ()
3434 if not rawdata .startswith (chr (128 )):
35- self .data = rawdata
36- return
35+ return rawdata
3736
3837 data = ''
3938 while len (rawdata ) > 0 :
@@ -101,4 +100,6 @@ def _split(self, data):
101100if __name__ == '__main__' :
102101 import sys
103102 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