Skip to content

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

@kvandake

Description

@kvandake

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:

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

      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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions