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 <mug66kk@gmail.com>
This commit is contained in:
kozova1 2021-02-01 12:12:38 +02:00
parent a124734ff2
commit 28dbc66376
No known key found for this signature in database
GPG key ID: 31C3892918C1DEFC

View file

@ -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.