Presto font for GBP (£) sign

Sorry if this has been answered elsewhere but searching for GBP or the £ character is doomed to failure.

I am using my lovely Presto to display my realtime energy statistics using the wonderful Octopus Home Mini and their graphQL API.

I started with the agile_pricing_display.py example. It’s basically working, but how to I display the £ sign? Just using vector.text(“£”) doesn’t display anything (and also doesn’t throw an error. However printing using display.text(“£”) does work.

I suppose the Roboto-Medium.af font file either doesn’t include the £ sign, or it is mapped somewhere else. Is there an easy way to print it? Or do I have to work out how to make a custom .af file with the £ sign included?

Many thanks!!

I believe the fonts generated in the .af format only offer a limited subset of characters. You should be able to generate these fonts according to your needs with the afinate command documented in the alright-fonts documentation (see the --characters option).

Thanks for your positive and helpful response.

I have managed to make a custom .af file using the instructions on https://github.com/pimoroni/presto/blob/main/docs/picovector.md. The alright branch name is now feature/port-to-c17 rather than just port-to-c17. I downloaded the fonts from https://fonts.google.com/. The resulting .af file is recognised by micropython in the Presto but unfortunately something is not right. The scaling is wrong (too big) and there are mistakes (eg the 9 is infilled and many characters including the £ sign have gaps. I’ll keep at it and let you know if I find out how to clean it up.

So I have got it working well enough for my needs.

The size issue is simple - I had not realised the significance of the second argument of vector.set_font(“fontFile.af”, 24). It is the font size.

I only needed a £ sign in addition to the characters in the included font file (Roboto-Medium.af) so I made a new font file from the google Roboto-Medium.ttf that includes the £ sign (u0163), then by switching to that font just before the vector.text(“£”,x,y) command and back again for the rest of the line, everything is OK. int(vector.measure_text(“£”)[2]) gives the width to add on to the x starting point for the following text.

I can live with the slightly misformed £ sign.

Hope this helps someone.