Skip to content

Commit

Permalink
Merge pull request #493 from LedgerHQ/decrease-HM-font-usage
Browse files Browse the repository at this point in the history
Remove usage of HM Alpha font
  • Loading branch information
nroggeman-ledger committed Dec 13, 2023
2 parents 00e153d + 46d4d01 commit b2565ee
Show file tree
Hide file tree
Showing 25 changed files with 51 additions and 107 deletions.
1 change: 0 additions & 1 deletion Makefile.defines
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ ifeq ($(TARGET_NAME),TARGET_STAX)
DEFINES += HAVE_BAGL_FONT_INTER_REGULAR_24PX
DEFINES += HAVE_BAGL_FONT_INTER_SEMIBOLD_24PX
DEFINES += HAVE_BAGL_FONT_INTER_MEDIUM_32PX
DEFINES += HAVE_BAGL_FONT_HMALPHAMONO_MEDIUM_32PX
DEFINES += HAVE_INAPP_BLE_PAIRING
DEFINES += HAVE_NBGL
DEFINES += HAVE_PIEZO_SOUND
Expand Down
1 change: 0 additions & 1 deletion lib_nbgl/doc/nbgl_layout.dox
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ The API to insert such an object is @ref nbgl_layoutAddCenteredInfo(), using @re
The colors and fonts for the texts depends of the \b style field used in @ref nbgl_layoutCenteredInfo_t.

- if @ref LARGE_CASE_INFO, main text is in @ref BLACK and large case (INTER 32px), subText in @ref BLACK in INTER 24px
- if @ref LEDGER_INFO, only text, in @ref BLACK and upper case (HM ALPHA MONO 32px), with Ledger border
- if @ref NORMAL_INFO, icon in black and main text in INTER 24px in @ref BLACK under it, subText in INTER 24px in @ref DARK_GRAY under it

@subsection choice_buttons Choice buttons
Expand Down
11 changes: 5 additions & 6 deletions lib_nbgl/doc/nbgl_page.dox
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The configuration of a page is provided in a single function call, and all prede

A few APIs are available to draw typical pages, like:

- @ref nbgl_pageDrawLedgerInfo() to draw a simple centered text in Ledger format (typically to provide the status of an action)
- @ref nbgl_pageDrawLedgerInfo() to draw a simple centered text in a center info in large case, with a round check icon (typically to provide the status of an action)
- @ref nbgl_pageDrawSpinner() to draw a spinner (typically a waiting screen)
- @ref nbgl_pageDrawInfo() to draw a centered info with potential footer (or bottom button), "tapable" container and top-right button
- @ref nbgl_pageDrawConfirmation() to draw a typical confirmation screen, for example when rejecting a transaction (with 1 button for confirmation)
Expand All @@ -63,11 +63,11 @@ or for a multi-pages configuration.

\image{inline} html page3.png "caption" height=300

This type is intended to draw a simple centered text in Ledger format (typically to provide the status of an action)
This type is intended to draw a simple centered text in large case, with a round check icon (typically to provide the status of an action)

The API to insert such an object is @ref nbgl_pageDrawLedgerInfo() with:

- The text to draw in Ledger frame (upper-case is mandatory).
- The text to draw in centered info
- A potential ticker configuration.

@subsubsection page_spinner Spinner
Expand All @@ -76,10 +76,9 @@ The API to insert such an object is @ref nbgl_pageDrawLedgerInfo() with:

This type is intended to to draw a spinner (typically a waiting screen)

The API to insert such an object is @ref nbgl_pageDrawLedgerInfo() with:
The API to insert such an object is @ref nbgl_pageDrawSpinner() with:

- The text to draw in Ledger frame (upper-case is mandatory).
- A potential ticker configuration.
- The text to draw.

@subsubsection page_info Generic information

