Embedded SDK
Embedded SDK
Classes | Macros | Typedefs | Enumerations | Functions
nbgl_fonts.h File Reference
#include "nbgl_types.h"
Include dependency graph for nbgl_fonts.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  nbgl_font_character_t
 fonts nicknames to be used for various wallet size targets (non-Nano) More...
 
struct  nbgl_font_t
 structure defining an ASCII font More...
 
struct  nbgl_font_unicode_character_t
 structure defining a unicode character (except the bitmap) More...
 
struct  nbgl_font_unicode_t
 structure defining a unicode font More...
 
struct  nbgl_unicode_ctx_s
 

Macros

#define PIC_CHAR(x)   ((const nbgl_font_character_t *) PIC(x))
 
#define PIC_BMP(x)   ((uint8_t const *) PIC(x))
 
#define LANGUAGE_PACK   void
 
#define BAGL_ENCODING_LATIN1   0
 
#define BAGL_ENCODING_UTF8   1
 
#define BAGL_ENCODING_DEFAULT   BAGL_ENCODING_UTF8
 
#define IS_UNICODE(__value)   ((__value) > 0xF0)
 

Typedefs

typedef struct nbgl_unicode_ctx_s nbgl_unicode_ctx_t
 

Enumerations

enum  nbgl_font_id_e {
  BAGL_FONT_INTER_REGULAR_24px , BAGL_FONT_INTER_SEMIBOLD_24px , BAGL_FONT_INTER_MEDIUM_32px , BAGL_FONT_INTER_REGULAR_24px_1bpp ,
  BAGL_FONT_INTER_SEMIBOLD_24px_1bpp , BAGL_FONT_INTER_MEDIUM_32px_1bpp , BAGL_FONT_OPEN_SANS_EXTRABOLD_11px_1bpp = 8u , BAGL_FONT_OPEN_SANS_LIGHT_16px_1bpp = 9u ,
  BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp = 10u , BAGL_FONT_INTER_REGULAR_28px = 11u , BAGL_FONT_INTER_SEMIBOLD_28px = 12u , BAGL_FONT_INTER_MEDIUM_36px = 13u ,
  BAGL_FONT_INTER_REGULAR_28px_1bpp = 14u , BAGL_FONT_INTER_SEMIBOLD_28px_1bpp = 15u , BAGL_FONT_INTER_MEDIUM_36px_1bpp = 16u , BAGL_FONT_LAST
}
 

Functions

const nbgl_font_tnbgl_font_getFont (unsigned int fontId)
 
const nbgl_font_tnbgl_getFont (nbgl_font_id_e fontId)
 return the non-unicode font corresponding to the given font ID 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...
 
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...
 
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...
 
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...
 
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...
 
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...
 
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...
 
