Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
44d6aed
Raise an error if a required method if not overridden when called
lesamouraipourpre Jul 8, 2021
381a890
Remove references to 'max_glyphs' from __init__ and bitmap_label, it …
lesamouraipourpre Jul 8, 2021
60590f1
Refactor line_spacing
lesamouraipourpre Jul 8, 2021
9552fdc
Refactor background_tight
lesamouraipourpre Jul 8, 2021
64a7d3e
Refactor x & y
lesamouraipourpre Jul 8, 2021
889679e
Refactor padding
lesamouraipourpre Jul 8, 2021
6eb5dd0
Refactor padding
lesamouraipourpre Jul 8, 2021
ff473a4
Refactor save_text
lesamouraipourpre Jul 8, 2021
31ad121
Refactor tab_replacement
lesamouraipourpre Jul 8, 2021
b259e6b
Refactor label_direction
lesamouraipourpre Jul 9, 2021
c4d43e2
Refactor color, background_color & palette
lesamouraipourpre Jul 9, 2021
fb75d66
Refactor base_alignment
lesamouraipourpre Jul 9, 2021
4bef392
Refactor anchor_point & anchored_position
lesamouraipourpre Jul 9, 2021
3f9a6b6
Refactor max_glyphs away (Closes #131)
lesamouraipourpre Jul 9, 2021
48357d4
Refactor local_group to a protected variable.
lesamouraipourpre Jul 9, 2021
068599c
Remove and update all pylint disables
lesamouraipourpre Jul 9, 2021
aedccd9
Reduce unnecessary kwarg usage
lesamouraipourpre Jul 10, 2021
915b360
Minor tweaks to advanced example
lesamouraipourpre Jul 10, 2021
95a822a
Refactor label __init__
lesamouraipourpre Jul 10, 2021
46fec3a
Refactor baseline
lesamouraipourpre Jul 10, 2021
d557cf8
Refactor bitmap
lesamouraipourpre Jul 10, 2021
a001c02
Refactor width & height
lesamouraipourpre Jul 10, 2021
5014b3d
Refactor tilegrid
lesamouraipourpre Jul 10, 2021
58c6644
Refactor boolean to bool
lesamouraipourpre Jul 10, 2021
fbe1fbd
Tweak the PyPortal example to specify the Font directory
lesamouraipourpre Jul 15, 2021
adddcf2
Add height & width properties to LabelBase
lesamouraipourpre Jul 15, 2021
b3acf4f
Print a message if max_glyphs is passed in
lesamouraipourpre Jul 15, 2021
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
Prev Previous commit
Next Next commit
Refactor line_spacing
  • Loading branch information
lesamouraipourpre committed Jul 8, 2021
commit 60590f1540fd92dbedde04a33368c3f8e3643e34
1 change: 1 addition & 0 deletions adafruit_display_text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def __init__(
super().__init__(x=x, y=y, scale=1)

self._font = font
self._line_spacing = line_spacing
self._ascent, self._descent = self._get_ascent_descent()
self.palette = Palette(2)
self._color = color
Expand Down
13 changes: 6 additions & 7 deletions adafruit_display_text/bitmap_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Label(LabelBase):
:param str text: Text to display
:param int color: Color of all text in RGB hex
:param int background_color: Color of the background, use `None` for transparent
:param double line_spacing: Line spacing of text to display
:param float line_spacing: Line spacing of text to display
:param boolean background_tight: Set `True` only if you want background box to tightly
surround text. When set to 'True' Padding parameters will be ignored.
:param int padding_top: Additional pixels added to background bounding box at top
Expand Down Expand Up @@ -116,7 +116,7 @@ def __init__(self, font, **kwargs) -> None:
x=kwargs.get("x", 0),
y=kwargs.get("y", 0),
text=kwargs.get("text", ""),
line_spacing=kwargs.get("line_spacing", 1.25),
line_spacing=self._line_spacing,
background_tight=kwargs.get("background_tight", False),
padding_top=kwargs.get("padding_top", 0),
padding_bottom=kwargs.get("padding_bottom", 0),
Expand Down Expand Up @@ -228,7 +228,6 @@ def _reset_text(
) = self._text_bounding_box(
self._text,
self._font,
self._line_spacing,
) # calculate the box size for a tight and loose backgrounds

if self._background_tight:
Expand All @@ -251,7 +250,6 @@ def _reset_text(
self.bitmap,
self._text,
self._font,
self._line_spacing,
self._padding_left - x_offset,
self._padding_top + y_offset,
)
Expand Down Expand Up @@ -325,7 +323,7 @@ def _line_spacing_ypixels(font, line_spacing: float) -> int:
return return_value

def _text_bounding_box(
self, text: str, font, line_spacing: float
self, text: str, font
) -> Tuple[int, int, int, int, int, int]:
ascender_max, descender_max = self._ascent, self._descent

Expand All @@ -342,6 +340,7 @@ def _text_bounding_box(
y_offset_tight = self._ascent // 2

newline = False
line_spacing = self._line_spacing

for char in text:

Expand Down Expand Up @@ -406,14 +405,13 @@ def _place_text(
bitmap,
text: str,
font,
line_spacing: float,
xposition: int,
yposition: int,
text_palette_index: int = 1,
background_palette_index: int = 0,
skip_index: int = 0, # set to None to write all pixels, other wise skip this palette index
# when copying glyph bitmaps (this is important for slanted text
# where rectangulary glyph boxes overlap)
# where rectangular glyph boxes overlap)
) -> Tuple[int, int, int, int]:
# placeText - Writes text into a bitmap at the specified location.
#
Expand All @@ -425,6 +423,7 @@ def _place_text(
left = None
right = x_start
top = bottom = y_start
line_spacing = self._line_spacing

for char in text:

Expand Down
1 change: 0 additions & 1 deletion adafruit_display_text/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def __init__(self, font, **kwargs) -> None:
self.y = kwargs.get("y", 0)

self.height = self._font.get_bounding_box()[1]
self._line_spacing = kwargs.get("line_spacing", 1.25)
self._bounding_box = None

self._background_tight = kwargs.get(
Expand Down