-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fixed the span text disappeared in label when setting the font attribute on span and setting an implicit style for Label on content page #28851
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
Fixed the span text disappeared in label when setting the font attribute on span and setting an implicit style for Label on content page #28851
Conversation
Hey there @@NanthiniMahalingam! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
@@ -116,7 +116,7 @@ internal static SpannableString ToSpannableStringNewWay( | |||
if (font.IsDefault && defaultFont.HasValue) | |||
font = defaultFont.Value; | |||
if (!font.IsDefault) | |||
spannable.SetSpan(new PlatformFontSpan(context ?? AAplication.Context, font.ToTypeface(fontManager), font.AutoScalingEnabled, (float)font.Size), start, end, SpanTypes.InclusiveInclusive); | |||
spannable.SetSpan(new PlatformFontSpan(context ?? AAplication.Context, font.ToTypeface(fontManager), font.AutoScalingEnabled, (float)fontManager.GetFontSize(font).Value), start, end, SpanTypes.InclusiveInclusive); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you include a related test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jsuarezruiz
The issue raises when adding the font size style globally in the application's resource file. As a result, I was unable to apply the global style in the host app, and I couldn't find any reference for applying the style globally.
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
Issue details
When setting the FontAttributes in a Span within a Label, and applying an implicit style to the Label (without specifying the FontSize in the style) from the ContentPage resources, while a global default style for label font size is defined in App.xaml, the default font is not applied correctly. Therefore span text disappeared.
Root cause
When setting FontAttributes in a Span within a Label, and applying an implicit style to the Label (without specifying the FontSize) from the ContentPage resources, while a global default style for label font size is defined in App.xaml, the default font is not applied because the implicit style does not explicitly define default FontSize.
Description changes
I retrieved the font size using FontManager.GetFontSize() instead of relying on the default font size from the Label, since font.IsDefault is false when setting FontAttributes in a Span within a Label.
Validated the behaviour in the following platforms
Reference
maui/src/Controls/src/Core/Platform/iOS/Extensions/FormattedStringExtensions.cs
Line 107 in af78f88
Test Case
The issue raises when adding the font size style globally in the application's resource file. As a result, I was unable to apply the global style in the host app, and I couldn't find any reference for applying the style globally.
Issues Fixed
Fixes #19190
Output images: