diegomura / diegomura/react-pdf
Custom font (Niramit) with some specific patterns of character unexpectedly creates mailto links in PDF text
- Dominant language
- TypeScript
- Stars
- 16.8k
- Forks
- 1.3k
- Avg merge
- 5h 6m
- Merged PRs (30d)
- 52
Description
**Describe the bug**
When using a registered custom font (Niramit) in `@react-pdf/renderer`, certain text strings such as `"Deposit 11111"`, `"o@pist."`, or `"ที่ 6"` become clickable mailto links in the generated PDF. Selecting and copying these strings also yields incorrect text (for example, `mailto:lr@dn.600000`), even though no link or mailto was defined.
**Reproduction**
Register the Niramit font and apply it to a `` style:
```ts
import React from 'react';
import { Document, Page, Text, Font, PDFDownloadLink } from '@react-pdf/renderer';
// Register the font
Font.register({
family: 'Niramit',
fonts: [
{
src: 'https://fonts.gstatic.com/s/niramit/v10/I_uuMpWdvgLdNxVLbbRQkiCvs5Y.ttf',
fontWeight: 400,
},
],
});
// Create Document Component
const MyDocument = () => (
ที่ 6
o@pist.
Deposit 11111
);
// App Component
const PDFGenerator = () => (
} fileName="document.pdf">
{({ loading }) => loading ? 'Loading document...' : 'Download PDF'}
);
export default PDFGenerator;
```
Open or download the PDF. Hover or click on the text "Deposit " - it behaves like a mailto link.
Copying and pasting the text results in strings like lr@dn.6 or i@ts.6, depending on surrounding characters.
**Expected behavior**
All text should render as normal, non-clickable text and copy-paste exactly as written.
**Screenshots**


[deposit_receipt - 2025-04-06T044900.096.pdf](https://github.com/user-attachments/files/19618584/deposit_receipt.-.2025-04-06T044900.096.pdf)
- Clicking on "Deposit" causes it to open a mail client using something like mailto:i@ts.6.
**Desktop (please complete the following information):**
OS: Windows 10
Browser: Chrome
"@react-pdf/renderer": "^3.1.14"
PDF Viewer: both Chrome’s built-in viewer and Adobe Acrobat XI
**Additional context**
This issue disappears when Font.register is removed or when any of the problematic characters are slightly altered. I was able to isolate the bug to very minimal inputs. From my testing, only the Niramit font triggers this behavior - likely due to how the text is embedded and interpreted in the final PDF when certain character patterns (e.g., word + number or email-like strings) are present.
Contributor guide
Assessment
This issue has not been assessed yet.