Skip to content

Commit

Permalink
adding_verbose_option
Browse files Browse the repository at this point in the history
  • Loading branch information
jposada202020 committed Feb 22, 2023
1 parent 55df0bf commit a467083
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
6 changes: 5 additions & 1 deletion adafruit_display_text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ class LabelBase(Group):
(4, " ") will indicate a tab replacement of 4 spaces, defaults to 4 spaces by
tab character
:param str label_direction: string defining the label text orientation. See the
subclass documentation for the possible values."""
subclass documentation for the possible values.
:param bool verbose: print debugging information in some internal functions. Default to False
"""

def __init__(
self,
Expand All @@ -243,6 +245,7 @@ def __init__(
base_alignment: bool = False,
tab_replacement: Tuple[int, str] = (4, " "),
label_direction: str = "LTR",
verbose: bool = False,
**kwargs, # pylint: disable=unused-argument
) -> None:
# pylint: disable=too-many-arguments, too-many-locals
Expand All @@ -266,6 +269,7 @@ def __init__(
self._label_direction = label_direction
self._tab_replacement = tab_replacement
self._tab_text = self._tab_replacement[1] * self._tab_replacement[0]
self._verbose = verbose

if "max_glyphs" in kwargs:
print("Please update your code: 'max_glyphs' is not needed anymore.")
Expand Down
25 changes: 15 additions & 10 deletions adafruit_display_text/bitmap_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ class Label(LabelBase):
tab character
:param str label_direction: string defining the label text orientation. There are 5
configurations possibles ``LTR``-Left-To-Right ``RTL``-Right-To-Left
``UPD``-Upside Down ``UPR``-Upwards ``DWR``-Downwards. It defaults to ``LTR``"""
``UPD``-Upside Down ``UPR``-Upwards ``DWR``-Downwards. It defaults to ``LTR``
:param bool verbose: print debugging information in some internal functions. Default to False
"""

# This maps label_direction to TileGrid's transpose_xy, flip_x, flip_y
_DIR_MAP = {
Expand Down Expand Up @@ -350,6 +353,7 @@ def _text_bounding_box(
final_y_offset_loose,
)

# pylint: disable = too-many-branches
def _place_text(
self,
bitmap: displayio.Bitmap,
Expand Down Expand Up @@ -418,19 +422,20 @@ def _place_text(
if y_blit_target < 0:
y_clip = -y_blit_target # clip this amount from top of bitmap
y_blit_target = 0 # draw the clipped bitmap at y=0

print(
'Warning: Glyph clipped, exceeds Ascent property: "{}"'.format(
char
if self._verbose:
print(
'Warning: Glyph clipped, exceeds Ascent property: "{}"'.format(
char
)
)
)

if (y_blit_target + my_glyph.height) > bitmap.height:
print(
'Warning: Glyph clipped, exceeds descent property: "{}"'.format(
char
if self._verbose:
print(
'Warning: Glyph clipped, exceeds descent property: "{}"'.format(
char
)
)
)

self._blit(
bitmap,
Expand Down

0 comments on commit a467083

Please sign in to comment.