Skip to content

Commit fab2ae6

Browse files
authored
Merge pull request #179 from varvedesign/codex/pdfcraft-residual-20261022
Vertical text metrics, and the last audit dispositions decided from source
2 parents 9a26235 + d3b291f commit fab2ae6

5 files changed

Lines changed: 49 additions & 12 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,10 @@ update, not for someone reading the commit log.
156156
- **PDF import keeps vertical writing vertical.** A PDF set in a vertical
157157
writing mode (`Identity-V`, or a CMap with `/WMode 1`) imported as one long
158158
horizontal line, so a Japanese or Chinese column arrived as the wrong
159-
document. Those runs now become Varve vertical text (`vertical-rl`), with the
160-
Import Report stating that each glyph advances one em because the font's
161-
vertical metrics are not read.
159+
document. Those runs now become Varve vertical text (`vertical-rl`), placed
160+
with the font's own vertical metrics (`/W2`, then `/DW2`), and consecutive
161+
runs that continue the pen position merge into one editable column instead of
162+
one layer per character.
162163
- **PDF export names characters the chosen font cannot draw.** The canvas falls
163164
back per glyph, but the PDF writer outlines the authored face, so a character
164165
that face does not map exported as a blank box while the editor showed it

‎docs/architecture/import-system.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ server (`tests/e2e/canvas/file-import.spec.ts`, snapshots inspected).
107107
| AVIF | Full | `ispe` box probe now recurses through `iprp`/`ipco` |
108108
| SVG / SVGZ | Editable vector | See fidelity matrix; `.svgz` is gunzipped by content sniff and retains the `svgz` source label in the Import Results report, including bounded malformed-input failures |
109109
| PSD / PSB | Partial | Version 1/2 `8BPS` files import a bounded layer tree (groups, bounds, visibility, opacity, and representable masks), and the asynchronous service path materializes supported layer pixels as embedded PNG image fills; header, dimension, encoded-size, and pixel budgets are checked before parsing; invalid or sentinel mask rectangles are omitted with a warning; effects, adjustment layers, smart objects, and exact text editing are reported as unsupported, with detected smart-object layers counted explicitly (imported as rendered pixels only; embedded artwork, warps, and re-editability are not extracted) |
110-
| PDF | Partial | Text and axis-aligned rectangle fills, per page. Content streams are decoded (zlib `FlateDecode`, ASCIIHex, ASCII85) and tokenized, so text positions come from the text matrix composed with the CTM and are mapped into page space (top-left origin, `/Rotate` applied, crop box used when it differs). Character codes resolve through the font's `/ToUnicode` CMap, otherwise the named base encoding plus `/Differences`. Page order follows the `/Kids` tree, with/inherited `/MediaBox`, `/Rotate` and `/Resources`. **Content the page does not show is not imported:** text in an invisible or clip-only render mode (`3 Tr`/`7 Tr`, the shape of a searchable OCR layer) and content inside an optional-content group the document's default configuration hides (a PDF "layer", as layered CAD exports ship) are counted and named in `unsupportedFeatures` instead of being painted as visible artwork. Vertical writing is preserved: a Type0 font whose CMap selects `/WMode 1` (`Identity-V`, or an embedded CMap that says so) is imported as a Varve vertical text node (`writingMode: vertical-rl`) instead of a single horizontal line. The per-glyph advance is one em because the font's `/W2` metrics are not read, and the capability note says so. **An encrypted document is refused with an explanation**, never imported as ciphertext that looks like an empty page. Everything else — images, form XObjects, curves, strokes, gradients, CMYK and pattern paints, composite-font runs with no mapping — is counted and named in `unsupportedFeatures`, never approximated. Bounded: 32 MB file, 16 MB per decoded stream, 50 pages |
110+
| PDF | Partial | Text and axis-aligned rectangle fills, per page. Content streams are decoded (zlib `FlateDecode`, ASCIIHex, ASCII85) and tokenized, so text positions come from the text matrix composed with the CTM and are mapped into page space (top-left origin, `/Rotate` applied, crop box used when it differs). Character codes resolve through the font's `/ToUnicode` CMap, otherwise the named base encoding plus `/Differences`. Page order follows the `/Kids` tree, with/inherited `/MediaBox`, `/Rotate` and `/Resources`. **Content the page does not show is not imported:** text in an invisible or clip-only render mode (`3 Tr`/`7 Tr`, the shape of a searchable OCR layer) and content inside an optional-content group the document's default configuration hides (a PDF "layer", as layered CAD exports ship) are counted and named in `unsupportedFeatures` instead of being painted as visible artwork. Vertical writing is preserved: a Type0 font whose CMap selects `/WMode 1` (`Identity-V`, or an embedded CMap that says so) is imported as a Varve vertical text node (`writingMode: vertical-rl`) instead of a single horizontal line. The per-glyph advance comes from the font's `/W2`, falling back to `/DW2` and then to one em; the capability note names the fallback where a font declares no vertical metrics. **An encrypted document is refused with an explanation**, never imported as ciphertext that looks like an empty page. Everything else — images, form XObjects, curves, strokes, gradients, CMYK and pattern paints, composite-font runs with no mapping — is counted and named in `unsupportedFeatures`, never approximated. Bounded: 32 MB file, 16 MB per decoded stream, 50 pages |
111111
| AI | Partial | `.ai` files with a PDF-compatible wrapper or legacy EPS header use the AI adapter; complex Illustrator effects, meshes, and native semantics are reported as losses; header-only or over-budget wrappers fail without fabricated nodes |
112112
| EPS | Partial | Basic paths |
113113
| Sketch | Partial | Symbols, shared styles and constraints not preserved |

