#1635·pdfkit

The custom font doesn`t apply when use into Table Cell

Author: kvandakeCreated Jul 12, 2025Updated Sep 6, 2026

Bug Report

Description of the problem

When I use custom font in CellOptions pdfkit ignore property because th source code has a bug in line https://github.com/foliojs/pdfkit/blob/master/lib/table/render.js#L86,

I think resolution be as use text function:

typescript
const doc = new PDFDocument({
  margin: 50,
  size: 'A4',
  layout: 'landscape',
});

doc.font(...)

P.S. I use typescript with @types/pdfkit and customFont doesn`t allow in CellOptions

Image

Code sample

typescript
      const tableHeaders = [
        {
          text: 'Header 1',
          // temporary fix
          font: { src: PDF_FONT_BOLD },
          fontSize: 12,
         // temporary fix
          customFont: true,
        },
        ...days.map((day) => ({
          text: day.getDate().toString(),
        })),
      ] as TableCell[];

Your environment

  • pdfkit version: 0.17.1
  • @types/pdfkit: 0.17.0
  • Node version: v20.12.2
  • Browser version (if applicable): Edge
  • Operating System: Windows 11