Applying Bold and/or Italic to a Custom Font

Nathan Sokalski 4,116 Reputation points
2020-11-22T21:09:39.66+00:00

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.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,296 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JarvanZhang 23,951 Reputation points
    2020-12-18T04:42:38.047+00:00

    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.

    0 comments No comments