Skip to content

CircuitPython Support for Package Resource Files #6356

Open
@shulltronics

Description

@shulltronics

Background

Hi, I'm working on a package called unigui that wraps displayio functionality into a widget set for use on CircuitPython boards as well as general-purpose computers and single-board computers via Blinka.

Problem

In addition to terminalio.FONT, I would like to have other built-in fonts distributed with my package. I'm accomplishing this for CPython by including BDF font files in my package and using the pkgutil module in the standard library to get their path and load them at runtime using adafruit_bitmap_font.load_font. See this for examples. However, this solution relies on a module that isn't available in CircuitPython.

Possible Solutions

Is there any way to reference static package resource files in CircuitPython? Ideally it would work in CPython as well, so that the package doesn't need any platform-dependent logic. One possible solution inspired by the above link might be to implement the pkgutil module in CircuitPython. Another might be to do the same thing as terminalio.FONT, where I somehow compile in the loaded font as a member of my module, accessible, for example, via unigui.FONT0. It seems like terminalio.FONT is compiled into the CircuitPython executable though, and I'm not sure how I would accomplish that for my package.

Moving Forward

If there already exists a solution for this problem, please let me know. Otherwise, if either of the above options seems feasible, I would be interested in working on them. I'm also open to other ideas for solutions. Thanks for the time and any guidance you can provide!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions