eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_font.h
Go to the documentation of this file.
1 /**************************************************************************
2 *
3 * Copyright 2014 by Petr Gargulak. eGUI Community.
4 * Copyright 2009-2013 by Petr Gargulak. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License Version 3
9 * or later (the "LGPL").
10 *
11 * As a special exception, the copyright holders of the eGUI project give you
12 * permission to link the eGUI sources with independent modules to produce an
13 * executable, regardless of the license terms of these independent modules,
14 * and to copy and distribute the resulting executable under terms of your
15 * choice, provided that you also meet, for each linked independent module,
16 * the terms and conditions of the license of that module.
17 * An independent module is a module which is not derived from or based
18 * on this library.
19 * If you modify the eGUI sources, you may extend this exception
20 * to your version of the eGUI sources, but you are not obligated
21 * to do so. If you do not wish to do so, delete this
22 * exception statement from your version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 *
28 * You should have received a copy of the GNU General Public License
29 * and the GNU Lesser General Public License along with this program.
30 * If not, see <http://www.gnu.org/licenses/>.
31 *
32 ***************************************************************************/
46 #ifndef __D4D_FONT_H
47 #define __D4D_FONT_H
48 
49 /******************************************************************************
50 * Includes
51 ******************************************************************************/
52 
53 /******************************************************************************
54 * D4D FONTS setting constants
55 *
56 */
62 #ifndef D4D_FNT_EXTSRC_SUPPORT
63  #define D4D_FNT_EXTSRC_SUPPORT D4D_FALSE
64 #endif
65 
68 /******************************************************************************
69 * D4D FONTS types
70 *
71 */
85 #define D4D_FNT_PRTY_UNDERLINE_MASK (0x03)
86 #define D4D_FNT_PRTY_UNDERLINE_NONE_MASK (0x00)
87 #define D4D_FNT_PRTY_UNDERLINE_LINE_MASK (0x01)
88 #define D4D_FNT_PRTY_UNDERLINE_DOT_MASK (0x02)
89 #define D4D_FNT_PRTY_UNDERLINE_RES_MASK (0x03)
90 /* @} */
91 
103 #define D4D_FNT_PRTY_STRIKETHROUGH_MASK (0x0C)
104 #define D4D_FNT_PRTY_STRIKETHROUGH_NONE_MASK (0x00)
105 #define D4D_FNT_PRTY_STRIKETHROUGH_SINGLE_MASK (0x04)
106 #define D4D_FNT_PRTY_STRIKETHROUGH_DOUBLE_MASK (0x08)
107 #define D4D_FNT_PRTY_STRIKETHROUGH_TRIPLE_MASK (0x0C)
108 
109 #define D4D_FNT_PRTY_STRIKETHROUGH_SHIFT (0x02)
110 /* @} */
111 
112 #define D4D_FNT_PRTY_TRANSPARENT_MASK (0x10)
113 #define D4D_FNT_PRTY_TRANSPARENT_NO_MASK (0x00)
114 #define D4D_FNT_PRTY_TRANSPARENT_YES_MASK (0x10)
115 
117 
120 /******************************************************************************
121 * Internal types
122 ******************************************************************************/
123 #define D4D_FONT_PACK_BITORDER 0x01
124 #define D4D_FONT_PACK_BITORDER_BIGEND 0
125 #define D4D_FONT_PACK_BITORDER_LITTLEEND 0x01
126 
127 #define D4D_FONT_PACK_SCANBASED 0x02
128 #define D4D_FONT_PACK_SCANBASED_ROW 0
129 #define D4D_FONT_PACK_SCANBASED_COLUMN 0x02
130 
131 #define D4D_FONT_PACK_SCANPREFERRED 0x04
132 #define D4D_FONT_PACK_SCANPREFERRED_ROW 0
133 #define D4D_FONT_PACK_SCANPREFERRED_COLUMN 0x04
134 
135 #define D4D_FONT_PACK_COMPRESSED 0x08
136 #define D4D_FONT_PACK_COMPRESSED_OFF 0
137 #define D4D_FONT_PACK_COMPRESSED_ON 0x08
138 
139 #define D4D_FONT_PACK_DATA_LEN 0x030
140 #define D4D_FONT_PACK_DATA_LEN_8B 0x00
141 #define D4D_FONT_PACK_DATA_LEN_16B 0x10
142 #define D4D_FONT_PACK_DATA_LEN_32B 0x20
143 
144 #define D4D_FONT_FLAGS_IX_STYLE 0x01
145 #define D4D_FONT_FLAGS_IX_STYLE_LINEAR 0x00
146 #define D4D_FONT_FLAGS_IX_STYLE_NONLINEAR 0x01
147 
148 #define D4D_FONT_FLAGS_IX_TYPE 0x02
149 #define D4D_FONT_FLAGS_IX_TYPE_LOOKUP 0x00
150 #define D4D_FONT_FLAGS_IX_TYPE_MAP 0x02
151 
152 #define D4D_FONT_FLAGS_FNT_WIDTH 0x04
153 #define D4D_FONT_FLAGS_FNT_WIDTH_MONOSPACE 0x00
154 #define D4D_FONT_FLAGS_FNT_WIDTH_PROPORTIONAL 0x04
155 
156 
157 
160 
161 #ifdef D4D_UNICODE
162  typedef D4D_TCHAR D4D_FONT_IX;
163  typedef Word D4D_FONT_REV;
164 #else
165  typedef Byte D4D_FONT_IX;
167 #endif
168 
171 typedef Byte D4D_FONT;
172 
173 
176 
177 #pragma pack (push)
178 #pragma pack (1)
179 
180  typedef struct
181  {
185 
186  typedef struct D4D_FONT_DESCRIPTOR_S
187  {
188  D4D_FONT_REV revision; //1 Font descriptor version number
189  D4D_FONT_FLAGS flags; //1 linear / non linear , proporcional or not,
190  D4D_FONT_IX startChar; //2/1 start char of used table
191  D4D_FONT_IX charCnt; //2/1 end char of used table
192  D4D_FONT_IX charDefault; //2/1 index of char that will be printed instead of
193  D4D_FONT_SIZE charSize; //1 Font size (size of font loaded in PC)
194  D4D_FONT_DSIZE charBmpSize; //2 Size of font bitmpap for non proportional fonts
195  D4D_FONT_SIZE charBaseLine; //1 offset from Y0 coordinate to baseline
196  D4D_FONT_SIZES charFullSize; //2 size of biggest char x/y
197  D4D_FONT_PACK pack; //1 packing condition of individual bitmaps 15
198  const D4D_FONT_IX *pIxTable; // Index table - is used when nonlinearIX is set in flags, flags also determine the type of IxTable
199  const D4D_FONT_OFFSET *pOffTable; // Offset table - used when proporcial font is set in flags
200  const D4D_FONT_SIZE *pSizeTable; // Size table - used when proporcial font is set in flags
201  const D4D_FONT_DATA *pFontData; // bitmap/font data array
202  const struct D4D_FONT_DESCRIPTOR_S* pNext; // pointer on next page for this font (used in unicode)
204 
205 #pragma pack (pop)
206 
207 typedef struct
208 {
211  D4D_FONT_SIZES scale; // the scale of the font in both axes values must be > 0
212  D4D_FONT_SIZES charSpacing; // increment for finest cell in x/y to provide line/char spacing
215 
216 typedef struct{
229 
230 /******************************************************************************
231 * Macros
232 ******************************************************************************/
233 
234 #define D4D_DECLARE_USR_FONT_TABLE_BEGIN(name) const D4D_FONT_TYPE name[] = {
235 
236 #define D4D_DECLARE_FONT_TABLE_BEGIN D4D_DECLARE_USR_FONT_TABLE_BEGIN(d4d_FontTable)
237 
238 
239 
240 #define D4D_DECLARE_FONT(fontId, font_descriptor, xScale, yScale, charSpace, lineSpace) \
241 {fontId, (D4D_FONT_DESCRIPTOR*)&(font_descriptor), { xScale, yScale }, { charSpace, lineSpace }, NULL}, // font info will be replaced by font descriptor
242 
243 #define D4D_DECLARE_FONT_FILE(fontId, fileName, xScale, yScale, charSpace, lineSpace) \
244 {fontId, NULL, { xScale, yScale }, { charSpace, lineSpace }, fileName}, // font info will be replaced by font descriptor
245 
246 
247 #define D4D_DECLARE_FONT_TABLE_END {0, NULL, {0, 0}, {0, 0}, NULL } };
248 
249 /******************************************************************************
250 * Global variables
251 ******************************************************************************/
252 
253 extern const D4D_FONT_TYPE d4d_FontTable[];
254 
255 /******************************************************************************
256 * Global functions
257 ******************************************************************************/
258 
259 void D4D_SetFontTable(D4D_FONT_TYPE* pFontTable);
261 
269 
270 
271 
272 #if D4D_EXTSRC_FILE_ENABLE != D4D_FALSE
273  D4D_BOOL D4D_ExtFntInit(void);
274  void D4D_ExtFntSetWorkPath(D4D_CHAR* pPath);
275  D4D_CHAR* D4D_ExtFntGetWorkPath(void);
276  D4D_FILEPTR D4D_OpenFntFile(D4D_CHAR* pFileName);
277 #endif
278 
279 #endif /* __D4D_FONT_H */
280 
281 
Byte D4D_FONT_SIZE
Definition: d4d_font.h:174
D4D_WCHAR D4D_TCHAR
Type definition of eGUI character (it depends on UNICODE setting if this is D4D_CHAR or D4D_WCHAR)...
Definition: d4d_types.h:284
Byte D4D_FONT
Definition: d4d_font.h:171
D4D_FONT_TYPE * pFontType
Definition: d4d_font.h:220
D4D_FONT_SIZE height
Definition: d4d_font.h:183
D4D_TCHAR D4D_GetChar(D4D_FONT_TYPE *pFontType, D4D_FONT_IX ix)
D4D_FONT_TYPE * D4D_GetFont(D4D_FONT ix)
Definition: d4d_font.c:340
struct D4D_FONT_DESCRIPTOR_S D4D_FONT_DESCRIPTOR
Byte D4D_FONT_IX
Definition: d4d_font.h:165
D4D_INDEX textLength
Definition: d4d_font.h:225
Byte D4D_FONT_DATA
Definition: d4d_font.h:170
const D4D_FONT_TYPE d4d_FontTable[]
D4D_COOR maxWidth
Definition: d4d_font.h:227
D4D_FONT_SIZES charSpacing
Definition: d4d_font.h:212
D4D_FONT_SIZE charSize
Definition: d4d_font.h:193
D4D_COLOR colorText
Definition: d4d_font.h:222
D4D_COOR y
Definition: d4d_font.h:218
D4D_FONT_PROPERTIES properties
Definition: d4d_font.h:224
const D4D_FONT_IX * pIxTable
Definition: d4d_font.h:198
const D4D_FONT_OFFSET * pOffTable
Definition: d4d_font.h:199
D4D_FONT_TYPE * D4D_GetFontTable(void)
Definition: d4d_font.c:330
void D4D_SetFontTable(D4D_FONT_TYPE *pFontTable)
Definition: d4d_font.c:314
struct D4D_FONT_DESCRIPTOR_S * pNext
Definition: d4d_font.h:202
D4D_CHAR * fileName
Definition: d4d_font.h:213
D4D_FONT ix_font
Definition: d4d_font.h:209
D4D_INDEX textOffset
Definition: d4d_font.h:226
Byte D4D_FONT_FLAGS
Definition: d4d_font.h:159
D4D_TCHAR * pText
Definition: d4d_font.h:219
Byte D4D_COOR
Type definition of eGUI coordination variables.
Definition: d4d_types.h:219
D4D_FONT_FLAGS flags
Definition: d4d_font.h:189
Byte D4D_FONT_REV
Definition: d4d_font.h:166
unsigned char Byte
Type definition of Byte (unsigned 8-bit).
Definition: d4d_types.h:151
D4D_FONT_DESCRIPTOR * pFontDescriptor
Definition: d4d_font.h:210
D4D_FONT_PACK pack
Definition: d4d_font.h:197
Byte D4D_FONT_PACK
Definition: d4d_font.h:158
D4D_COOR x
Definition: d4d_font.h:217
D4D_FONT_IX charCnt
Definition: d4d_font.h:191
const D4D_FONT_DATA * pFontData
Definition: d4d_font.h:201
D4D_FONT_DSIZE charBmpSize
Definition: d4d_font.h:194
D4D_COLOR colorBack
Definition: d4d_font.h:223
D4D_FONT_SIZES charFullSize
Definition: d4d_font.h:196
D4D_FONT_REV revision
Definition: d4d_font.h:188
Type definition of eGUI tabulation structure.
Definition: d4d_types.h:253
LWord D4D_INDEX
Type definition of eGUI general index variables.
Definition: d4d_types.h:206
Word D4D_FONT_DSIZE
Definition: d4d_font.h:175
D4D_FONT_SIZE charBaseLine
Definition: d4d_font.h:195
D4D_FONT_SIZES scale
Definition: d4d_font.h:211
D4D_FONT_IX charDefault
Definition: d4d_font.h:192
LWord D4D_BOOL
Type definition of eGUI boolean.
Definition: d4d_types.h:204
char D4D_CHAR
Type definition of eGUI ASCII character.
Definition: d4d_types.h:280
D4D_FONT_SIZE D4D_GetFontWidth(D4D_FONT ix)
Definition: d4d_font.c:398
D4D_FONT_SIZE D4D_GetCharWidth(D4D_FONT ix, D4D_TCHAR ch)
Definition: d4d_font.c:415
D4D_FONT_SIZE width
Definition: d4d_font.h:182
D4D_TAB * pTab
Definition: d4d_font.h:221
D4D_FONT_SIZES D4D_GetFontSize(D4D_FONT ix)
Definition: d4d_font.c:365
Word D4D_FONT_OFFSET
Definition: d4d_font.h:169
D4D_COOR D4D_GetNextTab(D4D_TAB *pTab, D4D_COOR pos)
Definition: d4d_font.c:618
LWord D4D_COLOR
Type definition of eGUI color variables.
Definition: d4d_types.h:262
Byte D4D_FONT_PROPERTIES
Definition: d4d_font.h:116
D4D_FONT_SIZE D4D_GetFontHeight(D4D_FONT ix)
Definition: d4d_font.c:381
unsigned short Word
Type definition of Word (unsigned 16-bit).
Definition: d4d_types.h:159
D4D_FONT_IX startChar
Definition: d4d_font.h:190
void * D4D_FILEPTR
Type definition of eGUI file pointer.
Definition: d4d_types.h:298
const D4D_FONT_SIZE * pSizeTable
Definition: d4d_font.h:200