‎docs/audits/pdfcraft/README.md‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ signature and Office interchange, all of which remain outside Varve's scope.
125125
| 5 | Preflight/audit reporting "clean" for artwork the user cannot see | verified at the rule level: no Varve preflight result may read as a completeness guarantee the check does not provide (ADR-0242 §6). No Varve check was found that reports a false clean for imported content, because hidden content is no longer imported (batch 9) |
126126
| 6 | Page rotation, page count and output size surviving save/reopen/export | **verified for save/reopen** — Varve's page-rotation model is per-page width/height, and a mixed-orientation document round-trips with order and node positions intact (commit `340262b60`). Export page geometry is the native writer's contract and is covered by `tests/e2e/export/native-pdf-contract.spec.ts`, not by a browser unit test |
127127
| 7 | Text edit identity (paragraph indices, property loss on re-edit) | already handled upstream: edits target authored node ids (ADR-0242), and the draft/target-switch paths are covered by `context/pendingEdits.ts` with `tests/e2e/save/text-draft-save.spec.ts` and `text-target-switch.spec.ts` |
128-
| 8 | Interaction classes: cursor over chrome following the canvas, a second menu open on the first, a panel clipped in a small window | **verified absent and pinned** — `tests/e2e/ui/chrome-ownership.spec.ts`: the hand-tool cursor does not leak onto the menubar, opening a second menu leaves exactly one, and at 1024x600 the inspector has no horizontal overflow and the Export tab stays reachable through the "More inspector tabs" menu. No UI change was needed |
128+
| 8 | Interaction classes: cursor over chrome following the canvas, a second menu open on the first, a panel clipped in a small window | **verified absent and pinned** — `tests/e2e/ui/chrome-ownership.spec.ts`: the hand-tool cursor does not leak onto the menubar, opening a second menu leaves exactly one, at 1024x600 the inspector has no horizontal overflow and the Export tab stays reachable through the "More inspector tabs" menu, and the Settings dialog fits or scrolls instead of clipping. No UI change was needed |
129129
| 8b | Autosave scheduling tied to repaint; failed-autosave retry suppression | deferred — `packages/editor/src/context/usePersistence.ts` belongs to another session; two writers on one file is worse than a delay |
130130
| 10 | Vertical writing (`Identity-V`) imported as one horizontal line, so a CJK column became the wrong document | **implemented and validated** — `/WMode 1` (name or embedded CMap) is detected and the run becomes a `vertical-rl` text node; unit tests cover detection and the browser test asserts the rendered ink is a column. Per-glyph `/W2` metrics and one-glyph-per-`Tj` column merging follow in batch 11. Commit `codex/pdfcraft-remainder-20261022` |
131131
| 11 | Vertical import refinement: per-glyph `/W2` metrics, one-glyph-per-`Tj` placement arriving as one layer per character, and parser notes that were generated but never shown | **implemented and validated** — `/W2` advances with a bounded `/DW2` fallback, consecutive vertical runs merge into one editable column, Import Results shows the parser's notes and wraps long detail rows, and deeply nested SVG now names the artwork it refused (row 3309). Unit and browser regressions extend batch 10's fixture; evidence in `docs/screenshots/pdfcraft/import-vertical-writing-*.png` |
@@ -174,17 +174,26 @@ with reasons. What remains, in priority order:
174174
3383, 3871), overlay placement with two menus (3190), and small-window
175175
clipping (3097, 3557, 3559). Each is a verification first; no UI change is
176176
assumed.
177-
3. **Row 3409 / batch 8 save paths**: land once the owning session releases
178-
`usePersistence.ts` and the native save path.
177+
3. **Row 3409 / batch 8 save paths**: the native save path is verified —
178+
`write_file_atomic` (`apps/desktop/src-tauri/src/lib.rs`) writes a unique
179+
temp, calls `sync_all` and **propagates its error** before the rename, and
180+
removes the temp on failure. The remaining piece is autosave scheduling in
181+
`usePersistence.ts`, which belongs to another session.
179182
4. **Row 3309**: the decoder was measured on a 5,000-level nested-group document
180183
and returns `ok` without throwing — `normalizeDocument` walks nodes flatly, so
181184
the reported stack overflow is not reachable at the decode boundary. What is
182185
still unmeasured is a render/bbox traversal at that depth; if a bound is added
183186
it belongs there, driven by a measured failure rather than a guess. The
184187
reachable import paths are bounded (SVG/Figma 256, PDF page tree 32) and the
185188
SVG ceiling now names refused artwork instead of importing nothing silently.
186-
5. **Row 3634/3504**: a per-node export deadline and a single decode-cap
187-
contract shared by render and export, if measurement shows they diverge.
189+
5. **Row 3504** verified: screen and export consume one decoded bitmap from
190+
`getImageCache()` via `resolveReplayImage`; the per-replay policy changes the
191+
*resolution* requested, never whether the content can be read, so the
192+
"readers disagree about what the document contains" class is absent.
193+
**Row 3634** stays open with a precise gap: export is cancellable and image
194+
resources have settlement timeouts, but there is no per-node render deadline,
195+
so a pathological effect at a very large output can run until the user
196+
cancels.
188197

