EdgeTX / edgetx

EdgeTX is the cutting edge open source firmware for your R/C radio
https://edgetx.org
GNU General Public License v2.0
1.59k stars 338 forks source link

lcd.sizeText() is not accurate #5609

Open offer-shmuely opened 1 week ago

offer-shmuely commented 1 week ago

Is there an existing issue for this problem?

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

philmoz commented 1 week ago

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

offer-shmuely commented 1 week ago

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 commented 1 week ago

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

LCD

image

LVGL

image

3djc commented 1 week ago

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

offer-shmuely commented 1 week ago

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.

philmoz commented 1 week ago

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.

offer-shmuely commented 1 week ago

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?