2

trying to follow Xamarin tutorial for a label view at : Label Tutorial

when applying italic font attribute in a span tag , while setting the size of the label text to any value in the label tag. the text size did not get applied to the text in the span with italic attribute.

<StackLayout Margin="20,35,20,25">
    <Label FontSize="50" TextColor="Blue">
        <Label.FormattedText>
            <FormattedString>
                <Span Text="underlined text" TextDecorations="Underline" />
                <Span Text=", emphasized" FontAttributes="Italic" />
            </FormattedString>
        </Label.FormattedText>
    </Label>
</StackLayout>

output from android emulator

Junior Jiang
  • 12,430
  • 1
  • 10
  • 30
Sh.Raai
  • 119
  • 1
  • 10
  • 1
    Hi , I have submitted as an issue in GitHub [here](https://github.com/xamarin/Xamarin.Forms/issues/8859) , you can follow up it .By the way , I also found a workaround and shared in answer , you can have a look at it when have time . – Junior Jiang Dec 12 '19 at 02:05

1 Answers1

4

I also found that it when the span with Italic attribute the FontSize of Label can not work. However , I found a WorkAround for this , you can set FontSize of this Span to solve it .

Have a look at follow code:

<StackLayout Margin="20,35,20,25">
    <Label FontSize="50" TextColor="Blue">
        <Label.FormattedText>
            <FormattedString>
                <Span Text="underlined text" TextDecorations="Underline" />
                <Span Text=", emphasized" FontSize="50" FontAttributes="Italic" />
            </FormattedString>
        </Label.FormattedText>
    </Label>
</StackLayout>

The effect :

enter image description here

I think next version of Xamarin Forms will fix it as soon as possible .

Junior Jiang
  • 12,430
  • 1
  • 10
  • 30