I have a problem with the footprint of the Ug8Lib. When using the 3 fonts below, my sketch size explodes from 14800bytes to 31200 bytes. This means, that the footprint for the u8g is almost 17kb. Using the only the 10x20 font, the the sketch size is something like 20k - still making a 5k footprint. I know that those fonts are large/huge - but i need that large digits.
Is there a simple way to reduce the footprint of the u8g lib ? Well, i actualy can live with an "7 segment" font - so as workaround i'm thinking about rendering the digits with the drawing primitves. But if there is an easy way the reduce the footprint - i would obviously would prefere the simple way...
thanks for your quick reply - I was just experimenting with the scale2x2 before reading your answer
Using 25 resp 14 font sizes yields in an sketch-size of about 23k. Still a bit on the heavy size, but for the moment, it's giving me enough free memory to continue. the only "problem" is, that the charackters look a bit "rough" due to the scaling.
Yet another question: How do i "make" my own font ? Is there a tool for it ? I have the use the 14r instead of the 14n because i need to display a capital "N" - but thats the only charakter I need ? Is there a tool to create my own font ? (i.e. replacing the "+" with an "N")
olikraus:
The size in bytes of each font is given in the overview pictures. You could also use a smaller font (with lesser size) and the setScale2x2 command.
Oliver
Oliver, does u8glib support partial fonts?
That way, if a person only wants something like large numbers, they can trim the font down
to contain only the numbers.
I include a few large fixed width fonts in openGLCD that are only + through :
i.e.
, - . / 0 1 2 3 4 5 6 7 8 9 :
Very useful for many applications.
The font format used in openGLCD also supports holes
so you have some characters with no definition.
So not only do you have a range (start and end character in the font),
but you can also have no definition for some characters within the range.
If you have a font definition in front of the data, it is pretty simple
to support partial fonts, but if you don't have a font definition, then it becomes
a much bigger task to add one to all the fonts.
Yes, partial fonts are supported, however one extra byte will be required for each "left out" glyph. For example with the glyphs "a", "b", "d", the start character is "a", end is "d", but one extra byte will be required for the none existing "c".
In U8glib i decided to provide three variants of a font. These variants are:
XXX
XXXr
XXXn
where font XXX contains up to 255 glyphs, XXXr only contains glyphs from 32 to 127 and XXXn only contains some numbers and numerical operators. For example the font "chikita" with variant "r" only has the following glyphs:
The "n" variant looks like this:
The "n" contains sufficient chars to create time and date information: "01.01.2014" or "05:55".
For U8glib fonts are derived from the .bdf file format. A simple tool (bdf2u8g) will convert the .bdf file into the internal format. ".bdf" is a plain text format which has been defined by Adobe long time back (see here Glyph Bitmap Distribution Format - Wikipedia). The .bdf file can be modfied by any text editor.
Here is a part of the 4x6 font:
A glyph starts with the "STARTCHAR" command and are terminated with the "ENDCHAR" command. With your text editor, simply remove chars by deleting everything between and including STARTCHAR and ENDCHAR. Then rerun bdf2u8g.
There are still some tools (like fontforge) for updating the bdf format itself. This might be more comfortable to delete single glyphs.
Fonts within U8glib are derived either directly from .bdf or are converted from .ttf files.
Those fonts which are derived from .bdf files only, are located here Google Code Archive - Long-term storage for Google Code Project Hosting.. For the .ttf fonts, the .bdf file is not part of the u8glib repo, but i can attach the bdf file for further modification to this thread (fubXX fonts for example).
One final note on bdf2u8g and the internal font format: bdf2u8g also does a compression on the font data. It is not just a simple collection of fixed sized bitmap images.
Thanks for this post, Im trying to save space by trimming some fonts and this made it very easy. I was hoping you could attach the bdf files for a few fonts that are not in the repo. I'm looking for the following if possible.