Skip to content

Commit 0aaa01b

Browse files
authored
Merge pull request #172 from varvedesign/codex/pdfcraft-batch7
PDF vertical import: /W2 metrics, one column per column, and honest import details
2 parents 7572b25 + 6b61631 commit 0aaa01b

25 files changed

Lines changed: 643 additions & 73 deletions

‎apps/website/src/pages/docs/file-formats.astro‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ const figmaImportFaq = {
167167
Character codes resolved through the font's <code>/ToUnicode</code> map, or its named
168168
base encoding plus <code>/Differences</code>, so accented and non-Latin text survives
169169
</li>
170+
<li>
171+
Vertical writing (<code>/Identity-V</code>, or a CMap with <code>/WMode 1</code>)
172+
imported as vertical columns with the writing mode set, including producers that
173+
position one glyph per text-showing operator
174+
</li>
170175
<li>Plain axis-aligned rectangle fills</li>
171176
<li>
172177
One Varve page per PDF page, in <code>/Kids</code> order, up to 50 pages; the remainder
@@ -179,7 +184,9 @@ const figmaImportFaq = {
179184
scan), and content inside an optional-content group the document's default configuration
180185
hides (a PDF layer, as layered CAD exports ship). Both are counted, and hidden layers are
181186
named in Import Results. Images, form XObjects, curves, strokes, gradients, CMYK and
182-
pattern paints are reported rather than approximated.
187+
pattern paints are reported rather than approximated. Import Results also lists what
188+
the parser did rather than what it lost, such as page rotation being applied or vertical
189+
runs becoming editable columns.
183190
</p>
184191
<p>
185192
An encrypted PDF (password-protected or permission-restricted) is refused with an

‎apps/website/src/pages/docs/tools/typography.astro‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ import '../../../styles/docs-prose.css';
101101
</p>
102102
<p>
103103
In a fixed area, wrapping consumes the physical height of the frame as the vertical inline extent. New columns progress leftward for vertical-rl and rightward for vertical-lr; authored line breaks remain authored breaks. The browser renderer uses a stable measured fallback when font bytes are unavailable, and native ttb shaping remains a separate runtime capability. HTML/CSS and SVG exports preserve writing-mode semantics; native PDF vertical text is currently reported as a target limitation rather than silently rotated.
104+
105+
PDF import reads a vertical font CMap (<code>/Identity-V</code> or <code>/WMode 1</code>) as vertical text: each column opens as an editable layer with Writing mode set to Vertical, right to left and the default Mixed character orientation, which you can change independently. Consecutive upright glyphs that a producer placed one at a time are merged into that column, while neighbouring columns stay separate layers.
104106
</p>
105107
</section>
106108

‎apps/website/tests/e2e/file-ingestion-marketing.spec.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ test('file formats documentation explains local file actions', async ({ page })
1212
await expect(
1313
page.getByText(/Inkscape live path effects keep their visible SVG path geometry/i),
1414
).toBeVisible();
15+
// The PDF section names the vertical-writing contract the importer now meets.
16+
await expect(
17+
page.getByText(/imported as vertical columns with the writing mode set/i),
18+
).toBeVisible();
19+
await expect(
20+
page.getByText(/Import Results also lists what the parser did rather than what it lost/i),
21+
).toBeVisible();
1522
await page.screenshot({
1623
path: test.info().outputPath('file-formats-local-actions.png'),
1724
fullPage: true,

‎docs/audits/pdfcraft/README.md‎

Lines changed: 104 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ Counts at cutoff 1: `cluster-assessed` 1,156 · `candidate` 75 ·
8181
`verified-already-correct-` 6 · `deferred` 4. 166 rows are individually
8282
adjudicated; the rest inherit a cluster verdict.
8383

84-
Counts for the 494 cutoff-2 issues: `cluster-assessed` 254 ·
85-
`outside-varve-scope` 165 · `implemented-validated` 47 · `candidate` 18 ·
86-
`verified-already-correct-` 9 · `deferred` 1. 92 of those rows are
87-
individually adjudicated (title, labels, body, and the discussion where it
88-
changed the reading); the rest inherit a cluster verdict with a stated reason.
84+
Counts for the 494 cutoff-2 issues: `cluster-assessed` 252 ·
85+
`outside-varve-scope` 164 · `implemented-validated` 50 · `candidate` 10 ·
86+
`verified-already-correct-` 17 · `deferred` 1. The rows named in the batch
87+
table were individually adjudicated (title, labels, body, and the discussion
88+
where it changed the reading); the rest inherit a cluster verdict with a
89+
stated reason.
8990
The 184 cutoff-1 closures were checked against the cluster map: none changed a
9091
Varve disposition, because the closed classes are redaction, printing, forms,
9192
signature and Office interchange, all of which remain outside Varve's scope.
@@ -126,7 +127,8 @@ signature and Office interchange, all of which remain outside Varve's scope.
126127
| 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` |
127128
| 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 |
128129
| 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 |
129-
| 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 advance is one em (`/W2` unread) and disclosed in the Import Report. Commit `codex/pdfcraft-remainder-20261022` |
130+
| 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` |
131+
| 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` |
130132
| 9 | PDF import invents content the page does not show: invisible/clip-only text, hidden optional-content layers, encrypted files imported as blank pages, and an inline image whose `EI` is followed by a delimiter | **implemented and validated** — `/OCProperties` visibility, `Tr` render modes, `/Encrypt` refusal with a failure status, and delimiter-terminated `EI`. Commits `3bdd3e336`, `bb2f53d24`; browser evidence in `tests/e2e/import/pdf-import-integrity.spec.ts` and `docs/screenshots/pdfcraft/` |
131133

132134
## Limitations (unresolved)
@@ -165,9 +167,9 @@ These are honest gaps, not completions:
165167
Cutoff 2 is taken and reconciled; batches 1–6 and 9 are complete or recorded
166168
with reasons. What remains, in priority order:
167169

168-
1. ~~Vertical-writing import (rows 3216/3711/3712)~~ — landed as batch 10. The
169-
remaining refinement is `/W2` per-glyph vertical metrics (currently one em)
170-
and `Tz`-upright placement inside a vertical run.
170+
1. ~~Vertical-writing import (rows 3216/3711/3712)~~ — landed as batches 10
171+
and 11. `/W2` metrics and one-glyph-per-`Tj` column merging are
172+
implemented; `Tz`-upright placement inside a vertical run remains open.
171173
2. **Batch 8 (interaction)**: verify cursor ownership over chrome (rows 3001,
172174
3383, 3871), overlay placement with two menus (3190), and small-window
173175
clipping (3097, 3557, 3559). Each is a verification first; no UI change is
@@ -178,7 +180,9 @@ with reasons. What remains, in priority order:
178180
and returns `ok` without throwing — `normalizeDocument` walks nodes flatly, so
179181
the reported stack overflow is not reachable at the decode boundary. What is
180182
still unmeasured is a render/bbox traversal at that depth; if a bound is added
181-
it belongs there, driven by a measured failure rather than a guess.
183+
it belongs there, driven by a measured failure rather than a guess. The
184+
reachable import paths are bounded (SVG/Figma 256, PDF page tree 32) and the
185+
SVG ceiling now names refused artwork instead of importing nothing silently.
182186
5. **Row 3634/3504**: a per-node export deadline and a single decode-cap
183187
contract shared by render and export, if measurement shows they diverge.
184188

@@ -187,3 +191,93 @@ State at handoff: branch `codex/pdfcraft-continuation-20261021`, cut from
187191
the review is reviewable without the unpushed local history. Commits: batch 9
188192
`3bdd3e336`, batch 2 `90f1e01d6`, batch 3 `3ed8e6a03`, batch 4 `3bfe7c04b`,
189193
batch 6 `340262b60`, refusal reporting `bb2f53d24`.
194+
195+
## Continuation record — batch 11 (2026-10-22)
196+
197+
Branch `codex/pdfcraft-batch7`, worktree `.worktrees/pdfcraft-b7`, cut from
198+
`origin/master` at `13e97dde3` (which already contained batch 10's vertical
199+
writing fix). Review: PR #172. This batch is the refinement batch 10 deferred, plus two
200+
honesty fixes found while validating it.
201+
202+
**What changed**
203+
204+
- `/W2` per-glyph vertical metrics are read from the descendant CIDFont, with
205+
the documented `/DW2` one-em default and a ten-em ceiling against hostile
206+
values. Batch 10 advanced every vertical glyph one em and disclosed that;
207+
the disclosure is no longer needed because the published metric is used.
208+
- Consecutive vertical runs merge into one editable column when they share the
209+
font and size, start where the previous pen stopped (quarter-em tolerance),
210+
and keep the same direction. One-glyph-per-`Tj` placement no longer produces
211+
one layer per character. A run that starts a new column stays separate.
212+
- Runs carry their display-space displacement (`advanceX/advanceY`), so
213+
continuity is measured in display space rather than assuming an unrotated
214+
page.
215+
- Import Results now shows the parser's capability notes when details are
216+
expanded. The notes (vertical columns, page rotation applied, crop box used,
217+
outside-page runs) were generated but never displayed. The file row now
218+
wraps with full-basis detail rows instead of squeezing capabilities,
219+
warnings and notes into three side-by-side slivers.
220+
- An SVG nested deeper than the 256-level parser ceiling now names the refused
221+
artwork. Before, it imported zero nodes and reported no warning.
222+
223+
**Evidence**
224+
225+
- `packages/import/src/pdfFidelity.test.ts`: 29 tests, including the merged
226+
one-glyph column, a neighbouring column that stays separate, and a fixture
227+
where a published half-em `/W2` advance is what joins two runs (the same
228+
file without `/W2` leaves them apart).
229+
- `tests/e2e/import/pdf-vertical-text.spec.ts`: two real File > Import runs.
230+
The first keeps batch 10's column-vs-line ink assertion. The second imports
231+
two columns, one written as a single `Tj` and one as six `Tj` operators,
232+
asserts 2 layers (not 7) and reads Writing mode from the Inspector. It also
233+
asserts the Import Results note "7 vertical text run(s) were imported as 2
234+
vertical column(s)".
235+
- `packages/import/src/svg.test.ts`: 31 tests; the new disclosure regression
236+
fails without the warning and a 250-level document still imports.
237+
- The full CI E2E shard exposed a regression from showing notes: a refused
238+
PDF displayed "This PDF is encrypted" twice, once as the error and once as a
239+
capability note, which also broke the existing encrypted-PDF assertion.
240+
Notes now render only for files that produced a document, with a unit
241+
regression (`ImportResults.test.tsx`, 16 tests).
242+
- Visual: `docs/screenshots/pdfcraft/import-vertical-writing-canvas.png`
243+
shows 縦書きの試験, 隣の列の文章 (one glyph per operator) and 離れた列 as three
244+
top-to-bottom columns with no overlap; the editor capture shows the
245+
Inspector reading Writing mode "Vertical, right to left"; the results
246+
capture shows the wrapped details and the column note.
247+
248+
**Validation (batch 11)**
249+
250+
```text
251+
Changed scope: packages/import PDF/SVG parsers and tests; packages/editor ImportResults and test; tests/e2e/import; website file-formats and typography docs plus the marketing test; PDFCraft audit records and screenshots.
252+
Validation plan: pnpm verify:plan selected 27 lanes with no full-suite escalation (format/lint, emoji/docs/claims/radius/spacing/sizing audits, E2E TypeScript, affected package typechecks and unit lanes, website unit/E2E, import and export browser domains).
253+
Commands actually run: pnpm verify:affected; pnpm typecheck:e2e; pnpm audit:docs; pnpm audit:emoji; lease-wrapped npx playwright test tests/e2e/import/pdf-vertical-text.spec.ts; production website captures at 1440x1000 and 390x844.
254+
Passed: all 27 planned lanes (2681s): editor unit 8,825 passed (2 skipped), import 430, desktop 90, website unit 312, website E2E 694 across both bases, import browser domain 12, export browser domain 16, focused vertical browser test 2; focused pdfFidelity 29, svg 31, ImportResults 15; E2E TypeScript; docs/emoji audits; no horizontal overflow at 1440/390/320.
255+
Skipped as unrelated: Rust workspace and native desktop GUI lanes (no Rust or native surface changed); the planner did not escalate.
256+
Escalations: none. Full suite run: no.
257+
```
258+
This run was executed on the batch-11 tree after rebasing onto the batch-10
259+
commit `13e97dde3`.
260+
261+
**Limitations of this batch**
262+
263+
- Automatic tate-chu-yoko compaction and `Tz`-upright placement are not
264+
inferred from a PDF. Glyphs and digits are preserved in one editable string;
265+
applying `textCombineUpright` or adjusting orientation remains an authoring
266+
decision.
267+
- Page `/Rotate` is applied to positions, as for horizontal text, so on a
268+
rotated page a vertical column is placed correctly but its glyphs are not
269+
rotated with the page. That general text-rotation gap is unchanged.
270+
- Imported text colour, font family and glyph outlines are still not carried;
271+
the importer reports substitution.
272+
273+
**Remaining queue (not closed by this batch)**
274+
275+
1. Row 3409 and the autosave scheduling work (batch 8b) stay with the session
276+
that owns `usePersistence.ts` and the native save path.
277+
2. Row 3504: shared decode-cap contract, test queued.
278+
3. Row 3634: per-node export deadline, queued pending measurement.
279+
4. Issues created after cutoff 2 (`2026-10-21T19:32:41Z`) are a follow-on
280+
queue and are not part of this coverage claim.
281+
Batch 8's interaction classes were verified and pinned separately
282+
(`tests/e2e/ui/chrome-ownership.spec.ts`), so that queue item is closed.
283+

‎docs/audits/pdfcraft/issue-ledger-cutoff2.summary.json‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,34 @@
3535
"issues_missing_from_cutoff2": 0
3636
},
3737
"new_issue_dispositions": {
38-
"implemented-validated": 47,
39-
"outside-varve-scope": 165,
40-
"cluster-assessed": 254,
41-
"candidate": 18,
42-
"verified-already-correct-": 9,
38+
"implemented-validated": 50,
39+
"outside-varve-scope": 164,
40+
"cluster-assessed": 252,
41+
"candidate": 10,
42+
"verified-already-correct-": 17,
4343
"deferred": 1
4444
},
4545
"reconciliation": {
4646
"open_issues_plus_open_prs_equals_reported_count": true,
4747
"duplicate_issue_numbers": 0,
4848
"failed_requests": 0
49+
},
50+
"batch_updates": {
51+
"batch_11_2026-10-22": {
52+
"issues": [3216, 3711, 3712, 3309],
53+
"result": {
54+
"3216": "implemented-validated",
55+
"3711": "implemented-validated",
56+
"3712": "implemented-validated",
57+
"3309": "verified-already-correct-"
58+
},
59+
"evidence": [
60+
"packages/import/src/pdfFidelity.test.ts",
61+
"tests/e2e/import/pdf-vertical-text.spec.ts",
62+
"packages/import/src/svg.test.ts",
63+
"docs/screenshots/pdfcraft/import-vertical-writing-canvas.png",
64+
"docs/screenshots/pdfcraft/import-vertical-writing-results.png"
65+
]
66+
}
4967
}
5068
}

0 commit comments

Comments
 (0)