Bug: Incorrect Hindi (Devanagari) text shaping/rendering (Short 'i' matra issue)
Before you submit
- I have searched existing issues
- I spent at least 5 minutes investigating and preparing this report
- I confirmed this is not caused by a network issue
- I have fully read and understood the README
- I am certain that this issue is with BabelDOC itself and can be reproduced through the BabelDOC cli
- I have uploaded the original file, or confirmed that this issue is unrelated to the original file
- I have uploaded the log.
- I confirm that the latest version of BabelDOC is being used.
- I am aware that the issue section of this project is only for submitting bugs that are clearly related to the BabelDOC core, with complete reproduction steps and relevant logs attached.** Otherwise, issues will be closed directly.
Environment
- OS:
- Python:
- BabelDOC:Describe the bug
Hi team,
I am using pdf2zh-next, which relies on BabelDOC for PDF generation, and I noticed a critical rendering bug with Hindi (Devanagari script) translations.
Expected Behavior
Hindi requires Complex Text Layout (CTL). For example, the short 'i' matra (ि) must visually render before the consonant it modifies. The word should look like this: विचार
Actual Behavior
The text is being drawn in its raw logical sequence without shaping. The matra is appearing after the consonant. It renders incorrectly like this: वचिार (and similar issues happen with words like मित्र -> मत्रि).
Steps to Reproduce
- Translate an English PDF to Hindi using BabelDOC as the backend.
- Check the generated bilingual/mono PDF output. Words with the short 'i' matra (and other complex conjuncts) are visually broken.
Suggested Cause
It seems the text shaping engine (e.g., uharfbuzz) is either not being applied to Indic scripts, or PyMuPDF is inserting the raw text strings without proper OpenType GSUB/GPOS table processing for the fallback font.
Screenshots
Steps to Reproduce
- Go to '...'
- Click on '...'
- See error
Expected Behavior
No response
Relevant Log Output or Screenshots
Original PDF File
No response
Additional Context
No response
Source: funstory-ai/BabelDOC