diff --git a/package.json b/package.json index 7a29ac5f..34648821 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,9 @@ "pnpm": { "patchedDependencies": { "react-pdf-html@2.0.4": "patches/react-pdf-html@2.0.4.patch" + }, + "overrides": { + "restructure": "3.0.0" } } } diff --git a/packages/backend/public/fonts/Marianne-Bold.ttf b/packages/backend/public/fonts/Marianne-Bold.ttf new file mode 100644 index 00000000..725bae98 Binary files /dev/null and b/packages/backend/public/fonts/Marianne-Bold.ttf differ diff --git a/packages/backend/public/fonts/Marianne-BoldItalic.ttf b/packages/backend/public/fonts/Marianne-BoldItalic.ttf new file mode 100644 index 00000000..51524cdb Binary files /dev/null and b/packages/backend/public/fonts/Marianne-BoldItalic.ttf differ diff --git a/packages/backend/public/fonts/Marianne-Regular.ttf b/packages/backend/public/fonts/Marianne-Regular.ttf new file mode 100644 index 00000000..7cdda3a1 Binary files /dev/null and b/packages/backend/public/fonts/Marianne-Regular.ttf differ diff --git a/packages/backend/public/fonts/Marianne-RegularItalic.ttf b/packages/backend/public/fonts/Marianne-RegularItalic.ttf new file mode 100644 index 00000000..80575683 Binary files /dev/null and b/packages/backend/public/fonts/Marianne-RegularItalic.ttf differ diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index 168a9784..77773cb9 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -5,6 +5,9 @@ import { ENV } from "./envVars"; import { generateOpenApi, initFastify } from "./router"; import { makeDebug } from "./features/debug"; import { initClauseV2 } from "./tmp"; +import { initFonts } from "@cr-vif/pdf"; + +initFonts("./public/"); const debug = makeDebug("index"); diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 096a14db..485a10f1 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -33,7 +33,7 @@ "@mui/material": "^5.15.15", "@prisma/client": "^4.8.1", "@rawwee/react-pdf-html": "^1.0.2", - "@react-pdf/renderer": "^3.4.2", + "@react-pdf/renderer": "^4.0.0", "@tanstack/react-query": "^4.18.0", "@tanstack/react-router": "^1.22.2", "@tanstack/router-devtools": "^1.22.2", diff --git a/packages/frontend/public/fonts/Marianne-Bold.ttf b/packages/frontend/public/fonts/Marianne-Bold.ttf new file mode 100644 index 00000000..725bae98 Binary files /dev/null and b/packages/frontend/public/fonts/Marianne-Bold.ttf differ diff --git a/packages/frontend/public/fonts/Marianne-BoldItalic.ttf b/packages/frontend/public/fonts/Marianne-BoldItalic.ttf new file mode 100644 index 00000000..51524cdb Binary files /dev/null and b/packages/frontend/public/fonts/Marianne-BoldItalic.ttf differ diff --git a/packages/frontend/public/fonts/Marianne-Regular.ttf b/packages/frontend/public/fonts/Marianne-Regular.ttf new file mode 100644 index 00000000..7cdda3a1 Binary files /dev/null and b/packages/frontend/public/fonts/Marianne-Regular.ttf differ diff --git a/packages/frontend/public/fonts/Marianne-RegularItalic.ttf b/packages/frontend/public/fonts/Marianne-RegularItalic.ttf new file mode 100644 index 00000000..80575683 Binary files /dev/null and b/packages/frontend/public/fonts/Marianne-RegularItalic.ttf differ diff --git a/packages/frontend/src/contexts/AuthContext.tsx b/packages/frontend/src/contexts/AuthContext.tsx index 0c735f10..ab7e41a9 100644 --- a/packages/frontend/src/contexts/AuthContext.tsx +++ b/packages/frontend/src/contexts/AuthContext.tsx @@ -86,6 +86,7 @@ export const AuthProvider = ({ children }: PropsWithChildren) => { user_id: data!.user!.id, }, }); + await electric.db.picture_lines.sync({}); return true; }, diff --git a/packages/frontend/src/main.tsx b/packages/frontend/src/main.tsx index 3aba228c..1eb9715a 100644 --- a/packages/frontend/src/main.tsx +++ b/packages/frontend/src/main.tsx @@ -8,12 +8,14 @@ import { Link } from "@tanstack/react-router"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { ErrorBoundary } from "react-error-boundary"; import { registerSW } from "virtual:pwa-register"; +import { initFonts } from "@cr-vif/pdf"; if ("serviceWorker" in navigator) { registerSW({}); } startReactDsfr({ defaultColorScheme: "system", Link: Link }); +initFonts(); const queryClient = new QueryClient({ defaultOptions: { diff --git a/packages/pdf/src/report.tsx b/packages/pdf/src/report.tsx index 3fabb9ad..948944f3 100644 --- a/packages/pdf/src/report.tsx +++ b/packages/pdf/src/report.tsx @@ -4,6 +4,30 @@ import React from "react"; import type { Udap, Report, Service_instructeurs, Clause_v2, Pictures } from "@cr-vif/electric-client/frontend"; import { Buffer } from "buffer"; +export const initFonts = (folder: string = "") => { + Font.register({ + family: "Marianne", + fonts: [ + { + src: `${folder}/fonts/Marianne-Regular.ttf`, + fontStyle: "normal", + fontWeight: "normal", + }, + { src: `${folder}/fonts/Marianne-Bold.ttf`, fontStyle: "normal", fontWeight: "bold" }, + { + src: `${folder}/fonts/Marianne-RegularItalic.ttf`, + fontStyle: "italic", + fontWeight: "normal", + }, + { + src: `${folder}/fonts/Marianne-BoldItalic.ttf`, + fontStyle: "italic", + fontWeight: "bold", + }, + ], + }); +}; + Font.registerHyphenationCallback((word) => { return [word]; }); @@ -33,31 +57,15 @@ export const ReportPDFDocument = ({ udap, htmlString, images, pictures }: Report