Skip to content

feat(text): add text leading trim#9919

Open
kisvegabor wants to merge 13 commits intolvgl:masterfrom
kisvegabor:text-leading-trim
Open

feat(text): add text leading trim#9919
kisvegabor wants to merge 13 commits intolvgl:masterfrom
kisvegabor:text-leading-trim

Conversation

@kisvegabor
Copy link
Copy Markdown
Member

Fixes #6131
Continues: #9743

I needed to generate all built-in fonts again, and the bitmaps are formatted differently (e.g. 0x7 -> 0x07) and also there are 1 bit differences in a few cases. I manually reverted the Montserrat 14 font's bitmaps to avoid having too many ref image changes, but in other fonts triggered some very small changes on some images.

@FASTSHIFT I also updated how static fonts are handled in VGLite.

This image show what this feature does:
image

Notes

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 26, 2026

Hi 👋, thank you for your PR!

We've run benchmarks in an emulated environment. Here are the results:

ARM Emulated 32b - lv_conf_perf32b

Scene Name Avg CPU (%) Avg FPS Avg Time (ms) Render Time (ms) Flush Time (ms)
All scenes avg. 27 37 7 7 0
Detailed Results Per Scene
Scene Name Avg CPU (%) Avg FPS Avg Time (ms) Render Time (ms) Flush Time (ms)
Empty screen 11 33 0 0 0
Moving wallpaper 2 33 1 1 0
Single rectangle 0 50 0 0 0
Multiple rectangles 0 33 0 0 0
Multiple RGB images 0 39 0 0 0
Multiple ARGB images 11 (+1) 39 (-2) 3 3 0
Rotated ARGB images 54 (-1) 44 15 15 0
Multiple labels 6 35 0 0 0
Screen sized text 81 (+1) 45 17 17 0
Multiple arcs 40 33 7 7 0
Containers 3 (-1) 37 0 0 0
Containers with overlay 88 (+2) 21 44 44 0
Containers with opa 16 (-1) 36 (-1) 1 1 0
Containers with opa_layer 18 34 5 5 0
Containers with scrolling 45 (+1) 45 12 12 0
Widgets demo 70 (-2) 39 (-1) 16 16 0
All scenes avg. 27 37 7 7 0

ARM Emulated 64b - lv_conf_perf64b

Scene Name Avg CPU (%) Avg FPS Avg Time (ms) Render Time (ms) Flush Time (ms)
All scenes avg. 25 (+1) 37 6 6 0
Detailed Results Per Scene
Scene Name Avg CPU (%) Avg FPS Avg Time (ms) Render Time (ms) Flush Time (ms)
Empty screen 11 33 0 0 0
Moving wallpaper 1 33 0 0 0
Single rectangle 0 50 0 0 0
Multiple rectangles 0 35 0 0 0
Multiple RGB images 0 39 0 0 0
Multiple ARGB images 11 42 0 0 0
Rotated ARGB images 29 33 9 9 0
Multiple labels 2 35 0 0 0
Screen sized text 84 46 18 18 0
Multiple arcs 40 (+9) 33 6 6 0
Containers 4 37 0 0 0
Containers with overlay 89 22 42 (+1) 42 (+1) 0
Containers with opa 14 36 (-2) 0 (-1) 0 (-1) 0
Containers with opa_layer 7 (+1) 37 (+1) 1 1 0
Containers with scrolling 48 (+1) 48 12 (+1) 12 (+1) 0
Widgets demo 68 (+1) 40 15 15 0
All scenes avg. 25 (+1) 37 6 6 0

Disclaimer: These benchmarks were run in an emulated environment using QEMU with instruction counting mode.
The timing values represent relative performance metrics within this specific virtualized setup and should
not be interpreted as absolute real-world performance measurements. Values are deterministic and useful for
comparing different LVGL features and configurations, but may not correlate directly with performance on
physical hardware. The measurements are intended for comparative analysis only.


🤖 This comment was automatically generated by a bot.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 94 files

Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/misc/lv_style_gen.h">

<violation number="1" location="src/misc/lv_style_gen.h:789">
P2: This header is generated by style_api_gen.py, so adding the new text leading trim API here will be overwritten. Please add the property to style_api_gen.py and regenerate the header instead.

(Based on your team's feedback about treating style_api_gen.py as the source of truth for lv_style_gen.h.) [FEEDBACK_USED]</violation>
</file>

<file name="src/widgets/label/lv_label.c">

<violation number="1" location="src/widgets/label/lv_label.c:852">
P2: Leading-trim draws text outside the object bounds (txt_coords y1/y2), but ext draw size still only uses `font_h/4`. If trims are larger than `font_h/4`, glyphs can be clipped. Update LV_EVENT_REFR_EXT_DRAW_SIZE to include the trim offsets when leading trim is enabled.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread src/misc/lv_style_gen.h
Comment thread src/widgets/label/lv_label.c Outdated
case LV_FONT_GLYPH_FORMAT_A8: {
const lv_font_t * resolved_font = glyph_draw_dsc->g->resolved_font;
vg_lite_buffer_t src_buf;
if(lv_font_has_static_bitmap(resolved_font)) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Encapsulating it into a function makes it easier to understand, so why is this change necessary?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to make it fallback to draw_buf creation in case of errors. I updated it.

@FASTSHIFT FASTSHIFT changed the title feat(text): add Text leading trim feat(text): add text leading trim Apr 2, 2026
Comment thread src/font/lv_font.h
Comment on lines +160 to +162
int32_t cap_height; /**< Cap height of the font*/
int32_t x_height; /**< x-height of the font*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move these right after line_height and base_line attributes to avoid padding bytes as much as possible?
The pointers below should also be moved to the top of the structure too but it's unrelated and can be done in a separate PR if you prefer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for CSS-like Text Leading-Trim

4 participants