µGFX  2.9
version 2.9
mf_config.h
1 /*
2  * This file is subject to the terms of the GFX License. If a copy of
3  * the license was not distributed with this file, you can obtain one at:
4  *
5  * http://ugfx.io/license.html
6  */
7 
8 /* Configuration constants for mcufont. */
9 
10 #ifndef _MF_CONFIG_H_
11 #define _MF_CONFIG_H_
12 
13 /*******************************************************
14  * Configuration settings related to GFX *
15  *******************************************************/
16 
17 #include "../../../gfx.h"
18 
19 /* Ensure definitions are compatible with uGFX */
20 #undef bool
21 #define bool gBool
22 
23 #if !GFX_USE_GDISP || !GDISP_NEED_TEXT
24  #define MF_NO_COMPILE // Don't compile any font code
25 #endif
26 
27 /* Prevent double definitions of standard int types */
28 #define MF_NO_STDINT_H
29 
30 /* Mapping from uGFX settings to mcufont settings */
31 #if GDISP_NEED_UTF8
32  #define MF_ENCODING MF_ENCODING_UTF8
33 #else
34  #define MF_ENCODING MF_ENCODING_ASCII
35 #endif
36 
37 #if GDISP_NEED_TEXT_WORDWRAP
38  #define MF_USE_ADVANCED_WORDWRAP 1
39 #else
40  #define MF_USE_ADVANCED_WORDWRAP 0
41 #endif
42 
43 #define MF_USE_KERNING GDISP_NEED_TEXT_KERNING
44 #define MF_FONT_FILE_NAME "src/gdisp/fonts/fonts.h"
45 
46 /* These are not used for now */
47 #define MF_USE_JUSTIFY 0
48 
49 /*******************************************************
50  * Configuration settings related to build environment *
51  *******************************************************/
52 
53 /* Name of the file that contains all the included fonts. */
54 #ifndef MF_FONT_FILE_NAME
55 #define MF_FONT_FILE_NAME "fonts.h"
56 #endif
57 
58 
59 /*****************************************
60  * Configuration settings related to API *
61  *****************************************/
62 
63 /* Encoding for the input data.
64  * With the unicode encodings, the library supports the range of unicode
65  * characters 0x0000-0xFFFF (the Basic Multilingual Plane).
66  *
67  * ASCII: Plain ascii (somewhat works with ISO8859-1 also)
68  * UTF8: UTF8 encoding (variable number of bytes)
69  * UTF16: UTF16 encoding (2 bytes per character, compatible with UCS-2)
70  * WCHAR: Use compiler's wchar_t (usually same as UTF16)
71  */
72 #define MF_ENCODING_ASCII 0
73 #define MF_ENCODING_UTF8 1
74 #define MF_ENCODING_UTF16 2
75 #define MF_ENCODING_WCHAR 3
76 #ifndef MF_ENCODING
77 #define MF_ENCODING MF_ENCODING_UTF8
78 #endif
79 
80 
81 /************************************************************************
82  * Configuration settings related to visual appearance of rendered text *
83  ************************************************************************/
84 
85 /* Minimum space between characters, in percents of the glyph width.
86  * Increasing this causes the kerning module to leave more space between
87  * characters.
88  */
89 #ifndef MF_KERNING_SPACE_PERCENT
90 #define MF_KERNING_SPACE_PERCENT 15
91 #endif
92 
93 /* Minimum space between characters, in pixels. Added to the percentual
94  * spacing. This pixel-based value guarantees enough space even with small
95  * fonts.
96  */
97 #ifndef MF_KERNING_SPACE_PIXELS
98 #define MF_KERNING_SPACE_PIXELS 3
99 #endif
100 
101 /* Maximum adjustment done by the kerning algorithm, as percent of the
102  * glyph width.
103  */
104 #ifndef MF_KERNING_LIMIT
105 #define MF_KERNING_LIMIT 20
106 #endif
107 
108 /* Spacing of tabulator stops. The value is multiplied by the width of the
109  * 'm' character in the current font.
110  */
111 #ifndef MF_TABSIZE
112 #define MF_TABSIZE 8
113 #endif
114 
115 
116 /*************************************************************************
117  * Configuration settings to strip down library to reduce resource usage *
118  *************************************************************************/
119 
120 /* Enable or disable the kerning module.
121  * Disabling it saves some code size and run time, but causes the spacing
122  * between characters to be less consistent.
123  */
124 #ifndef MF_USE_KERNING
125 #define MF_USE_KERNING 1
126 #endif
127 
128 /* Enable or disable the advanced word wrap algorithm.
129  * If disabled, uses a simpler algorithm.
130  */
131 #ifndef MF_USE_ADVANCED_WORDWRAP
132 #define MF_USE_ADVANCED_WORDWRAP 1
133 #endif
134 
135 /* Enable of disable the justification algorithm.
136  * If disabled, mf_render_justified renders just left-aligned.
137  */
138 #ifndef MF_USE_JUSTIFY
139 #define MF_USE_JUSTIFY 1
140 #endif
141 
142 /* Enable or disable the center and right alignment code.
143  * If disabled, any alignment results in MF_ALIGN_LEFT.
144  */
145 #ifndef MF_USE_ALIGN
146 #define MF_USE_ALIGN 1
147 #endif
148 
149 /* Enable or disable the support for tab alignment.
150  * If disabled, tabs will be rendered as regular space character.
151  */
152 #ifndef MF_USE_TABS
153 #define MF_USE_TABS 1
154 #endif
155 
156 /* Number of vertical zones to use when computing kerning.
157  * Larger values give more accurate kerning, but are slower and use somewhat
158  * more memory. There is no point to increase this beyond the height of the
159  * font.
160  */
161 #ifndef MF_KERNING_ZONES
162 #define MF_KERNING_ZONES 16
163 #endif
164 
165 
166 
167 /* Add extern "C" when used from C++. */
168 #ifdef __cplusplus
169 #define MF_EXTERN extern "C"
170 #else
171 #define MF_EXTERN
172 #endif
173 
174 #endif
175