diff --git a/src/pdf/render/observationPage.ts b/src/pdf/render/observationPage.ts index f579a206..d3b8ef58 100644 --- a/src/pdf/render/observationPage.ts +++ b/src/pdf/render/observationPage.ts @@ -404,7 +404,7 @@ export async function addObservationPage( const value = group .map((f) => { const lbl = locale === 'en' ? f.labelEnSnapshot : f.labelFrSnapshot - return f.requiresVetReferral ? `⚠ ${lbl}` : lbl + return f.requiresVetReferral ? `(!) ${lbl}` : lbl }) .join(' · ') sections.push({ diff --git a/tests/unit/pdf.roundtrip.test.ts b/tests/unit/pdf.roundtrip.test.ts index 3af90664..54341ddc 100644 --- a/tests/unit/pdf.roundtrip.test.ts +++ b/tests/unit/pdf.roundtrip.test.ts @@ -2,6 +2,7 @@ import { describe, it, expect, vi } from 'vitest' import { AFRelationship, PDFDocument } from 'pdf-lib' import { exportReportToPdf } from '@/pdf/export' import { importReportFromPdf, ImportError } from '@/pdf/import' +import { embedFonts } from '@/pdf/fonts' import type { Report } from '@/domain/schema/report' vi.mock('@/pdf/render/svgToPng', () => ({ rasterizeSvg: async () => new Uint8Array([137, 80, 78, 71]) })) @@ -61,6 +62,21 @@ describe('PDF roundtrip', () => { expect(frImported.version).toBe(enImported.version) }) + it('vet-referral marker is encodable by the body font (regression: WinAnsi cannot encode U+26A0)', async () => { + // observationPage prefixes vet-referral leaves with a marker that + // is rendered using the WinAnsi-encoded StandardFonts.Helvetica. + // The previous "⚠ " marker (U+26A0) threw `WinAnsi cannot encode "⚠"` + // the moment the text-height estimator measured the leaf label. + // Guard against re-introducing a non-WinAnsi marker by exercising + // the same path: load the body font and measure a label that + // carries the prefix. + const doc = await PDFDocument.create() + const fonts = await embedFonts(doc) + expect(() => + fonts.bodyRegular.widthOfTextAtSize('(!) Difficulté de déglutition', 10), + ).not.toThrow() + }) + it('rejects a legacy v1 PDF with a version-specific message', async () => { const doc = await PDFDocument.create() doc.addPage()