removed comments and re-ran black

This commit is contained in:
Margaret Matocha 2020-06-05 20:24:03 -05:00
parent f8c69dbe6b
commit 2efbd77edd

View file

@ -97,17 +97,15 @@ class Label(displayio.Group):
self.palette.make_transparent(0)
self.palette[1] = color
self._background_color = background_color
# bounds = self._font.get_bounding_box()
self.height = self._font.get_bounding_box()[1]
self._line_spacing = line_spacing
self._boundingbox = None
self._background_tight = (
background_tight # sets padding status for text background
background_tight # sets padding status for text background box
)
self._background_color = background_color
self._background_palette = displayio.Palette(1)
self.append(
displayio.TileGrid(
@ -146,9 +144,7 @@ class Label(displayio.Group):
ascender_max = max(ascender_max, this_glyph.height + this_glyph.dy)
descender_max = max(descender_max, -this_glyph.dy)
box_width = (
self._boundingbox[2] + self._padding_left + self._padding_right
) # left + right padding
box_width = self._boundingbox[2] + self._padding_left + self._padding_right
x_box_offset = -self._padding_left
box_height = (
(ascender_max + descender_max)
@ -204,9 +200,7 @@ class Label(displayio.Group):
glyph = self._font.get_glyph(ord(character))
if not glyph:
continue
right = max(
right, x + glyph.shift_x
) # studied the docs! This is the correct spacing
right = max(right, x + glyph.shift_x)
if y == 0: # first line, find the Ascender height
top = min(top, -glyph.height - glyph.dy + y_offset)
bottom = max(bottom, y - glyph.dy + y_offset)
@ -267,49 +261,6 @@ class Label(displayio.Group):
self.pop()
self._text = new_text
self._boundingbox = (left, top, left + right, bottom - top)
# if self._background_tight: # draw a tight bounding box
# box_width = self._boundingbox[2]
# box_height = self._boundingbox[3]
# x_box_offset = 0
# y_box_offset = top
# else: # draw a "loose" bounding box to include any ascenders/descenders.
# # check a few glyphs for maximum ascender and descender height
# # Enhancement: it would be preferred to access the font "FONT_ASCENT" and
# # "FONT_DESCENT" in the imported BDF file
# glyphs = "M j'" # choose glyphs with highest ascender and lowest
# # descender, will depend upon font used
# ascender_max = descender_max = 0
# for char in glyphs:
# this_glyph = self._font.get_glyph(ord(char))
# ascender_max = max(ascender_max, this_glyph.height + this_glyph.dy)
# descender_max = max(descender_max, -this_glyph.dy)
# box_width = self._boundingbox[2] + self._padding_left + self._padding_right
# x_box_offset = -self._padding_left
# box_height = (
# (ascender_max + descender_max)
# + int((lines - 1) * self.height * self._line_spacing)
# + self._padding_top
# + self._padding_bottom
# )
# y_box_offset = -ascender_max + y_offset - self._padding_top
# self._update_background_color(self._background_color)
# box_width = max(0, box_width) # remove any negative values
# box_height = max(0, box_height) # remove any negative values
# background_bitmap = displayio.Bitmap(box_width, box_height, 1)
# tile_grid = displayio.TileGrid(
# background_bitmap,
# pixel_shader=self._background_palette,
# x=left + x_box_offset,
# y=y_box_offset,
# )
# self[0] = tile_grid # update the background bitmap in first item of the group
self[0] = self._create_background_box(lines, y_offset)
@property