Migrated this patch from https://git.reviewboard.kde.org/r/125442/ since it had whitespace errors and the submitter disappeared.
- Okular compiles and all tests pass (except for parttest, which was already failing in master)
- Don't have any RTL PDFs or the ability to read or write in any RTL languages, so unable to test the functionality. But on the reviewboard page, folks said it worked, and the diff is the same.