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

Add TSkLabel.TextSize property #250

Open
havrlisan opened this issue Jul 21, 2023 · 6 comments
Open

Add TSkLabel.TextSize property #250

havrlisan opened this issue Jul 21, 2023 · 6 comments

Comments

@havrlisan
Copy link

TSkLabel should have a public property for retrieving text size. Currently, a private method GetFitSize(var AWidth, AHeight) is used for calculating the control size depending on its alignment. Still, there should be another one that will always return the size of the text and is independent of the control's alignment.

@checkdigits
Copy link

When you say "size of the text" do you mean "dimensions of the text"?

This is not as easy as it sounds.

For example, in this image, you can return a Rect which bounds the widest extent of the text:

image

which would be this kind of thing:

image

But what about if the text is rotated?

image

Now the Rect is like this:

image

...but do you actually want this?

image

@checkdigits
Copy link

Also note that in the recent version of Skia4Delphi the labels can now mix the font sizes and styles. :)

@havrlisan
Copy link
Author

havrlisan commented Jul 21, 2023

Thanks for the fast reply, Ian. I understand your point, but what I want to achieve is simply the same size of the control when the AutoSize property is set to true. Consider this scenario:

I have a TLayout with TAlignLayout.Top, and inside the TLayout are two TSkLabel controls whose Align is set to Left (meaning AutoSize is applied to Width only). I want the TLayout.Height to be set according to its content height, which, in this case, is the bigger height of the two TSkLabel controls. However, I cannot retrieve the true text height of either of the two labels because currently there is no way to directly get it. What I can do, however, is:

  • set the label's Align to None,
  • retrieve the updated height (which TSkLabel retrieved from a private method GetFitSize),
  • re-set the label's Align to Left.

I am aware that TSkLabel has a collection of strings (or words) instead of a single string, but what I'm asking for here is to retrieve the total size of the TSkLabel. Having the ability to retrieve the size of every word would be a great feature, but I cannot see it being used in almost any scenario (as pretty much anything you would want to do with a single word is available through Skia's text and decoration settings).

The same goes for text rotation. I am only asking for the AutoSize's calculated size to be available through a function/property even without AutoSize set to true.

@checkdigits
Copy link

Sounds like this function might not currently exist. There might be a combination of skCanvas properties which can be used but I'm not sure.

This might be one for @paulocesarbot or @viniciusfbb to answer, I think.

@havrlisan
Copy link
Author

Sounds like this function might not currently exist. There might be a combination of skCanvas properties which can be used but I'm not sure.

This might be one for @paulocesarbot or @viniciusfbb to answer, I think.

I've used Skia for some time now, and my request is straightforward. This function can be found right here, in the FMX.Skia.pas unit.

On a non-related matter, I sincerely hope that Skia4Delphi will remain 100% open-source after integrating into FMX.

@checkdigits
Copy link

On a non-related matter, I sincerely hope that Skia4Delphi will remain 100% open-source after integrating into FMX

Yes that is correct. Skia4Delphi and the FMX integration are related but not quite the same and the Skia4Delphi project will continue to be as it is now.

The integration, of course, is not open source as such, but the source is available as it always is with the RTL and related units.

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

No branches or pull requests

2 participants