question

njsokalski avatar image
0 Votes"
njsokalski asked ·

Applying Bold and/or Italic to a Custom Font

I have a custom font (a .ttf file) that I am using in my project. I am able to use the font with no problem, but I cannot apply the FontAttributes (Bold & Italic) to it. Some fonts have separate .ttf files for regular/bold/italic/bolditalic, but in my case, there is only one file. In the UWP version of my app, I was simply able to set a property such as FontWeight to make the font bold, but that does not work with Xamarin.Forms. What can I do? Thanks.

dotnet-xamarinforms-xaml
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JarvanZhang-MSFT avatar image
0 Votes"
JarvanZhang-MSFT answered ·

Hello,​

Welcome to our Microsoft Q&A platform!

Xamarin.Forms provides the FontAttributes property to set the font style. It could also be used for the custom font.

You could specify a value to the FontAttributes in the page.xaml. Check the code:

<Label Text="Hello Forms with XAML" FontAttributes="Italic" FontFamily="Lobster" />
<Label Text="Hello Forms with XAML" FontFamily="Lobster" />
<Label Text="Hello Forms with XAML" FontAttributes="Bold " FontFamily="Lobster" />


Best Regards,

Jarvan Zhang



If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.