Skip to content

[Bug]: pdf font spacing differs between headless/headed with remote fonts #39509

@ignyx

Description

@ignyx

Version

1.58.2

Steps to reproduce

  1. Assume browsers and system dependencies are already installed
  2. git clone https://github.com/ignyx/playwright-issue.git
  3. npm install
  4. Read repro-font-spacing.mjs
  5. node repro-font-spacing.mjs
  6. Open the newly created font-test-headless.pdf and font-test-headed.pdf side-by-side in your favorite pdf viewer

Expected behavior

When embedding remote fonts, I expect rendered text to have same length, regardless of headless: true/false.

Actual behavior

Text in the pdf from the headless browser is longer than the text in the headed browser.

Image

Additional context

The fonts are successfully embedded into the PDFs.

In the HTML, an example is given with another remote font.

When commenting out the remote fonts and using the system font "Roboto", the length is identical (no issue).

This may seem trivial, but for longer paragraphs, words may overflow and the text may span more lines in the headless than in the browser (things that work in the browser look differently in the headless).

I couldn't find any related issue, or anything in the documentation, or on SO.

The issue may not be an issue with playwright itself.

Environment

System:
    OS: Linux 6.12 Debian GNU/Linux 13 (trixie) 13 (trixie)
    CPU: (12) x64 Intel(R) Core(TM) i7-10710U CPU @ 1.10GHz
    Memory: 2.45 GB / 15.46 GB
    Container: Yes
  Binaries:
    Node: 24.4.1 - ~/.nvm/versions/node/v24.4.1/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 11.4.2 - ~/.nvm/versions/node/v24.4.1/bin/npm
    pnpm: 10.14.0 - ~/.local/share/pnpm/pnpm
  IDEs:
    VSCode: 1.109.5 - /usr/bin/code
  Languages:
    Bash: 5.2.37 - /usr/bin/bash
  npmPackages:
    @playwright/test: ^1.58.2 => 1.58.2

Thanks for your help !

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions