-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Remove uses of font.get_charmap #5410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+13
−16
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -63,5 +63,4 @@ | |
|
||
print(dir(font)) | ||
|
||
cmap = font.get_charmap() | ||
print(font.get_kerning) |
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
|
@@ -883,13 +883,12 @@ def get_char_width(charcode): | |
# Make the "Differences" array, sort the ccodes < 255 from | ||
# the multi-byte ccodes, and build the whole set of glyph ids | ||
# that we need from this font. | ||
cmap = font.get_charmap() | ||
glyph_ids = [] | ||
differences = [] | ||
multi_byte_chars = set() | ||
for c in characters: | ||
ccode = c | ||
gind = cmap.get(ccode) or 0 | ||
gind = font.get_char_index(ccode) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
glyph_ids.append(gind) | ||
glyph_name = font.get_glyph_name(gind) | ||
if ccode <= 255: | ||
|
@@ -999,12 +998,11 @@ def embedTTFType42(font, characters, descriptor): | |
# Make the 'W' (Widths) array, CidToGidMap and ToUnicode CMap | ||
# at the same time | ||
cid_to_gid_map = ['\u0000'] * 65536 | ||
cmap = font.get_charmap() | ||
widths = [] | ||
max_ccode = 0 | ||
for c in characters: | ||
ccode = c | ||
gind = cmap.get(ccode) or 0 | ||
gind = font.get_char_index(ccode) | ||
glyph = font.load_char(ccode, flags=LOAD_NO_HINTING) | ||
widths.append((ccode, glyph.horiAdvance / 6)) | ||
if ccode < 65536: | ||
|
@@ -2010,7 +2008,6 @@ def draw_text_woven(chunks): | |
between chunks of 1-byte characters and 2-byte characters. | ||
Only used for Type 3 fonts.""" | ||
chunks = [(a, ''.join(b)) for a, b in chunks] | ||
cmap = font.get_charmap() | ||
|
||
# Do the rotation and global translation as a single matrix | ||
# concatenation up front | ||
|
@@ -2040,7 +2037,7 @@ def draw_text_woven(chunks): | |
lastgind = None | ||
for c in chunk: | ||
ccode = ord(c) | ||
gind = cmap.get(ccode) | ||
gind = font.get_char_index(ccode) | ||
if gind is not None: | ||
if mode == 2 and chunk_type == 2: | ||
glyph_name = font.get_glyph_name(gind) | ||
|
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is out of date and should have been removed in #5299.