adafruit_display_text.label

Displays text labels using CircuitPython’s displayio.

  • Author(s): Scott Shawcroft

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_display_text.label.Label(font, *, x=0, y=0, text='', max_glyphs=None, color=16777215, background_color=None, line_spacing=1.25, background_tight=False, padding_top=0, padding_bottom=0, padding_left=0, padding_right=0, anchor_point=None, anchored_position=None, scale=1, **kwargs)

A label displaying a string of text. The origin point set by x and y properties will be the left edge of the bounding box, and in the center of a M glyph (if its one line), or the (number of lines * linespacing + M)/2. That is, it will try to have it be center-left as close as possible.

Parameters:
  • font (Font) – A font class that has get_bounding_box and get_glyph. Must include a capital M for measuring character size.
  • text (str) – Text to display
  • max_glyphs (int) – The largest quantity of glyphs we will display
  • color (int) – Color of all text in RGB hex
  • line_spacing (double) – Line spacing of text to display
anchor_point

Point that anchored_position moves relative to. Tuple with decimal percentage of width and height. (E.g. (0,0) is top left, (1.0, 0.5): is middle right.)

anchored_position

Position relative to the anchor_point. Tuple containing x,y pixel coordinates.

background_color

Color of the background as an RGB hex number.

bounding_box

An (x, y, w, h) tuple that completely covers all glyphs. The first two numbers are offset from the x, y origin of this group

color

Color of the text as an RGB hex number.

font

Font to use for text display.

line_spacing

The amount of space between lines of text, in multiples of the font’s bounding-box height. (E.g. 1.0 is the bounding-box height)

scale

Set the scaling of the label, in integer values

text

Text to display.

bitmap_label

Text graphics handling for CircuitPython, including text boxes

  • Author(s): Kevin Matocha

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_display_text.bitmap_label.Label(font, x=0, y=0, text='', max_glyphs=None, color=16777215, background_color=None, line_spacing=1.25, background_tight=False, padding_top=0, padding_bottom=0, padding_left=0, padding_right=0, anchor_point=None, anchored_position=None, save_text=True, scale=1, **kwargs)

A label displaying a string of text that is stored in a bitmap. Note: This bitmap_label.py library utilizes a bitmap to display the text. This method is memory-conserving relative to label.py. The max_glyphs parameter is ignored and is present only for direct compatability with label.py.

For further reduction in memory usage, set save_text=False (text string will not be stored and line_spacing and font are immutable with save_text set to False).

The origin point set by x and y properties will be the left edge of the bounding box, and in the center of a M glyph (if its one line), or the (number of lines * linespacing + M)/2. That is, it will try to have it be center-left as close as possible.

Parameters:
  • font (Font) – A font class that has get_bounding_box and get_glyph. Must include a capital M for measuring character size.
  • text (str) – Text to display
  • max_glyphs (int) – Unnecessary parameter (provided only for direct compability

with label.py) :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 boolean background_tight: Set True only if you want background box to tightly surround text :param int padding_top: Additional pixels added to background bounding box at top :param int padding_bottom: Additional pixels added to background bounding box at bottom :param int padding_left: Additional pixels added to background bounding box at left :param int padding_right: Additional pixels added to background bounding box at right :param (double,double) anchor_point: Point that anchored_position moves relative to.

Tuple with decimal percentage of width and height. (E.g. (0,0) is top left, (1.0, 0.5): is middle right.)
Parameters:anchored_position ((int,int)) – Position relative to the anchor_point. Tuple

containing x,y pixel coordinates. :param int scale: Integer value of the pixel scaling :param bool save_text: Set True to save the text string as a constant in the

label structure. Set False to reduce memory use.
anchor_point

Point that anchored_position moves relative to. Tuple with decimal percentage of width and height. (E.g. (0,0) is top left, (1.0, 0.5): is middle right.)

anchored_position

Position relative to the anchor_point. Tuple containing x,y pixel coordinates.

background_color

Color of the background as an RGB hex number.

bounding_box

An (x, y, w, h) tuple that completely covers all glyphs. The first two numbers are offset from the x, y origin of this group

color

Color of the text as an RGB hex number.

font

Font to use for text display.

line_spacing

The amount of space between lines of text, in multiples of the font’s bounding-box height. (E.g. 1.0 is the bounding-box height)

scale

Set the scaling of the label, in integer values

text

Text to displayed.