Back to Devexpress

DXFontRepository.AddFont(String) Method

corelibraries-devexpress-dot-drawing-dot-dxfontrepository-dot-addfont-x28-system-dot-string-x29.md

latest2.5 KB
Original Source

DXFontRepository.AddFont(String) Method

Loads a font from a file.

Namespace : DevExpress.Drawing

Assembly : DevExpress.Drawing.v25.2.dll

NuGet Package : DevExpress.Drawing

Declaration

csharp
public void AddFont(
    string fontFileName
)
vb
Public Sub AddFont(
    fontFileName As String
)

Parameters

NameTypeDescription
fontFileNameString

The full path to the font file.

|

Remarks

The AddFont method supports the following font formats:

  • TrueType fonts (.TTF)

  • OpenType fonts that use CFF (Compact Font Format) glyph outlines (.OTF)

  • OpenType Font Collections (.TTC, .OTC) that contain multiple fonts in a single file

To avoid excessive layout recalculations, add the required fonts to DXFontRepository before you load a document, report or dashboard that uses these fonts.

Loaded fonts are not saved to the document, report or dashboard. They are used to display, print, or export the document, report or dashboard to PDF.

The code sample below adds custom fonts to DXFontRepository. This example uses the following Google fonts:

csharp
using DevExpress.Drawing;
//...

DXFontRepository.Instance.AddFont(@"Fonts\advent-pro.regular.ttf");
DXFontRepository.Instance.AddFont(@"Fonts\Roboto-Light.ttf");
//...

FontRepository.Instance.Dispose();
vb
Imports DevExpress.Drawing
'...
DXFontRepository.Instance.AddFont("Fonts\advent-pro.regular.ttf")
DXFontRepository.Instance.AddFont("Fonts\Roboto-Light.ttf")
'...

DXFontRepository.Instance.Dispose()

See Also

DXFontRepository Class

DXFontRepository Members

DevExpress.Drawing Namespace