Custom Fonts

Since R2 2017 Telerik UI for WinForms supports custom fonts. This means that you can use your own fonts without installing them on the local machine.

The following steps will show how you can load and use the new font:

1. First you need to add the font as an embedded resource. Then you can load it with the following code:

var fontStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"SamplesCS.Resources.Roboto-Medium.ttf");
var names = Assembly.GetExecutingAssembly().GetManifestResourceNames();

var font = ThemeResolutionService.GetCustomFont("Roboto Medium");

Dim fontStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("SamplesCS.Resources.Roboto-Medium.ttf")
Dim names = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames()
Dim font = ThemeResolutionService.GetCustomFont("Roboto Medium")

2. Use the following properties to set the font.

radLabel1.LabelElement.CustomFont = font.Name;
radLabel1.LabelElement.CustomFontSize = 42;
radLabel1.LabelElement.CustomFontStyle = FontStyle.Regular;

radLabel1.LabelElement.CustomFont = font.Name
radLabel1.LabelElement.CustomFontSize = 42
radLabel1.LabelElement.CustomFontStyle = FontStyle.Regular

The important part here is that the above properties are available for the VisualElement ancestors (which are most of our elements).

The below image shows the result:


See Also

In this article
Not finding the help you need? Improve this article