Skip to content

Commit

Permalink
Support old matplotlib by font.getsize
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed Feb 14, 2023
1 parent b56fedf commit 5732284
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion imgviz/draw/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ def text_size(text, size, font_path=None):
lines = text.splitlines()
n_lines = len(lines)
longest_line = max(lines, key=len)
width, height = font.getbbox(longest_line)[2:]
if hasattr(font, "getbbox"):
width, height = font.getbbox(longest_line)[2:]
else:
width, height = font.getsize(longest_line)
return height * n_lines, width


Expand Down

0 comments on commit 5732284

Please sign in to comment.