Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite3236e9

Browse files
committed
Remove used_characters tracking in mathtext.
Backends that need to track what characters have been used (pdf/ps, forsubsetting purposes) already have their own logic to do so, so don't doit in mathtext as well.Changes in Fonts are only touching private API.Changes in the call signature of MathtextBackendAgg/MathtextBackendPathlook like they are touching public API, but it is in fact impossible foran external user to construct a valid `box` parameter (this requiresclasses defined in `_mathtext`), so `get_results` is effectively privateAPI from a caller PoV. It is also impossible to register newMathtextBackends without touching private API.Thus, the only difference is in the tuple returned byMathtextBackendAgg, which now has one fewer element. Because the returnvalue is a tuple which is unpacked at the call site, it is not possibleto emit a proper deprecation warning (one would need to know whether theresult is being unpacked to 6 or 7 values). Callers can work aroundthis by e.g. unpacking the last item into `*_`. Note that because thisis only for MathtextBackendAgg (i.e., a raster backend), it is unlikelythat callers actually care about the used_characters info at all.
1 parent1101b8e commite3236e9

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
``MathtextBackendAgg.get_results`` no longer returns ``used_characters``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
The last item (``used_characters``) in the tuple returned by
4+
``MathtextBackendAgg.get_results`` has been removed. In order to unpack this
5+
tuple in a backward and forward-compatible way, use e.g.
6+
``ox, oy, width, height, descent, image, *_ = parse(...)``,
7+
which will ignore ``used_characters`` if it was present.

‎lib/matplotlib/_mathtext.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def __init__(self, default_font_prop, mathtext_backend):
8989
"""
9090
self.default_font_prop=default_font_prop
9191
self.mathtext_backend=mathtext_backend
92-
self.used_characters= {}
9392

9493
defget_kern(self,font1,fontclass1,sym1,fontsize1,
9594
font2,fontclass2,sym2,fontsize2,dpi):
@@ -147,7 +146,6 @@ def render_glyph(self, ox, oy, font, font_class, sym, fontsize, dpi):
147146
parameters (see `get_metrics` for their detailed description).
148147
"""
149148
info=self._get_info(font,font_class,sym,fontsize,dpi)
150-
self.used_characters.setdefault(info.font.fname,set()).add(info.num)
151149
self.mathtext_backend.render_glyph(ox,oy,info)
152150

153151
defrender_rect_filled(self,x1,y1,x2,y2):
@@ -169,14 +167,6 @@ def get_underline_thickness(self, font, fontsize, dpi):
169167
"""
170168
raiseNotImplementedError()
171169

172-
defget_used_characters(self):
173-
"""
174-
Get the set of characters that were used in the math
175-
expression. Used by backends that need to subset fonts so
176-
they know which glyphs to include.
177-
"""
178-
returnself.used_characters
179-
180170
defget_sized_alternatives_for_symbol(self,fontname,sym):
181171
"""
182172
Override if your font provides multiple sizes of the same

‎lib/matplotlib/backends/backend_agg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def draw_path(self, gc, path, transform, rgbFace=None):
211211

212212
defdraw_mathtext(self,gc,x,y,s,prop,angle):
213213
"""Draw mathtext using :mod:`matplotlib.mathtext`."""
214-
ox,oy,width,height,descent,font_image,used_characters= \
214+
ox,oy,width,height,descent,font_image= \
215215
self.mathtext_parser.parse(s,self.dpi,prop)
216216

217217
xd=descent*sin(radians(angle))
@@ -260,7 +260,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
260260
returnw,h,d
261261

262262
ifismath:
263-
ox,oy,width,height,descent,fonts,used_characters= \
263+
ox,oy,width,height,descent,font_image= \
264264
self.mathtext_parser.parse(s,self.dpi,prop)
265265
returnwidth,height,descent
266266

‎lib/matplotlib/mathtext.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def render_rect_filled(self, x1, y1, x2, y2):
134134
y=int(y1)
135135
self.image.draw_rect_filled(int(x1),y,np.ceil(x2),y+height)
136136

137-
defget_results(self,box,used_characters):
137+
defget_results(self,box):
138138
self.mode='bbox'
139139
orig_height=box.height
140140
orig_depth=box.depth
@@ -152,8 +152,7 @@ def get_results(self, box, used_characters):
152152
self.width,
153153
self.height+self.depth,
154154
self.depth,
155-
self.image,
156-
used_characters)
155+
self.image)
157156
self.image=None
158157
returnresult
159158

@@ -182,7 +181,7 @@ def render_glyph(self, ox, oy, info):
182181
defrender_rect_filled(self,x1,y1,x2,y2):
183182
self.rects.append((x1,self.height-y2,x2-x1,y2-y1))
184183

185-
defget_results(self,box,used_characters):
184+
defget_results(self,box):
186185
_mathtext.ship(0,0,box)
187186
returnself._Result(self.width,
188187
self.height+self.depth,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp