diegomura / diegomura/react-pdf
Not Support Burmese Language in unicode
- Dominant language
- TypeScript
- Stars
- 16.8k
- Forks
- 1.3k
- Avg merge
- 5h 6m
- Merged PRs (30d)
- 52
Description
## **Describe the bug**
Myanmar Unicode text is rendered incorrectly in `@react-pdf/renderer` even when using a proper Unicode font such as **Pyidaungsu.ttf**. The same text renders correctly in modern browsers (Chrome, Firefox) and when generating PDFs with Puppeteer.
Interestingly, when the text is encoded in **Zawgyi**, it renders correctly with the same font registration, while Unicode text does not. This suggests that complex text shaping for Myanmar Unicode may not be supported during PDF rendering.
---
## **To Reproduce**
1. Register a Myanmar Unicode font (e.g. `Pyidaungsu.ttf`).
2. Render a `` component containing Myanmar Unicode text.
3. Generate the PDF.
4. Open the generated PDF.
Example:
```tsx
import { Document, Page, Text, Font } from "@react-pdf/renderer";
Font.register({
family: "Pyidaungsu",
src: "/fonts/Pyidaungsu.ttf",
});
export default function MyDocument() {
return (
သီဟိုဠ်မှ ဉာဏ်ကြီးရှင်သည် အာယုဝဍ္ဎနဆေးညွှန်းစာကို ဇလွန်ဈေးဘေး
);
}
```
The same text displays correctly in a browser using the same font but is rendered incorrectly in the generated PDF.
---
## **Expected behavior**
Myanmar Unicode text should render correctly when using a Unicode-compliant font such as `Pyidaungsu.ttf`, just as it does in modern browsers and browser-based PDF generation tools.
Complex scripts such as Myanmar require proper OpenType shaping (glyph substitution and positioning). It appears that this shaping step is either missing or incomplete in the current text rendering pipeline.
---
## **Screenshots**
* Browser rendering (correct)
* Generated PDF rendering (incorrect)
---
## **Desktop**
* **OS:** macOS Tahoe 26.5.2
* **Browser:** Chrome 150
* **@react-pdf/renderer version:** (your version, e.g. 4.5.1)
---
Contributor guide
Research direction
Start by reproducing the supplied @react-pdf/renderer example with Font.register, Pyidaungsu.ttf, and the Myanmar Unicode text, then compare the generated PDF with browser rendering. Trace the Text rendering pipeline and its font-shaping step; done means Myanmar Unicode renders correctly in the generated PDF with the registered Unicode font.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- computer-graphics, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100