PicoVector Fonts/Text for Micropython 1.20.6 Update (Tufty 2040)

I am sorry to report, or it just could be me, but 1.20.6 has not resolved my issue w/ PicoVector Text/Fonts. - The device will either freeze or display a grey screen; whenever I try to use any fonts/text via PictoVector.

It could be as simple as:

#IMPORT LIBRARIES
from picographics import PicoGraphics, DISPLAY_TUFTY_2040
from picovector import PicoVector, ANTIALIAS_NONE, ANTIALIAS_X4, ANTIALIAS_X16

#SET DISPLAY
display = PicoGraphics(display=DISPLAY_TUFTY_2040)

#SET VECTOR, ANTIALIASING & FONT TYPE {download.af fonts from resources above. Upload through Thonny in root "/" }
vector = PicoVector(display)
vector.set_antialiasing(ANTIALIAS_X4)
result = vector.set_font("Fonts/IndieFlower-Regular.af", 50)  #vector.setfont("font-name-directory",font-size-int)

#SET PALETTE
WHITE = display.create_pen(255,255,255)
BLACK = display.create_pen(0,0,0)

while True:

    #BLACK BG
    display.set_pen(BLACK)
    display.clear()
    
    #SET PEN AND DISPLAY TEXT - vector.text("TextHere",X,Y,ANGLEDEG)
    display.set_pen(WHITE)
    vector.text("Hello World!", 60, 90, 0)

    #UPDATE SCREEN
    display.update()

Even tried various examples (copy and paste, just to be sure I didn’t mistype), but nothing works. No issues with any of the clock examples. Being playing around with that.

I need help, please, with the PicoVector Text.

Did you flash_nuke / erase the flash before re flashing it?
It makes sure something isn’t being left behind.
It shouldn’t be needed, but I do it when I need a clean start to sort something out.
Raspberry Pi Documentation - Raspberry Pi Pico and Pico W

Nope!! – nuked it, then updated to 1.20.6. Same issue. Grey and/or frozen screen.

Just in case, I am losing it, is the script above correct??

But other then that, I am at a lose as to why I can’t run PicoVector Text.

I’ll give your code a try on my Tufty. Won’t be tonight though, been a rough week / day. Need to take it easy tonight. My chronic pain flared up a bit tonight. The Golden Years, pfft.

Copied and pasted the following @gadgetoid code: (black/grey frozen screen)

import time
import math
import random
import machine
from picographics import PicoGraphics, DISPLAY_TUFTY_2040, PEN_RGB332
from picovector import PicoVector, Polygon, RegularPolygon, Rectangle, ANTIALIAS_NONE, ANTIALIAS_X4, ANTIALIAS_X16

machine.freq(250_000_000)

display = PicoGraphics(DISPLAY_TUFTY_2040, pen_type=PEN_RGB332)
display.set_backlight(0.8)

vector = PicoVector(display)
vector.set_antialiasing(ANTIALIAS_NONE)


RED = display.create_pen(255, 0, 0)
ORANGE = display.create_pen(255, 128, 0)
YELLOW = display.create_pen(255, 255, 0)
GREEN = display.create_pen(0, 255, 0)
BLUE = display.create_pen(0, 0, 255)
VIOLET = display.create_pen(255, 0, 255)

BLACK = display.create_pen(0, 0, 0)
GREY = display.create_pen(128, 128, 128)
WHITE = display.create_pen(255, 255, 255)
result = vector.set_font("Fonts/OpenSans-Regular.af", 30)

WIDTH, HEIGHT = display.get_bounds()

X = int(WIDTH / 2)
Y = int(HEIGHT / 2)

a = 0

frames = 0

t_count = 0
t_total = 0

while True:
    tstart = time.ticks_ms()
    display.set_pen(BLACK)
    display.clear()
    for x in range(8):
        c = 31 + (x * 32)
        display.set_pen(display.create_pen(255-c, 0, c))
        vector.text("Hello World\nHello World", X, Y, angle=x * 45 + a)
    display.update()
    a += 1

    
    tfinish = time.ticks_ms()

    total = tfinish - tstart
    t_total += total
    t_count += 1

    if t_count == 60:
        per_frame_avg = t_total / t_count
        print(f"60 frames in {t_total}ms, avg {per_frame_avg:.02f}ms per frame, {1000/per_frame_avg:.02f} FPS")
        t_count = 0
        t_total = 0

    # pause for a moment (important or the USB serial device will fail)
    # try to pace at 60fps or 30fps
    if total > 1000 / 30:
        time.sleep(0.0001)
    elif total > 1000 / 60:
        t = 1000 / 30 - total
        time.sleep(t / 1000)
    else:
        t = 1000 / 60 - total
        time.sleep(t / 1000)
