diff --git a/README.md b/README.md index 37cfd5e79..30286eba6 100644 --- a/README.md +++ b/README.md @@ -78,3 +78,19 @@ npm run dev cd backend/ npm run test ``` + + +## Export PDF Language Support +To support multiple languages with special characters we need to register fonts and set the fontFamily (example in ExportContent.tsx) +Download font families tts or otf files from https://fonts.google.com/noto to assets/fonts/ + +Currently can only use a single file at a time, so we can merge multiple using script from https://github.com/notofonts/nototools/blob/main/nototools/merge_fonts.py. + +The current CombinedFont.ttf contains: +* NotoSans-Regular.ttf +* NotoSerifDevanagari-Regular.ttf +* NotoKufiArabic-Regular.ttf +* NotoSansThai-Regular.ttf +* NotoSerifBengali_Condensed-Regular.ttf +* NotoSerifGurmukhi-Regular.ttf +* NotoSansHebrew-Regular.ttf diff --git a/frontend/src/assets/fonts/CombinedFonts.ttf b/frontend/src/assets/fonts/CombinedFonts.ttf new file mode 100644 index 000000000..2382596dd Binary files /dev/null and b/frontend/src/assets/fonts/CombinedFonts.ttf differ diff --git a/frontend/src/assets/fonts/NotoKufiArabic-Regular.ttf b/frontend/src/assets/fonts/NotoKufiArabic-Regular.ttf new file mode 100644 index 000000000..b04620fa0 Binary files /dev/null and b/frontend/src/assets/fonts/NotoKufiArabic-Regular.ttf differ diff --git a/frontend/src/assets/fonts/NotoSans-Regular.ttf b/frontend/src/assets/fonts/NotoSans-Regular.ttf new file mode 100644 index 000000000..a1b8994ed Binary files /dev/null and b/frontend/src/assets/fonts/NotoSans-Regular.ttf differ diff --git a/frontend/src/assets/fonts/NotoSansHebrew-Regular.ttf b/frontend/src/assets/fonts/NotoSansHebrew-Regular.ttf new file mode 100644 index 000000000..ca7a0fdb7 Binary files /dev/null and b/frontend/src/assets/fonts/NotoSansHebrew-Regular.ttf differ diff --git a/frontend/src/assets/fonts/NotoSansKR-Regular.ttf b/frontend/src/assets/fonts/NotoSansKR-Regular.ttf new file mode 100644 index 000000000..1b14d3247 Binary files /dev/null and b/frontend/src/assets/fonts/NotoSansKR-Regular.ttf differ diff --git a/frontend/src/assets/fonts/NotoSansMonoCJKjp-Regular.otf b/frontend/src/assets/fonts/NotoSansMonoCJKjp-Regular.otf new file mode 100644 index 000000000..25927d8cd Binary files /dev/null and b/frontend/src/assets/fonts/NotoSansMonoCJKjp-Regular.otf differ diff --git a/frontend/src/assets/fonts/NotoSansSC-Regular.ttf b/frontend/src/assets/fonts/NotoSansSC-Regular.ttf new file mode 100644 index 000000000..4d4cadb98 Binary files /dev/null and b/frontend/src/assets/fonts/NotoSansSC-Regular.ttf differ diff --git a/frontend/src/assets/fonts/NotoSansThai-Regular.ttf b/frontend/src/assets/fonts/NotoSansThai-Regular.ttf new file mode 100644 index 000000000..a6c4d1c94 Binary files /dev/null and b/frontend/src/assets/fonts/NotoSansThai-Regular.ttf differ diff --git a/frontend/src/assets/fonts/NotoSerifBengali_Condensed-Regular.ttf b/frontend/src/assets/fonts/NotoSerifBengali_Condensed-Regular.ttf new file mode 100644 index 000000000..031986c06 Binary files /dev/null and b/frontend/src/assets/fonts/NotoSerifBengali_Condensed-Regular.ttf differ diff --git a/frontend/src/assets/fonts/NotoSerifDevanagari-Regular.ttf b/frontend/src/assets/fonts/NotoSerifDevanagari-Regular.ttf new file mode 100644 index 000000000..51f876473 Binary files /dev/null and b/frontend/src/assets/fonts/NotoSerifDevanagari-Regular.ttf differ diff --git a/frontend/src/assets/fonts/NotoSerifGurmukhi-Regular.ttf b/frontend/src/assets/fonts/NotoSerifGurmukhi-Regular.ttf new file mode 100644 index 000000000..37e0ed142 Binary files /dev/null and b/frontend/src/assets/fonts/NotoSerifGurmukhi-Regular.ttf differ diff --git a/frontend/src/assets/fonts/NotoSerifJP-Regular.otf b/frontend/src/assets/fonts/NotoSerifJP-Regular.otf new file mode 100644 index 000000000..541a86b62 Binary files /dev/null and b/frontend/src/assets/fonts/NotoSerifJP-Regular.otf differ diff --git a/frontend/src/components/ExportChat/ExportContent.tsx b/frontend/src/components/ExportChat/ExportContent.tsx index 315c45388..61b952254 100644 --- a/frontend/src/components/ExportChat/ExportContent.tsx +++ b/frontend/src/components/ExportChat/ExportContent.tsx @@ -1,13 +1,31 @@ -import { Document, Page, View, Text, StyleSheet } from "@react-pdf/renderer"; +import { + Document, + Page, + View, + Text, + StyleSheet, + Font, +} from "@react-pdf/renderer"; import { ChatMessage } from "../../models/chat"; import { EmailInfo } from "../../models/email"; import ExportChatBox from "./ExportChatBox"; import ExportEmailBox from "./ExportEmailBox"; import { PHASE_NAMES } from "../../models/phase"; +import CombinedFonts from "../../assets/fonts/CombinedFonts.ttf"; +import NotoSerifJP from "../../assets/fonts/NotoSerifJP-Regular.otf"; +import NotoSansSC from "../../assets/fonts/NotoSansSC-Regular.ttf"; + +Font.register({ family: "CombinedFonts", src: CombinedFonts }); + +// chinese and japanese - currently multi lang not supported +Font.register({ family: "NotoSerifJP", src: NotoSerifJP }); +Font.register({ family: "NotoSansSC", src: NotoSansSC }); + const styles = StyleSheet.create({ page: { backgroundColor: "white", + fontFamily: "CombinedFonts", }, pageContent: { flexDirection: "row",