|
Arduino Graphic LCD Library
|
#include <GlcdBitmapFont.h>

Classes | |
| struct | Header |
| Font header. More... | |
Public Member Functions | |
| GlcdBitmapFont (SeekableInputStream *inputStream) | |
| unsigned char | getInfo () |
| unsigned char | getCharacterWidth () |
| unsigned char | getCharacterHeight () |
| unsigned char | getSequenceCount () |
| unsigned char | getGlyphLength () |
| virtual unsigned char | readGlyphData (unsigned char *buf, char c) |
Protected Member Functions | |
| virtual unsigned int | getGlyphOffset (char c) |
Protected Attributes | |
| Header | header |
| unsigned char | glyphLength |
| SeekableInputStream * | inputStream |
| unsigned int | dataOffset |
Arduino Graphic LCD Library.
The representation of a glcd font.
Glcd bitmap font is an array which represents the font glyph as a bitmap.
This font has fixed glyph size.
The first bytes specify the font's information and glyph sequences;
Header example:
unsigned char info; unsigned char characterWidth; unsigned char characterHeight; unsigned char sequenceCount;
0x00, 0xww, 0xhh, 0xnn | | | |___ Sequence count | | |_________ Character height (in bits) | |_______________ Character width (in bits) |_____________________ Into
The next bytes, after the head, specify the sequences information, each sequence have 3 information:
unsigned char first; unsigned char last; unsigned char offset[msb]; unsigned char offset[lsb];
The sequence informations are followed one by another. Example: Considering a font with 2 sequences, this could be the sequence bytes:
0x20, 0x22, 0x00, 0xff, 0x40, 0x43, 0x0d, 0xff,
which means we have a sequence that starts with the 0x20 char and goes to the 0x22, and the glyph data are stored at the 0x00ff offset. Another sequence starts with the 0x40 char and goes to the 0x43, and the glyph data are stored at the 0x0dff offset.
File structure
Header organization:
+-------------------------+ | Font info | \ +-------------------------+ \ | Character width | \ +-------------------------+ } Header | Character height | / +-------------------------+ / | Sequence count | / +-------------------------+ | First character | \ +-------------------------+ \ | Last character | \ +-------------------------+ } Sequence #0 | Offset MSB | / +-------------------------+ / | Offset LSB | / +-------------------------+ | First character | \ +-------------------------+ \ | Last character | \ +-------------------------+ } Sequence #n | Offset MSB | / +-------------------------+ / | Offset LSB | / +-------------------------+ | | 0b00000000 | | 0b00000000 | | 0b00000000 | FONT DATA | 0b00000000 | ARRAY OF BYTES | 0b00000000 | | 0b00000000 | | 0b00000000 | | 0b00000000 +-------------------------+
Font data
Each character could have any multiple by 8 height. For characters which is 8 bits height, they are just made by bytes in sequence, as follows:
L L L L L
i i i i i
n n n n n
e e e e e
0 1 2 3 4 ...
+------------------------...
| b7 | b7 | b7 | b7 | b7 |
| b6 | b6 | b6 | b6 | b6 |
| b5 | b5 | b5 | b5 | b5 |
| b4 | b4 | b4 | b4 | b4 |
| b3 | b3 | b3 | b3 | b3 |
| b2 | b2 | b2 | b2 | b2 |
| b1 | b1 | b1 | b1 | b1 |
| b0 | b0 | b0 | b0 | b0 |
+------------------------...
Or, this is a character with width equals 5 and height equals 8: (can be the "T" letter)
+-+-+-+-+-+-+
|1|1|1|1|1|1| -> the MSB
|1|1|1|1|1|1|
|0|0|1|1|0|0|
|0|0|1|1|0|0|
|0|0|1|1|0|0|
|0|0|1|1|0|0|
|0|0|1|1|0|0|
|0|0|0|0|0|0| -> the LSB
+-+-+-+-+-+-+
Just when a character which has the height bigger than 8 that the things comes more difficult. For example, imagine if the above letter with w: 10 and h: 16.
+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+
|1|1|1|1|1|1|1|1|1|1|1|1| |0|0|0|0|1|1|1|1|0|0|0|0| -> the MSB
|1|1|1|1|1|1|1|1|1|1|1|1| |0|0|0|0|1|1|1|1|0|0|0|0|
|1|1|1|1|1|1|1|1|1|1|1|1| |0|0|0|0|1|1|1|1|0|0|0|0|
|1|1|1|1|1|1|1|1|1|1|1|1| |0|0|0|0|1|1|1|1|0|0|0|0|
|0|0|0|0|1|1|1|1|0|0|0|0| |0|0|0|0|1|1|1|1|0|0|0|0|
|0|0|0|0|1|1|1|1|0|0|0|0| |0|0|0|0|0|0|0|0|0|0|0|0|
|0|0|0|0|1|1|1|1|0|0|0|0| |0|0|0|0|0|0|0|0|0|0|0|0|
|0|0|0|0|1|1|1|1|0|0|0|0| |0|0|0|0|0|0|0|0|0|0|0|0| -> the LSB
+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+
The first 10 bytes are the top part of the character, and the las 10 bytes are the bottom part of the character.
Definition at line 161 of file GlcdBitmapFont.h.
| GlcdBitmapFont::GlcdBitmapFont | ( | SeekableInputStream * | inputStream | ) |
Public constructor.
| inputStream | The associated input stream. |
Definition at line 16 of file GlcdBitmapFont.cpp.
| unsigned char GlcdBitmapFont::getCharacterHeight | ( | ) |
Gets the character height.
Definition at line 34 of file GlcdBitmapFont.cpp.
| unsigned char GlcdBitmapFont::getCharacterWidth | ( | ) |
Gets the character width.
Definition at line 30 of file GlcdBitmapFont.cpp.
| unsigned char GlcdBitmapFont::getGlyphLength | ( | ) |
Gets the glyph length.
Definition at line 42 of file GlcdBitmapFont.cpp.
|
protectedvirtual |
Gets the offset to the given character.
| c | The character to be used. |
Definition at line 55 of file GlcdBitmapFont.cpp.
| unsigned char GlcdBitmapFont::getInfo | ( | ) |
| unsigned char GlcdBitmapFont::getSequenceCount | ( | ) |
Gets the sequence count.
Definition at line 38 of file GlcdBitmapFont.cpp.
|
virtual |
Gets the array of bytes representing the given character.
| buf | The buffer. |
| c | The character. |
Definition at line 46 of file GlcdBitmapFont.cpp.
|
protected |
|
protected |
Glyph length.
Definition at line 178 of file GlcdBitmapFont.h.
|
protected |
Definition at line 173 of file GlcdBitmapFont.h.
|
protected |
Input stream which font data comes from.
Definition at line 183 of file GlcdBitmapFont.h.