Skip to content

Commit

Permalink
feat: add marianne font
Browse files Browse the repository at this point in the history
  • Loading branch information
ledouxm committed Nov 13, 2024
1 parent 26fcfe5 commit a356145
Show file tree
Hide file tree
Showing 15 changed files with 208 additions and 36 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Binary file added packages/backend/public/fonts/Marianne-Bold.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Binary file added packages/frontend/public/fonts/Marianne-Bold.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions packages/frontend/src/contexts/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const AuthProvider = ({ children }: PropsWithChildren) => {
user_id: data!.user!.id,
},
});
await electric.db.picture_lines.sync({});

return true;
},
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
50 changes: 29 additions & 21 deletions packages/pdf/src/report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
});
Expand Down Expand Up @@ -33,31 +57,15 @@ export const ReportPDFDocument = ({ udap, htmlString, images, pictures }: Report
<body>
<style>
body {
font-family: Helvetica;
font-family: Marianne;
}
strong {
font-family: Helvetica-Bold;
font-weight: bold;
}
em {
font-family: Helvetica-Oblique;
}
strong em span {
font-family: Helvetica-BoldOblique;
}
em strong span {
font-family: Helvetica-BoldOblique;
}
strong em {
font-family: Helvetica-BoldOblique;
}
em strong {
font-family: Helvetica-BoldOblique;
font-style: italic;
}
.marianne-img {
Expand Down Expand Up @@ -103,7 +111,7 @@ export const ReportPDFDocument = ({ udap, htmlString, images, pictures }: Report
.right-texts > div {
text-align: right;
font-size: 14px;
font-family: Helvetica-Bold;
font-weight: bold;
}
.meeting-date {
Expand Down
Loading

0 comments on commit a356145

Please sign in to comment.