danfickle / danfickle/openhtmltopdf

Support right-to-left (RTL) text and mixed direction text.

Open
#9 10 comments 0 reactions 0 assignees View on GitHub
java2d-work-needed
Dominant language
Java
Stars
2.2k
Forks
423
PR merge metrics
No merged PRs in 30d

Description

Support RTL text such as Arabic. I've divided this issue up into the following tasks. Note that Bidi and ArabicShaping classes come from ICU4J. The aim is to provide identical output to Chrome browser with dir="auto" set on html element. The implementation uses interfaces with a do nothing implementation by default to avoid a compulsory dependency on ICU4J.
- [x] Split document up into paragraphs. The owner of each text node is said to be the nearest parent block element.
- [x] Split paragraphs up into directional runs with Bidi::setPara, Bidi::countRuns and Bidi::getVisualRun.
- [x] Determine if a line is predominantly RTL and right align it if it is.
- [x] Also if a line is predominantly RTL, lay its children out from right to left instead of left to right.
- [x] Shape text with ArabicShaping::shape. This will turn isolate characters into begin, middle or end forms depending on position in word.
- [x] Reorder text from RTL to LTR so we can output it with the standard showText instead of character by character backwards. This uses Bidi::writeReverse.
- [x] Deshape characters if the shaped versions are missing in the font.
- [x] Use fallback font in case character still doesn't exist in font. For example latin characters, when using an Arabic font.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.