Version 1.20.3
Bluetooth
This release bumps the MicroPython version we're building against from 1.20
to 856e08b1931b88271816a2f60648f6ff332235b2
and includes various Bluetooth-related libraries into our build. Bluetooth support should be at feature parity with the official MicroPython release. Read more about it at https://www.raspberrypi.com/news/new-functionality-bluetooth-for-pico-w/
A Knowledge Of Font
Many of you expressed a desire to work with bitmap fonts outside of the rather uninspiring set we ship with PicoGraphics.
This has led to a couple of tweaks to PicoGraphics bitmap fonts. First up-
Fixed Width / Monospaced
All of out fonts conform to a fixed grid up to 16 pixels tall and - in theory - unlimited pixels wide. Within this grid, individual characters can have different widths which are computed when the font is generated and saved into the font data. This lets us calculate text widths really quickly and lets us squeeze characters up against each other to fit more on screen.
This is not, as it happens, ideal for displaying numbers. With "1" being narrower than "0", a real-time display of some variable could cause decimal places or larger numbers to jump erratically and be difficult to read. We've added a new fixed_width=
argument to text()
. Specify this when you draw text in MicroPython and all the characters will behave themselves and stay a fixed distance from each other.
How does it look? Well here's bitmap8
at 2x scale in both fixed and variable modes:
Custom Bitmap Fonts
Honestly, I don't know why I waited so long to make this happen. Our fonts are just data read from memory, and the code doesn't care if that memory is flash storage (built in fonts) or allocated by MicroPython (a bytearray in a .py file or a raw font loaded from user flash).
It's always been possible to use custom fonts in C, if you were determined enough to pick apart the font structure and painstakingly key in your own pixels.
And therein lies the problem. The biggest hurdle for users wanting custom fonts is preparing the font data. Our custom format is a little weird, mostly focusing on ASCII, plus some useful characters for - loosely - supporting languages other than British English and some even weirder diacritic mark support I glued on to sort-of support some unicode.
In typical fashion I decided to solve this "problem" by getting lost in a side project for viewing, editing and converting Pico Graphics fonts - pgfutil. It's extremely alpha, but you can find it here: https://github.com/gadgetoid/pgfutil
To load a custom bitmap font in PicoGraphics you just pass it into set_font()
. Eg:
display.set_font(open("font14.bitmapfont", "rb").read())
display.text("The quick brown fox jumps over the lazy dog", 10, 10, 240, 2)
An 8x8 font will cost you about 1k of RAM, and a 16x16 font around 3.6k. This is small compared to - for example - the 150k a 320x240 screen needs for 16-bit RGB but still big enough that you'll need to be careful how many fonts you use.
Font data is mutable, too. Do with that what you will 😆
Full Changelog: v1.20.2...v1.20.3
MicroPython changes: micropython/micropython@v1.20.0...856e08b