dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.97k stars 1.71k forks source link

Using Label's Style in ContentPage.Resources or not, it makes different appearance #23707

Open cotrasys opened 1 month ago

cotrasys commented 1 month ago

Description

I tested on .NET8 MAUI latest 8.0.70 and GA 8.0.3, can't solve this issue.

Here is a picture (I didn't test it on Mac, sorry) Using Style in styles.xaml Using Style from ContentPage
image image
2024-07-19_05-40-14-午後 2024-07-19_05-40-38-午後
image imageimage
I tried .NET7 MAUI 7.0.101, it seems to use same fonts and no issue. Using Style in styles.xaml Using Style from ContentPage
Image7 ImageImage7

Steps to Reproduce

  1. Clone this project and build / run app.
  2. Check each pages. You can switch page by button.

You can reproduce by below step without cloning.

  1. Create new project and place the Label control use to 'SubHeadline' style on MainPage, like this
            <Label Style="{StaticResource SubHeadline}" Text="abcdefghijklmnopqrstuvwxyz" />
            <Label Style="{StaticResource SubHeadline}" Text="ABCDEFGHIJKLMNOPQRSTUVWXYZ" />
            <Label Style="{StaticResource SubHeadline}" Text="!#$%'()*+,-./:;=?@[\]^_`{|}~" />
  2. Copy that MainPage and give another name, write down Label's style on ContentPage.Resouces
    <ContentPage.Resources>
        <ResourceDictionary>
            <!--  This equals to SubHeadline  -->
            <Style TargetType="Label">
                <Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource MidnightBlue}, Dark={StaticResource White}}" />
                <Setter Property="FontSize" Value="24" />
                <Setter Property="HorizontalOptions" Value="Center" />
                <Setter Property="HorizontalTextAlignment" Value="Center" />
            </Style>
        </ResourceDictionary>
    </ContentPage.Resources>
  3. Build & run the app, confirm the different font with comparing the pages

Link to public reproduction project repository

https://github.com/cotrasys/LabelStyleFontIssue

Version with bug

8.0.70 SR7

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

7.0.101

Affected platforms

iOS, Android, Windows

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

github-actions[bot] commented 1 month ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

ninachen03 commented 1 month ago

This issue has been verified and repro on Visual Studio 17.11.0 Preview 4.0 (8.0.70 & 8.0.3)

image

cotrasys commented 1 month ago

Is related on this issue? #19882 This occured from Version 8 and says about Resources problem.

cotrasys commented 1 month ago

I tested on Mac 8.0.70 using VS2022 Mac 17.6.13, it has same issue as other platforms.

Using Style in styles.xaml Using Style from ContentPage
MainPage StyledPage

@samhouts could you add the label of "platform/macOS" ?