forked from matplotlib/matplotlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Type1Font._tokens into a top-level function _tokenize that is a coroutine. The parsing stage consuming the tokens can instruct the tokenizer to return a binary token - this is necessary when decrypting the CharStrings and Subrs arrays, since the preceding context determines which 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 the function, since passing the information about binary tokens would not easily 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 have token-specific helper methods. The position data will be needed when modifying the file, as the font is transformed or subsetted. A new helper function _expression can be used to consume tokens that form a balanced subexpression delimited by [] or {}. This helps fix a bug in UniqueID removal: if the font includes PostScript code that checks if the UniqueID is set in the current dictionary, the previous code broke that code instead of removing the UniqueID definition. Fonts can include UniqueID in the encrypted portion as well as the cleartext one, and removal is now done in both portions. Fix a bug related to font weight: the key is title-cased and not lower-cased, so font.prop['weight'] should not exist.
- Loading branch information
Showing
5 changed files
with
744 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
The Courier10PitchBT-Bold.pfb file is a Type-1 version of | ||
Courier 10 Pitch BT Bold by Bitstream, obtained from | ||
<https://ctan.org/tex-archive/fonts/courierten>. It is included | ||
here as test data only, but the following license applies. | ||
|
||
|
||
(c) Copyright 1989-1992, Bitstream Inc., Cambridge, MA. | ||
|
||
You are hereby granted permission under all Bitstream propriety rights | ||
to use, copy, modify, sublicense, sell, and redistribute the 4 Bitstream | ||
Charter (r) Type 1 outline fonts and the 4 Courier Type 1 outline fonts | ||
for any purpose and without restriction; provided, that this notice is | ||
left intact on all copies of such fonts and that Bitstream's trademark | ||
is acknowledged as shown below on all unmodified copies of the 4 Charter | ||
Type 1 fonts. | ||
|
||
BITSTREAM CHARTER is a registered trademark of Bitstream Inc. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
``Type1Font`` objects include more properties | ||
--------------------------------------------- | ||
|
||
The `.type1font.Type1Font.prop` dictionary now includes more keys, such | ||
as ``CharStrings`` and ``Subrs``. The value of the ``Encoding`` key is | ||
now a dictionary mapping codes to glyph names. The | ||
`.type1font.Type1Font.transform` method now correctly removes | ||
``UniqueID`` properties from the font. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.