diff options
author | Christian Vogel <vogelchr@vogel.cx> | 2010-10-11 20:49:39 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2012-02-03 23:59:35 +0100 |
commit | 45d88fa052995da4fb77deb72ddf1597cfdb058c (patch) | |
tree | 9f9f144c5bf8913ef7d1d4fa4e3d76d3209b8c16 /src/target/firmware/include | |
parent | 41eed0ee31a11815c07bf4b789d723ee73dc20cd (diff) |
Calypso FB: 8 Fonts, header file and utility functions.
I only activate two fonts, Helvetica Regular 8pt and bold
14pt because the others bloat the binary too much.
Diffstat (limited to 'src/target/firmware/include')
-rw-r--r-- | src/target/firmware/include/fb/font.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/target/firmware/include/fb/font.h b/src/target/firmware/include/fb/font.h new file mode 100644 index 00000000..680ee476 --- /dev/null +++ b/src/target/firmware/include/fb/font.h @@ -0,0 +1,80 @@ +#ifndef _FB_FONT_H +#define _FB_FONT_H + +#include <stdint.h> +#include <unistd.h> + +/* + Example: + Font Helvetica 14 + + + Character W ('X' and '.' is the character font data) + + X.....X......&... + X.....X......X... + X....X.X.....X... + .X...X.X....X.... + .X...X.X....X.... + .X...X.X....X.... + ..X.X....X.X..... + ..X.X....X.X..... + ..X.X....X.X..... + ...X......X...... + @%..X......X...$.. + <---dwidth----> + + @ is the cursor position (origin) for this character + $ is the cursor position (origin) for the next character + % is the character boundingbox origin, + & is the character boundingbox top right corner + + */ + +/* data for char c is found by getting the index into the + chardata array from the charoffs array. + + if charoffs[c] == FB_FONT_NOCHAR, then this glyph does + not exist! Better use the convenience function fb_font_get_char below! */ + +#define FB_FONT_NOCHAR 0xffff + +struct fb_font { + int8_t height; /* total height of font */ + int8_t ascent; /* topmost pixel is "ascend" above + current cursor position y */ + uint8_t firstchar,lastchar; /* range of characters in font (iso8859-1) */ + uint8_t const *chardata; + uint16_t const *charoffs; /* byte offsets relative to chardata */ + uint8_t const *widths; /* widths for characters */ +}; + +struct fb_char { + int8_t width; + int8_t bbox_w,bbox_h,bbox_x,bbox_y; + uint8_t data[0]; +}; + +/* there are currently 6 fonts available, Helvetica 8, 14, 24 point + in bold and regular shapes. The following enum has to match the + order of the array fb_fonts in framebuffer.c! +*/ + +enum fb_font_id { +// FB_FONT_4X6, +// FB_FONT_5X8, + FB_FONT_HELVR08, +// FB_FONT_HELVR14 +// FB_FONT_HELVR24, +// FB_FONT_HELVB08, + FB_FONT_HELVB14, +// FB_FONT_HELVB24 +}; + +extern const struct fb_font *fb_fonts[]; // note: has to match fb_font_id enum! + +extern const struct fb_char * +fb_font_get_char(const struct fb_font *fnt,unsigned char c); + +#endif + |