Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lcd.sizeText() is not accurate #5609

Open
1 task done
offer-shmuely opened this issue Oct 12, 2024 · 7 comments
Open
1 task done

lcd.sizeText() is not accurate #5609

offer-shmuely opened this issue Oct 12, 2024 · 7 comments
Labels
bug 🪲 Something isn't working triage Bug report awaiting review / sorting

Comments

@offer-shmuely
Copy link
Contributor

Is there an existing issue for this problem?

  • 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 offer-shmuely added bug 🪲 Something isn't working triage Bug report awaiting review / sorting labels Oct 12, 2024
@philmoz
Copy link
Collaborator

philmoz commented Oct 12, 2024

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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

LCD

image

LVGL

image

@3djc
Copy link
Collaborator

3djc commented Oct 12, 2024

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
Copy link
Contributor Author

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
Copy link
Collaborator

philmoz commented Oct 12, 2024

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
Copy link
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working triage Bug report awaiting review / sorting
Projects
None yet
Development

No branches or pull requests

3 participants