Skip to content

adding_verbose_option #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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