Skip to content

Issues with fetching fonts while using the addon. #216

@irumvanselme

Description

@irumvanselme

[Issue]

I am working on a React project that involves fetching fonts on demand. Everything works perfectly on the frontend. However, when running the same components in Storybook, the fonts are not loading correctly due to the Storybook addon, which intercepts HTTP requests.

When we removed the addon, the fonts loaded correctly in Storybook.

The fonts being returned are different from what is expected, and certain font data (such as the cmap table) is missing. This was discovered during debugging and could provide a clue to the issue.

The Problem:

The fonts returned are not identical to the ones served from the server.

[Steps to Reproduce]

Create a simple React project.
Add Storybook and the storybook-addon-mock addon.
Add @react-pdf/renderer.
Use custom fonts.
Try to download the PDF generated in Storybook.
The fonts in the PDF will be invalid or incomplete.

[screenshots]
image
requestes fetched over using fetch works perfectly, but ones with xhr api are failing, the ones for fonts.

image

Error in particular, I am facing, Font does not have cmap.tables.

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