From 28dbc663769069b01d852796b124fcd923ff3c6c Mon Sep 17 00:00:00 2001 From: kozova1 Date: Mon, 1 Feb 2021 12:12:38 +0200 Subject: [PATCH] drivers: draw565: Added bounding_box() function that returns the size of a string. This function returns a tuple of (width, height) of the string, as it would appear if used in draw.string() Signed-off-by: kozova1 --- wasp/draw565.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wasp/draw565.py b/wasp/draw565.py index 884d1a8..f82a345 100644 --- a/wasp/draw565.py +++ b/wasp/draw565.py @@ -330,6 +330,14 @@ class Draw565(object): if width: self.fill(bg, x, y, rightpad, h) + def bounding_box(self, s): + """Return the bounding box of a string. + + :param s: A string + :returns: Tuple of (width, height) + """ + return _bounding_box(s, self._font) + def wrap(self, s, width): """Chunk a string so it can rendered within a specified width.