-
Notifications
You must be signed in to change notification settings - Fork 681
Description
Describe the bug
I found a bug in FopGlyphProcessor when rendering Thai language with FOP support enabled. The application crashes with IndexOutOfBoundsException because the processor assumes a 1:1 mapping between characters and glyphs.
To Reproduce
When rendering Thai characters like "ํา" (Sara Am), the FOP shaping engine decomposes one character into two glyphs (Nikkhahit + Lak Khang).
The current loop in FopGlyphProcessor.convertToBytesWithGlyphs iterates based on the glyph count but tries to access the charBuffer using the same index:
for (int i = 0; i < limit; i++) { // ... longTag.put(glyphCode, new int[]{..., charBuffer.get(i)}); // This throws Exception when limit > charBuffer size }
Expected behavior
The processor should handle cases where the number of glyphs is greater than the number of characters by correctly mapping glyphs back to their original source characters using FOP's CharAssociation.
Screenshots
Image Image ImageSystem
OpenPDF version: 3.0.0
FOP version: 2.11
Language: Thai