diff --git a/public/fonts/Roboto-Regular.ttf b/public/fonts/Roboto-Regular.ttf new file mode 100644 index 00000000..ddf4bfac Binary files /dev/null and b/public/fonts/Roboto-Regular.ttf differ diff --git a/public/fonts/SourceHanSansCN-Regular.otf b/public/fonts/SourceHanSansCN-Regular.otf new file mode 100644 index 00000000..56832dd8 Binary files /dev/null and b/public/fonts/SourceHanSansCN-Regular.otf differ diff --git a/src/components/pdf/MyDocument.tsx b/src/components/pdf/MyDocument.tsx index 4059f984..3c4409a1 100644 --- a/src/components/pdf/MyDocument.tsx +++ b/src/components/pdf/MyDocument.tsx @@ -1,9 +1,17 @@ import React from "react"; import { Document, Page, Text, StyleSheet, Font } from "@react-pdf/renderer"; +import type { I18n } from "next-i18next"; Font.register({ - family: "Roboto", - src: "https://fonts.gstatic.com/s/roboto/v27/KFOmCnqEu92Fr1Mu4mxP.ttf", + family: "Roboto,SourceHanSansCN", + fonts: [ + { + src: "/fonts/SourceHanSansCN-Regular.otf", + }, + { + src: "/fonts/Roboto-Regular.ttf", + }, + ], }); const styles = StyleSheet.create({ @@ -14,7 +22,7 @@ const styles = StyleSheet.create({ }, section: { fontSize: 12, - fontFamily: "Roboto", + fontFamily: "Roboto,SourceHanSansCN", marginBottom: 20, lineHeight: 1.5, }, @@ -24,12 +32,14 @@ interface MyDocumentProps { content: string; } -const MyDocument: React.FC = ({ content }) => ( - - - {content} - - -); +const MyDocument: React.FC = ({ content }) => { + return ( + + + {content} + + + ); +}; export default MyDocument;