question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Right-to-Left (RTL) support for Hebrew and Arabic

See original GitHub issue

Please add Right-to-Left (RTL) support for languages like Hebrew and Arabic…

Something like:

doc.rtl(true);

doc.text('...', {rtl: true});

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:14
  • Comments:58 (14 by maintainers)

github_iconTop GitHub Comments

9reactions
FlandersBurgercommented, Oct 31, 2019

Simply reversing the text before it goes to pdfkit seems to work for both Hebrew and Arabic (I’m just eyeballing the text however since I speak neither)

const isHebrew = (text) => {
  return text.search(/[\u0590-\u05FF]/) >= 0;
};

const isArabic = (text) => {
  return text.search(/[\u0600-\u06FF]/) >= 0;
};


const rightToLeftText = (text) => {
  if (isHebrew(text) || isArabic(text)) {
    return text.split(' ').reverse().join(' ');
  } else {
    return text;
  }
};

rightToLeftText('أنا أتحدث اللغة العربية');
rightToLeftText('אני מדברת עברית');

8reactions
devongovettcommented, Dec 12, 2019

The only correct implementation will be the Unicode bidi algorithm. Anything else, especially reverse(), will be incorrect.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Right-to-left script - Wikipedia
Arabic, Hebrew, Persian, Pashto, Urdu, Kashmiri and Sindhi are the most widespread R2L writing systems in modern times. The Hebrew language is still...
Read more >
Right-to-Left (RTL) Language Support - Salesforce Help
To make right-to-left (RTL) language users feel more at home, Salesforce supports Arabic and Hebrew as end-user languages and Urdu as a platform...
Read more >
Right-to-left language support and bidirectional text
Bidirectional text occurs when the control hosts both RTL text (such as Arabic or Hebrew) and LTR text within the same string of...
Read more >
Right to left - Foundations - Human Interface Guidelines - Design
Support right-to-left languages like Arabic and Hebrew by reversing your interface as needed to match the reading direction of the related scripts.
Read more >
Use Right-to-left (RTL) text and content - Hebrew and Arabic ...
If you're a Pro user, please contact us at support@strikingly.com or chat with us, and we'll help you install the code on your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found