'''

Both bits of code above are working OK for me - double check you’ve got the font saved into to the correct directory on your Pico? Might also be worth checking that your Fonts directory is capitalised?

1 Like

Good Morning (or in your case Afternoon) Hel!!

Sadly, yes. The fonts directory is indeed capitalised. Even if I drop the fonts into the main directory, no go. Same issue all around - black/grey screen frozen (requires a reboot of device).

Cheers,
Tomas

As a note, if I mistype the name of the font or its directory name - it will error out before the program executes. – I tried to see what happens… yup… doesn’t even run.

I have no issues running non-font Vector graphics. The lovely circle you, (@hel), created works spot one. The clocks, also no issues. But introduce fonts, sorrow follows…

That’s really odd 🤔

Looks like you’ve got quite a lot of files there - you could try uploading just one font to your Tufty, in case you’re running out of space or it’s the number of files that’s causing MicroPython to fall over in some way?

Sadly, nope. I’ve deleted all the fonts, except one. Same issue. Device is stuck on a grey/black-lit screen.

#IMPORT LIBRARIES
from picographics import PicoGraphics, DISPLAY_TUFTY_2040
from picovector import PicoVector, ANTIALIAS_NONE, ANTIALIAS_X4, ANTIALIAS_X16

#SET DISPLAY
display = PicoGraphics(display=DISPLAY_TUFTY_2040)

#SET VECTOR, ANTIALIASING & FONT TYPE {download.af fonts from resources above. Upload through Thonny in root "/" }
vector = PicoVector(display)
vector.set_antialiasing(ANTIALIAS_X4)
result = vector.set_font("IndieFlower-Regular.af", 50)  #vector.setfont("font-name-directory",font-size-int)

#SET PALETTE
WHITE = display.create_pen(255,255,255)
BLACK = display.create_pen(0,0,0)

while True:

    #BLACK BG
    display.set_pen(BLACK)
    display.clear()
    
    #SET PEN AND DISPLAY TEXT - vector.text("TextHere",X,Y,ANGLEDEG)
    display.set_pen(WHITE)
    vector.text("Hello World!", 60, 90, 0)

    #UPDATE SCREEN
    display.update()

HOWEVER in this example, you can see the device itself is still processing (console output is filtering in) – but no screen:

import time
import math
import random
import machine
from picographics import PicoGraphics, DISPLAY_TUFTY_2040, PEN_RGB332
from picovector import PicoVector, Polygon, RegularPolygon, Rectangle, ANTIALIAS_NONE, ANTIALIAS_X4, ANTIALIAS_X16

machine.freq(250_000_000)

display = PicoGraphics(DISPLAY_TUFTY_2040, pen_type=PEN_RGB332)
display.set_backlight(0.8)

vector = PicoVector(display)
vector.set_antialiasing(ANTIALIAS_NONE)


RED = display.create_pen(255, 0, 0)
ORANGE = display.create_pen(255, 128, 0)
YELLOW = display.create_pen(255, 255, 0)
GREEN = display.create_pen(0, 255, 0)
BLUE = display.create_pen(0, 0, 255)
VIOLET = display.create_pen(255, 0, 255)

BLACK = display.create_pen(0, 0, 0)
GREY = display.create_pen(128, 128, 128)
WHITE = display.create_pen(255, 255, 255)
result = vector.set_font("IndieFlower-Regular.af", 30)

WIDTH, HEIGHT = display.get_bounds()

X = int(WIDTH / 2)
Y = int(HEIGHT / 2)

a = 0

frames = 0

t_count = 0
t_total = 0

while True:
    tstart = time.ticks_ms()
    display.set_pen(BLACK)
    display.clear()
    for x in range(8):
        c = 31 + (x * 32)
        display.set_pen(display.create_pen(255-c, 0, c))
        vector.text("Hello World\nHello World", X, Y, angle=x * 45 + a)
    display.update()
    a += 1

    
    tfinish = time.ticks_ms()

    total = tfinish - tstart
    t_total += total
    t_count += 1

    if t_count == 60:
        per_frame_avg = t_total / t_count
        print(f"60 frames in {t_total}ms, avg {per_frame_avg:.02f}ms per frame, {1000/per_frame_avg:.02f} FPS")
        t_count = 0
        t_total = 0

    # pause for a moment (important or the USB serial device will fail)
    # try to pace at 60fps or 30fps
    if total > 1000 / 30:
        time.sleep(0.0001)
    elif total > 1000 / 60:
        t = 1000 / 30 - total
        time.sleep(t / 1000)
    else:
        t = 1000 / 60 - total
        time.sleep(t / 1000)

image

I am at a total lose as to why this is happening…

🤔🤔🤔 Have you tried deleting your main.py in case that’s interfering with the other script in some way?

Other than that I’m stumped, might be worth dropping the details on the Pico Vector bugs thread: PicoVector · Issue #835 · pimoroni/pimoroni-pico · GitHub

I’ll try to run that code on my Tufty today.
It’s been a rough week for me. My wife had a fall and is in the hospital with a broken femur. A lot of stuff got put aside for a bit.

Oh gosh, hope she’s doing OK and has a swift recovery!

It’s going to be a very long recovery. The surgery for the broken femur is done. Knee replacement is next. Rehab will be a long process.

Can somebody post a link to the fonts etc? Brain is fried today.

:(

There’s some pre-converted Alright Fonts here: https://github.com/lowfatcode/alright-fonts/tree/main/sample-fonts

The following posted above worked for me. The font’s I found on github, but can’t find them now to post the link? What I downloaded was alright-fonts-main.zip

I’m deeply sorry to hear about your wife. My best to her. A very speed recovery.

1 Like

Ops, should have mentioned, I flash_nuked and then flashed with 120.6.
@Mad_Monk if you have specific code you’d like me to try, post it and I’ll try it.