@quario/pdf 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.5.0] - 2026-09-05
11
+
12
+ ### Added
13
+
14
+ - **A spanning cell draws as one box** across the columns it covers, through
15
+ `@quario/layout`. It takes no part in measuring them, and a spanning row that
16
+ slices across pages or page-column strips follows the geometry of the strip
17
+ each slice lands in.
18
+ - **`valign`** on table cells and split slots, through `@quario/layout`: middle
19
+ and bottom place the content in the height its row or split leaves over it.
20
+
21
+ ### Changed
22
+
23
+ - **A row's box is drawn by the row's cells**, through `@quario/layout`. A box
24
+ declared on a table row used to be one rect across the columns; each covered
25
+ cell now draws its own. A row's `borderBottom` still reads as one continuous
26
+ edge, a row's `borderLeft` becomes an edge on every cell rather than one at
27
+ the row's outer left, and a bordered row is taller by its border's width,
28
+ since a border occupies height as a cell's always has.
29
+
30
+ - **Embedding TrueType fonts now needs `fontkit`, not `@pdf-lib/fontkit`.**
31
+ Install `fontkit` instead; nothing else about `options.fonts` changes. The
32
+ old package's bundle crashed with a bare `ReferenceError` on any OpenType
33
+ face needing a shaping state machine — which is every Devanagari, Bengali,
34
+ Tamil, Khmer or Myanmar webfont in practice, and some fifty further scripts
35
+ besides. Those faces now measure, embed and draw. Which scripts a face
36
+ supports remains the font's and the parser's to answer, not this package's.
37
+
38
+ - **`pdf-lib` is now `@cantoo/pdf-lib`.** A maintained fork, and what
39
+ `fontkit`'s subsetting requires. Rendered documents are unchanged in what
40
+ they draw: every drawn string is identical and every filled area lands in
41
+ the same place, but the file's bytes differ, so a host comparing digests
42
+ against stored output will see them move once.
43
+
10
44
  ## [0.4.0] - 2026-09-03
11
45
 
12
46
  ### Changed
package/README.md CHANGED
@@ -5,7 +5,7 @@ definition straight to a paginated PDF. No headless browser, no print CSS, deter
5
5
 
6
6
  quario does the typesetting — pagination, keep-together, tables, fonts, the document outline —
7
7
  through `@quario/layout`, the same layout the viewer paints on screen, so the preview and the