189198
State at handoff: branch `codex/pdfcraft-continuation-20261021`, cut from
190199
`origin/master` at `2e8c5b018`, with the cutoff-1 batch cherry-picked onto it so

‎docs/audits/pdfcraft/issue-ledger-cutoff2.tsv‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
3403 open low priority: low interaction cluster-assessed Cursor/overlay ownership and small-window layout are queued candidates, not assumed defects. cutoff2
232232
3405 open low priority: low other cluster-assessed No transferable mechanism identified in the report text. cutoff2
233233
3407 open medium bug,priority: medium page-geometry outside-varve-scope File size unchanged after page deletion: Varve rewrites its own document, not a PDF container; the claim is about their writer. cutoff2
234-
3409 closed medium priority: medium save-io deferred Atomic save does not propagate staging-file close errors: the native save path is documented in docs/architecture/filesystem-boundary.md, but the file is being edited by another session; two writers on one path is worse than a delay. cutoff2
234+
3409 closed medium priority: medium save-io verified-already-correct- Atomic save propagates staging-file errors: write_file_atomic (apps/desktop/src-tauri/src/lib.rs) writes a unique temp, calls sync_all and returns its error before the rename, and removes the temp on failure. Residual: a filesystem that reports ENOSPC only at close(2) is not observed separately, which is the standard Rust File contract. cutoff2
235235
3410 open high bug,priority: high,needs info other cluster-assessed No transferable mechanism identified in the report text. cutoff2
236236
3414 open high priority: high,multiple issues save-io verified-already-correct- GUI hangs on a corrupt incremental-update xref: Varve does not trust the xref table; it scans objects with bounded budgets and reports truncation. cutoff2
237237
3417 closed medium bug,duplicate,priority: medium printer outside-varve-scope No device-printing workflow: Platform.printPdf/listPrinters are implemented but uncalled; the print surface is PDF/X export. cutoff2
@@ -284,7 +284,7 @@
284284
3501 open medium priority: medium,multiple issues forms outside-varve-scope No Varve form model and none planned; the text-metric and glyph-coverage mechanisms inside form reports are routed to the fonts-glyphs rows. cutoff2
285285
3502 open medium priority: medium forms outside-varve-scope No Varve form model and none planned; the text-metric and glyph-coverage mechanisms inside form reports are routed to the fonts-glyphs rows. cutoff2
286286
3503 open medium priority: medium forms outside-varve-scope No Varve form model and none planned; the text-metric and glyph-coverage mechanisms inside form reports are routed to the fonts-glyphs rows. cutoff2
287-
3504 open medium priority: medium render candidate Readers use different decode caps, so they read different documents: Varve bounds decode in one place (objects.ts MAX_STREAM_BYTES) for the importer; render/export share the asset, so the class is structurally absent. Verified by inspection; test queued. cutoff2
287+
3504 open medium priority: medium render verified-already-correct- Readers disagreeing about content because of different decode caps: screen and export share one image cache (resolveReplayImage + getImageCache); the per-replay policy changes requested resolution, not readability, so the class is structurally absent. cutoff2
288288
3505 open medium priority: medium fonts-glyphs implemented-validated Korean tofu in UI: batch 2 covers the export contract; UI fallback is the browser's, already per-glyph. cutoff2
289289
3507 open high priority: high other cluster-assessed No transferable mechanism identified in the report text. cutoff2
290290
3508 open high priority: high text-edit cluster-assessed Varve edits authored text nodes, not extracted PDF runs; the identity rule is ADR-0242. cutoff2
@@ -361,7 +361,7 @@
361361
3626 open medium priority: medium,needs info printer outside-varve-scope No device-printing workflow: Platform.printPdf/listPrinters are implemented but uncalled; the print surface is PDF/X export. cutoff2
362362
3629 open low priority: low interaction cluster-assessed Cursor/overlay ownership and small-window layout are queued candidates, not assumed defects. cutoff2
363363
3632 open low priority: low interaction cluster-assessed Cursor/overlay ownership and small-window layout are queued candidates, not assumed defects. cutoff2
364-
3634 open medium priority: medium save-io candidate Export/OCR/print have no per-page time limit: Varve export has cancellation and resource timeouts (settleEngineImageResources), but no per-node deadline. Queued. cutoff2
364+
3634 open medium priority: medium save-io candidate Per-node export deadline: export is cancellable (AbortSignal threaded through exportService) and image resources have settlement timeouts, but there is no per-node render deadline, so a pathological effect at a very large output runs until cancelled. Implementing a deadline needs a measured case; kept as a candidate rather than guessed. cutoff2
365365
3638 open medium enhancement,priority: medium other cluster-assessed No transferable mechanism identified in the report text. cutoff2
366366
3640 open medium priority: medium,shared build-release cluster-assessed Their packaging and release tooling; Varve's pipeline has its own gates. cutoff2
367367
3644 open critical priority: critical pdf-structure implemented-validated Remove-hidden deletes a 7 Tr clip title: no such surface; clip-mode text is not imported. cutoff2

