[PR #284] [CLOSED] add cyrilic and other fonts via roboto-mono #297

Closed
opened 2026-06-06 22:10:06 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/vxcontrol/pentagi/pull/284
Author: @vchaplygim
Created: 4/23/2026
Status: Closed

Base: mainHead: fix/pdf-cyrillic-fonts


📝 Commits (1)

  • fa4a04d add cyrilic and other fonts via roboto-mono

📊 Changes

9 files changed (+26 additions, -4 deletions)

View changed files

frontend/public/fonts/Inter-Bold.ttf (+0 -0)
frontend/public/fonts/Inter-BoldItalic.ttf (+0 -0)
frontend/public/fonts/Inter-Italic.ttf (+0 -0)
frontend/public/fonts/Inter-Regular.ttf (+0 -0)
frontend/public/fonts/RobotoMono-Bold.ttf (+0 -0)
frontend/public/fonts/RobotoMono-BoldItalic.ttf (+0 -0)
frontend/public/fonts/RobotoMono-Italic.ttf (+0 -0)
frontend/public/fonts/RobotoMono-Regular.ttf (+0 -0)
📝 frontend/src/lib/report-pdf.tsx (+26 -4)

📄 Description

Description of the Change

Problem

PDF reports render Cyrillic (and other non-Latin) characters as mojibake. The report-pdf.tsx used built-in PDF fonts (Helvetica for body text, Courier for code blocks), which use WinAnsiEncoding — a 256-character encoding that cannot represent Cyrillic. Code points above U+00FF get truncated to charCode & 0xFF, mapping Cyrillic characters to ASCII (e.g., "пентест" → "?5=B5AB").

The repository already contained Inter and Roboto Mono fonts (woff2 format) with their licenses, but they were never wired up in the PDF renderer.

Solution

  • Added TTF variants of Inter and Roboto Mono — required because @react-pdf/renderer uses fontkit internally which does not support woff2 in browser environments
  • Updated report-pdf.tsx to register these fonts using full absolute URLs (window.location.origin + path), which is necessary because the is-url library used internally by @react-pdf/font rejects relative paths and silently falls back to Helvetica
  • Both TTF fonts include Cyrillic Unicode coverage with Identity-H encoding

The woff2 files and license files already present in the repository are unchanged.

Closes #

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)

Areas Affected

  • Core Services (Frontend UI/Backend API)

Testing and Verification

Test Configuration

PentAGI Version: latest
Docker Version: 27.x
Host OS: Ubuntu 24.04
LLM Provider: any
Enabled Features: none required

Test Steps

  1. Create a flow/task that produces a report with Cyrillic (Russian) text
  2. Open the report and click "Download PDF"
  3. Open the downloaded PDF

Test Results

Before fix: Cyrillic characters rendered as mojibake (e.g., "?5=B5AB" instead of "пентест")
After fix: Cyrillic characters render correctly in all text elements (headings, paragraphs, code blocks)

Security Considerations

No security implications. Font files are served as static assets from the same origin.

Performance Impact

Font files are fetched once and cached by the browser. Total additional asset size: ~1.7MB (4× Inter TTF + 4× Roboto Mono TTF).

Documentation Updates

  • README.md updates
  • API documentation updates
  • Configuration documentation updates
  • GraphQL schema updates
  • Other: none required

Deployment Notes

No special deployment steps required. Font files are included in the Docker image under the frontend static assets directory.

Checklist

Code Quality

  • My code follows the project's coding standards
  • I have added/updated necessary documentation
  • I have added tests to cover my changes
  • All new and existing tests pass
  • I have run npm run lint (for TypeScript/JavaScript code)

Security

  • I have considered security implications
  • Changes maintain or improve the security model
  • Sensitive information has been properly handled

Compatibility

  • Changes are backward compatible
  • Breaking changes are clearly marked and documented
  • Dependencies are properly updated

Documentation

  • Documentation is clear and complete
  • Comments are added for non-obvious code
  • API changes are documented

Additional Notes

