Skip to content

Conversation

hollandjake
Copy link
Contributor

@hollandjake hollandjake commented Jun 20, 2025

THIS IS A WIP, to allow you to contribute feedback/changes

What kind of change does this PR introduce?

  • Replace jest with vitest (fixes jests lack of support for ESM only modules)
  • Replace linebreaker with newer unicode 16 compatible version (needs a bump to node 20)
  • Rewrite of text rendering/sizing
    • Split text rendering into layout and render
    • Allows computation of bounds without a single modification to the document state
  • Introduce new text rendering options for more intuitive rendering
    • LayoutEngine.text: render the same as existing using the PDF spec rules on positioning (this means rotated text can go above the start position)
    • LayoutEngine.textBox: render text from the top left of the text bounds (this means that rotated text is forced inside the text box
    • LayoutEngine.box: render a simple rectangle (but this can be rotated)

Checklist:

  • Unit Tests
  • Documentation
  • Update CHANGELOG.md
  • Ready to be merged

Based on #1625

This stops jest being the limiting factor which is stopping the use of ESM only packages
@hollandjake hollandjake marked this pull request as draft June 20, 2025 10:11
@blikblum
Copy link
Member

Great work.

Aside from UTF16 support what is different in the new lib?

Wondering if with this change will be possible to render a text box with custom background / borders

@hollandjake
Copy link
Contributor Author

Hi @blikblum,

The new changes are mainly a complete rewrite of how we handle text processing, both to enable rotation handling more smoothly as well as finally sort out those pesky numerical errors we've been getting.

Yep just sorting backgrounds now along with a few other text based improvements such as font contexts

@hollandjake
Copy link
Contributor Author

@blikblum quick question do we still need the virtual-fs.js, I notice its not exported or used anywhere?

@blikblum
Copy link
Member

Its used by the bundlers like webpack

@hollandjake
Copy link
Contributor Author

Added a new commit to fix the build process (not technically part of the scope of this task, but was needed to ensure the build would work). Have tested with browserify, webpack, native browser import, esm, cjs, umd (standalone), and umd through unkpg

- Current process fails on the external dependencies
- This modernizes both the test and build process
- And fixes the package defined exports
@hollandjake
Copy link
Contributor Author

Still working on this, been sorting out testing and fixing bugs found along the way

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