Repository navigation
Conversation
…ines. Kerned names such as `Jane Walker` fit at their measured width in text and tables. `widthOfString()` now respects `wordSpacing`. Fixes foliojs#1882
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rework layout to use shaped glyph advances when fitting and drawing lines. Kerned names such as
Jane Walkerfit at their measured width in text and tables.widthOfString()now respectswordSpacing. Fixes #1882What kind of change does this PR introduce?
Checklist:
I tasked OpenAI Astra 6.2 to rework layout to match well established text rendering libraries / programs
This is the proposed changes.
But it comes with a 3.3x perf overhead making not suitable for prime time. Creating a PR just for record, to maybe be used as base for future improvements.
The findings:
The standalone browser bundle grew by 1.16 KiB gzipped (+0.43%). The runtime impact depends on the workload. A 100-row Helvetica table took 2 ms longer (+11%), while a long Roboto paragraph with varying text took 3.3× as long. The latter is the main performance concern.
Runtime
I compared the working tree with
3973f09, the commit containing #1846. These are median times from 15 alternating runs after warm-up on Node 24.12. Each sample started with a fresh document. The table timing includes PDF finalization. Paragraph timings cover layout and drawing with compression disabled.Across production source files, including the two new modules, the net change is +25 lines and +631 bytes, with no added dependency. Heap usage was not measured.