From ba30e0dbaf08d27a8353ffa33876600f3948bc54 Mon Sep 17 00:00:00 2001 From: Bastien Chanot Date: Mon, 18 May 2026 21:44:25 +0200 Subject: [PATCH] feat(pdf): embed Helvetica + Times-Roman standard fonts (MVP) --- src/pdf/fonts.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/pdf/fonts.ts b/src/pdf/fonts.ts index 10b8628c..b6465872 100644 --- a/src/pdf/fonts.ts +++ b/src/pdf/fonts.ts @@ -1,4 +1,4 @@ -import type { PDFDocument, PDFFont } from 'pdf-lib' +import { PDFDocument, StandardFonts, type PDFFont } from 'pdf-lib' export interface EmbeddedFonts { bodyRegular: PDFFont @@ -6,13 +6,11 @@ export interface EmbeddedFonts { headingRegular: PDFFont } -/** - * Embeds Inter (body) and Fraunces (headings) into the PDF document. - * Font files are fetched from /fonts/ in the public directory. - * Both fonts must be TTF (pdf-lib does not support woff2 directly). - */ -export async function embedFonts( - _pdfDoc: PDFDocument, -): Promise { - throw new Error('not implemented') +export async function embedFonts(pdfDoc: PDFDocument): Promise { + const [bodyRegular, bodyBold, headingRegular] = await Promise.all([ + pdfDoc.embedFont(StandardFonts.Helvetica), + pdfDoc.embedFont(StandardFonts.HelveticaBold), + pdfDoc.embedFont(StandardFonts.TimesRoman), + ]) + return { bodyRegular, bodyBold, headingRegular } }