Commit 02c5f49
committed
Fix notdef handling when subsetting Type 1 fonts
There's no guarantee that `.notdef` will appear as character code 0 in
the encoding table [1], so always inserting it there may clobber an
existing glyph. And in fact, with the strange encoding of Computer
Modern, its symbol font _does_ have an entry in 0 for the minus sign.
We only actually need `.notdef` in the `todo` list of charstrings to
simulate, not in the `encoding` dictionary (which is only used again in
`_postscript_encoding`, and that specifically ignores `.notdef`), so
move it there.
Also, fix an inefficiency when simulating charstrings: once we simulate
a glyph, it should be added to the `done` set immediately, otherwise it
remains on the `todo` set, and gets simulated a second time (or possibly
more since the set may `pop` in any order.)
[1] See the Adobe Type 1 Font Format specification in
https://adobe-type-tools.github.io/font-tech-notes/pdfs/T1_SPEC.pdf
which says that "A Type 1 font program must have a `.notdef`
character defined in its CharStrings dictionary, even if it is not
referenced by the encoding vector." but does _not_ say it must be 0.1 parent 1cba207 commit 02c5f49
4 files changed
Lines changed: 8 additions & 7 deletions
File tree
- lib/matplotlib
- tests
- baseline_images/test_usetex
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
866 | 866 | | |
867 | 867 | | |
868 | 868 | | |
869 | | - | |
870 | 869 | | |
871 | | - | |
| 870 | + | |
872 | 871 | | |
873 | 872 | | |
874 | 873 | | |
875 | 874 | | |
876 | 875 | | |
| 876 | + | |
877 | 877 | | |
878 | 878 | | |
879 | | - | |
880 | 879 | | |
881 | 880 | | |
882 | 881 | | |
| |||
949 | 948 | | |
950 | 949 | | |
951 | 950 | | |
952 | | - | |
| 951 | + | |
| 952 | + | |
953 | 953 | | |
954 | 954 | | |
955 | 955 | | |
| |||
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
0 commit comments