77
88Usage::
99
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})
1414
1515Sources:
1616
3838
3939class _Token :
4040 """
41- A token in a PostScript stream
41+ A token in a PostScript stream.
4242
4343 Attributes
4444 ----------
4545 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.
4847 raw : str
49- the raw text of the token
50-
48+ Raw text of the token.
5149 kind : str
52- description of the token (for debugging or testing)
50+ Description of the token (for debugging or testing).
5351 """
5452 __slots__ = ('pos' , 'raw' )
5553 kind = '?'
@@ -177,9 +175,8 @@ def _tokenize(data: bytes, skip_ws: bool):
177175 """
178176 A generator that produces _Token instances from Type-1 font code.
179177
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.
183180
184181 Parameters
185182 ----------
@@ -279,18 +276,16 @@ class _BalancedExpression(_Token):
279276
280277def _expression (initial , tokens , data ):
281278 """
282- Consume some number of tokens and return a balanced PostScript expression
279+ Consume some number of tokens and return a balanced PostScript expression.
283280
284281 Parameters
285282 ----------
286283 initial : _Token
287- the token that triggered parsing a balanced expression
288-
284+ The token that triggered parsing a balanced expression.
289285 tokens : iterator of _Token
290- following tokens
291-
286+ Following tokens.
292287 data : bytes
293- underlying data that the token positions point to
288+ Underlying data that the token positions point to.
294289
295290 Returns
296291 -------
@@ -332,17 +327,20 @@ class Type1Font:
332327 parts : tuple
333328 A 3-tuple of the cleartext part, the encrypted part, and the finale of
334329 zeros.
330+
335331 decrypted : bytes
336- The decrypted form of parts[1].
332+ The decrypted form of ``parts[1]``.
333+
337334 prop : dict[str, Any]
338335 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
346344 """
347345 __slots__ = ('parts' , 'decrypted' , 'prop' , '_pos' , '_abbr' )
348346 # the _pos dict contains (begin, end) indices to parts[0] + decrypted
@@ -445,7 +443,7 @@ def _split(self, data):
445443 @staticmethod
446444 def _decrypt (ciphertext , key , ndiscard = 4 ):
447445 """
448- Decrypt ciphertext using the Type-1 font algorithm
446+ Decrypt ciphertext using the Type-1 font algorithm.
449447
450448 The algorithm is described in Adobe's "Adobe Type 1 Font Format".
451449 The key argument can be an integer, or one of the strings
@@ -467,7 +465,7 @@ def _decrypt(ciphertext, key, ndiscard=4):
467465 @staticmethod
468466 def _encrypt (plaintext , key , ndiscard = 4 ):
469467 """
470- Encrypt plaintext using the Type-1 font algorithm
468+ Encrypt plaintext using the Type-1 font algorithm.
471469
472470 The algorithm is described in Adobe's "Adobe Type 1 Font Format".
473471 The key argument can be an integer, or one of the strings
0 commit comments