New to Telerik UI for Xamarin? Download free 30-day trial

Embeded Fonts in Telerik UI for Xamarin Controls

Environment

Product Version 2021.2.615.1
Product TreeView for Xamarin

Description

This article shows how to add embedded fonts in shared project and how to use the font in Telerik UI for Xamarin controls.

Solution

  1. Create a folder Resources inside the .NET Standar project and then create a subfolder Fonts.

  2. Add your .ttf file or .otf file inside the Fonts folder.

  3. Register the font inside the AssemblyInfo.cs file.

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
[assembly: ExportFont("telerikfontexamples.otf", Alias = "TE")]
  1. Consume the font inside any Telerik UI for Xamarin control and set the icon's where applicable.

Exmaple with the TreeView expand collapse indicator

Add the font alias ad a value of the FontFamily and the icon code as a value of the symbol/glyph/text property:

 <Style TargetType="telerikTreeView:ExpandCollapseIndicator">
    <Setter Property="FontFamily" Value="TE"/>
    <Setter Property="CollapsedSymbol" Value="&#xE824;"/>
    <Setter Property="ExpandedSymbol" Value="&#xE80D;"/>
</Style>
In this article