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
Create a folder Resources inside the .NET Standar project and then create a subfolder Fonts.
Add your
.ttf
file or.otf
file inside the Fonts folder.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")]
- 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=""/>
<Setter Property="ExpandedSymbol" Value=""/>
</Style>