Skip to content

Commit

Permalink
fix(draw_label) Detect and skip first ' ' after recolor command
Browse files Browse the repository at this point in the history
  • Loading branch information
C47D committed Oct 19, 2024
1 parent 094367c commit 4140a34
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/draw/lv_draw_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ void lv_draw_label_iterate_characters(lv_draw_unit_t * draw_unit, const lv_draw_
int32_t letter_w;
cmd_state_t cmd_state = CMD_STATE_WAIT;
lv_color_t recolor = lv_color_black(); /* Holds the selected color inside the recolor command */
uint8_t is_first_space_after_cmd = 0;

/*Write out all lines*/
while(dsc->text[line_start] != '\0') {
Expand Down Expand Up @@ -314,6 +315,13 @@ void lv_draw_label_iterate_characters(lv_draw_unit_t * draw_unit, const lv_draw_
}
}

if((cmd_state == CMD_STATE_PAR) && (letter == ' ') && (is_first_space_after_cmd == 0)) {
is_first_space_after_cmd = 1;
}
else {
is_first_space_after_cmd = 0;
}

/* Skip the color parameter and wait the space after it
* Once we have reach the space ' ', then we will extract the color information
* and store it into the recolor variable */
Expand Down Expand Up @@ -346,6 +354,11 @@ void lv_draw_label_iterate_characters(lv_draw_unit_t * draw_unit, const lv_draw_
/*After the parameter the text is in the command*/
cmd_state = CMD_STATE_IN;
}

/* Don't draw the first space after the recolor command */
if(is_first_space_after_cmd) {
continue;
}
}

/* Check if the text selection is enabled */
Expand Down

0 comments on commit 4140a34

Please sign in to comment.