Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
And some more cleanups.
The removed comment in backend_agg regarding rgb came in in 281b7b7, but
is now irrelevant.
  • Loading branch information
anntzer committed Jul 9, 2017
commit 79cfe14466900dea1ad10176e4c644a09da5c6f7
12 changes: 5 additions & 7 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,17 +694,17 @@ def _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath):

def get_text_width_height_descent(self, s, prop, ismath):
"""
get the width and height, and the offset from the bottom to the
baseline (descent), in display coords of the string s with
:class:`~matplotlib.font_manager.FontProperties` prop
Get the width, height, and descent (offset from the bottom
to the baseline), in display coords, of the string *s* with
:class:`~matplotlib.font_manager.FontProperties` *prop*
"""
if ismath == 'TeX':
# todo: handle props
size = prop.get_size_in_points()
texmanager = self._text2path.get_texmanager()
fontsize = prop.get_size_in_points()
w, h, d = texmanager.get_text_width_height_descent(s, fontsize,
renderer=self)
w, h, d = texmanager.get_text_width_height_descent(
s, fontsize, renderer=self)
return w, h, d

dpi = self.points_to_pixels(72)
Expand Down Expand Up @@ -2151,7 +2151,6 @@ def print_figure(self, filename, dpi=None, facecolor=None, edgecolor=None,
# the backend to support file-like object, i'm going
# to leave it as it is. However, a better solution
# than stringIO seems to be needed. -JJL
#result = getattr(self, method_name)
result = print_method(
io.BytesIO(),
dpi=dpi,
Expand Down Expand Up @@ -2203,7 +2202,6 @@ def print_figure(self, filename, dpi=None, facecolor=None, edgecolor=None,
_bbox_inches_restore = None

try:
#result = getattr(self, method_name)(
result = print_method(
filename,
dpi=dpi,
Expand Down
13 changes: 5 additions & 8 deletions lib/matplotlib/backends/backend_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,17 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):

def get_text_width_height_descent(self, s, prop, ismath):
"""
get the width and height in display coords of the string s
with FontPropertry prop

# passing rgb is a little hack to make caching in the
# texmanager more efficient. It is not meant to be used
# outside the backend
Get the width, height, and descent (offset from the bottom
to the baseline), in display coords, of the string *s* with
:class:`~matplotlib.font_manager.FontProperties` *prop*
"""
if rcParams['text.usetex']:
# todo: handle props
size = prop.get_size_in_points()
texmanager = self.get_texmanager()
fontsize = prop.get_size_in_points()
w, h, d = texmanager.get_text_width_height_descent(s, fontsize,
renderer=self)
w, h, d = texmanager.get_text_width_height_descent(
s, fontsize, renderer=self)
return w, h, d

if ismath:
Expand Down
12 changes: 0 additions & 12 deletions lib/matplotlib/backends/backend_cairo.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,18 +549,6 @@ def _save(self, fo, fmt, **kwargs):

self.figure.draw(renderer)

show_fig_border = False # for testing figure orientation and scaling
if show_fig_border:
ctx.new_path()
ctx.rectangle(0, 0, width_in_points, height_in_points)
ctx.set_line_width(4.0)
ctx.set_source_rgb(1,0,0)
ctx.stroke()
ctx.move_to(30,30)
ctx.select_font_face('sans-serif')
ctx.set_font_size(20)
ctx.show_text('Origin corner')

ctx.show_page()
surface.finish()
if fmt == 'svgz':
Expand Down