Comments (5)
if(headerBlockRightStatusSpans_Text[i][0])
lv_style_set_text_letter_space(&headerBlockRightStatusSpans[i]->style, 5);
I had to comment out this part or else I see something else troubling. No "E" or "F".
Anyways, after commenting out that part, I see this:
I can't reproduce the issue right this moment. I tried master
and release/v9.1
. I stepped through lv_draw_span
in a debugger although I'm not sure what I'm looking for yet 🙂 It's very possible that there is some subtle bug related to the second span of a spangroup. The span drawing code is large.
next steps
Are you sure the exact snippet you sent exposes the problem on your system? Or did you modify it and now the problem doesn't occur for that snippet?
Are you using a font that has some problem with the letter "B"? Can you try using a different character for the second span to rule out that possibility?
from lvgl.
@andyrea76
I've formatted your comment to have the code in a
```c
code
```
block for syntax highlighting.
from lvgl.
yes, having cut the code out of my project and got the windows simulator running, replacing lv_spangroup_create(rightHeaderRegion); with lv_spangroup_create(lv_screen_active());
i see the same thing as you where only the first 4 letters appear.
the real application is using unicode characters ( hence the commented out MSG_xxxx ends to the lines assigning 'A'-'F' instead ) but i just simplified it to prove the point
the fact that it stops showing the letters after D is surely a concern? all the test obviously does is to add padding after a string if there was a message in that element so it would make no sense to stop on the 4th item
the debugger shows that the elements are all looking vaguely valid in the watch window and appear to have the right string of text
but you only get A -> D printed
from lvgl.
leaving the letter spacing adjustment but removing the 'if' line still shows up the issue
from lvgl.
To summarize, there are two unique problems here
- The second span in a spangroup shows a garbage character instead of the real character.
- Setting the letter space style can cause the right side to be cut off.
Thanks for testing some things.
Problem 1
Can that problem be reproduced?
Problem 2
Yes, this is undesirable behavior. I spent a while creating a fix, but I began to see that zero-length spans and letter_space
are totally incompatible with each other. It would easily be a 100 line refactor to make both work together. Congrats on exposing a significant weakness in spangroup!
My advice for getting your project working is to not use letter_space
and zero-length spans at the same time.
As I said, getting both to work together is a big deal, but here are some fixes to make either letter_space
or zero-length spans work reliably on their own. I tested with LV_SPAN_MODE_EXPAND
and LV_SPAN_MODE_BREAK
with your example using either letter_space
style or zero-length spans but not both at the same time.
I can't make any promises about not breaking any other span features like ellipsis. I can be more thorough in a PR.
diff --git a/src/widgets/span/lv_span.c b/src/widgets/span/lv_span.c
index 8af5f2416..df38d4431 100644
--- a/src/widgets/span/lv_span.c
+++ b/src/widgets/span/lv_span.c
@@ -479,7 +479,11 @@ int32_t lv_spangroup_get_expand_height(lv_obj_t * obj, int32_t width)
/* break word deal width */
if(isfill && next_ofs > 0 && snippet_cnt > 0) {
- if(max_w < use_width) {
+ int32_t drawn_width = use_width;
+ if(_lv_ll_get_next(&spans->child_ll, cur_span) == NULL) {
+ drawn_width -= snippet.letter_space;
+ }
+ if(max_w < drawn_width) {
break;
}
@@ -502,7 +506,7 @@ int32_t lv_spangroup_get_expand_height(lv_obj_t * obj, int32_t width)
max_line_h = snippet.line_h;
}
snippet_cnt ++;
- max_w = max_w - use_width - snippet.letter_space;
+ max_w = max_w - use_width;
if(isfill || max_w <= 0) {
break;
}
@@ -871,9 +875,13 @@ static void lv_draw_span(lv_obj_t * obj, lv_layer_t * layer)
if(isfill) {
if(next_ofs > 0 && lv_get_snippet_count() > 0) {
+ int32_t drawn_width = use_width;
+ if(_lv_ll_get_next(&spans->child_ll, cur_span) == NULL) {
+ drawn_width -= snippet.letter_space;
+ }
/* To prevent infinite loops, the lv_text_get_next_line() may return incomplete words, */
/* This phenomenon should be avoided when lv_get_snippet_count() > 0 */
- if(max_w < use_width) {
+ if(max_w < drawn_width) {
break;
}
uint32_t tmp_ofs = next_ofs;
@@ -898,7 +906,7 @@ static void lv_draw_span(lv_obj_t * obj, lv_layer_t * layer)
}
lv_snippet_push(&snippet);
- max_w = max_w - use_width - snippet.letter_space;
+ max_w = max_w - use_width;
if(isfill || max_w <= 0) {
break;
}
@@ -946,7 +954,7 @@ static void lv_draw_span(lv_obj_t * obj, lv_layer_t * layer)
uint32_t i;
for(i = 0; i < item_cnt; i++) {
lv_snippet_t * pinfo = lv_get_snippet(i);
- txts_w = txts_w + pinfo->txt_w + pinfo->letter_space;
+ txts_w = txts_w + pinfo->txt_w;
}
txts_w -= lv_get_snippet(item_cnt - 1)->letter_space;
align_ofs = max_width > txts_w ? max_width - txts_w : 0;
from lvgl.
Related Issues (20)
- macOS buiold failure
- LVGL Integration strategy for Zephyr HOT 3
- Better sync between LVGL and Zephyr for runtime hw rotation HOT 2
- Animation and keyboard input conflict
- Setting system time under Linux affects ticks HOT 1
- screen refresh rate is very low HOT 5
- Problem with lv_demo_widgets demo(Instrument panel) after porting code to hardware HOT 1
- Button Matrix cannot be removed from lv_conf.h HOT 1
- Tiny TTF causes crash in certain situations HOT 1
- Tiny TTF should be caching stbtt_FindGlyphIndex HOT 26
- Line 11 of src/libs/tiny_ttf.c declared incorrectly HOT 1
- Docs build break HOT 1
- 8.4/9.1 Hardware based display rotation input devices HOT 5
- LV_COLOR_16_SWAP removal and performance HOT 2
- About the Release Date of New Versions HOT 2
- Slider Indicator Bigger Image Replacement on Press Event HOT 1
- "Does the lv_fs_dir_open function support opening directories with Chinese paths?" HOT 2
- ESP32 SPIFFS HOT 4
- animation LV_ANIM_REPEAT_INFINITE not works? HOT 1
- Overflow focus not handled correctly on full_refresh=0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lvgl.