markdown-transform icon indicating copy to clipboard operation
markdown-transform copied to clipboard

Add custom fonts support for Unicode PDFs

Open kunal-595 opened this issue 5 months ago • 0 comments

Closes #455

This PR adds support for custom Unicode fonts in PDF generation, allowing users to render Unicode characters (Arabic, Chinese, Japanese, etc.) by providing their own font files.

Changes

  • Modified PdfTransformerBase.js to accept an optional fonts parameter in pdfMakeToPdfStreamWithCallback() and pdfMakeToPdfStream() methods
  • Updated PdfTransformer.js to accept and pass through the fonts parameter in pdfMakeToPdfBuffer() method
  • Exported defaultFonts from packages/markdown-pdf/index.js to allow users to extend the default Liberation fonts
  • Added documentation in packages/markdown-pdf/README.md with usage examples showing how to use custom Unicode fonts
  • Maintained full backward compatibility - existing code works unchanged

Flags

  • Breaking Changes: None - the fonts parameter is optional and defaults to existing Liberation fonts
  • Testing: Existing unit tests should pass unchanged; new functionality allows Unicode rendering when custom fonts are provided
  • Dependencies: No new dependencies added

Screenshots or Video

N/A - API enhancement for font support

Related Issues

  • Issue #455
  • Pull request #634

Author Checklist

  • [x] Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • [x] Vital features and changes captured in unit and/or integration tests
  • [x] Commits messages follow AP format
  • [x] Extend the documentation, if necessary

kunal-595 avatar Oct 21 '25 08:10 kunal-595