Custom font with u8glib

Hi,

I'm making a power (voltage/current) sensor for a solar panel and displaying it on a 128x64 OLED. It works great, I'm using the u8glib library with the u8g_font_helvB24 font to display the wattage (see attachment, I'll fix the negative amps soon!).

However when including the whole u8g_font_helvB24 font, my sketch uses 27 348 bytes (89%) because it includes all the chars and symbols. But I only need the numbers and the letter W. There's a numbers-only version of the font (u8g_font_helvB24n) which is much smaller, when using it my sketch is down to 16 536 bytes (53%) but it only shows the number without the letter W.

How could I make a version of the u8g_font_helvB24n font that includes the letter W? I looked at the code, but it's not commented so I don't know which codes represent what letter...

Thanks a lot,
Guillaume

Hi.

Have a look at u8glib github page (click !)
You can learn a lot over there.
Also have a look at this part of that site
You can select a font there, and click on the link next to it.
You will see a page that tells you all you need to know about that font.
And you'll see all characters in there, and at what position the characters are.

After that you could extract the characters you need ("W"), and replace a character you don't need, or add it.
You'd create your own font for your application.
Some testing will be required.

Be aware of the licence that come with these fonts, and be sure you comply with it.

@gfk:
Each font comes with three variants: full, reduced and numbers only. As MAS3 pointed out details should be listed on the wiki page. You could use "u8g_font_helvB24r" to use the reduced font (however, this will still include a-z and A-Z). helvB24 has 11K, helvB24r has around 5K, helvB24n has only 800 Bytes (see the wiki page).

In order to create a custom font, which only includes the chars you really need, you have to modify the font source.
Download the font source (bdf file) from here: https://raw.githubusercontent.com/olikraus/u8glib/master/tools/font/bdf/helvB24.bdf

Remove all chars, which are not required for your project. Use a normal plain texteditor for this. Chars start with the keyword "STARTCHAR" and end with "ENDCHAR".

Use bdf2u8g_101.exe to convert the bdf file to a u8glib readable array.
See bdf2u8g · olikraus/u8glib Wiki · GitHub for details.

Download bdf2u8g here: U8glib - Google Drive

Oliver