-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
Comments
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: which would be this kind of thing: But what about if the text is rotated? Now the Rect is like this: ...but do you actually want this? |
Also note that in the recent version of Skia4Delphi the labels can now mix the font sizes and styles. :) |
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:
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. |
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. |
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. |
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.
The text was updated successfully, but these errors were encountered: