7
7
8
8
Usage::
9
9
10
- >>> font = Type1Font(filename)
11
- >>> clear_part, encrypted_part, finale = font.parts
12
- >>> slanted_font = font.transform({'slant': 0.167})
13
- >>> extended_font = font.transform({'extend': 1.2})
10
+ font = Type1Font(filename)
11
+ clear_part, encrypted_part, finale = font.parts
12
+ slanted_font = font.transform({'slant': 0.167})
13
+ extended_font = font.transform({'extend': 1.2})
14
14
15
15
Sources:
16
16
38
38
39
39
class _Token :
40
40
"""
41
- A token in a PostScript stream
41
+ A token in a PostScript stream.
42
42
43
43
Attributes
44
44
----------
45
45
pos : int
46
- position, i.e. offset from the beginning of the data
47
-
46
+ Position, i.e. offset from the beginning of the data.
48
47
raw : str
49
- the raw text of the token
50
-
48
+ Raw text of the token.
51
49
kind : str
52
- description of the token (for debugging or testing)
50
+ Description of the token (for debugging or testing).
53
51
"""
54
52
__slots__ = ('pos' , 'raw' )
55
53
kind = '?'
@@ -177,9 +175,8 @@ def _tokenize(data: bytes, skip_ws: bool):
177
175
"""
178
176
A generator that produces _Token instances from Type-1 font code.
179
177
180
- The consumer of the generator may send an integer to the tokenizer
181
- to indicate that the next token should be _BinaryToken of the given
182
- length.
178
+ The consumer of the generator may send an integer to the tokenizer to
179
+ indicate that the next token should be _BinaryToken of the given length.
183
180
184
181
Parameters
185
182
----------
@@ -279,18 +276,16 @@ class _BalancedExpression(_Token):
279
276
280
277
def _expression (initial , tokens , data ):
281
278
"""
282
- Consume some number of tokens and return a balanced PostScript expression
279
+ Consume some number of tokens and return a balanced PostScript expression.
283
280
284
281
Parameters
285
282
----------
286
283
initial : _Token
287
- the token that triggered parsing a balanced expression
288
-
284
+ The token that triggered parsing a balanced expression.
289
285
tokens : iterator of _Token
290
- following tokens
291
-
286
+ Following tokens.
292
287
data : bytes
293
- underlying data that the token positions point to
288
+ Underlying data that the token positions point to.
294
289
295
290
Returns
296
291
-------
@@ -332,17 +327,20 @@ class Type1Font:
332
327
parts : tuple
333
328
A 3-tuple of the cleartext part, the encrypted part, and the finale of
334
329
zeros.
330
+
335
331
decrypted : bytes
336
- The decrypted form of parts[1].
332
+ The decrypted form of ``parts[1]``.
333
+
337
334
prop : dict[str, Any]
338
335
A dictionary of font properties. Noteworthy keys include:
339
- FontName - PostScript name of the font
340
- Encoding - dict from numeric codes to glyph names
341
- FontMatrix - bytes object encoding a matrix
342
- UniqueID - optional font identifier, dropped when modifying the font
343
- CharStrings - dict from glyph names to byte code
344
- Subrs - array of byte code subroutines
345
- OtherSubrs - bytes object encoding some PostScript code
336
+
337
+ - FontName: PostScript name of the font
338
+ - Encoding: dict from numeric codes to glyph names
339
+ - FontMatrix: bytes object encoding a matrix
340
+ - UniqueID: optional font identifier, dropped when modifying the font
341
+ - CharStrings: dict from glyph names to byte code
342
+ - Subrs: array of byte code subroutines
343
+ - OtherSubrs: bytes object encoding some PostScript code
346
344
"""
347
345
__slots__ = ('parts' , 'decrypted' , 'prop' , '_pos' , '_abbr' )
348
346
# the _pos dict contains (begin, end) indices to parts[0] + decrypted
@@ -445,7 +443,7 @@ def _split(self, data):
445
443
@staticmethod
446
444
def _decrypt (ciphertext , key , ndiscard = 4 ):
447
445
"""
448
- Decrypt ciphertext using the Type-1 font algorithm
446
+ Decrypt ciphertext using the Type-1 font algorithm.
449
447
450
448
The algorithm is described in Adobe's "Adobe Type 1 Font Format".
451
449
The key argument can be an integer, or one of the strings
@@ -467,7 +465,7 @@ def _decrypt(ciphertext, key, ndiscard=4):
467
465
@staticmethod
468
466
def _encrypt (plaintext , key , ndiscard = 4 ):
469
467
"""
470
- Encrypt plaintext using the Type-1 font algorithm
468
+ Encrypt plaintext using the Type-1 font algorithm.
471
469
472
470
The algorithm is described in Adobe's "Adobe Type 1 Font Format".
473
471
The key argument can be an integer, or one of the strings
0 commit comments