Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
nbgl_fonts.h
Go to the documentation of this file.
1
6
7#ifndef NBGL_FONTS_H
8#define NBGL_FONTS_H
9
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16/*********************
17 * INCLUDES
18 *********************/
19#include "nbgl_types.h"
20#include "ux_loc.h"
21
22/*********************
23 * DEFINES
24 *********************/
25#define PIC_CHAR(x) ((const nbgl_font_character_t *) PIC(x))
26#define PIC_BMP(x) ((uint8_t const *) PIC(x))
27
32#if SMALL_FONT_HEIGHT == 24
33#define SMALL_REGULAR_FONT BAGL_FONT_INTER_REGULAR_24px
34#define SMALL_BOLD_FONT BAGL_FONT_INTER_SEMIBOLD_24px
35#define LARGE_MEDIUM_FONT BAGL_FONT_INTER_MEDIUM_32px
36#define LARGE_OBFUSCATED_MEDIUM_FONT BAGL_FONT_OBFUSCATED_INTER_MEDIUM_32px
37#define SMALL_REGULAR_1BPP_FONT BAGL_FONT_INTER_REGULAR_24px_1bpp
38#define SMALL_BOLD_1BPP_FONT BAGL_FONT_INTER_SEMIBOLD_24px_1bpp
39#define SMALL_OBFUSCATED_BOLD_1BPP_FONT BAGL_FONT_OBFUSCATED_INTER_SEMIBOLD_24px_1bpp
40#define LARGE_MEDIUM_1BPP_FONT BAGL_FONT_INTER_MEDIUM_32px_1bpp
41#define LARGE_OBFUSCATED_MEDIUM_1BPP_FONT BAGL_FONT_OBFUSCATED_INTER_MEDIUM_32px_1bpp
42#elif SMALL_FONT_HEIGHT == 28
43#define SMALL_REGULAR_FONT BAGL_FONT_INTER_REGULAR_28px
44#define SMALL_BOLD_FONT BAGL_FONT_INTER_SEMIBOLD_28px
45#define LARGE_MEDIUM_FONT BAGL_FONT_INTER_MEDIUM_36px
46#define LARGE_OBFUSCATED_MEDIUM_FONT BAGL_FONT_OBFUSCATED_INTER_MEDIUM_36px
47#define SMALL_REGULAR_1BPP_FONT BAGL_FONT_INTER_REGULAR_28px_1bpp
48#define SMALL_BOLD_1BPP_FONT BAGL_FONT_INTER_SEMIBOLD_28px_1bpp
49#define SMALL_OBFUSCATED_BOLD_1BPP_FONT BAGL_FONT_OBFUSCATED_INTER_SEMIBOLD_28px_1bpp
50#define LARGE_MEDIUM_1BPP_FONT BAGL_FONT_INTER_MEDIUM_36px_1bpp
51#define LARGE_OBFUSCATED_MEDIUM_1BPP_FONT BAGL_FONT_OBFUSCATED_INTER_MEDIUM_36px_1bpp
52#elif SMALL_FONT_HEIGHT == 18
53#define SMALL_REGULAR_FONT BAGL_FONT_NANOTEXT_MEDIUM_18px_1bpp
54#define SMALL_BOLD_FONT BAGL_FONT_NANOTEXT_BOLD_18px_1bpp
55#define LARGE_MEDIUM_FONT BAGL_FONT_NANODISPLAY_SEMIBOLD_24px_1bpp
56#define LARGE_OBFUSCATED_MEDIUM_FONT BAGL_FONT_OBFUSCATED_NANODISPLAY_SEMIBOLD_24px_1bpp
57#define SMALL_REGULAR_1BPP_FONT BAGL_FONT_NANOTEXT_MEDIUM_18px_1bpp
58#define SMALL_BOLD_1BPP_FONT BAGL_FONT_NANOTEXT_BOLD_18px_1bpp
59#define SMALL_OBFUSCATED_BOLD_1BPP_FONT BAGL_FONT_OBFUSCATED_NANOTEXT_BOLD_18px_1bpp
60#define LARGE_MEDIUM_1BPP_FONT BAGL_FONT_NANODISPLAY_SEMIBOLD_24px_1bpp
61#define LARGE_OBFUSCATED_MEDIUM_1BPP_FONT BAGL_FONT_OBFUSCATED_NANODISPLAY_SEMIBOLD_24px_1bpp
62#endif // SMALL_FONT_HEIGHT
63
64/**********************
65 * TYPEDEFS
66 **********************/
67
72// WARNING: please DON'T CHANGE the order/values of the fields below!
73// (otherwise python tools that generate data will need to be modified too)
74typedef struct {
75 uint32_t bitmap_offset;
76 uint32_t encoding : 1;
77 uint32_t width : 6;
78 uint32_t x_min_offset : 4;
79 uint32_t y_min_offset : 6;
80 uint32_t x_max_offset : 4;
81 uint32_t y_max_offset : 6;
83
88typedef struct {
89 uint32_t bitmap_len;
90 uint8_t font_id;
91 uint8_t bpp;
92 uint8_t height;
93 uint8_t line_height;
94 uint8_t char_kerning;
95 uint8_t crop;
96 uint8_t y_min;
97 uint8_t
99 uint8_t
102 *const characters;
103 uint8_t const *bitmap;
105
106#define BAGL_ENCODING_LATIN1 0
107#define BAGL_ENCODING_UTF8 1
108#define BAGL_ENCODING_DEFAULT BAGL_ENCODING_UTF8
109
114// WARNING: please DON'T CHANGE the order of the fields below!
115// (otherwise python tools that generate data will need to be modified too)
116typedef struct {
117 uint32_t char_unicode : 21;
118 uint32_t encoding : 1;
119 uint32_t width : 6;
120 uint32_t x_min_offset : 4;
121 uint32_t y_min_offset : 6;
122 uint32_t x_max_offset : 4;
123 uint32_t y_max_offset : 6;
124 uint32_t bitmap_offset : 15;
125 uint32_t over_previous : 1;
127
131typedef struct {
132 uint16_t bitmap_len;
133 uint8_t font_id;
134 uint8_t bpp;
135 uint8_t height;
136 uint8_t line_height;
137 uint8_t char_kerning;
138 uint8_t crop;
139 uint8_t y_min;
140 uint8_t unused[3];
142
143typedef enum {
162
163 // OBFSUCATED FONTS
182 BAGL_FONT_LAST // MUST ALWAYS BE THE LAST, FOR AUTOMATED INVALID VALUE CHECKS
184
191
192/**********************
193 * GLOBAL PROTOTYPES
194 **********************/
196uint16_t nbgl_getSingleLineTextWidth(nbgl_font_id_e fontId, const char *text);
197uint16_t nbgl_getSingleLineTextWidthInLen(nbgl_font_id_e fontId, const char *text, uint16_t maxLen);
198uint16_t nbgl_getTextWidth(nbgl_font_id_e fontId, const char *text);
199uint8_t nbgl_getCharWidth(nbgl_font_id_e fontId, const char *text);
202uint16_t nbgl_getTextNbLines(const char *text);
203uint16_t nbgl_getTextHeight(nbgl_font_id_e fontId, const char *text);
204uint16_t nbgl_getTextLength(const char *text);
206 const char *text,
207 uint16_t maxWidth,
208 uint16_t *len,
209 uint16_t *width,
210 bool wrapping);
212 const char *text,
213 uint16_t maxWidth,
214 bool wrapping);
216 const char *text,
217 uint16_t maxWidth,
218 bool wrapping);
220 const char *text,
221 uint16_t maxWidth,
222 uint16_t *len,
223 uint16_t *width);
225 const char *text,
226 uint16_t maxWidth,
227 uint16_t maxNbLines,
228 uint16_t *len,
229 bool wrapping);
230void nbgl_textWrapOnNbLines(nbgl_font_id_e fontId, char *text, uint16_t maxWidth, uint8_t nbLines);
232 const char *origText,
233 uint16_t maxWidth,
234 uint8_t nbLines,
235 char *reducedText,
236 uint16_t reducedTextLen);
238 const char *text,
239 uint8_t nbLinesPerPage,
240 uint16_t maxWidth);
241
242uint32_t nbgl_popUnicodeChar(const uint8_t **text, uint16_t *text_length, bool *is_unicode);
246void nbgl_refreshUnicodeFont(const LANGUAGE_PACK *lp);
247
248/**********************
249 * MACROS
250 **********************/
251#define IS_UNICODE(__value) ((__value) > 0xF0)
252
253#ifdef __cplusplus
254} /* extern "C" */
255#endif
256
257#endif /* NBGL_FONTS_H */
struct nbgl_unicode_ctx_s nbgl_unicode_ctx_t
void nbgl_textWrapOnNbLines(nbgl_font_id_e fontId, char *text, uint16_t maxWidth, uint8_t nbLines)
void nbgl_getTextMaxLenAndWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, uint16_t *len, uint16_t *width, bool wrapping)
uint16_t nbgl_getTextNbLines(const char *text)
uint8_t nbgl_getTextNbPagesInWidth(nbgl_font_id_e fontId, const char *text, uint8_t nbLinesPerPage, uint16_t maxWidth)
nbgl_unicode_ctx_t * nbgl_getUnicodeFont(nbgl_font_id_e font_id)
const nbgl_font_unicode_character_t * nbgl_getUnicodeFontCharacter(uint32_t unicode)
uint32_t nbgl_popUnicodeChar(const uint8_t **text, uint16_t *text_length, bool *is_unicode)
uint16_t nbgl_getSingleLineTextWidth(nbgl_font_id_e fontId, const char *text)
uint8_t nbgl_getCharWidth(nbgl_font_id_e fontId, const char *text)
void nbgl_refreshUnicodeFont(const LANGUAGE_PACK *lp)
bool nbgl_getTextMaxLenInNbLines(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, uint16_t maxNbLines, uint16_t *len, bool wrapping)
nbgl_font_id_e
Definition nbgl_fonts.h:143
@ BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp
Definition nbgl_fonts.h:152
@ BAGL_FONT_OBFUSCATED_OPEN_SANS_LIGHT_16px_1bpp
Definition nbgl_fonts.h:171
@ BAGL_FONT_OBFUSCATED_INTER_REGULAR_28px_1bpp
Definition nbgl_fonts.h:176
@ BAGL_FONT_OBFUSCATED_INTER_MEDIUM_32px_1bpp
Definition nbgl_fonts.h:169
@ BAGL_FONT_INTER_REGULAR_28px_1bpp
Definition nbgl_fonts.h:156
@ BAGL_FONT_OBFUSCATED_NANOTEXT_BOLD_18px_1bpp
Definition nbgl_fonts.h:180
@ BAGL_FONT_OBFUSCATED_INTER_SEMIBOLD_24px
Definition nbgl_fonts.h:165
@ BAGL_FONT_NANOTEXT_MEDIUM_18px_1bpp
Definition nbgl_fonts.h:159
@ BAGL_FONT_INTER_SEMIBOLD_28px
Definition nbgl_fonts.h:154
@ BAGL_FONT_INTER_REGULAR_24px_1bpp
Definition nbgl_fonts.h:147
@ BAGL_FONT_OPEN_SANS_EXTRABOLD_11px_1bpp
Definition nbgl_fonts.h:150
@ BAGL_FONT_OBFUSCATED_NANODISPLAY_SEMIBOLD_24px_1bpp
Definition nbgl_fonts.h:181
@ BAGL_FONT_INTER_REGULAR_24px
Definition nbgl_fonts.h:144
@ BAGL_FONT_OBFUSCATED_OPEN_SANS_REGULAR_11px_1bpp
Definition nbgl_fonts.h:172
@ BAGL_FONT_OBFUSCATED_INTER_REGULAR_24px_1bpp
Definition nbgl_fonts.h:167
@ BAGL_FONT_OBFUSCATED_INTER_REGULAR_24px
Definition nbgl_fonts.h:164
@ BAGL_FONT_INTER_REGULAR_28px
Definition nbgl_fonts.h:153
@ BAGL_FONT_INTER_MEDIUM_32px
Definition nbgl_fonts.h:146
@ BAGL_FONT_INTER_MEDIUM_36px
Definition nbgl_fonts.h:155
@ BAGL_FONT_OBFUSCATED_INTER_SEMIBOLD_28px
Definition nbgl_fonts.h:174
@ BAGL_FONT_INTER_MEDIUM_36px_1bpp
Definition nbgl_fonts.h:158
@ BAGL_FONT_OBFUSCATED_INTER_SEMIBOLD_24px_1bpp
Definition nbgl_fonts.h:168
@ BAGL_FONT_NANODISPLAY_SEMIBOLD_24px_1bpp
Definition nbgl_fonts.h:161
@ BAGL_FONT_INTER_SEMIBOLD_24px
Definition nbgl_fonts.h:145
@ BAGL_FONT_OBFUSCATED_INTER_REGULAR_28px
Definition nbgl_fonts.h:173
@ BAGL_FONT_OBFUSCATED_INTER_MEDIUM_36px_1bpp
Definition nbgl_fonts.h:178
@ BAGL_FONT_OBFUSCATED_INTER_MEDIUM_36px
Definition nbgl_fonts.h:175
@ BAGL_FONT_INTER_MEDIUM_32px_1bpp
Definition nbgl_fonts.h:149
@ BAGL_FONT_OPEN_SANS_LIGHT_16px_1bpp
Definition nbgl_fonts.h:151
@ BAGL_FONT_OBFUSCATED_INTER_SEMIBOLD_28px_1bpp
Definition nbgl_fonts.h:177
@ BAGL_FONT_OBFUSCATED_NANOTEXT_MEDIUM_18px_1bpp
Definition nbgl_fonts.h:179
@ BAGL_FONT_LAST
Definition nbgl_fonts.h:182
@ BAGL_FONT_INTER_SEMIBOLD_24px_1bpp
Definition nbgl_fonts.h:148
@ BAGL_FONT_OBFUSCATED_OPEN_SANS_EXTRABOLD_11px_1bpp
Definition nbgl_fonts.h:170
@ BAGL_FONT_OBFUSCATED_INTER_MEDIUM_32px
Definition nbgl_fonts.h:166
@ BAGL_FONT_NANOTEXT_BOLD_18px_1bpp
Definition nbgl_fonts.h:160
@ BAGL_FONT_INTER_SEMIBOLD_28px_1bpp
Definition nbgl_fonts.h:157
bool nbgl_getTextMaxLenAndWidthFromEnd(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, uint16_t *len, uint16_t *width)
uint8_t nbgl_getFontHeight(nbgl_font_id_e fontId)
void nbgl_textReduceOnNbLines(nbgl_font_id_e fontId, const char *origText, uint16_t maxWidth, uint8_t nbLines, char *reducedText, uint16_t reducedTextLen)
uint16_t nbgl_getTextWidth(nbgl_font_id_e fontId, const char *text)
uint16_t nbgl_getTextHeightInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
uint16_t nbgl_getTextLength(const char *text)
uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
const nbgl_font_t * nbgl_getFont(nbgl_font_id_e fontId)
uint16_t nbgl_getTextHeight(nbgl_font_id_e fontId, const char *text)
uint8_t nbgl_getFontLineHeight(nbgl_font_id_e fontId)
uint16_t nbgl_getSingleLineTextWidthInLen(nbgl_font_id_e fontId, const char *text, uint16_t maxLen)
uint32_t nbgl_getUnicodeFontCharacterByteCount(void)
Included by every low-level NBGL header, to forbid them in apollo app code.
common types for Graphical Library
fonts nicknames to be used for various wallet size targets (non-Nano)
Definition nbgl_fonts.h:74
uint32_t width
width of character in pixels
Definition nbgl_fonts.h:77
uint32_t encoding
method used to encode bitmap data
Definition nbgl_fonts.h:76
uint32_t x_min_offset
x_min = x_min_offset
Definition nbgl_fonts.h:78
uint32_t bitmap_offset
offset of this character in chars buffer
Definition nbgl_fonts.h:75
uint32_t y_min_offset
y_min = (y_min + y_min_offset)
Definition nbgl_fonts.h:79
uint32_t x_max_offset
x_max = width - x_max_offset
Definition nbgl_fonts.h:80
uint32_t y_max_offset
y_max = (height - y_max_offset)
Definition nbgl_fonts.h:81
structure defining an ASCII font
Definition nbgl_fonts.h:88
uint8_t char_kerning
kerning for the font
Definition nbgl_fonts.h:94
uint8_t crop
If false, x_min_offset+y_min_offset=bytes to skip.
Definition nbgl_fonts.h:95
uint8_t first_char
ASCII code of the first character in bitmap and in characters fields.
Definition nbgl_fonts.h:98
uint8_t font_id
ID of the font, from nbgl_font_id_e.
Definition nbgl_fonts.h:90
uint32_t bitmap_len
Size in bytes of the associated bitmap.
Definition nbgl_fonts.h:89
uint8_t const * bitmap
array containing bitmaps of all characters
Definition nbgl_fonts.h:103
const nbgl_font_character_t *const characters
array containing definitions of all characters
Definition nbgl_fonts.h:102
uint8_t height
height of all characters in pixels
Definition nbgl_fonts.h:92
uint8_t line_height
height of a line for all characters in pixels
Definition nbgl_fonts.h:93
uint8_t last_char
ASCII code of the last character in bitmap and in characters fields.
Definition nbgl_fonts.h:100
uint8_t y_min
Most top Y coordinate of any char in the font.
Definition nbgl_fonts.h:96
uint8_t bpp
number of bits per pixels
Definition nbgl_fonts.h:91
structure defining a unicode character (except the bitmap)
Definition nbgl_fonts.h:116
uint32_t encoding
method used to encode bitmap data
Definition nbgl_fonts.h:118
uint32_t char_unicode
plane value from 0 to 16 then 16-bit code.
Definition nbgl_fonts.h:117
uint32_t width
width of character in pixels
Definition nbgl_fonts.h:119
uint32_t x_min_offset
x_min = x_min_offset
Definition nbgl_fonts.h:120
uint32_t y_min_offset
y_min = (y_min + y_min_offset)
Definition nbgl_fonts.h:121
uint32_t y_max_offset
y_max = (height - y_max_offset)
Definition nbgl_fonts.h:123
uint32_t over_previous
flag set to 1 when displayed over previous char
Definition nbgl_fonts.h:125
uint32_t x_max_offset
x_max = width - x_max_offset
Definition nbgl_fonts.h:122
uint32_t bitmap_offset
offset of this character in chars buffer
Definition nbgl_fonts.h:124
structure defining a unicode font
Definition nbgl_fonts.h:131
uint8_t crop
If false, x_min_offset+y_min_offset=bytes to skip.
Definition nbgl_fonts.h:138
uint8_t y_min
Most top Y coordinate of any char in the font.
Definition nbgl_fonts.h:139
uint16_t bitmap_len
Size in bytes of all characters bitmaps.
Definition nbgl_fonts.h:132
uint8_t unused[3]
for alignment
Definition nbgl_fonts.h:140
uint8_t height
height of all characters in pixels
Definition nbgl_fonts.h:135
uint8_t font_id
ID of the font, from nbgl_font_id_e.
Definition nbgl_fonts.h:133
uint8_t char_kerning
kerning for the font
Definition nbgl_fonts.h:137
uint8_t line_height
height of a line for all characters in pixels
Definition nbgl_fonts.h:136
uint8_t bpp
Number of bits per pixels, (interpreted as nbgl_bpp_t).
Definition nbgl_fonts.h:134
const nbgl_font_unicode_character_t * characters
Definition nbgl_fonts.h:187
const nbgl_font_unicode_t * font
Definition nbgl_fonts.h:186
uint32_t unicode_character_byte_count
Definition nbgl_fonts.h:189
const uint8_t * bitmap
Definition nbgl_fonts.h:188