The adafruit_display_text library currently has two different types of label functions in it. This guide goes over those label functions and the differences between them. If you are less concerned about the details and just want to know which to use for your new project, go with BitmapLabel.

Label

Starting from CircuitPython 7.0.0 there is no longer a max_size restriction for Group objects.

This is the original Label class. Each glyph within the text is stored in its own Bitmap and TileGrid objects, and those all get put into a single Group object. In prior versions of CircuitPython there was a parameter max_glyphs that enforced a limitation in the underlying Group that limited the number of items in the Group. In CircuitPython 7.0.0 this limitation has been removed from Group and therefore also no longer applies to Label.

If you set a background_color, then the background will get its own TileGrid and Bitmap as well. The diagram above depicts a Label with no background Bitmap in it.

BitmapLabel

This is a newer class that was introduced more recently after many features were added into the original Label class. In the BitmapLabel, all of the glyphs are stored inside of a single Bitmap and TileGrid. This tends to result in lower memory usage, especially for long strings.

Starting from CircuitPython 7.0.0 there is no longer a max_size restriction for Group objects.

BitmapLabel typically will use a little bit less RAM -- it can be helpful sometimes in larger projects to switch from Label to BitmapLabel to save more RAM for your projects other needs.

OutlinedLabel

Starting with the release version 3.1.0 the Adafruit_Display_Text Library supports an OutlinedLabel which lets you make text with an outline stroke of a specified size and color.

Here is a screenshot of an OutlinedLabel with pink text color and green outline_color. The code below is an example of this.

text_area = OutlinedLabel(
    terminalio.FONT,
    text="Outlined\nLabel",
    color=0xFF00FF,
    outline_color=0x00FF00,
    outline_size=1,
    scale=5,
)

Scrolling Label

Starting with the release version 2.22.0 the Adafruit_Display_Text library supports ScrollingLabel. The ScrollingLabel class is a label that can have a specified maximum number of characters showing at a time and will scroll through a larger message, like a marquee.

The ScrollingLabel depicted above is initialized with the following code:

text = "Hello world CircuitPython scrolling label"
my_scrolling_label = ScrollingLabel(
    terminalio.FONT, 
    text=text, 
    max_characters=20, 
    animate_time=0.1, 
    scale=2
)
while True:
    my_scrolling_label.update()

Advanced Color Masking 

BitmapLabel can be used with None value for color and any opaque value for background_color to produce a transparent "cutout" of the text in the label. You can put rainbows or other interesting things in the background, and layer the BitmapLabel on top to produce fancy text graphics. See the example here.

This guide was first published on Mar 09, 2021. It was last updated on Jun 11, 2024.

This page (Types of Labels) was last updated on Mar 30, 2024.

Text editor powered by tinymce.