Font licenses are already present in frontend/public/fonts/:

  • Inter: SIL Open Font License 1.1 (OFL.txt)
  • Roboto Mono: Apache License 2.0 (LICENSE-Apache-2.0.txt)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/vxcontrol/pentagi/pull/284 **Author:** [@vchaplygim](https://github.com/vchaplygim) **Created:** 4/23/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/pdf-cyrillic-fonts` --- ### 📝 Commits (1) - [`fa4a04d`](https://github.com/vxcontrol/pentagi/commit/fa4a04d57a07d0a21c7ca077572743d418079701) add cyrilic and other fonts via roboto-mono ### 📊 Changes **9 files changed** (+26 additions, -4 deletions) <details> <summary>View changed files</summary> ➕ `frontend/public/fonts/Inter-Bold.ttf` (+0 -0) ➕ `frontend/public/fonts/Inter-BoldItalic.ttf` (+0 -0) ➕ `frontend/public/fonts/Inter-Italic.ttf` (+0 -0) ➕ `frontend/public/fonts/Inter-Regular.ttf` (+0 -0) ➕ `frontend/public/fonts/RobotoMono-Bold.ttf` (+0 -0) ➕ `frontend/public/fonts/RobotoMono-BoldItalic.ttf` (+0 -0) ➕ `frontend/public/fonts/RobotoMono-Italic.ttf` (+0 -0) ➕ `frontend/public/fonts/RobotoMono-Regular.ttf` (+0 -0) 📝 `frontend/src/lib/report-pdf.tsx` (+26 -4) </details> ### 📄 Description ### Description of the Change #### Problem PDF reports render Cyrillic (and other non-Latin) characters as mojibake. The `report-pdf.tsx` used built-in PDF fonts (Helvetica for body text, Courier for code blocks), which use WinAnsiEncoding — a 256-character encoding that cannot represent Cyrillic. Code points above U+00FF get truncated to `charCode & 0xFF`, mapping Cyrillic characters to ASCII (e.g., "пентест" → "?5=B5AB"). The repository already contained Inter and Roboto Mono fonts (woff2 format) with their licenses, but they were never wired up in the PDF renderer. #### Solution - Added TTF variants of Inter and Roboto Mono — required because `@react-pdf/renderer` uses `fontkit` internally which does not support woff2 in browser environments - Updated `report-pdf.tsx` to register these fonts using full absolute URLs (`window.location.origin + path`), which is necessary because the `is-url` library used internally by `@react-pdf/font` rejects relative paths and silently falls back to Helvetica - Both TTF fonts include Cyrillic Unicode coverage with Identity-H encoding The woff2 files and license files already present in the repository are unchanged. Closes # ### Type of Change - [x] 🐛 Bug fix (non-breaking change which fixes an issue) ### Areas Affected - [x] Core Services (Frontend UI/Backend API) ### Testing and Verification #### Test Configuration PentAGI Version: latest Docker Version: 27.x Host OS: Ubuntu 24.04 LLM Provider: any Enabled Features: none required #### Test Steps 1. Create a flow/task that produces a report with Cyrillic (Russian) text 2. Open the report and click "Download PDF" 3. Open the downloaded PDF #### Test Results Before fix: Cyrillic characters rendered as mojibake (e.g., "?5=B5AB" instead of "пентест") After fix: Cyrillic characters render correctly in all text elements (headings, paragraphs, code blocks) ### Security Considerations No security implications. Font files are served as static assets from the same origin. ### Performance Impact Font files are fetched once and cached by the browser. Total additional asset size: ~1.7MB (4× Inter TTF + 4× Roboto Mono TTF). ### Documentation Updates - [ ] README.md updates - [ ] API documentation updates - [ ] Configuration documentation updates - [ ] GraphQL schema updates - [ ] Other: none required ### Deployment Notes No special deployment steps required. Font files are included in the Docker image under the frontend static assets directory. ### Checklist #### Code Quality - [x] My code follows the project's coding standards - [x] I have added/updated necessary documentation - [ ] I have added tests to cover my changes - [x] All new and existing tests pass - [x] I have run npm run lint (for TypeScript/JavaScript code) #### Security - [x] I have considered security implications - [x] Changes maintain or improve the security model - [x] Sensitive information has been properly handled #### Compatibility - [x] Changes are backward compatible - [ ] Breaking changes are clearly marked and documented - [x] Dependencies are properly updated #### Documentation - [x] Documentation is clear and complete - [x] Comments are added for non-obvious code - [x] API changes are documented ### Additional Notes Font licenses are already present in `frontend/public/fonts/`: - Inter: SIL Open Font License 1.1 (`OFL.txt`) - Roboto Mono: Apache License 2.0 (`LICENSE-Apache-2.0.txt`) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-06 22:10:06 -04:00
yindo closed this issue 2026-06-06 22:10:06 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vxcontrol/pentagi#297