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

Skip to content

Commit 005cfde

Browse files
committed
Merge pull request #4031 from mdboom/font-advance-width
API : Font advance width This resets _all_ of the images with text.
2 parents 86e5e65 + f8dc710 commit 005cfde

File tree

978 files changed

+63555
-75245
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

978 files changed

+63555
-75245
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2015-01-23 Text bounding boxes are now computed with advance width rather than
2+
ink area. This may result in slightly different placement of text.
3+
14
2014-10-27 Allowed selection of the backend using the `MPLBACKEND` environment
25
variable. Added documentation on backend selection methods.
36

lib/matplotlib/backends/backend_agg.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,15 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
202202
font.draw_glyphs_to_bitmap(antialiased=rcParams['text.antialiased'])
203203
d = font.get_descent() / 64.0
204204
# The descent needs to be adjusted for the angle
205+
xo, yo = font.get_bitmap_offset()
206+
xo /= 64.0
207+
yo /= 64.0
205208
xd = -d * np.sin(np.deg2rad(angle))
206209
yd = d * np.cos(np.deg2rad(angle))
207210

208211
#print x, y, int(x), int(y), s
209212
self._renderer.draw_text_image(
210-
font, np.round(x - xd), np.round(y + yd) + 1, angle, gc)
213+
font, np.round(x - xd + xo), np.round(y + yd + yo) + 1, angle, gc)
211214

212215
def get_text_width_height_descent(self, s, prop, ismath):
213216
"""
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_axes/axhspan_epoch.svg

Lines changed: 67 additions & 63 deletions
Loading
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_axes/axvspan_epoch.svg

Lines changed: 67 additions & 63 deletions
Loading
Binary file not shown.
Loading

0 commit comments

Comments
 (0)