Skip to content

Commit 285b5bf

Browse files
Remove language dependency from NBGL
1 parent fddeb90 commit 285b5bf

File tree

10 files changed

+130
-124
lines changed

10 files changed

+130
-124
lines changed

lib_nbgl/include/nbgl_fonts.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,20 @@ extern "C" {
1515
* INCLUDES
1616
*********************/
1717
#include "nbgl_types.h"
18+
#ifdef HAVE_LANGUAGE_PACK
19+
#include "ux_loc_nbgl.h"
20+
#endif // HAVE_LANGUAGE_PACK
1821

1922
/*********************
2023
* DEFINES
2124
*********************/
2225
#define PIC_CHAR(x) ((const nbgl_font_character_t *) PIC(x))
2326
#define PIC_BMP(x) ((uint8_t const *) PIC(x))
2427

28+
#ifndef HAVE_LANGUAGE_PACK
29+
#define LANGUAGE_PACK void
30+
#endif // HAVE_LANGUAGE_PACK
31+
2532
/**
2633
* @brief fonts nicknames to be used for various wallet size targets (non-Nano)
2734
*
@@ -212,9 +219,7 @@ uint32_t nbgl_popUnicodeChar(const uint8_t **text, uint16_t *text_length, bool *
212219
nbgl_unicode_ctx_t *nbgl_getUnicodeFont(nbgl_font_id_e font_id);
213220
const nbgl_font_unicode_character_t *nbgl_getUnicodeFontCharacter(uint32_t unicode);
214221
uint32_t nbgl_getUnicodeFontCharacterByteCount(void);
215-
#ifdef HAVE_LANGUAGE_PACK
216-
void nbgl_refreshUnicodeFont(void);
217-
#endif
222+
void nbgl_refreshUnicodeFont(const LANGUAGE_PACK *lp);
218223
#endif // HAVE_UNICODE_SUPPORT
219224

220225
/**********************

lib_nbgl/include/nbgl_obj.h

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -393,18 +393,14 @@ typedef char *(*onTextDrawCallback_t)(uint8_t token);
393393
*
394394
*/
395395
typedef struct PACKED__ nbgl_button_s {
396-
nbgl_obj_t obj; ///< common part
397-
color_t innerColor; ///< color set inside of the button
398-
color_t borderColor; ///< color set to button's border
399-
color_t foregroundColor; ///< color set to '1' bits in icon, and text. '0' are set to
400-
///< innerColor color.
401-
nbgl_radius_t radius; ///< radius of the corners, must be a multiple of 4.
402-
nbgl_font_id_e fontId; ///< id of the font to use, if any
403-
bool localized; ///< if set to true, means the following 'text' field is considered as a
404-
const char *text; ///< single line UTF-8 text (NULL terminated)
405-
#ifdef HAVE_LANGUAGE_PACK
406-
UX_LOC_STRINGS_INDEX textId; ///< id of the text single line UTF-8 text
407-
#endif // HAVE_LANGUAGE_PACK
396+
nbgl_obj_t obj; ///< common part
397+
color_t innerColor; ///< color set inside of the button
398+
color_t borderColor; ///< color set to button's border
399+
color_t foregroundColor; ///< color set to '1' bits in icon, and text. '0' are set to
400+
///< innerColor color.
401+
nbgl_radius_t radius; ///< radius of the corners, must be a multiple of 4.
402+
nbgl_font_id_e fontId; ///< id of the font to use, if any
403+
const char *text; ///< single line UTF-8 text (NULL terminated)
408404
onTextDrawCallback_t onDrawCallback; ///< function called if not NULL, with above token as
409405
///< parameter to get the text of the button
410406
uint8_t token; ///< token to use as param of onDrawCallback
@@ -421,17 +417,13 @@ typedef struct PACKED__ nbgl_text_area_s {
421417
nbgl_aligment_t textAlignment; ///< alignment of text within the area
422418
nbgl_style_t style; ///< to define the style of border
423419
nbgl_font_id_e fontId; ///< id of the font to use
424-
bool localized; ///< if set to true, use textId instead of text
425420
bool autoHideLongLine; ///< if set to true, replace beginning of line by ... to keep it single
426421
///< line
427422
bool wrapping; ///< if set to true, break lines on ' ' when possible
428423
uint8_t nbMaxLines; ///< if >0, replace end (3 last chars) of line (nbMaxLines-1) by "..." and
429424
///< stop display here
430425
const char *text; ///< ASCII text to draw (NULL terminated). Can be NULL.
431426
uint16_t len; ///< number of bytes to write (if 0, max number of chars or strlen is used)
432-
#ifdef HAVE_LANGUAGE_PACK
433-
UX_LOC_STRINGS_INDEX textId; ///< id of the UTF-8 text
434-
#endif // HAVE_LANGUAGE_PACK
435427
onTextDrawCallback_t
436428
onDrawCallback; ///< function called if not NULL to get the text of the text area
437429
uint8_t token; ///< token to use as param of onDrawCallback

lib_nbgl/src/nbgl_draw.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,10 @@ nbgl_font_id_e nbgl_drawText(const nbgl_area_t *area,
543543
{
544544
// text is a series of characters, each character being a bitmap
545545
// we need to align bitmaps on width multiple of 4 limitation.
546-
int16_t x = area->x0;
547-
nbgl_area_t rectArea;
548-
const nbgl_font_t *font = nbgl_getFont(fontId);
546+
int16_t x = area->x0;
547+
nbgl_area_t rectArea;
548+
const nbgl_font_t *font = nbgl_getFont(fontId);
549+
nbgl_unicode_ctx_t *unicode_ctx = NULL;
549550

550551
LOG_DEBUG(DRAW_LOGGER,
551552
"nbgl_drawText: x0 = %d, y0 = %d, w = %d, h = %d, fontColor = %d, "
@@ -558,10 +559,6 @@ nbgl_font_id_e nbgl_drawText(const nbgl_area_t *area,
558559
area->backgroundColor,
559560
text);
560561

561-
#ifdef HAVE_UNICODE_SUPPORT
562-
nbgl_unicode_ctx_t *unicode_ctx = nbgl_getUnicodeFont(fontId);
563-
#endif // HAVE_UNICODE_SUPPORT
564-
565562
rectArea.backgroundColor = area->backgroundColor;
566563
rectArea.bpp = (nbgl_bpp_t) font->bpp;
567564

@@ -583,6 +580,9 @@ nbgl_font_id_e nbgl_drawText(const nbgl_area_t *area,
583580

584581
if (is_unicode) {
585582
#ifdef HAVE_UNICODE_SUPPORT
583+
if (unicode_ctx == NULL) {
584+
unicode_ctx = nbgl_getUnicodeFont(fontId);
585+
}
586586
const nbgl_font_unicode_character_t *unicodeCharacter
587587
= nbgl_getUnicodeFontCharacter(unicode);
588588
// if not supported char, go to next one

0 commit comments

Comments
 (0)