New to Telerik Reporting? Download free 30-day trial

privateFonts Element Overview

Defines a collection that allows the Reporting Engine to use a private version of an existing font without the requirement to install the font on the host machine. If the font is already installed the installed font is used.

Known issue with the Windows Platform: If you order the fonts in the PrivateFontCollection first regular then bold the GDI+ measure string size for bold font style is incorrect. This is observed in Windows 8.1 and later and may lead to unexpected rendering and aligning issues. For more information see Wrong Measurements from MeasureString.

Known issue with Azure: The required .NET API for handling private fonts is making GDI calls that are blocked in Azure App Services. If private fonts are required our recommendation is to use Cloud Service plan. More details can be found in Custom Fonts not working on Azure App Service.

Known issue with PDF rendering in .NET Core application on Linux: The PDF rendering engine needs to obtain the bytes for fonts used in the report. The font resolving mechanism currently relies on the privateFonts element to provide path to each font along with a style description. This includes the substitute fonts that are picked by the runtime when the font, used in the report, is not available.

Known issue with privateFonts in .NET Core application on Linux: The library libgdiplus that we use as GDI+ implementatin for Linux returns as a Family Font Name the Preferred Family rather than Family name from the font meta information. Details may be found in Font.Name returns incorrect results on Linux. The two names may be different in the general case. In such scenario, the font should be referenced with its Family name for Windows and Preferred Family name for Linux.

In the rare case when the Preferred Family name of two fonts conincide and the Family names are different, on Linux only the second font registered as private would be respected as it will override the first one.

The private fonts are used for all rendering extensions. Still the font rendering on the client computer depends on the viewer configuration and document format specifications:

  • PDF: The rendering extension embeds fonts by default. This functionality is controlled by the FontEmbedding device information setting;
  • HTML5 Rendering: In order web browser to render HTML with private fonts you have to set up font-face rules. For more information see the W3.org article for font-face rules;
  • WPF XAML rendering: embeds private fonts by default;
  • Silverlight XAML rendering: In addition to add the private fonts as content to the WCF hosting project you have to add the fonts as resources to the Silverlight project with the same relative path;
  • For all other document formats the Reporting Engine is using private fonts but in order the document viewer to use them the fonts should be installed on the client computer;
  • Windows Forms Report Viewer uses Image rendering to render in EMF+ that don't support private fonts.

As with most types of software, font files are licensed, rather than sold, and licenses that govern the use of fonts vary from vendor to vendor. As a developer it is your responsibility to ensure that you have the required license rights for any font you use as private font, or otherwise redistribute.

<privateFonts>
    <add />
</privateFonts>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

<privateFonts> element

Attributes None
Child Elements add - Optional element. Adds a font to the collection.
Parent Elements
  • configuration - Specifies the root element in every configuration file that is used by the common language runtime and the .NET Framework applications.
  • Telerik.Reporting - Configures all settings that Telerik Reporting Engine uses.

<add> element

Attribute
fontFamily The attribute is required and case sensitive.
path The attribute is required and is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see MSDN Directory.GetCurrentDirectory() method
For web projects you can use ~ operator to specify a root-relative path for a font. For more informarion see MSDN ASP.NET Web Project Paths.
fontStyle The attribute is optional with valid values Regular, Bold, Italic, Strikeout and Underline. The default value is Regular. Specify this attribute if you have to specify font family with multiple font files for different style or if specified font file is not containing Regular style.
Child elements None
Parent element privateFonts

Example

The following example demonstrates how to configure the reporting engine to use Ubuntu and Courier New fonts. The fonts are part of the project with the following properties:

XML-based configuration file:

<?xml version="1.0"?>
<configuration>
...
    <Telerik.Reporting>
        <privateFonts>
            <add fontFamily="Courier New" path="CourBI.ttf" fontStyle="Bold, Italic" />
            <add fontFamily="ubuntu" path="Ubuntu-R.ttf" />
            <add fontFamily="Courier New" path="CourI.ttf" fontStyle="Italic" />
        </privateFonts>
    </Telerik.Reporting>
...
</configuration>

JSON-based configuration file:

"telerikReporting": {
    "privateFonts": [
        {
            "fontFamily": "ubuntu",
            "path": "Ubuntu-R.ttf",
        },
        {
            "fontFamily": "Courier New",
            "path": "CourI.ttf",
            "fontStyle": "Italic"
        },
        {
            "fontFamily": "CourBI",
            "path": "CourBI.ttf",
            "fontStyle": "Bold,Italic"
        }
    ]
}

See Also

In this article