8000 Better document the semantics of get_text_width_height_descent. · matplotlib/matplotlib@5d480c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5d480c5

Browse files
committed
Better document the semantics of get_text_width_height_descent.
Including whitespace seems to be the current behavior for agg and makes right-alignment works as it does. It is also necessary to make e.g. the currently PR'ed rainbow_text (based on `annotation(..., xycoords=textobj)` implementation work. Documenting the behavior is in particular useful for third-party backend implementers (mplcairo got this wrong previously).
1 parent f6a781f commit 5d480c5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,9 +636,10 @@ def _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath):
636636

637637
def get_text_width_height_descent(self, s, prop, ismath):
638638
"""
639-
Get the width, height, and descent (offset from the bottom
640-
to the baseline), in display coords, of the string *s* with
641-
`.FontProperties` *prop*.
639+
Get the width, height, and descent (offset from the bottom to the baseline), in
640+
display coords, of the string *s* with `.FontProperties` *prop*.
641+
642+
Whitespace at the start and the end of *s* is included in the reported width.
642643
"""
643644
fontsize = prop.get_size_in_points()
644645

0 commit comments

Comments
 (0)
0