New to Telerik Document ProcessingStart a free 30-day trial

Registering Custom Font Variants (Regular, Bold, Italic) for Conversion in Telerik Document Processing

Updated on Nov 26, 2025

Environment

VersionProductAuthor
2025.4.1104RadPdfProcessing/RadWordsProcessingDesislava Yordanova

Description

When converting DOCX files to PDF using PdfProcessing for Telerik Document Processing, missing or incorrectly registered font variants may result in fallback fonts being applied in the output PDF. This article explains how to properly register custom font variants (Regular, Bold, Italic) for the Barlow (or other) font family in Telerik Document Processing to ensure accurate rendering during DOCX to PDF conversion. It covers why fonts may fall back to defaults, and provides step-by-step code examples for registering each font style and weight using FontsRepository. Finally, it demonstrates how to perform the conversion with the registered fonts, ensuring consistent output in PDF documents.

Solution

To ensure proper rendering of the custom (e.g. Barlow) font family in converted PDFs, register each font variant and style individually before conversion. Follow the steps below:

  1. Register the Regular variant of the Barlow font:

    csharp
    byte[] barlowRegular = File.ReadAllBytes(@"..\..\Barlow\Barlow-Regular.ttf");
    var barlowFamily = new FontFamily("Barlow");
    FontsRepository.RegisterFont(barlowFamily, FontStyles.Normal, FontWeights.Normal, barlowRegular);
  2. Register the Regular variant of the Barlow Condensed font:

    csharp
    byte[] barlowCondensed = File.ReadAllBytes(@"..\..\Barlow\BarlowCondensed-Regular.ttf");
    var barlowCondensedFamily = new FontFamily("Barlow Condensed");
    FontsRepository.RegisterFont(barlowCondensedFamily, FontStyles.Normal, FontWeights.Normal, barlowCondensed);
  3. Register the Bold variant of the Barlow Condensed font:

    csharp
    byte[] barlowCondensedBold = File.ReadAllBytes(@"..\..\Barlow\BarlowCondensed-Bold.ttf");
    var barlowCondensedFamilyBold = new FontFamily("Barlow Condensed");
    FontsRepository.RegisterFont(barlowCondensedFamilyBold, FontStyles.Normal, FontWeights.Bold, barlowCondensedBold);
  4. Register the Regular variant of the Barlow Semi Condensed font:

    csharp
    byte[] barlowSemiCondensed = File.ReadAllBytes(@"..\..\Barlow\BarlowSemiCondensed-Regular.ttf");
    var barlowSemiCondensedFamily = new FontFamily("Barlow Semi Condensed");
    FontsRepository.RegisterFont(barlowSemiCondensedFamily, FontStyles.Normal, FontWeights.Normal, barlowSemiCondensed);
  5. Register the Bold variant of the Barlow Semi Condensed font:

    csharp
    byte[] barlowSemiCondensedBold = File.ReadAllBytes(@"..\..\Barlow\BarlowSemiCondensed-Bold.ttf");
    var barlowSemiCondensedFamilyBold = new FontFamily("Barlow Semi Condensed SemiBold");
    FontsRepository.RegisterFont(barlowSemiCondensedFamilyBold, FontStyles.Normal, FontWeights.Bold, barlowSemiCondensedBold);
  6. Convert the DOCX file to PDF using the registered fonts:

    csharp
    string inputFilePath = @"path-to-docx-file.docx";
    string outputFilePath = @"output-path.pdf";
    DocxFormatProvider docxProvider = new DocxFormatProvider();
    PdfFormatProvider pdfProvider = new PdfFormatProvider();
    RadFlowDocument document;
    
    using (FileStream inputStream = new FileStream(inputFilePath, FileMode.Open))
    {
        document = docxProvider.Import(inputStream, TimeSpan.FromSeconds(10));
    }
    
    using (FileStream outputStream = new FileStream(outputFilePath, FileMode.Create))
    {
        pdfProvider.Export(document, outputStream, TimeSpan.FromSeconds(10));
    }

Ensure the font name matches exactly in the DOCX and in the system font list. If the DOCX uses "Barlow Semi Condensed SemiBold", but the registered font is "Barlow Semi Condensed Bold", fallback occurs.

See Also