mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
long_txt fixed incorrect width calculation of break characters.
This commit is contained in:
parent
d85efb9926
commit
ab4c2bcd93
@ -190,31 +190,32 @@ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Check the transversed string pixel width*/
|
|
||||||
letter_w = lv_font_get_glyph_width(font, letter, letter_next);
|
letter_w = lv_font_get_glyph_width(font, letter, letter_next);
|
||||||
cur_w += letter_w;
|
cur_w += letter_w;
|
||||||
|
|
||||||
|
/* Always update the output width on the first character..
|
||||||
|
* Must do this here incase first letter is a break character. */
|
||||||
|
if( i == 0 && word_w_ptr != NULL) *word_w_ptr = cur_w;
|
||||||
|
|
||||||
/* Test if this character fits within max_width */
|
/* Test if this character fits within max_width */
|
||||||
if( break_index == NO_BREAK_FOUND && cur_w > max_width) {
|
if( break_index == NO_BREAK_FOUND && cur_w > max_width) {
|
||||||
/* break_index is now pointing at the character that doesn't fit */
|
|
||||||
break_index = i;
|
break_index = i;
|
||||||
if(break_index > 0) { /* zero is possible if first character doesn't fit in width */
|
if(break_index > 0) { /* zero is possible if first character doesn't fit in width */
|
||||||
lv_txt_encoded_prev(txt, &break_index);
|
lv_txt_encoded_prev(txt, &break_index);
|
||||||
}
|
}
|
||||||
|
/* break_index is now pointing at the character that doesn't fit */
|
||||||
break_letter_count = word_len - 1;
|
break_letter_count = word_len - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the output width */
|
|
||||||
if( word_w_ptr != NULL && break_index == NO_BREAK_FOUND ) {
|
|
||||||
*word_w_ptr = cur_w;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Check for new line chars and breakchars*/
|
/*Check for new line chars and breakchars*/
|
||||||
if(letter == '\n' || letter == '\r' || is_break_char(letter)) {
|
if(letter == '\n' || letter == '\r' || is_break_char(letter)) {
|
||||||
word_len--;
|
word_len--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update the output width */
|
||||||
|
if( word_w_ptr != NULL && break_index == NO_BREAK_FOUND ) *word_w_ptr = cur_w;
|
||||||
|
|
||||||
if(letter_w > 0) {
|
if(letter_w > 0) {
|
||||||
cur_w += letter_space;
|
cur_w += letter_space;
|
||||||
}
|
}
|
||||||
@ -299,7 +300,7 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
|
|||||||
uint32_t letter_next = lv_txt_encoded_next(txt, &i_next); /*Gets current character*/
|
uint32_t letter_next = lv_txt_encoded_next(txt, &i_next); /*Gets current character*/
|
||||||
tmp = i_next;
|
tmp = i_next;
|
||||||
letter_next = lv_txt_encoded_next(txt, &i_next); /*Gets subsequent character*/
|
letter_next = lv_txt_encoded_next(txt, &i_next); /*Gets subsequent character*/
|
||||||
if(letter_next == '\0') return tmp;
|
if(letter_next == '\0') i = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user