‎tests/e2e/ui/chrome-ownership.spec.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,33 @@ test.describe('chrome ownership', () => {
5656
await expect(page.getByRole('menu')).toHaveCount(0);
5757
});
5858

59+
test('the settings dialog scrolls instead of clipping in a small window', async ({ page }) => {
60+
await page.setViewportSize({ width: 1024, height: 600 });
61+
await page.keyboard.press('Control+Comma');
62+
const dialog = page.getByRole('dialog');
63+
await dialog.waitFor({ state: 'visible', timeout: 10000 });
64+
65+
const geometry = await page.evaluate(() => {
66+
const el = document.querySelector('.varve-dialog--settings') as HTMLElement | null;
67+
if (!el) return null;
68+
const body = el.querySelector('.settings-dialog__layout') as HTMLElement | null;
69+
const rect = el.getBoundingClientRect();
70+
return {
71+
withinViewport: rect.top >= -1 && rect.bottom <= window.innerHeight + 1,
72+
horizontalOverflow: el.scrollWidth - el.clientWidth,
73+
bodyScrollable: body
74+
? body.scrollHeight > body.clientHeight + 1 || body.scrollWidth > body.clientWidth + 1
75+
: true,
76+
};
77+
});
78+
expect(geometry).not.toBeNull();
79+
// A dialog taller than the window must fit or scroll, never be clipped.
80+
expect(geometry!.horizontalOverflow).toBeLessThanOrEqual(2);
81+
expect(geometry!.withinViewport || geometry!.bodyScrollable).toBe(true);
82+
await page.keyboard.press('Escape');
83+
await expect(dialog).toHaveCount(0);
84+
});
85+
5986
test('the inspector stays reachable and unclipped in a small window', async ({ page }) => {
6087
await page.setViewportSize({ width: 1024, height: 600 });
6188
const overflow = await page.evaluate(() => {

0 commit comments

Comments
 (0)