How to add custom font in Xamarin.Forms Calendar (SfCalendar)?
You can customize the month view with a custom font family by using the DayHeaderFontFamily, HeaderFontFamily, DayCellFontFamily property of MonthViewSettings in Xamarin.Forms Calendar.
The following steps describe how to add a custom font file in the platform-specific projects.
Android
Add a custom font file in the Assets folder and set Build Action to AndroidAsset for the font file.
iOS
STEP1: Add a custom font file in the Resources folder and set Build Action to BundleResource. Then, ensure that the copy to output directory is set to AlwaysCopy.
STEP2: Add a custom font file name in the info.plist file as demonstrated in the following code sample.
<dict>…… <key>UIAppFonts</key> <array> <string>Lobster-Regular.ttf</string> </array> ……</dict>
UWP
Add a custom font file in the Assets folder and set Build Action to Content.
XAML
Set custom font for calendar month view using font family properties.
<calendar:SfCalendar x:Name="calendar" DataSource="{Binding Appointments}"> <calendar:SfCalendar.MonthViewSettings> <calendar:MonthViewSettings> <calendar:MonthViewSettings.HeaderFontFamily> <OnPlatform x:TypeArguments="x:String" iOS="Lobster-Regular" Android="Lobster-Regular.ttf" WinPhone="Assets/Lobster-Regular.ttf#Lobster" /> </calendar:MonthViewSettings.HeaderFontFamily> <calendar:MonthViewSettings.DayHeaderFontFamily> <OnPlatform x:TypeArguments="x:String" iOS="Lobster-Regular" Android="Lobster-Regular.ttf" WinPhone="Assets/Lobster-Regular.ttf#Lobster" /> </calendar:MonthViewSettings.DayHeaderFontFamily> <calendar:MonthViewSettings.DayCellFontFamily> <OnPlatform x:TypeArguments="x:String" iOS="Lobster-Regular" Android="Lobster-Regular.ttf" WinPhone="Assets/Lobster-Regular.ttf#Lobster" /> </calendar:MonthViewSettings.DayCellFontFamily> </calendar:MonthViewSettings> </calendar:SfCalendar.MonthViewSettings> <calendar:SfCalendar.BindingContext> <local:ViewModel/> </calendar:SfCalendar.BindingContext> </calendar:SfCalendar>
Output
Conclusion
I hope you enjoyed learning about how to add custom font in Xamarin.Forms Calendar (SfCalendar).
You can refer to our Xamarin.Forms Calendar feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Xamarin.Forms Calendar example to understand how to create and manipulate data.
For current customers, you can check out our Document Processing Libraries from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-trac, or feedback portal. We are always happy to assist you!