# Fonts Customization

With the Custom Font Resolver, you can configure fonts for Page, RDLX, and Section reports (in the CrossPlatform compatibility mode) on different platforms.

## Content



You can run reports on different platforms, and it is important to ensure that a report uses the same fonts. With the ActiveReports' custom font resolver, you can configure fonts for Page, RDLX, and Section reports (in the **CrossPlatform** compatibility mode) on different platforms.


> type=note
> **Note**: Custom font settings have higher priority over fonts from the config file or the system font settings.

To learn about how to configure custom fonts in the ActiveReports.config file, see [Configure ActiveReports using Config File](/activereportsnet/docs/v19.2/devops/customization/configure-ar).

### Use the Custom Font Resolver in Preview

In some situations, you can use the custom fonts resolver through code by specifying the [PageReport.FontResolver](/activereportsnet/api/v19.2/MESCIUS.ActiveReports/GrapeCity.ActiveReports.PageReport.html#FONTRESOLVER) property in the **Windows Forms Viewer** and [UseFontResolver](/activereportsnet/api/v19.2/MESCIUS.ActiveReports.Web.Viewer/GrapeCity.ActiveReports.Web.Viewer.ReportViewerConfiguration.html) in the **JavaScript Viewer**, as shown in the following code examples.

```csharp
var report = new PageReport(…);
report.FontResolver = DirectoryFontResolver.Instance;
viewer1.LoadDocument(report.Document);
```

```csharp
app.UseReportViewer(settings => {
  settings.UseFontResolver(DirectoryFontResolver.Instance);
  settings.UseFileStore(ResourcesRootDirectory)
});
```

### Configure Fonts for Preview and Export

You can configure fonts for preview and export on all platforms without installation as in the following examples.

### Example 1

```
public sealed class WindowsFontResolver : GrapeCity.ActiveReports.IFontResolver
{
   static readonly GrapeCity.Documents.Text.FontCollection _fonts = new GrapeCity.Documents.Text.FontCollection();
   static WindowsFontResolver()
   {
        GrapeCity.Documents.Text.Windows.FontLinkHelper.UpdateFontLinks(_fonts, true);
        _fonts.DefaultFont = _fonts.FindFamilyName("Arial");
   }
   public static GrapeCity.ActiveReports.IFontResolver Instance = new WindowsFontResolver();
   private WindowsFontResolver() { }
   GrapeCity.Documents.Text.FontCollection GrapeCity.ActiveReports.IFontResolver.GetFonts(string familyName, bool isBold, bool isItalic)
   {
        var fonts = new GrapeCity.Documents.Text.FontCollection();
        fonts.Add(_fonts.FindFamilyName(familyName, isBold, isItalic) ?? _fonts.DefaultFont);
        GrapeCity.Documents.Text.Windows.FontLinkHelper.UpdateEudcLinks(fonts);
        return fonts;
   }
}
```

### Example 2

```
public sealed class DirectoryFontResolver : GrapeCity.ActiveReports.IFontResolver
{
   static readonly GrapeCity.Documents.Text.FontCollection _fonts = new GrapeCity.Documents.Text.FontCollection();
   static DirectoryFontResolver()
   {
      // see https://developers.redhat.com/blog/2018/11/07/dotnet-special-folder-api-linux/
      _fonts.RegisterDirectory(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts));
      _fonts.DefaultFont = _fonts.FindFamilyName("Arial");
   }
   public static GrapeCity.ActiveReports.IFontResolver Instance = new DirectoryFontResolver();
   private DirectoryFontResolver() { }
   GrapeCity.Documents.Text.FontCollection GrapeCity.ActiveReports.IFontResolver.GetFonts(string familyName, bool isBold, bool isItalic)
   {
      var fonts = new GrapeCity.Documents.Text.FontCollection();
      var font = _fonts.FindFamilyName(familyName, isBold, isItalic);
      if (font != null) fonts.Add(font);
      fonts.Add(_fonts.DefaultFont);
      return fonts;
   }
}
```

See the [FontResolver](https://github.com/activereports/Samples19/tree/main/API/PageAndRDLX/FontResolver) sample for more details.

### Link one Font to Another

If you need to link just one font to another (for example, link an EUDC font to an installed font), you can do it with [DsPdf](https://developer.mescius.com/document-solutions/dot-net-pdf-api/docs/online/overview.html) and [DsImaging](https://developer.mescius.com/document-solutions/dot-net-imaging-api/docs/online/overview.html) APIs, using the following code.

```csharp
GrapeCity.Documents.Text.Windows.FontLinkHelper.UpdateFontLinks(null, true);
var fonts = new System.Collections.Generic.List();
GrapeCity.Documents.Text.FontCollection.SystemFonts.SelectByFamilyName("MS UI Gothic", fonts);
if (fonts.Count > 0)
 { 

    var eudcFonts = new GrapeCity.Documents.Text.FontCollection();
    using (var stream = new System.IO.FileStream(@"C:\EudcFonts\DFHSG3J.tte", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
    eudcFonts.LoadFonts(stream);
    foreach (var font in fonts)
      { 

        font.ClearEudcFontLinks();
        foreach (var eudcFont in eudcFonts) font.AddEudcFont(eudcFont); 
      }
  }
```

## See Also

#### Samples

[Font Resolver](/activereportsnet/docs/v19.2/samples/samples-ar/api-sample/page-and-rdl-api/font-resolver-sample)