18 lines
603 B
TypeScript
18 lines
603 B
TypeScript
import { PDFDocument, StandardFonts, type PDFFont } from 'pdf-lib'
|
|
|
|
/** Helvetica body, Times heading: WinAnsi standard fonts (TTF planned). */
|
|
export interface EmbeddedFonts {
|
|
bodyRegular: PDFFont
|
|
bodyBold: PDFFont
|
|
headingRegular: PDFFont
|
|
}
|
|
|
|
export async function embedFonts(pdfDoc: PDFDocument): Promise<EmbeddedFonts> {
|
|
const [bodyRegular, bodyBold, headingRegular] = await Promise.all([
|
|
pdfDoc.embedFont(StandardFonts.Helvetica),
|
|
pdfDoc.embedFont(StandardFonts.HelveticaBold),
|
|
pdfDoc.embedFont(StandardFonts.TimesRoman),
|
|
])
|
|
return { bodyRegular, bodyBold, headingRegular }
|
|
}
|