Skip to content

Fully autonomous AI Agents system capable of performing complex penetration testing tasks

feat: add Noto Sans font family for enhanced PDF report generation

Dmitry Ng93aae130157e
diff --git a/frontend/public/fonts/NotoSans-Bold.ttf b/frontend/public/fonts/NotoSans-Bold.ttf
new file mode 100644
index 00000000..27131f8f
Binary files /dev/null and b/frontend/public/fonts/NotoSans-Bold.ttf differ
diff --git a/frontend/public/fonts/NotoSans-BoldItalic.ttf b/frontend/public/fonts/NotoSans-BoldItalic.ttf
new file mode 100644
index 00000000..1c06d9a8
Binary files /dev/null and b/frontend/public/fonts/NotoSans-BoldItalic.ttf differ
diff --git a/frontend/public/fonts/NotoSans-Italic.ttf b/frontend/public/fonts/NotoSans-Italic.ttf
new file mode 100644
index 00000000..c7c67b28
Binary files /dev/null and b/frontend/public/fonts/NotoSans-Italic.ttf differ
diff --git a/frontend/public/fonts/NotoSans-Regular.ttf b/frontend/public/fonts/NotoSans-Regular.ttf
new file mode 100644
index 00000000..d5522095
Binary files /dev/null and b/frontend/public/fonts/NotoSans-Regular.ttf differ
diff --git a/frontend/public/fonts/NotoSansMono-Bold.ttf b/frontend/public/fonts/NotoSansMono-Bold.ttf
new file mode 100644
index 00000000..612de028
Binary files /dev/null and b/frontend/public/fonts/NotoSansMono-Bold.ttf differ
diff --git a/frontend/public/fonts/NotoSansMono-Regular.ttf b/frontend/public/fonts/NotoSansMono-Regular.ttf
new file mode 100644
index 00000000..541efd80
Binary files /dev/null and b/frontend/public/fonts/NotoSansMono-Regular.ttf differ
diff --git a/frontend/public/fonts/NotoSansSC-Bold.otf b/frontend/public/fonts/NotoSansSC-Bold.otf
new file mode 100644
index 00000000..bcc11bc3
Binary files /dev/null and b/frontend/public/fonts/NotoSansSC-Bold.otf differ
diff --git a/frontend/public/fonts/NotoSansSC-Regular.otf b/frontend/public/fonts/NotoSansSC-Regular.otf
new file mode 100644
index 00000000..fc0fda93
Binary files /dev/null and b/frontend/public/fonts/NotoSansSC-Regular.otf differ
diff --git a/frontend/public/fonts/README.md b/frontend/public/fonts/README.md
index 962b2301..1fa9ae32 100644
--- a/frontend/public/fonts/README.md
+++ b/frontend/public/fonts/README.md
@@ -1,15 +1,54 @@
# Fonts
-This directory contains web fonts used in the PentAGI frontend application.
+
+This directory contains fonts used by the PentAGI frontend application, including web UI and PDF report generation.
+
## Inter
+
- **Files**: `inter-*.woff2` (8 files)
- **License**: SIL Open Font License 1.1
- **License File**: [OFL.txt](./OFL.txt)
- **Source**: https://github.com/rsms/inter
- **Copyright**: Copyright (c) 2016 The Inter Project Authors
+- **Usage**: Main UI font for the web application.
+
## Roboto Mono
+
- **Files**: `roboto-mono-*.woff2` (8 files)
- **License**: Apache License 2.0
- **License File**: [LICENSE-Apache-2.0.txt](./LICENSE-Apache-2.0.txt)
- **Source**: https://github.com/google/roboto
- **Copyright**: Google Inc.
-Both fonts are open source and freely redistributable under their respective licenses.
+- **Usage**: Monospace font for code display in the web UI.
+
+## Noto Sans
+
+- **Files**: `NotoSans-Regular.ttf`, `NotoSans-Bold.ttf`, `NotoSans-Italic.ttf`, `NotoSans-BoldItalic.ttf`
+- **License**: SIL Open Font License 1.1
+- **License File**: [OFL.txt](./OFL.txt)
+- **Source**: https://github.com/googlefonts/noto-fonts
+- **Copyright**: Copyright 2022 The Noto Project Authors
+- **Usage**: Main body font in PDF reports. Covers Latin, Cyrillic, Greek, Devanagari, Vietnamese, and many other scripts.
+
+## Noto Sans Mono
+
+- **Files**: `NotoSansMono-Regular.ttf`, `NotoSansMono-Bold.ttf`
+- **License**: SIL Open Font License 1.1
+- **License File**: [OFL.txt](./OFL.txt)
+- **Source**: https://github.com/googlefonts/noto-fonts
+- **Copyright**: Copyright 2022 The Noto Project Authors
+- **Usage**: Monospace font for code blocks in PDF reports. Covers Latin and Cyrillic.
+
+## Noto Sans SC (Simplified Chinese)
+
+- **Files**: `NotoSansSC-Regular.otf`, `NotoSansSC-Bold.otf`
+- **License**: SIL Open Font License 1.1
+- **License File**: [OFL.txt](./OFL.txt)
+- **Source**: https://github.com/notofonts/noto-cjk
+- **Copyright**: Copyright 2014-2021 Adobe Systems Incorporated
+- **Usage**: CJK font for Chinese, Japanese, and Korean characters in PDF reports. Loaded on demand when CJK text is detected.
+
+## Notes
+
+All fonts are open source and freely redistributable under their respective licenses (SIL OFL 1.1 and
+Apache 2.0), both compatible with the MIT license of the PentAGI product. Fonts are served from the
+same origin as the application and never loaded from external servers.
diff --git a/frontend/src/lib/report-pdf.tsx b/frontend/src/lib/report-pdf.tsx
index fb9ac9f8..d66de790 100644
--- a/frontend/src/lib/report-pdf.tsx
+++ b/frontend/src/lib/report-pdf.tsx
@@ -1,8 +1,76 @@
-import { Document, Page, pdf, StyleSheet, Text, View } from '@react-pdf/renderer';
+import { Document, Font, Page, pdf, StyleSheet, Text, View } from '@react-pdf/renderer';
import { marked } from 'marked';
import { Log } from './log';
+// Register Noto Sans (covers Latin + Cyrillic + Greek + many other scripts)
+Font.register({
+ family: 'NotoSans',
+ fonts: [
+ { fontStyle: 'normal', fontWeight: 'normal', src: '/fonts/NotoSans-Regular.ttf' },
+ { fontStyle: 'normal', fontWeight: 'bold', src: '/fonts/NotoSans-Bold.ttf' },
+ { fontStyle: 'italic', fontWeight: 'normal', src: '/fonts/NotoSans-Italic.ttf' },
+ { fontStyle: 'italic', fontWeight: 'bold', src: '/fonts/NotoSans-BoldItalic.ttf' },
+ ],
+});
+
+// Register Noto Sans Mono (covers Latin + Cyrillic for code blocks)
+Font.register({
+ family: 'NotoSansMono',
+ fonts: [
+ { fontStyle: 'normal', fontWeight: 'normal', src: '/fonts/NotoSansMono-Regular.ttf' },
+ { fontStyle: 'normal', fontWeight: 'bold', src: '/fonts/NotoSansMono-Bold.ttf' },
+ ],
+});
+
+// Register Noto Sans SC (Simplified Chinese, covers CJK + Latin)
+Font.register({
+ family: 'NotoSansSC',
+ fonts: [
+ { fontStyle: 'normal', fontWeight: 'normal', src: '/fonts/NotoSansSC-Regular.otf' },
+ { fontStyle: 'normal', fontWeight: 'bold', src: '/fonts/NotoSansSC-Bold.otf' },
+ ],
+});
+
+// Disable word hyphenation (breaks CJK and Cyrillic incorrectly)
+Font.registerHyphenationCallback((word) => [word]);
+
+// Regex that matches any CJK unified ideographs or CJK punctuation/fullwidth chars
+const CJK_RE = /[\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF\u3000-\u303F\uFF01-\uFF60\uFFE0-\uFFE6]+/g;
+
+interface TextSegment {
+ isCJK: boolean;
+ text: string;
+}
+
+/**
+ * Splits a string into alternating non-CJK and CJK segments so each segment
+ * can be rendered with the appropriate font family.
+ */
+const splitByCJK = (text: string): TextSegment[] => {
+ const segments: TextSegment[] = [];
+ let lastIndex = 0;
+
+ CJK_RE.lastIndex = 0;
+
+ let match: null | RegExpExecArray;
+
+ while ((match = CJK_RE.exec(text)) !== null) {
+ if (match.index > lastIndex) {
+ segments.push({ isCJK: false, text: text.slice(lastIndex, match.index) });
+ }
+
+ segments.push({ isCJK: true, text: match[0] });
+ lastIndex = match.index + match[0].length;
+ }
+
+ if (lastIndex < text.length) {
+ segments.push({ isCJK: false, text: text.slice(lastIndex) });
+ }
+
+ return segments.length > 0 ? segments : [{ isCJK: false, text }];
+};
+
// PDF styles for @react-pdf/renderer - Enhanced beautiful styles
const pdfStyles = StyleSheet.create({
bold: {
@@ -10,7 +78,7 @@ const pdfStyles = StyleSheet.create({
},
code: {
color: '#dc2626',
- fontFamily: 'Courier',
+ fontFamily: 'NotoSansMono',
fontSize: 9,
fontWeight: 'bold',
},
@@ -20,7 +88,7 @@ const pdfStyles = StyleSheet.create({
borderRadius: 4,
borderWidth: 1,
color: '#e2e8f0',
- fontFamily: 'Courier',
+ fontFamily: 'NotoSansMono',
fontSize: 8.5,
lineHeight: 1.4,
marginBottom: 8,
@@ -112,7 +180,7 @@ const pdfStyles = StyleSheet.create({
page: {
backgroundColor: '#ffffff',
color: '#334155',
- fontFamily: 'Helvetica',
+ fontFamily: 'NotoSans',
fontSize: 10,
lineHeight: 1.5,
padding: 40,
@@ -330,6 +398,46 @@ const parseMarkdownTokens = (markdown: string): ParsedContent[] => {
return result;
};
+// Render a raw text string, splitting CJK segments to switch font family
+const renderTextWithCJK = (
+ text: string,
+ baseFamily: string,
+ boldFamily: string,
+ keyPrefix: string,
+ bold = false,
+ italic = false,
+) => {
+ const segments = splitByCJK(text);
+
+ if (segments.length === 1 && !segments[0]?.isCJK) {
+ // Fast path: no CJK — return plain string so the parent Text handles it
+ return text;
+ }
+
+ return segments.map((seg, idx) => {
+ const family = seg.isCJK ? (bold ? 'NotoSansSC' : 'NotoSansSC') : bold ? boldFamily : baseFamily;
+ // CJK fonts have no true italic; skip italic for CJK segments
+ const style: Record<string, string> = { fontFamily: family };
+
+ if (bold && !seg.isCJK) {
+ style.fontWeight = 'bold';
+ }
+
+ if (italic && !seg.isCJK) {
+ style.fontStyle = 'italic';
+ }
+
+ return (
+ <Text
+ key={`${keyPrefix}-cjk-${idx}`}
+ style={style}
+ >
+ {seg.text}
+ </Text>
+ );
+ });
+};
+
// Helper function to render inline tokens with formatting
const renderInlineTokens = (tokens: InlineToken[], keyPrefix: string) => {
return tokens.map((token, idx) => {
@@ -354,20 +462,40 @@ const renderInlineTokens = (tokens: InlineToken[], keyPrefix: string) => {
appliedStyles.push(pdfStyles.link);
}
- // If we have any styles, wrap in Text component
+ // If we have any styles, wrap in Text component with CJK-aware rendering
if (appliedStyles.length > 0) {
+ const isBold = !!token.bold;
+ const isItalic = !!token.italic;
+ const isCode = !!token.code;
+ const rendered = isCode
+ ? textContent
+ : renderTextWithCJK(
+ textContent,
+ 'NotoSans',
+ 'NotoSans',
+ `${keyPrefix}-inline-${idx}`,
+ isBold,
+ isItalic,
+ );
+
return (
<Text
key={`${keyPrefix}-inline-${idx}`}
style={appliedStyles}
>
- {textContent}
+ {rendered}
</Text>
);
}
- // Return plain text without wrapper
- return textContent;
+ // Plain text: render with CJK-aware font split (returns string if no CJK)
+ const rendered = renderTextWithCJK(textContent, 'NotoSans', 'NotoSans', `${keyPrefix}-inline-${idx}`);
+
+ if (typeof rendered === 'string') {
+ return rendered;
+ }
+
+ return <Text key={`${keyPrefix}-inline-${idx}`}>{rendered}</Text>;
});
};