Skip to content

Commit 9112015

Browse files
authored
Merge pull request #181 from jposada202020/adding_verbose_option
adding_verbose_option
2 parents 55df0bf + a467083 commit 9112015

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

adafruit_display_text/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ class LabelBase(Group):
221221
(4, " ") will indicate a tab replacement of 4 spaces, defaults to 4 spaces by
222222
tab character
223223
:param str label_direction: string defining the label text orientation. See the
224-
subclass documentation for the possible values."""
224+
subclass documentation for the possible values.
225+
:param bool verbose: print debugging information in some internal functions. Default to False
226+
"""
225227

226228
def __init__(
227229
self,
@@ -243,6 +245,7 @@ def __init__(
243245
base_alignment: bool = False,
244246
tab_replacement: Tuple[int, str] = (4, " "),
245247
label_direction: str = "LTR",
248+
verbose: bool = False,
246249
**kwargs, # pylint: disable=unused-argument
247250
) -> None:
248251
# pylint: disable=too-many-arguments, too-many-locals
@@ -266,6 +269,7 @@ def __init__(
266269
self._label_direction = label_direction
267270
self._tab_replacement = tab_replacement
268271
self._tab_text = self._tab_replacement[1] * self._tab_replacement[0]
272+
self._verbose = verbose
269273

270274
if "max_glyphs" in kwargs:
271275
print("Please update your code: 'max_glyphs' is not needed anymore.")

adafruit_display_text/bitmap_label.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ class Label(LabelBase):
8080
tab character
8181
:param str label_direction: string defining the label text orientation. There are 5
8282
configurations possibles ``LTR``-Left-To-Right ``RTL``-Right-To-Left
83-
``UPD``-Upside Down ``UPR``-Upwards ``DWR``-Downwards. It defaults to ``LTR``"""
83+
``UPD``-Upside Down ``UPR``-Upwards ``DWR``-Downwards. It defaults to ``LTR``
84+
:param bool verbose: print debugging information in some internal functions. Default to False
85+
86+
"""
8487

8588
# This maps label_direction to TileGrid's transpose_xy, flip_x, flip_y
8689
_DIR_MAP = {
@@ -350,6 +353,7 @@ def _text_bounding_box(
350353
final_y_offset_loose,
351354
)
352355

356+
# pylint: disable = too-many-branches
353357
def _place_text(
354358
self,
355359
bitmap: displayio.Bitmap,
@@ -418,19 +422,20 @@ def _place_text(
418422
if y_blit_target < 0:
419423
y_clip = -y_blit_target # clip this amount from top of bitmap
420424
y_blit_target = 0 # draw the clipped bitmap at y=0
421-
422-
print(
423-
'Warning: Glyph clipped, exceeds Ascent property: "{}"'.format(
424-
char
425+
if self._verbose:
426+
print(
427+
'Warning: Glyph clipped, exceeds Ascent property: "{}"'.format(
428+
char
429+
)
425430
)
426-
)
427431

428432
if (y_blit_target + my_glyph.height) > bitmap.height:
429-
print(
430-
'Warning: Glyph clipped, exceeds descent property: "{}"'.format(
431-
char
433+
if self._verbose:
434+
print(
435+
'Warning: Glyph clipped, exceeds descent property: "{}"'.format(
436+
char
437+
)
432438
)
433-
)
434439

435440
self._blit(
436441
bitmap,

0 commit comments

Comments
 (0)