Expand Down
14 changes: 7 additions & 7 deletions lib_nbgl/doc/nbgl_use_case.dox
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ static void onConfirmAbandon(void) {
static void reviewChoice(bool confirm) {
if (confirm) {
// display a status page and go back to main
nbgl_useCaseStatus("TRANSACTION\nSIGNED",true,appMain);
nbgl_useCaseStatus("Transaction signed",true,appMain);
}
else {
nbgl_useCaseConfirm("Reject transaction?","Yes, Reject","Go back to transaction",onConfirmAbandon);
Expand Down Expand Up @@ -488,7 +488,7 @@ static void onConfirmAbandon(void) {
static void reviewChoice(bool confirm) {
if (confirm) {
// display a status page and go back to main
nbgl_useCaseStatus("TRANSACTION\nSIGNED",true,appMain);
nbgl_useCaseStatus("Transaction signed",true,appMain);
}
else {
nbgl_useCaseConfirm("Reject transaction?","Yes, Reject","Go back to transaction",onConfirmAbandon);
Expand Down Expand Up @@ -573,7 +573,7 @@ static void onConfirmAbandon(void) {
static void reviewChoice(bool confirm) {
if (confirm) {
// display a status page and go back to main
nbgl_useCaseStatus("TRANSACTION\nSIGNED",true,appMain);
nbgl_useCaseStatus("Transaction signed",true,appMain);
}
else {
// display a confirmation to confirm/cancel rejection
Expand Down Expand Up @@ -619,7 +619,7 @@ static void onConfirmAbandon(void) {
static void reviewChoice(bool confirm) {
if (confirm) {
// display a status page and go back to main
nbgl_useCaseStatus("TRANSACTION\nSIGNED",true,appMain);
nbgl_useCaseStatus("Transaction signed",true,appMain);
}
else {
// display a confirmation to confirm/cancel rejection
Expand Down Expand Up @@ -722,7 +722,7 @@ static void onConfirmAbandon(void) {
static void reviewChoice(bool confirm) {
if (confirm) {
// display a status page and go back to main
nbgl_useCaseStatus("TRANSACTION\nSIGNED",true,appMain);
nbgl_useCaseStatus("Transaction signed",true,appMain);
}
else {
nbgl_useCaseConfirm("Reject transaction?","Yes, Reject","Go back to transaction",onConfirmAbandon);
Expand Down Expand Up @@ -789,7 +789,7 @@ Here is the code to display something similar to example picture:
// called when either confirm button or reject token is called
static void displayAddressCallback(bool confirm) {
if (confirm) {
nbgl_useCaseStatus("ADDRESS\nVERIFIED",true,app_fullEthereum);
nbgl_useCaseStatus("Address\nVerified",true,app_fullEthereum);
}
else {
nbgl_useCaseStatus("Address rejected",false,app_fullEthereum);
Expand All @@ -809,7 +809,7 @@ void app_ethereumVerifyAddress(void) {

@subsection use_case_addr_confirm_ext Extended Address Confirmation Use Case

\image{inline} html UseCase-AddressConfirmationExt.png "caption" height=300
\image{inline} html UseCase-AddressConfirmationExt.png "caption" height=500

When an address needs to be confirmed, it can be displayed in a Address Confirmation Use Case, at first as simple page with
the raw address (as text). An extra button under the raw address enables to open a modal page to see the address as a QR code.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lib_nbgl/doc/resources/UseCase-Status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lib_nbgl/doc/resources/page3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion lib_nbgl/include/nbgl_font_rom.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
********************************************************************************/

#ifdef HAVE_SE_TOUCH
#include "nbgl_font_hmalpha_mono_medium_32.inc"
#include "nbgl_font_inter_regular_24.inc"
#include "nbgl_font_inter_semibold_24.inc"
#include "nbgl_font_inter_medium_32.inc"
Expand Down
4 changes: 0 additions & 4 deletions lib_nbgl/include/nbgl_font_rom_struct.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
&fontINTER_MEDIUM_32PX,
#endif // HAVE_BAGL_FONT_INTER_MEDIUM_32PX

#ifdef HAVE_BAGL_FONT_HMALPHAMONO_MEDIUM_32PX
&fontHMALPHAMONO_MEDIUM_32PX,
#endif // HAVE_BAGL_FONT_HMALPHAMONO_MEDIUM_32PX

#ifdef HAVE_BAGL_FONT_INTER_REGULAR_24PX
&fontINTER_REGULAR_24PX_1BPP,
#endif // HAVE_BAGL_FONT_INTER_REGULAR_24PX
Expand Down
1 change: 0 additions & 1 deletion lib_nbgl/include/nbgl_fonts.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ typedef enum {
BAGL_FONT_INTER_REGULAR_24px,
BAGL_FONT_INTER_SEMIBOLD_24px,
BAGL_FONT_INTER_MEDIUM_32px,
BAGL_FONT_HM_ALPHA_MONO_MEDIUM_32px,
BAGL_FONT_INTER_REGULAR_24px_1bpp,
BAGL_FONT_INTER_SEMIBOLD_24px_1bpp,
BAGL_FONT_INTER_MEDIUM_32px_1bpp,
Expand Down
1 change: 0 additions & 1 deletion lib_nbgl/include/nbgl_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ typedef enum {
LARGE_CASE_INFO, ///< text in BLACK and large case (INTER 32px), subText in black in Inter24px
LARGE_CASE_BOLD_INFO, ///< text in BLACK and large case (INTER 32px), subText in black bold
///< Inter24px, text3 in black Inter24px
LEDGER_INFO, ///< only text, in BLACK and upper case (HM ALPHA MONO), with Ledger border
NORMAL_INFO, ///< Icon in black, a potential text in black bold 24px under it, a potential text
///< in dark gray (24px) under it, a potential text in black (24px) under it
PLUGIN_INFO ///< A potential text in black 32px, a potential text in black (24px) under it, a
Expand Down
1 change: 0 additions & 1 deletion lib_nbgl/include/nbgl_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ typedef enum {
*/
typedef enum {
NO_STYLE, ///< no border
LEDGER_BORDER, ///< Ledger style border, only for @ref TEXT_AREA
INVERTED_COLORS ///< Inverted background and rounded corners, only for @ref TEXT_AREA
} nbgl_style_t;

Expand Down
4 changes: 2 additions & 2 deletions lib_nbgl/serialization/generate_data_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void test_draw_nbgl_text_area()

.textColor = BLACK,
.textAlignment = BOTTOM_RIGHT,
.style = LEDGER_BORDER,
.style = NO_STYLE,
.fontId = BAGL_FONT_INTER_MEDIUM_32px,
.localized = false,
.autoHideLongLine = true,
Expand Down Expand Up @@ -218,7 +218,7 @@ void test_draw_nbgl_button()
.borderColor = DARK_GRAY,
.foregroundColor = LIGHT_GRAY,
.radius = RADIUS_24_PIXELS,
.fontId = BAGL_FONT_HM_ALPHA_MONO_MEDIUM_32px,
.fontId = BAGL_FONT_INTER_MEDIUM_32px,
.localized = true,
.text = "Test button",
};
Expand Down
10 changes: 4 additions & 6 deletions lib_nbgl/serialization/nbgl_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,17 @@ class NbglFontId(IntEnum):
BAGL_FONT_INTER_REGULAR_24px = 0,
BAGL_FONT_INTER_SEMIBOLD_24px = 1,
BAGL_FONT_INTER_MEDIUM_32px = 2,
BAGL_FONT_HM_ALPHA_MONO_MEDIUM_32px = 3
BAGL_FONT_INTER_REGULAR_24px_1bpp = 4
BAGL_FONT_INTER_SEMIBOLD_24px_1bpp = 5
BAGL_FONT_INTER_MEDIUM_32px_1bpp = 6
BAGL_FONT_INTER_REGULAR_24px_1bpp = 3
BAGL_FONT_INTER_SEMIBOLD_24px_1bpp = 4
BAGL_FONT_INTER_MEDIUM_32px_1bpp = 5
BAGL_FONT_OPEN_SANS_EXTRABOLD_11px_1bpp = 8
BAGL_FONT_OPEN_SANS_LIGHT_16px_1bpp = 9
BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp = 10


class NbglStyle(IntEnum):
NO_STYLE = 0,
LEDGER_BORDER = 1,
INVERTED_COLORS = 2
INVERTED_COLORS = 1


def parse_str(data: bytes) -> str:
Expand Down
4 changes: 2 additions & 2 deletions lib_nbgl/serialization/test_bytes_deserialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_draw_nbgl_text_area(data_test):

text_color=NbglColor.BLACK,
text_alignment=NbglAlignment.BOTTOM_RIGHT,
style=NbglStyle.LEDGER_BORDER,
style=NbglStyle.NO_STYLE,
font_id=NbglFontId.BAGL_FONT_INTER_MEDIUM_32px,
localized=False,
auto_hide_long_line=True,
Expand Down Expand Up @@ -271,7 +271,7 @@ def test_draw_nbgl_button(data_test):
border_color=NbglColor.DARK_GRAY,
foreground_color=NbglColor.LIGHT_GRAY,
radius=NbglRadius.RADIUS_24_PIXELS,
font_id=NbglFontId.BAGL_FONT_HM_ALPHA_MONO_MEDIUM_32px,
font_id=NbglFontId.BAGL_FONT_INTER_MEDIUM_32px,
text="Test button",
localized=True
),
Expand Down
4 changes: 2 additions & 2 deletions lib_nbgl/serialization/test_json_ser_deser.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def test_json_deserialize_text_area():
},
'text_color': 'BLACK',
'text_alignment': 'RIGHT_BOTTOM',
'style': 'LEDGER_BORDER',
'style': 'NO_STYLE',
'font_id': 'BAGL_FONT_INTER_SEMIBOLD_24px',
'localized': True,
'auto_hide_long_line': True,
Expand All @@ -385,7 +385,7 @@ def test_json_deserialize_text_area():
),
text_color=NbglColor.BLACK,
text_alignment=NbglAlignment.RIGHT_BOTTOM,
style=NbglStyle.LEDGER_BORDER,
style=NbglStyle.NO_STYLE,
font_id=NbglFontId.BAGL_FONT_INTER_SEMIBOLD_24px,
localized=True,
auto_hide_long_line=True,
Expand Down
6 changes: 4 additions & 2 deletions lib_nbgl/src/nbgl_fonts.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ extern const LANGUAGE_PACK *language_pack;
#endif // defined(HAVE_LANGUAGE_PACK)

#if defined(BOLOS_OS_UPGRADER_APP)
#include "nbgl_font_hmalpha_mono_medium_32.inc"
#include "nbgl_font_inter_regular_24.inc"
#include "nbgl_font_inter_semibold_24.inc"
#include "nbgl_font_inter_medium_32.inc"
Expand Down Expand Up @@ -121,7 +120,7 @@ const nbgl_font_t *nbgl_getFont(nbgl_font_id_e fontId)
* @brief 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.
*
* @param txt (in/out) text to get character from. Updated after pop to the next UTF-8 char
* @param text (in/out) text to get character from. Updated after pop to the next UTF-8 char
* @param textLen (in/out) remaining length in given text (before '\n' or '\0')
* @param is_unicode (out) set to true if it's a real unicode (not ASCII)
* @return unicode (or ascii-7) value of the found character
Expand Down Expand Up @@ -290,6 +289,7 @@ uint16_t nbgl_getSingleLineTextWidth(nbgl_font_id_e fontId, const char *text)
*
* @param fontId font ID
* @param text text in UTF8
* @param maxLen max number of bytes to parse
* @return the width in pixels of the text
*/
uint16_t nbgl_getSingleLineTextWidthInLen(nbgl_font_id_e fontId, const char *text, uint16_t maxLen)
Expand Down Expand Up @@ -417,6 +417,7 @@ uint16_t nbgl_getTextLength(const char *text)
* @param maxWidth maximum width in bytes, if text is greater than that the parsing is escaped
* @param len (output) consumed bytes in text fitting in maxWidth
* @param width (output) set to maximum width in pixels in text fitting in maxWidth
* @param wrapping if true, lines are split on separators like spaces, \n...
*
* @return true if maxWidth is reached, false otherwise
*
Expand Down Expand Up @@ -866,6 +867,7 @@ uint8_t nbgl_getTextNbPagesInWidth(nbgl_font_id_e fontId,
* @param fontId font ID
* @param text text to get the height from
* @param maxWidth maximum width in which the text must fit
* @param wrapping if true, lines are split on separators like spaces, \n...
* @return the height in pixels
*/
uint16_t nbgl_getTextHeightInWidth(nbgl_font_id_e fontId,
Expand Down
16 changes: 3 additions & 13 deletions lib_nbgl/src/nbgl_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1408,11 +1408,8 @@ int nbgl_layoutAddCenteredInfo(nbgl_layout_t *layout, const nbgl_layoutCenteredI
textArea->textColor = BLACK;
textArea->text = PIC(info->text1);
textArea->textAlignment = CENTER;
if (info->style == LEDGER_INFO) {
textArea->fontId = BAGL_FONT_HM_ALPHA_MONO_MEDIUM_32px;
}
else if ((info->style == LARGE_CASE_INFO) || (info->style == LARGE_CASE_BOLD_INFO)
|| (info->style == PLUGIN_INFO)) {
if ((info->style == LARGE_CASE_INFO) || (info->style == LARGE_CASE_BOLD_INFO)
|| (info->style == PLUGIN_INFO)) {
textArea->fontId = BAGL_FONT_INTER_MEDIUM_32px;
}
else {
Expand All @@ -1423,14 +1420,7 @@ int nbgl_layoutAddCenteredInfo(nbgl_layout_t *layout, const nbgl_layoutCenteredI
textArea->obj.area.height = nbgl_getTextHeightInWidth(
textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping);

if (info->style == LEDGER_INFO) {
textArea->style = LEDGER_BORDER;
textArea->obj.area.width = SCREEN_WIDTH - 2 * 40;
textArea->obj.area.height += 2 * 16;
}
else {
textArea->style = NO_STYLE;
}
textArea->style = NO_STYLE;
if (container->nbChildren > 0) {
textArea->obj.alignment = BOTTOM_MIDDLE;
textArea->obj.alignTo = (nbgl_obj_t *) container->children[container->nbChildren - 1];
Expand Down
28 changes: 0 additions & 28 deletions lib_nbgl/src/nbgl_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,34 +836,6 @@ static void draw_textArea(nbgl_text_area_t *obj, nbgl_obj_t *prevObj, bool compu
else {
nbgl_frontDrawRect(&rectArea);
}
// draw border with given style
if (obj->style == LEDGER_BORDER) {
// draw horizontal segments (4 pixels stroke)
rectArea.x0 = obj->obj.area.x0;
rectArea.y0 = obj->obj.area.y0;
rectArea.width = 24;
rectArea.height = 4;
nbgl_frontDrawHorizontalLine(&rectArea, 0xF, obj->textColor); // top left
rectArea.x0 = obj->obj.area.x0 + obj->obj.area.width - rectArea.width;
nbgl_frontDrawHorizontalLine(&rectArea, 0xF, obj->textColor); // top right
rectArea.y0 = obj->obj.area.y0 + obj->obj.area.height - 4;
nbgl_frontDrawHorizontalLine(&rectArea, 0xF, obj->textColor); // bottom right
rectArea.x0 = obj->obj.area.x0;
nbgl_frontDrawHorizontalLine(&rectArea, 0xF, obj->textColor); // bottom left
// draw vertical segments (4 pixels stroke)
rectArea.x0 = obj->obj.area.x0;
rectArea.y0 = obj->obj.area.y0 + 4;
rectArea.width = 4;
rectArea.height = 12;
rectArea.backgroundColor = obj->textColor;
nbgl_frontDrawRect(&rectArea); // top left
rectArea.x0 = obj->obj.area.x0 + obj->obj.area.width - rectArea.width;
nbgl_frontDrawRect(&rectArea); // top right
rectArea.y0 = obj->obj.area.y0 + obj->obj.area.height - rectArea.height - 4;
nbgl_frontDrawRect(&rectArea); // bottom right
rectArea.x0 = obj->obj.area.x0;
nbgl_frontDrawRect(&rectArea); // bottom left
}

fontHeight = nbgl_getFontHeight(fontId);
lineHeight = nbgl_getFontLineHeight(fontId);
Expand Down
Loading

0 comments on commit b2565ee

Please sign in to comment.