Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Commitb8c0521
committed
Improve the Type-1 font parsing
Move Type1Font._tokens into a top-level function _tokenize that is acoroutine. The parsing stage consuming the tokens can instruct thetokenizer to return a binary token - this is necessary when decryptingthe CharStrings and Subrs arrays, since the preceding context determineswhich parts of the data need to be decrypted.The function now also parses the encrypted portion of the font file.To support usage as a coroutine, move the whitespace filtering into thefunction, since passing the information about binary tokens would noteasily work through a filter.The function now returns tokens as subclasses of a new _Token class,which carry the position and value of the token and can havetoken-specific helper methods. The position data will be needed whenmodifying the file, as the font is transformed or subsetted.A new helper function _expression can be used to consume tokens thatform a balanced subexpression delimited by [] or {}. This helps fix abug in UniqueID removal: if the font includes PostScript code thatchecks if the UniqueID is set in the current dictionary, the previouscode broke that code instead of removing the UniqueID definition. Fontscan include UniqueID in the encrypted portion as well as the cleartextone, and removal is now done in both portions.Fix a bug related to font weight: the key is title-cased and notlower-cased, so font.prop['weight'] should not exist.1 parentb9e71c5 commitb8c0521
File tree
5 files changed
+631
-177
lines changed- LICENSE
- doc/api/next_api_changes/behavior
- lib/matplotlib
- tests
5 files changed
+631
-177
lines changedLines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + |
Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + |
Binary file not shown.
Lines changed: 40 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
13 | 13 |
| |
14 | 14 |
| |
15 | 15 |
| |
16 |
| - | |
17 |
| - | |
18 | 16 |
| |
19 | 17 |
| |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
20 | 42 |
| |
21 | 43 |
| |
22 | 44 |
| |
23 | 45 |
| |
24 | 46 |
| |
25 | 47 |
| |
26 | 48 |
| |
27 |
| - | |
28 |
| - | |
| 49 | + | |
29 | 50 |
| |
30 | 51 |
| |
31 |
| - | |
| 52 | + | |
32 | 53 |
| |
33 | 54 |
| |
34 |
| - | |
| 55 | + | |
35 | 56 |
| |
36 | 57 |
| |
37 | 58 |
| |
| |||
42 | 63 |
| |
43 | 64 |
| |
44 | 65 |
| |
45 |
| - | |
46 |
| - | |
| 66 | + | |
47 | 67 |
| |
48 | 68 |
| |
49 |
| - | |
| 69 | + | |
50 | 70 |
| |
51 | 71 |
| |
52 |
| - | |
| 72 | + | |
53 | 73 |
| |
54 | 74 |
| |
55 | 75 |
| |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
56 | 86 |
| |
57 | 87 |
| |
58 | 88 |
| |
|
0 commit comments
Comments
(0)