Skip to content

Commit

Permalink
241 support more characters in exported logs (#247)
Browse files Browse the repository at this point in the history
* export for multiple languages

* add readme instructions for adding fonts
  • Loading branch information
heatherlogan-scottlogic authored Sep 11, 2023
1 parent 7b5f5c6 commit e23bd1b
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 1 deletion.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file added frontend/src/assets/fonts/CombinedFonts.ttf
Binary file not shown.
Binary file not shown.
Binary file added frontend/src/assets/fonts/NotoSans-Regular.ttf
Binary file not shown.
Binary file not shown.
Binary file added frontend/src/assets/fonts/NotoSansKR-Regular.ttf
Binary file not shown.
Binary file not shown.
Binary file added frontend/src/assets/fonts/NotoSansSC-Regular.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added frontend/src/assets/fonts/NotoSerifJP-Regular.otf
Binary file not shown.
20 changes: 19 additions & 1 deletion frontend/src/components/ExportChat/ExportContent.tsx
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit e23bd1b

Please sign in to comment.