Skip to content

Commit c22614e

Browse files
committed
Merge pull request #5412 from tacaswell/cp_font_cmap
Merge pull request #5410 from mdboom/get-charmap-removal
2 parents a340827 + c9fbfab commit c22614e

File tree

6 files changed

+13
-16
lines changed

6 files changed

+13
-16
lines changed

examples/misc/ftface_props.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,4 @@
6363

6464
print(dir(font))
6565

66-
cmap = font.get_charmap()
6766
print(font.get_kerning)

lib/matplotlib/_mathtext_data.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
"""
22
font data tables for truetype and afm computer modern fonts
33
"""
4-
# this dict maps symbol names to fontnames, glyphindex. To get the
5-
# glyph index from the character code, you have to use get_charmap
64
from __future__ import (absolute_import, division, print_function,
75
unicode_literals)
86

lib/matplotlib/backends/backend_pdf.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -883,13 +883,12 @@ def get_char_width(charcode):
883883
# Make the "Differences" array, sort the ccodes < 255 from
884884
# the multi-byte ccodes, and build the whole set of glyph ids
885885
# that we need from this font.
886-
cmap = font.get_charmap()
887886
glyph_ids = []
888887
differences = []
889888
multi_byte_chars = set()
890889
for c in characters:
891890
ccode = c
892-
gind = cmap.get(ccode) or 0
891+
gind = font.get_char_index(ccode)
893892
glyph_ids.append(gind)
894893
glyph_name = font.get_glyph_name(gind)
895894
if ccode <= 255:
@@ -999,12 +998,11 @@ def embedTTFType42(font, characters, descriptor):
999998
# Make the 'W' (Widths) array, CidToGidMap and ToUnicode CMap
1000999
# at the same time
10011000
cid_to_gid_map = ['\u0000'] * 65536
1002-
cmap = font.get_charmap()
10031001
widths = []
10041002
max_ccode = 0
10051003
for c in characters:
10061004
ccode = c
1007-
gind = cmap.get(ccode) or 0
1005+
gind = font.get_char_index(ccode)
10081006
glyph = font.load_char(ccode, flags=LOAD_NO_HINTING)
10091007
widths.append((ccode, glyph.horiAdvance / 6))
10101008
if ccode < 65536:
@@ -2011,7 +2009,6 @@ def draw_text_woven(chunks):
20112009
between chunks of 1-byte characters and 2-byte characters.
20122010
Only used for Type 3 fonts."""
20132011
chunks = [(a, ''.join(b)) for a, b in chunks]
2014-
cmap = font.get_charmap()
20152012

20162013
# Do the rotation and global translation as a single matrix
20172014
# concatenation up front
@@ -2041,7 +2038,7 @@ def draw_text_woven(chunks):
20412038
lastgind = None
20422039
for c in chunk:
20432040
ccode = ord(c)
2044-
gind = cmap.get(ccode)
2041+
gind = font.get_char_index(ccode)
20452042
if gind is not None:
20462043
if mode == 2 and chunk_type == 2:
20472044
glyph_name = font.get_glyph_name(gind)

lib/matplotlib/backends/backend_ps.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,15 +762,14 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
762762
ps_name = ps_name.encode('ascii', 'replace').decode('ascii')
763763
self.set_font(ps_name, prop.get_size_in_points())
764764

765-
cmap = font.get_charmap()
766765
lastgind = None
767766
#print 'text', s
768767
lines = []
769768
thisx = 0
770769
thisy = 0
771770
for c in s:
772771
ccode = ord(c)
773-
gind = cmap.get(ccode)
772+
gind = font.get_char_index(ccode)
774773
if gind is None:
775774
ccode = ord('?')
776775
name = '.notdef'
@@ -1138,10 +1137,9 @@ def print_figure_impl():
11381137
for font_filename, chars in six.itervalues(ps_renderer.used_characters):
11391138
if len(chars):
11401139
font = get_font(font_filename)
1141-
cmap = font.get_charmap()
11421140
glyph_ids = []
11431141
for c in chars:
1144-
gind = cmap.get(c) or 0
1142+
gind = font.get_char_index(c)
11451143
glyph_ids.append(gind)
11461144

11471145
fonttype = rcParams['ps.fonttype']

lib/matplotlib/tests/test_font_manager.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import os
88

9-
from matplotlib.font_manager import findfont, FontProperties
9+
from matplotlib.font_manager import (findfont, FontProperties, get_font)
1010
from matplotlib import rc_context
1111

1212

@@ -17,3 +17,9 @@ def test_font_priority():
1717
font = findfont(
1818
FontProperties(family=["sans-serif"]))
1919
assert_equal(os.path.basename(font), 'cmmi10.ttf')
20+
21+
# Smoketest get_charmap, which isn't used internally anymore
22+
font = get_font(font)
23+
cmap = font.get_charmap()
24+
assert len(cmap) == 131
25+
assert cmap[8729] == 30

lib/matplotlib/textpath.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ def get_glyphs_with_font(self, font, s, glyph_map=None,
173173

174174
# Mostly copied from backend_svg.py.
175175

176-
cmap = font.get_charmap()
177176
lastgind = None
178177

179178
currx = 0
@@ -192,7 +191,7 @@ def get_glyphs_with_font(self, font, s, glyph_map=None,
192191

193192
for c in s:
194193
ccode = ord(c)
195-
gind = cmap.get(ccode)
194+
gind = font.get_char_index(ccode)
196195
if gind is None:
197196
ccode = ord('?')
198197
gind = 0

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy