@qrcommunication/gigapdf-lib 0.64.0 → 0.65.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
@@ -4,6 +4,20 @@ All notable changes to `@qrcommunication/gigapdf-lib` are documented here.
4
4
  The format follows [Keep a Changelog](https://keepachangelog.com/) and the
5
5
  project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [0.65.0] - 2026-06-22
8
+
9
+ ### Added
10
+
11
+ - **Office→PDF phase-2 fonts** — `officeToPdfWith(office, fonts)` (ABI
12
+ `gp_office_to_pdf_with_fonts`, core `office_to_pdf_with_fonts`) completes the
13
+ two-phase font flow opened by `officeNeededFonts`: hand back the host-fetched
14
+ faces for the families a container **references but doesn't embed** (e.g.
15
+ Carlito for a Calibri reference) and styled runs lay out + paint with the right
16
+ metrics instead of drifting onto the bundled fallback. The supplied faces are
17
+ merged with whatever the document embeds itself — **embedded faces win on
18
+ conflict** — so an empty `fonts` array yields exactly `officeToPdf`'s output
19
+ (no regression). `fonts` uses the same packed blob as `htmlRender`.
20
+
7
21
  ## [0.64.0] - 2026-06-22
8
22
 
9
23
  Office↔PDF fidelity program — import all formats → PDF and export PDF → all
package/dist/index.cjs CHANGED
@@ -281,6 +281,32 @@ var GigaPdfEngine = class _GigaPdfEngine {
281
281
  (p, l) => this._jsonOrNull((o) => this.ex.gp_office_needed_fonts(p, l, o))
282
282
  );
283
283
  }
284
+ /**
285
+ * Phase 2 for {@link officeNeededFonts} — render an Office container to PDF with
286
+ * the host-fetched `fonts` embedded, so families the container **references but
287
+ * doesn't embed** (reported by {@link officeNeededFonts}) lay out with the right
288
+ * metrics (e.g. Carlito for a Calibri reference) instead of drifting onto the
289
+ * bundled fallback. Faces the container embeds itself win on conflict, so an
290
+ * empty `fonts` array yields exactly {@link officeToPdf}'s output. Empty array
291
+ * if the bytes are not a recognized Office container.
292
+ *
293
+ * @example
294
+ * const reqs = giga.officeNeededFonts(docx); // phase 1: what to fetch
295
+ * const fonts = await Promise.all( // host fetches each url → TTF
296
+ * (reqs ?? []).map(async (r) => ({ ...r, ttf: await fetchTtf(r.url) }))
297
+ * );
298
+ * const pdf = giga.officeToPdfWith(docx, fonts); // phase 2: render with them
299
+ */
300
+ officeToPdfWith(office, fonts = []) {
301
+ const blob = packHtmlFonts(fonts);
302
+ return this._withBytes(
303
+ office,
304
+ (op, ol) => this._withBytes(
305
+ blob,
306
+ (fp, fl) => this._buffer((o) => this.ex.gp_office_to_pdf_with_fonts(op, ol, fp, fl, o))
307
+ )
308
+ );
309
+ }
284
310
  /**
285
311
  * Image (PNG/JPEG/GIF/WebP/AVIF) → one-page PDF, format auto-detected: the
286
312
  * image is centred and scaled to fit on an A4 portrait page. PNG/JPEG embed