Repository navigation
feat(text-edit): preview committed Type3 text edits in the original font (#723) - #780
Closed
oscar981-op wants to merge 2 commits into
Closed
oscar981-op wants to merge 2 commits into
oscar981-op wants to merge 2 commits into
Conversation
…ndation#723) A replacement in a Type3 font was drawn live in Helvetica because the painter cannot use a Type3 font as a CSS font. The preview now renders the edited text through PDF.js from a small temporary PDF built with pdf-lib: one page with the same box, the page's fonts copied in (CharProcs and Resources included), and the new text drawn by the saver's own code path, so the glyph codes, positions and Standard-14 fallback for missing glyphs are the same as in the saved file. - text-edit-inplace: split the read-only analysis (analyseerPagina) and the encoder (maakInPlaceResultaat) out of applyForPage; Type3 widths are scaled by the FontMatrix and a Type3 glyph only counts as present when its name has a CharProcs entry. - text-edits: export tekenTextEdit (draw one edit like the saver). - type3-voorbeeld: debounced build per edit signature, stale builds and renders discarded or cancelled, cache per run and zoom, temp document freed when the edit goes away or the document closes; Helvetica preview stays while pending or on failure. - rendering: draw the bitmap in the page frame when available. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pixel test passed pdf.js a standardFontDataUrl built with path.sep. On Windows that ends in a backslash, and pdf.js rejects a factory URL without a trailing slash, so getDocument failed and the preview status became 'mislukt'. Build the directory with forward slashes instead (fs.readFile accepts them on Windows). The preview now keeps the error behind a failed status (type3VoorbeeldFout), and the test prints it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
Collaborator
|
Thank you, @oscar981-op! This change is included in release 2026.44.1 through the release PR #841, as one squashed commit with you as the author, so this PR is closed rather than merged. During review we added the following on top, with regression tests: pages without Type3 fonts skip the preview work entirely, so text edits on large pages stay fast. |
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.
Part of #723. Committed text edits in a Type3 font are now shown on the canvas in the original font. While the text editor box is open it still shows Helvetica, so this PR does not close the issue.
Approach
applyForPageis split into a read-onlyanalyseerPaginaandmaakInPlaceResultaat(encodeRun). The preview runs the analysis on the shared pdf-lib document without changing it.js/text/type3-voorbeeld.jsbuilds a one-page PDF with the original box. The fontsencodeRunpicks are copied in withPDFObjectCopier(CharProcs and the font's Resources included), and the text is drawn with the saver's owntekenTextEdit. Glyph codes, positions, Tc/Tw/Tz, justification, decorations and the Standard-14 fallback are therefore identical to the saved file.rendering.jsdraws that bitmap in the page frame, so rotation is handled.document-release.js)Tests
js/text/type3-voorbeeld.test.mjs(11 tests):Full suite: 0 failures.
tscandvite buildare clean.Not yet checked in the running app / limits
🤖 Generated with Claude Code