uint32_t nbgl_popUnicodeChar (const uint8_t **text, uint16_t *text_length, 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...
 

Detailed Description

Fonts types of the new BOLOS Graphical Library

Definition in file nbgl_fonts.h.

Macro Definition Documentation

◆ BAGL_ENCODING_DEFAULT

#define BAGL_ENCODING_DEFAULT   BAGL_ENCODING_UTF8

Definition at line 100 of file nbgl_fonts.h.

◆ BAGL_ENCODING_LATIN1

#define BAGL_ENCODING_LATIN1   0

Definition at line 98 of file nbgl_fonts.h.

◆ BAGL_ENCODING_UTF8

#define BAGL_ENCODING_UTF8   1

Definition at line 99 of file nbgl_fonts.h.

◆ IS_UNICODE

#define IS_UNICODE (   __value)    ((__value) > 0xF0)

Definition at line 228 of file nbgl_fonts.h.

◆ LANGUAGE_PACK

#define LANGUAGE_PACK   void

Definition at line 29 of file nbgl_fonts.h.

◆ PIC_BMP

#define PIC_BMP (   x)    ((uint8_t const *) PIC(x))

Definition at line 26 of file nbgl_fonts.h.

◆ PIC_CHAR

#define PIC_CHAR (   x)    ((const nbgl_font_character_t *) PIC(x))

Definition at line 25 of file nbgl_fonts.h.

Typedef Documentation

◆ nbgl_unicode_ctx_t

Enumeration Type Documentation

◆ nbgl_font_id_e

Enumerator
BAGL_FONT_INTER_REGULAR_24px 
BAGL_FONT_INTER_SEMIBOLD_24px 
BAGL_FONT_INTER_MEDIUM_32px 
BAGL_FONT_INTER_REGULAR_24px_1bpp 
BAGL_FONT_INTER_SEMIBOLD_24px_1bpp 
BAGL_FONT_INTER_MEDIUM_32px_1bpp 
BAGL_FONT_OPEN_SANS_EXTRABOLD_11px_1bpp 
BAGL_FONT_OPEN_SANS_LIGHT_16px_1bpp 
BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp 
BAGL_FONT_INTER_REGULAR_28px 
BAGL_FONT_INTER_SEMIBOLD_28px 
BAGL_FONT_INTER_MEDIUM_36px 
BAGL_FONT_INTER_REGULAR_28px_1bpp 
BAGL_FONT_INTER_SEMIBOLD_28px_1bpp 
BAGL_FONT_INTER_MEDIUM_36px_1bpp 
BAGL_FONT_LAST 

Definition at line 140 of file nbgl_fonts.h.

Function Documentation

◆ nbgl_font_getFont()

const nbgl_font_t* nbgl_font_getFont ( unsigned int  fontId)

◆ nbgl_getCharWidth()

uint8_t nbgl_getCharWidth ( nbgl_font_id_e  fontId,
const char *  text 
)

return the width in pixels of the given UTF-8 character

Parameters
fontIdfont ID
textUTF-8 character
Returns
the width in pixels of the character

Definition at line 372 of file nbgl_fonts.c.

◆ nbgl_getFont()

const nbgl_font_t* nbgl_getFont ( nbgl_font_id_e  fontId)

return the non-unicode font corresponding to the given font ID

Parameters
fontIdfont ID
Returns
the found font or NULL

Definition at line 136 of file nbgl_fonts.c.

◆ nbgl_getFontHeight()

uint8_t nbgl_getFontHeight ( nbgl_font_id_e  fontId)

return the height in pixels of the font with the given font ID

Parameters
fontIdfont ID
Returns
the height in pixels

Definition at line 398 of file nbgl_fonts.c.

◆ nbgl_getFontLineHeight()

uint8_t nbgl_getFontLineHeight ( nbgl_font_id_e  fontId)

return the height in pixels of the line of font with the given font ID

Parameters
fontIdfont ID
Returns
the height in pixels

Definition at line 410 of file nbgl_fonts.c.

◆ nbgl_getSingleLineTextWidth()

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

Parameters
fontIdfont ID
texttext in UTF8
Returns
the width in pixels of the text

Definition at line 334 of file nbgl_fonts.c.

◆ nbgl_getSingleLineTextWidthInLen()

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.

Parameters
fontIdfont ID
texttext in UTF8
maxLenmax number of bytes to parse
Returns
the width in pixels of the text

Definition at line 348 of file nbgl_fonts.c.

◆ nbgl_getTextHeight()

uint16_t nbgl_getTextHeight ( nbgl_font_id_e  fontId,
const char *  text 
)

return the height of the given multiline text, with the given font.

Parameters
fontIdfont ID
texttext to get the height from
Returns
the height in pixels

Definition at line 441 of file nbgl_fonts.c.

◆ nbgl_getTextHeightInWidth()

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.

Parameters
fontIdfont ID
texttext to get the height from
maxWidthmaximum width in which the text must fit
wrappingif true, lines are split on separators like spaces,
...
Returns
the height in pixels

Definition at line 1048 of file nbgl_fonts.c.

◆ nbgl_getTextLength()

uint16_t nbgl_getTextLength ( const char *  text)

return the number of bytes of the given text, excluding final '
' or '\0'

Note
'
' and '\0' are considered as end of string
Parameters
texttext to get the number of bytes from
Returns
the number of bytes in the given text

Definition at line 454 of file nbgl_fonts.c.

◆ nbgl_getTextMaxLenAndWidth()

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

Parameters
fontIdfont ID
textinput UTF-8 string, possibly multi-line (but only first line, before
, is used)
maxWidthmaximum 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
wrappingif true, lines are split on separators like spaces,
...
Returns
true if maxWidth is reached, false otherwise

Definition at line 482 of file nbgl_fonts.c.

◆ nbgl_getTextMaxLenAndWidthFromEnd()

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

Note
works only with ASCII string
Parameters
fontIdfont ID
textinput ascii string, possibly multi-line (but only first line is handled)
maxWidthmaximum 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
Returns
true if maxWidth is reached, false otherwise

Definition at line 681 of file nbgl_fonts.c.

◆ nbgl_getTextMaxLenInNbLines()

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

Parameters
fontIdfont ID
textinput UTF-8 string, possibly multi-line
maxWidthmaximum width in bytes, if text is greater than that the parsing is escaped
maxNbLinesmaximum number of lines, if text is greater than that the parsing is escaped
len(output) consumed bytes in text fitting in maxWidth
wrappingif true, lines are split on separators like spaces,
...
Returns
true if maxNbLines is reached, false otherwise

Definition at line 572 of file nbgl_fonts.c.

◆ nbgl_getTextNbLines()

uint16_t nbgl_getTextNbLines ( const char *  text)

return the number of lines in the given text, according to the found '
's

Parameters
texttext to get the number of lines from
Returns
the number of lines in the given text

Definition at line 422 of file nbgl_fonts.c.

◆ nbgl_getTextNbLinesInWidth()

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

Parameters
fontIdfont ID
textUTF-8 text to get the number of lines from
maxWidthmaximum width in which the text must fit
wrappingif true, lines are split on separators like spaces,
...
Returns
the number of lines in the given text

Definition at line 731 of file nbgl_fonts.c.

◆ nbgl_getTextNbPagesInWidth()

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

Parameters
fontIdfont ID
textUTF-8 text to get the number of pages from
nbLinesPerPagenumber of lines in a page
maxWidthmaximum width in which the text must fit
Returns
the number of pages in the given text

Definition at line 885 of file nbgl_fonts.c.

◆ nbgl_getTextWidth()

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)

Parameters
fontIdfont ID
texttext in UTF8
Returns
the width in pixels of the text

Definition at line 360 of file nbgl_fonts.c.

◆ nbgl_popUnicodeChar()

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.

Parameters
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)
Returns
unicode (or ascii-7) value of the found character

Definition at line 150 of file nbgl_fonts.c.

◆ nbgl_textReduceOnNbLines()

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.

Note
the number of line must be odd
Parameters
fontIdfont ID
origText(input) ASCII string, must be single line
maxWidthmaximum 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 1179 of file nbgl_fonts.c.

◆ nbgl_textWrapOnNbLines()

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,.

Parameters
fontIdfont ID
text(input/output) UTF-8 string, possibly multi-line
maxWidthmaximum 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.