Skip to content

Conversation

@NanthiniMahalingam
Copy link
Contributor

@NanthiniMahalingam NanthiniMahalingam commented Apr 8, 2025

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

  • Android
  • Windows
  • iOS
  • Mac

Reference

var platformFont = font.IsDefault ? null : font.ToUIFont(fontManager);

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:

Before After

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Apr 8, 2025
@dotnet-policy-service
Copy link
Contributor

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.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Apr 8, 2025
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);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@NanthiniMahalingam NanthiniMahalingam marked this pull request as ready for review April 10, 2025 13:05
@NanthiniMahalingam NanthiniMahalingam requested a review from a team as a code owner April 10, 2025 13:06
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PureWeen PureWeen changed the base branch from main to inflight/current May 22, 2025 18:18
@PureWeen PureWeen merged commit edba6d4 into dotnet:inflight/current May 22, 2025
80 checks passed
github-actions bot pushed a commit that referenced this pull request May 22, 2025
github-actions bot pushed a commit that referenced this pull request May 30, 2025
github-actions bot pushed a commit that referenced this pull request May 30, 2025
@rmarinho rmarinho added this to the .NET 9 SR8 milestone May 30, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jun 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-label Label, Span community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[regression/8.0.3] Setting a style on a label causes spans with FontAttributes to be ignored on Android

4 participants