Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom font in PDF export #1329

Open
1 task done
blwsk opened this issue Dec 16, 2024 · 1 comment
Open
1 task done

Custom font in PDF export #1329

blwsk opened this issue Dec 16, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@blwsk
Copy link

blwsk commented Dec 16, 2024

Is your feature request related to a problem? Please describe.
We use custom fonts in our production block editor and want the same fonts to be used in our exported PDFs. Currently, it appears as though the editor font is hardcoded to Inter: https://github.com/TypeCellOS/BlockNote/blob/main/packages/xl-pdf-exporter/src/pdf/pdfExporter.tsx#L57C10-L74

Describe the solution you'd like

  • Add support for overriding the default page styles, allowing a font to be specified. Ideally, other style properties like page margin could be altered, too, for future flexibility.
  • Support registering custom fonts, overriding the default registerFont method.

Describe alternatives you've considered
No alternatives come to mind, aside from perhaps forgoing the default block / inline style mappers and writing our own versions for every block or inline content type. Doing so would decrease the value provided by the package.

Additional context
Happy to submit a PR.

Bonus

  • I'm a sponsor and would appreciate if you could look into this sooner than later 💖

(https://github.com/poggiolabs is a sponsor)

@blwsk blwsk added the enhancement New feature or request label Dec 16, 2024
@YousefED
Copy link
Collaborator

Hi!

Thanks for the feedback. A currently possible alternative is to subclass PDFExporter and override registerFont to register the alternative font files, and change the font type in this.styles.

Have you considered this? I agree this might not be very clear, so happy to accept a PR with a clearer API and / or documentation (or we can do this on the next iteration or if this approach doesn't work).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants