Embedded SDK
Embedded SDK
|
#include <string.h>
#include "app_config.h"
#include "nbgl_debug.h"
#include "nbgl_draw.h"
#include "nbgl_fonts.h"
#include "os_helpers.h"
#include "os_pic.h"
Go to the source code of this file.
Macros | |
#define | PIC_FONT(x) ((nbgl_font_t const *) PIC(x)) |
#define | BAGL_FONT_ID_MASK 0x0FFF |
#define | IS_WORD_DELIM(c) (c == ' ' || c == '\n' || c == '\b' || c == '\f' || c == '-' || c == '_') |
Functions | |
const nbgl_font_t * | nbgl_getFont (nbgl_font_id_e fontId) |
return the non-unicode font corresponding to the given font ID More... | |
uint32_t | nbgl_popUnicodeChar (const uint8_t **text, uint16_t *textLen, bool *is_unicode) |
Get the coming unicode value on the given UTF-8 string. If the value is a simple ASCII character, is_unicode is set to false. More... | |
uint16_t | nbgl_getSingleLineTextWidth (nbgl_font_id_e fontId, const char *text) |
return the max width in pixels of the given text until the first or \0 is encountered More... | |
uint16_t | nbgl_getSingleLineTextWidthInLen (nbgl_font_id_e fontId, const char *text, uint16_t maxLen) |
return the max width in pixels of the given text until the first or \0 is encountered, or maxLen characters have been parsed. More... | |
uint16_t | nbgl_getTextWidth (nbgl_font_id_e fontId, const char *text) |
return the max width in pixels of the given text (can be multiline) More... | |
uint8_t | nbgl_getCharWidth (nbgl_font_id_e fontId, const char *text) |
return the width in pixels of the given UTF-8 character More... | |
uint8_t | nbgl_getFontHeight (nbgl_font_id_e fontId) |
return the height in pixels of the font with the given font ID More... | |
uint8_t | nbgl_getFontLineHeight (nbgl_font_id_e fontId) |
return the height in pixels of the line of font with the given font ID More... | |
uint16_t | nbgl_getTextNbLines (const char *text) |
return the number of lines in the given text, according to the found ' 's More... | |
uint16_t | nbgl_getTextHeight (nbgl_font_id_e fontId, const char *text) |
return the height of the given multiline text, with the given font. More... | |
uint16_t | nbgl_getTextLength (const char *text) |
return the number of bytes of the given text, excluding final ' ' or '\0' More... | |
void | nbgl_getTextMaxLenAndWidth (nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, uint16_t *len, uint16_t *width, bool wrapping) |
compute the max width of the first line of the given text fitting in maxWidth More... | |
bool | nbgl_getTextMaxLenInNbLines (nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, uint16_t maxNbLines, uint16_t *len, bool wrapping) |
compute the len of the given text (in bytes) fitting in the given maximum nb lines, with the given maximum width More... | |
bool | nbgl_getTextMaxLenAndWidthFromEnd (nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, uint16_t *len, uint16_t *width) |
compute the len and width of the given text fitting in the maxWidth, starting from end of text More... | |
uint16_t | nbgl_getTextNbLinesInWidth (nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping) |
compute the number of lines of the given text fitting in the given maxWidth More... | |
uint8_t | nbgl_getTextNbPagesInWidth (nbgl_font_id_e fontId, const char *text, uint8_t nbLinesPerPage, uint16_t maxWidth) |
compute the number of pages of nbLinesPerPage lines per page of the given text fitting in the given maxWidth More... | |
uint16_t | nbgl_getTextHeightInWidth (nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping) |
return the height of the given multiline text, with the given font. More... | |
void | nbgl_textWrapOnNbLines (nbgl_font_id_e fontId, char *text, uint16_t maxWidth, uint8_t nbLines) |
Modifies the given text to wrap it on the given max width (in pixels), in the given nbLines If possible,. More... | |
void | nbgl_textReduceOnNbLines (nbgl_font_id_e fontId, const char *origText, uint16_t maxWidth, uint8_t nbLines, char *reducedText, uint16_t reducedTextLen) |
Create a reduced version of given ASCII text to wrap it on the given max width (in pixels), in the given nbLines. More... | |
Implementation of fonts array
Definition in file nbgl_fonts.c.
#define BAGL_FONT_ID_MASK 0x0FFF |
Definition at line 24 of file nbgl_fonts.c.
#define IS_WORD_DELIM | ( | c | ) | (c == ' ' || c == '\n' || c == '\b' || c == '\f' || c == '-' || c == '_') |
Definition at line 26 of file nbgl_fonts.c.
#define PIC_FONT | ( | x | ) | ((nbgl_font_t const *) PIC(x)) |
Definition at line 23 of file nbgl_fonts.c.
uint8_t nbgl_getCharWidth | ( | nbgl_font_id_e | fontId, |
const char * | text | ||
) |
return the width in pixels of the given UTF-8 character
fontId | font ID |
text | UTF-8 character |
Definition at line 372 of file nbgl_fonts.c.
const nbgl_font_t* nbgl_getFont | ( | nbgl_font_id_e | fontId | ) |
return the non-unicode font corresponding to the given font ID
fontId | font ID |
Definition at line 136 of file nbgl_fonts.c.
uint8_t nbgl_getFontHeight | ( | nbgl_font_id_e | fontId | ) |
return the height in pixels of the font with the given font ID
fontId | font ID |
Definition at line 398 of file nbgl_fonts.c.
uint8_t nbgl_getFontLineHeight | ( | nbgl_font_id_e | fontId | ) |
return the height in pixels of the line of font with the given font ID
fontId | font ID |
Definition at line 410 of file nbgl_fonts.c.
uint16_t nbgl_getSingleLineTextWidth | ( | nbgl_font_id_e | fontId, |
const char * | text | ||
) |
return the max width in pixels of the given text until the first
or \0 is encountered
fontId | font ID |
text | text in UTF8 |
Definition at line 334 of file nbgl_fonts.c.
uint16_t nbgl_getSingleLineTextWidthInLen | ( | nbgl_font_id_e | fontId, |
const char * | text, | ||
uint16_t | maxLen | ||
) |
return the max width in pixels of the given text until the first
or \0 is encountered, or maxLen characters have been parsed.
fontId | font ID |
text | text in UTF8 |
maxLen | max number of bytes to parse |
Definition at line 348 of file nbgl_fonts.c.
uint16_t nbgl_getTextHeight | ( | nbgl_font_id_e | fontId, |
const char * | text | ||
) |
return the height of the given multiline text, with the given font.
fontId | font ID |
text | text to get the height from |
Definition at line 441 of file nbgl_fonts.c.
uint16_t nbgl_getTextHeightInWidth | ( | nbgl_font_id_e | fontId, |
const char * | text, | ||
uint16_t | maxWidth, | ||
bool | wrapping | ||
) |
return the height of the given multiline text, with the given font.
fontId | font ID |
text | text to get the height from |
maxWidth | maximum width in which the text must fit |
wrapping | if true, lines are split on separators like spaces, ... |
Definition at line 1048 of file nbgl_fonts.c.
uint16_t nbgl_getTextLength | ( | const char * | text | ) |
return the number of bytes of the given text, excluding final '
' or '\0'
text | text to get the number of bytes from |
Definition at line 454 of file nbgl_fonts.c.
void nbgl_getTextMaxLenAndWidth | ( | nbgl_font_id_e | fontId, |
const char * | text, | ||
uint16_t | maxWidth, | ||
uint16_t * | len, | ||
uint16_t * | width, | ||
bool | wrapping | ||
) |
compute the max width of the first line of the given text fitting in maxWidth
fontId | font ID |
text | input UTF-8 string, possibly multi-line (but only first line, before , is used) |
maxWidth | maximum width in bytes, if text is greater than that the parsing is escaped |
len | (output) consumed bytes in text fitting in maxWidth |
width | (output) set to maximum width in pixels in text fitting in maxWidth |
wrapping | if true, lines are split on separators like spaces, ... |
Definition at line 482 of file nbgl_fonts.c.
bool nbgl_getTextMaxLenAndWidthFromEnd | ( | nbgl_font_id_e | fontId, |
const char * | text, | ||
uint16_t | maxWidth, | ||
uint16_t * | len, | ||
uint16_t * | width | ||
) |
compute the len and width of the given text fitting in the maxWidth, starting from end of text
fontId | font ID |
text | input ascii string, possibly multi-line (but only first line is handled) |
maxWidth | maximum width in bytes, if text is greater than that the parsing is escaped |
len | (output) consumed bytes in text fitting in maxWidth |
width | (output) set to maximum width in pixels in text fitting in maxWidth |
Definition at line 681 of file nbgl_fonts.c.
bool nbgl_getTextMaxLenInNbLines | ( | nbgl_font_id_e | fontId, |
const char * | text, | ||
uint16_t | maxWidth, | ||
uint16_t | maxNbLines, | ||
uint16_t * | len, | ||
bool | wrapping | ||
) |
compute the len of the given text (in bytes) fitting in the given maximum nb lines, with the given maximum width
fontId | font ID |
text | input UTF-8 string, possibly multi-line |
maxWidth | maximum width in bytes, if text is greater than that the parsing is escaped |
maxNbLines | maximum number of lines, if text is greater than that the parsing is escaped |
len | (output) consumed bytes in text fitting in maxWidth |
wrapping | if true, lines are split on separators like spaces, ... |
Definition at line 572 of file nbgl_fonts.c.
uint16_t nbgl_getTextNbLines | ( | const char * | text | ) |
return the number of lines in the given text, according to the found '
's
text | text to get the number of lines from |
Definition at line 422 of file nbgl_fonts.c.
uint16_t nbgl_getTextNbLinesInWidth | ( | nbgl_font_id_e | fontId, |
const char * | text, | ||
uint16_t | maxWidth, | ||
bool | wrapping | ||
) |
compute the number of lines of the given text fitting in the given maxWidth
fontId | font ID |
text | UTF-8 text to get the number of lines from |
maxWidth | maximum width in which the text must fit |
wrapping | if true, lines are split on separators like spaces, ... |
Definition at line 731 of file nbgl_fonts.c.
uint8_t nbgl_getTextNbPagesInWidth | ( | nbgl_font_id_e | fontId, |
const char * | text, | ||
uint8_t | nbLinesPerPage, | ||
uint16_t | maxWidth | ||
) |
compute the number of pages of nbLinesPerPage lines per page of the given text fitting in the given maxWidth
fontId | font ID |
text | UTF-8 text to get the number of pages from |
nbLinesPerPage | number of lines in a page |
maxWidth | maximum width in which the text must fit |
Definition at line 885 of file nbgl_fonts.c.
uint16_t nbgl_getTextWidth | ( | nbgl_font_id_e | fontId, |
const char * | text | ||
) |
return the max width in pixels of the given text (can be multiline)
fontId | font ID |
text | text in UTF8 |
Definition at line 360 of file nbgl_fonts.c.
Get the coming unicode value on the given UTF-8 string. If the value is a simple ASCII character, is_unicode is set to false.
text | (in/out) text to get character from. Updated after pop to the next UTF-8 char |
textLen | (in/out) remaining length in given text (before ' ' or '\0') |
is_unicode | (out) set to true if it's a real unicode (not ASCII) |
Definition at line 150 of file nbgl_fonts.c.
void nbgl_textReduceOnNbLines | ( | nbgl_font_id_e | fontId, |
const char * | origText, | ||
uint16_t | maxWidth, | ||
uint8_t | nbLines, | ||
char * | reducedText, | ||
uint16_t | reducedTextLen | ||
) |
Create a reduced version of given ASCII text to wrap it on the given max width (in pixels), in the given nbLines.
fontId | font ID |
origText | (input) ASCII string, must be single line |
maxWidth | maximum width in pixels |
nbLines | (input) number of lines to reduce the text to. The middle of the text is replaced by ... |
reducedText | (output) reduced text |
reducedTextLen | (input) max size of reduced text |
Definition at line 1177 of file nbgl_fonts.c.
void nbgl_textWrapOnNbLines | ( | nbgl_font_id_e | fontId, |
char * | text, | ||
uint16_t | maxWidth, | ||
uint8_t | nbLines | ||
) |
Modifies the given text to wrap it on the given max width (in pixels), in the given nbLines If possible,.
fontId | font ID |
text | (input/output) UTF-8 string, possibly multi-line |
maxWidth | maximum width in pixels |
nbLines | (input) If the text doesn't fit in this number of lines, the last chars will be replaced by ... |
Definition at line 1068 of file nbgl_fonts.c.