mirror of
https://github.com/documenso/documenso.git
synced 2026-07-25 17:35:05 +10:00
perf: upgrade @libpdf/core to 0.3.3 and deduplicate font registration (#2598)
Upgrade @libpdf/core from 0.2.12 to 0.3.3, which includes: - WebCrypto SHA-256 replacing pure-JS @noble/hashes (10x signing speedup) - Iterative collectReachableRefs (fixes stack overflow on large PDFs) - Iterative Math.max helpers in xref writer (fixes remaining stack overflow) Extract duplicated FontLibrary.use() calls from render-certificate, render-audit-logs, and insert-field-in-pdf-v2 into a shared ensureFontLibrary() helper with has() guards so fonts are only registered once per process.
This commit is contained in:
@@ -9,7 +9,6 @@ import { DateTime } from 'luxon';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import type { Canvas } from 'skia-canvas';
|
||||
import { FontLibrary } from 'skia-canvas';
|
||||
import { Image as SkiaImage } from 'skia-canvas';
|
||||
import { UAParser } from 'ua-parser-js';
|
||||
import { renderSVG } from 'uqr';
|
||||
@@ -22,6 +21,7 @@ import {
|
||||
} from '../../constants/recipient-roles';
|
||||
import type { TDocumentAuditLogBaseSchema } from '../../types/document-audit-logs';
|
||||
import { svgToPng } from '../../utils/images/svg-to-png';
|
||||
import { ensureFontLibrary } from './helpers';
|
||||
|
||||
type ColumnWidths = [number, number, number];
|
||||
|
||||
@@ -724,13 +724,7 @@ export async function renderCertificate({
|
||||
pageWidth,
|
||||
pageHeight,
|
||||
}: GenerateCertificateOptions) {
|
||||
const fontPath = path.join(process.cwd(), 'public/fonts');
|
||||
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
FontLibrary.use({
|
||||
['Caveat']: [path.join(fontPath, 'caveat.ttf')],
|
||||
['Inter']: [path.join(fontPath, 'inter-variablefont_opsz,wght.ttf')],
|
||||
});
|
||||
ensureFontLibrary();
|
||||
|
||||
const minimumMargin = 10;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user