Skip to content

fix: Fixes rendering of non-Latin alphabet characters in PDF export - #2937

Merged
antsgar merged 3 commits into
mainfrom
fix/render-other-alphabets-in-pdf-export
Sep 29, 2025
Merged

antsgar merged 3 commits into
mainfrom
fix/render-other-alphabets-in-pdf-export

Conversation

@antsgar

@antsgar antsgar commented Sep 23, 2025 •

Copy link
Copy Markdown
Contributor

Currently characters from non-Latin alphabets are not rendering correctly in PDF exports. The reason is @react-pdf/renderer, the library we use to render the PDF, comes with a limited set of included fonts which aren't able to render these characters. In order to fix this problem, we need to register the appropriate fonts and use them in the styling. This PR:

  • Updates react-pdf to the latest version.
  • Checks which Unicode scripts are contained in each Lexical text node using an external library.
  • Adds Webpack compilation for local assets folder.
  • Maps each Unicode script to the appropriate Noto Sans font that is able to render those characters, and gets the link for the font from Google Fonts CDN fetches the font from local assets.
  • Sets the specified fonts as the font family for the node.
  • Registers the fonts before rendering the PDF.
  • Adds error handling so that if the rendering fails the error toast is displayed.

@antsgar
antsgar requested a review from amanharwara September 23, 2025 17:50
@antsgar
antsgar merged commit 6b408a6 into main Sep 29, 2025
3 checks passed
@antsgar
antsgar deleted the fix/render-other-alphabets-in-pdf-export branch September 29, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants