edgetx icon indicating copy to clipboard operation
edgetx copied to clipboard

lcd.sizeText() is not accurate

Open offer-shmuely opened this issue 1 year ago • 7 comments

Is there an existing issue for this problem?

  • [X] I have searched the existing issues

What part of EdgeTX is the focus of this bug?

Transmitter firmware

Current Behavior

background:

I am trying to write a widget (re-write the BattAnalog), in a way that it will be fully adaptive to different widget zone This way we could use it also in different TX resolutions placing the text while trying to maximize the usage of the widget real estate is a hard task, I am using the lcd.sizeText(), but it must be accurate to achieve a good results.

the issue:

lcd.sizeText() is too conservative, it take a lot of spares

image

Expected Behavior

lcd.sizeText() should return the exact size of the text given

image

Steps To Reproduce

sample widgets: WIDGETS.ZIP

Version

2.10.4

Transmitter

RadioMaster TX16S / TX16SMK2

Operating System (OS)

Windows

OS Version

win11

Anything else?

No response

offer-shmuely avatar Oct 12 '24 09:10 offer-shmuely

lcd.sizeText() calculates the width of the string passed; but always returns the height of the largest character in the font (not the string parameter).

screenshot_t15_24-10-12_21-33-30

philmoz avatar Oct 12 '24 10:10 philmoz

that is exactly the bug :-) the function does request my string, and it does calculate the width based on my string I do expect it to calculate the height as well based on my string

offer-shmuely avatar Oct 12 '24 15:10 offer-shmuely

this is issue exist both on LCD version as well as on LVGL

LCD

image

LVGL

image

offer-shmuely avatar Oct 12 '24 15:10 offer-shmuely

First, not a bug since this is per design: it allows to concatenate text in efficient way, by giving a 'next' point given your current exact text, and a height that will allow this, or text to come to fit

3djc avatar Oct 12 '24 15:10 3djc

Ok, So can I get another function, or an additional flag In such a way the function will calculate the size based on the string I send it(!), and not based on theoretical string that will never come?

I like to build a dynamic widget, that will not assume any predefined size. and we do not have css tools, So I like to have that can help me achieve my goal.

offer-shmuely avatar Oct 12 '24 16:10 offer-shmuely

Unlikely - text is fixed height in LVGL (which is used for both cases). There is no facility provided to get the pixel height of an individual character.

philmoz avatar Oct 12 '24 20:10 philmoz

tough one :-( Lets try from other directions, I notice that all the A-Z a-z are the same height as a typical "A" height. Why the special characters are different height? Is changing the font, only on the special characters, is an option?

offer-shmuely avatar Oct 12 '24 21:10 offer-shmuely

The character heights are determined by the font source used to create the lvgl fonts. You also need to remember that the fonts contain characters for non-english translations which are taller.

screenshot_t15_24-10-31_22-08-36

philmoz avatar Oct 31 '24 11:10 philmoz

I like the getTextSize to calculate the size based on the given text, and not on a text that maybe. It should not be static on the height, the same it is not static for width

offer-shmuely avatar Oct 31 '24 20:10 offer-shmuely

@philmoz Since there is still no implementation of lvgl.textSize() Can it be implemented as new function, but this time accurate to the suppled string?

offer-shmuely avatar Aug 01 '25 13:08 offer-shmuely

As I've already explained, the height of the font is a fixed value which is already returned correctly by the lcd.getTextSize function.

philmoz avatar Aug 01 '25 21:08 philmoz