8
- document break their pages in the same places. [pdf-lib](https://pdf-lib.js.org) writes the file. You get typesetting plus pdf-lib: no Chromium
8
+ document break their pages in the same places. [`@cantoo/pdf-lib`](https://github.com/Cantoo-Scribe/pdf-lib) writes the file. You get typesetting plus pdf-lib: no Chromium
9
9
  in your container, no page-load race, no fonts-not-ready flake.
10
10
 
11
11
  ## Install
@@ -14,13 +14,13 @@ in your container, no page-load race, no fonts-not-ready flake.
14
14
  npm install quario @quario/pdf
15
15
  ```
16
16
 
17
- pdf-lib comes along as a dependency; the engine is a peer, installed beside it. ESM-only, Node 22+, and browser-ready through
17
+ `@cantoo/pdf-lib` comes along as a dependency; the engine is a peer, installed beside it. ESM-only, Node 22+, and browser-ready through
18
18
  any standards-based ESM bundler. The renderer returns bytes, so the host decides where they go.
19
19
 
20
20
  Embedding TrueType fonts also needs the optional peer:
21
21
 
22
22
  ```bash
23
- npm install @pdf-lib/fontkit
23
+ npm install fontkit
24
24
  ```
25
25
 
26
26
  It loads only when you pass `fonts` to the factory. The base-14 families need nothing extra.
package/lib/embed.js CHANGED
@@ -11,27 +11,18 @@
11
11
  * variants indexed by `bold + 2 * italic`, a missing variant falling back to
12
12
  * the family's regular — so a `FaceRef` on the list names one font here.
13
13
  */
14
- import { StandardFonts } from "pdf-lib";
14
+ import { StandardFonts } from "@cantoo/pdf-lib";
15
15
 
16
+ // A family's four names are one stem plus the weight and slant suffixes that
17
+ // family spells, so each family names its two and the four are walked out of
18
+ // them rather than written twelve times over.
19
+ /** @type {(stem: string, slant: string) => string[]} */
20
+ let variants = (stem, slant) =>
21
+ ["", "Bold", slant, "Bold" + slant].map((v) => /** @type {any} */ (StandardFonts)[stem + v]);
16
22
  let BASE = {
17
- sans: [
18
- StandardFonts.Helvetica,
19
- StandardFonts.HelveticaBold,
20
- StandardFonts.HelveticaOblique,
21
- StandardFonts.HelveticaBoldOblique,
22
- ],
23
- serif: [
24
- StandardFonts.TimesRoman,
25
- StandardFonts.TimesRomanBold,
26
- StandardFonts.TimesRomanItalic,
27
- StandardFonts.TimesRomanBoldItalic,
28
- ],
29
- mono: [
30
- StandardFonts.Courier,
31
- StandardFonts.CourierBold,
32
- StandardFonts.CourierOblique,
33
- StandardFonts.CourierBoldOblique,
34
- ],
23
+ sans: variants("Helvetica", "Oblique"),
24
+ serif: variants("TimesRoman", "Italic"),
25
+ mono: variants("Courier", "Oblique"),
35
26
  };
36
27
 
37
28
  /** @typedef {{ families: Record<string, any[]> }} Fonts */
@@ -43,9 +34,9 @@ let BASE = {
43
34
  let useFontkit = async (doc) => {
44
35
  let fontkit;
45
36
  try {
46
- fontkit = (await import("@pdf-lib/fontkit")).default;
37
+ fontkit = await import("fontkit");
47
38
  } catch {
48
- throw Error("options.fonts: install @pdf-lib/fontkit to embed TrueType families");
39
+ throw Error("options.fonts: install fontkit to embed TrueType families");
49
40
  }
50
41
  doc.registerFontkit(fontkit);
51
42
  };
package/lib/index.d.ts CHANGED
@@ -21,7 +21,7 @@ export interface PdfOptions {
21
21
  /**
22
22
  * TrueType families to embed (subset), selected from styles by
23
23
  * `family: '<name>'`. Fonts are trusted host assets. Requires the optional
24
- * peer `@pdf-lib/fontkit`; the base-14 families need nothing extra.
24
+ * peer `fontkit`; the base-14 families need nothing extra.
25
25
  */
26
26
  fonts?: Record<string, PdfFontFamily>;
27
27
  }
package/lib/index.js CHANGED
@@ -13,7 +13,7 @@
13
13
  * sibling modules, which ship beside it — the package publishes `lib/`
14
14
  * verbatim.
15
15
  */
16
- import { PDFDocument } from "pdf-lib";
16
+ import { PDFDocument } from "@cantoo/pdf-lib";
17
17
  import { layout } from "@quario/layout";
18
18
  import { embedFonts } from "./embed.js";
19
19
  import { outline } from "./outline.js";
package/lib/outline.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * own position. pdf-lib has no bookmark API, so the objects are built through
8
8
  * its low-level context — the only place in this target that does.
9
9
  */
10
- import { PDFHexString, PDFName, PDFNumber } from "pdf-lib";
10
+ import { PDFHexString, PDFName, PDFNumber } from "@cantoo/pdf-lib";
11
11
 
12
12
  // A PDF *text string*: UTF-16BE with a BOM, so a title survives whatever the
13
13
  // author wrote. `PDFHexString.fromText` encodes exactly that.
package/lib/painter.js CHANGED
@@ -10,11 +10,11 @@
10
10
  * image can never cover it (LICENSE section 6).
11
11
  */
12
12
  import { breathe } from "quario";
13
- import { degrees, drawImage, drawText, rgb } from "pdf-lib";
13
+ import { degrees, drawImage, drawText, rgb } from "@cantoo/pdf-lib";
14
14
  import { fontFor } from "./embed.js";
15
15
 
16
- /** @typedef {import('pdf-lib').PDFPage} PDFPage */
17
- /** @typedef {import('pdf-lib').PDFName} PDFName */
16
+ /** @typedef {import('@cantoo/pdf-lib').PDFPage} PDFPage */
17
+ /** @typedef {import('@cantoo/pdf-lib').PDFName} PDFName */
18
18
 
19
19
  // The operator builder wants explicit rotation and skew; report text has none.
20
20
  let NO_TURN = degrees(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quario/pdf",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "The browserless, paginated PDF render target for quario — in the makings, not yet released",
5
5
  "homepage": "https://getquario.com",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -36,23 +36,24 @@
36
36
  "postpack": "node -e \"require('fs').rmSync('LICENSE',{force:true})\""
37
37
  },
38
38
  "dependencies": {
39
- "@quario/layout": "^0.1.0",
40
- "pdf-lib": "^1.17.1"
39
+ "@cantoo/pdf-lib": "^2.9.1",
40
+ "@quario/layout": "^0.2.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@arethetypeswrong/cli": "^0.18.3",
44
- "@pdf-lib/fontkit": "^1.1.1",
45
44
  "@size-limit/preset-small-lib": "^13.0.3",
46
- "quario": "^0.4.0",
45
+ "@types/fontkit": "^2.0.9",
46
+ "fontkit": "^2.0.4",
47
+ "quario": "^0.5.0",
47
48
  "size-limit": "^13.0.3",
48
49
  "typescript": "^7.0.2"
49
50
  },
50
51
  "peerDependencies": {
51
- "@pdf-lib/fontkit": "^1.1.1",
52
- "quario": "^0.4.0"
52
+ "fontkit": "^2.0.4",
53
+ "quario": "^0.5.0"
53
54
  },
54
55
  "peerDependenciesMeta": {
55
- "@pdf-lib/fontkit": {
56
+ "fontkit": {
56
57
  "optional": true
57
58
  }
58
59
  },
@@ -62,7 +63,7 @@
62
63
  "ignore": [
63
64
  "quario",
64
65
  "@quario/layout",
65
- "pdf-lib"
66
+ "@cantoo/pdf-lib"
66
67
  ],
67
68
  "limit": "6 kB"
68
69
  }