Pico Display Pack 2 - Adding Fonts

A simple question - is there an easy way (ie without having to compile a new uf2 firmware file) to add another font when using a Pico and Display Pack 2?

I’m pondering a project which would benefit from some symbols being displayed to indicate button functions. Most simple would be adding something like FontAwesome or similar. Easy to do on a Pi, but not so easy I think on a Pico?

Running stuff under MicroPython, currently using the Pimoroni uf2 file.

Have a look at this:
Adding a font to ebook.py (Badger) - Support - Pimoroni Buccaneers

If want any special new characters just work out the bit pattern and substitute for one you do not use.

This might also help:

It is pure MicroPython and should be pretty easy to port over.

If you only want a few symbols you can just create them and place them in position. I will give it a go. How big do they need to be? 32x32 pixels should be OK?

3 Likes

Thanks @Tonygo2 - looks like what I was after.

Yes I would just want a few, and can make them up based on the existing font symbols.
They don’t need to be large - 32x32 should be fine.

Will dig into your linked pages at the weekend and take it from there.

Here is an example on the Display 2

# Display User Symbols on the Display2 screen
# Tony Goodhew 16th March 2023
import time

from picographics import PicoGraphics, DISPLAY_PICO_DISPLAY_2, get_buffer_size, PEN_RGB332
from pimoroni import RGBLED
# Reduced colours to save RAM
display = PicoGraphics(display=DISPLAY_PICO_DISPLAY_2, pen_type=PEN_RGB332, rotate=0)
display.set_backlight(0.8)
display.set_font("bitmap8") # Lower case included

led = RGBLED(6, 7, 8)
led.set_rgb(0,0,0)     # Turn RGBLED OFF

powers =[]
z = 1
for i in range(32):
    powers.append(z)
    z = z * 2

# Define a 32x32 pixel symbol
test1 = [0b11111111111111111111111111111111,
         0b11000000000000000000000000000001,
         0b10100000000000000000000000000001,
         0b10010000000000000000000000000001,
         0b10001000000000000000000000000001,
         0b10000100000000000000000000000001,
         0b10000010000000000000000000000001,
         0b10000001000000000000000000000001,
         0b10000000100000000000000000000001,
         0b10000000010000000000000000000001,
         0b10000000001000000000000000000001,
         0b10000000000100000000000000000001,
         0b10000000000010000000000000000001,
         0b10000000000001000000000000000001,
         0b10000000000000100000000000000001,
         0b10000000000000010000000000000001,
         0b10000000000000001000000000000001,
         0b10000000000000000100000000000001,
         0b10000000000000000010000000000001,
         0b10000000000000000001000000000001,
         0b10000000000000000000100000000001,
         0b10000000000000000000010000000001,
         0b10000000000000000000001000000001,
         0b10000000000000000000000100000001,
         0b10000000000000000000000010000001,
         0b10000000000000000000000001000001,
         0b10000000000000000000000000100001,
         0b10000000000000000000000000010001,
         0b10000000000000000000000000001001,
         0b10000000000000000000000000000101,
         0b10000000000000000000000000000011,
         0b11111111111111111111111111111111]

# Place a symbol on the screen
def symbol(t,xoff,yoff):
    for yy in range(32):
        line = t[yy]
        for xx in range(32):
            xxx = 31 - xx
            if (line & powers[xxx]) == powers[xxx]:
                display.set_pen(255)
            else:
                display.set_pen(0)        
            display.pixel(xx + xoff, yy +yoff)


symbol(test1,0,46)
symbol(test1,0,160)
symbol(test1,319-32,48)
symbol(test1,319-32,162)
display.update()

3 Likes

You sir are a gentleman and a scholar - that will do very nicely for what I have planned.

Many thanks :D