b62b0b7c05bae1dc5d8feb540a4cde0d5d97e38a
[bertos.git] / gfx / font.h
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
6  * Bertos is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * As a special exception, you may use this file as part of a free software
21  * library without restriction.  Specifically, if other files instantiate
22  * templates or use macros or inline functions from this file, or you compile
23  * this file and link it with other files to produce an executable, this
24  * file does not by itself cause the resulting executable to be covered by
25  * the GNU General Public License.  This exception does not however
26  * invalidate any other reasons why the executable file might be covered by
27  * the GNU General Public License.
28  *
29  * Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
30  *
31  * -->
32  *
33  * \version $Id$
34  *
35  * \author Stefano Fedrigo <aleph@develer.com>
36  *
37  * \brief Font 8x6 IBM-PC 8bit
38  */
39
40 /*#*
41  *#* $Log$
42  *#* Revision 1.7  2006/07/19 12:56:26  bernie
43  *#* Convert to new Doxygen style.
44  *#*
45  *#* Revision 1.6  2006/05/27 22:31:34  bernie
46  *#* Switch to a smaller default fount.
47  *#*
48  *#* Revision 1.5  2006/03/13 02:06:04  bernie
49  *#* FONT_HAS_GLYPH(): New macro.
50  *#*
51  *#* Revision 1.4  2006/02/15 09:10:15  bernie
52  *#* Implement prop fonts; Fix algo styles.
53  *#*
54  *#* Revision 1.3  2006/02/10 12:29:05  bernie
55  *#* Add multiple font support in bitmaps.
56  *#*
57  *#* Revision 1.2  2005/11/04 18:17:45  bernie
58  *#* Fix header guards and includes for new location of gfx module.
59  *#*
60  *#* Revision 1.1  2005/11/04 18:11:35  bernie
61  *#* Move graphics stuff from mware/ to gfx/.
62  *#*
63  *#* Revision 1.6  2005/04/11 19:10:28  bernie
64  *#* Include top-level headers from cfg/ subdir.
65  *#*
66  *#* Revision 1.5  2005/03/01 23:26:45  bernie
67  *#* Use new CPU-neutral program-memory API.
68  *#*
69  *#* Revision 1.4  2004/12/31 16:42:55  bernie
70  *#* Sanitize for non-Harvard processors.
71  *#*
72  *#* Revision 1.3  2004/08/25 14:12:09  rasky
73  *#* Aggiornato il comment block dei log RCS
74  *#*
75  *#* Revision 1.2  2004/06/03 11:27:09  bernie
76  *#* Add dual-license information.
77  *#*
78  *#* Revision 1.1  2004/05/23 15:43:16  bernie
79  *#* Import mware modules.
80  *#*
81  *#* Revision 1.2  2004/03/24 15:48:53  bernie
82  *#* Remove Copyright messages from Doxygen output
83  *#*
84  *#* Revision 1.1  2004/01/13 12:15:28  aleph
85  *#* Move font table in program memory; add font.h
86  *#*
87  *#*/
88 #ifndef GFX_FONT_H
89 #define GFX_FONT_H
90
91 #include <cfg/compiler.h> /* uint8_t */
92 #include <mware/pgm.h> /* PROGMEM */
93
94 typedef struct Font
95 {
96         /**
97          * Pointer to glyph data.
98          *
99          * Data is an array of at most 256 glyphs packed together.
100          * Raster format must be the same of the bitmap.
101          */
102         const PROGMEM uint8_t *glyph;
103
104         uint8_t width;     /**< Pixel width of character cell. */
105         uint8_t height;    /**< Pixel height of character cell. */
106
107         uint8_t first;     /**< First encoded character in glyph array. */
108         uint8_t last;      /**< Last encoded character in glyph array (inclusive). */
109
110         /** Array of glyph offsets in bytes. NULL for fixed-width fonts. */
111         const PROGMEM uint16_t *offset;
112         const PROGMEM uint8_t *widths;
113
114 } Font;
115
116
117 /** Return true if glyph \a c is available in \a font. */
118 #define FONT_HAS_GLYPH(font, c) ((c) >= (font)->first && (c) <= (font)->last)
119
120
121 /** The default font. */
122 #define default_font font_luBS14
123 extern const struct Font default_font;
124
125 #endif /* GFX_FONT_H */