Skip to content

Table falsely propagate font families when providing fonts in column/row style #1746

Description

@ykw9263

Bug Report

Description of the problem

Fonts collections in table column / row style propagates their font families to cells. When a font with no family options is provided in cell styles, the table falsely apply the family with the font.

Code sample

  doc.table({
    rowStyles: [{
        font: { src: SOME_TTC_FONT, family: FONT_FAMILY },
    }]
  })
  .row([
    { text: 'Hello World', font: { src: SOME_TTF_FONT } }
  ]);
// throws `Variations require a font with the fvar, gvar and glyf, or CFF2 tables`
  doc.table({
    rowStyles: [{
        font: { src: SOME_TTC_FONT, family: FONT_FAMILY },
    }]
  })
  .row([
    { text: 'foo' }
    { text: 'bar', font: { src: SOME_TTF_FONT } }
  ]);
// SOME_TTF_FONT is never applied as FONT_FAMILY hit the cache.

Font src should be binded with its family and not be merged with other family names across styles. PR#1744 fixes the issue together with #1743.

Originally posted by @ykw9263 in #1744 (comment), edited

Your environment

  • pdfkit version: 0.19.1
  • Node version: 24.15.0
  • Browser version (if applicable): N/A
  • Operating System: Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions