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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: