Share via

Applying Bold and/or Italic to a Custom Font

Nathan Sokalski 4,111 Reputation points
Nov 22, 2020, 9:09 PM

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,377 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JarvanZhang 23,966 Reputation points
    Dec 18, 2020, 4:42 AM

    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.