Skip to content

Conversation

@FoamyGuy
Copy link
Contributor

@FoamyGuy FoamyGuy commented Dec 3, 2025

This requires the bitmaptools.replace_color() function added here: adafruit/circuitpython#10732 so can only be used with absolute newest builds until next release is made.

Adds a new AccentLabel class that makes it possible use different foreground/background colors for specified ranges of text within the label.

I'm planning to use it most immediately for literary clock MagTag project to highlight the part of the book quote that contains the actual time.

The new example demonstrates its functionality. It looks like this when run:
image

@FoamyGuy
Copy link
Contributor Author

FoamyGuy commented Dec 4, 2025

The latest commit adds more convenient substring based APIs for adding/removing accent. It also updates the example to use them, and to demonstrate using more than one accent/color and removing an accent. Here is a recording of the new version of the example:

accent_label_demo.webm

@FoamyGuy FoamyGuy requested a review from a team December 4, 2025 14:59
Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if this could just be a part of BitmapLabel instead of being a separate subclass. I would say the same for OutlinedLabel and ScrollingLabel. I could imagine you want all these features at once.

@FoamyGuy
Copy link
Contributor Author

FoamyGuy commented Dec 4, 2025

That would be cool! I can work on it.

I had considered using the outline technique for the accent, but not the idea of combing it into one class that can do all of those functions. Scrolling + Accent together will be a little trickier due to having to consider the scroll offset when finding accented ranges, but should be doable still I think.

A future addition that might also be cool is multi-font so accented ranges could use an alternate font like bold or italic versions.

@FoamyGuy
Copy link
Contributor Author

FoamyGuy commented Dec 4, 2025

I'm working on a new branch for the combined version. I'll make a new PR when it's ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants