Matplotlib: Writing right-to-left text (Hebrew, Arabic, etc.)

For Arabic you need both bidi.algorithm.get_display and arabic_reshaper modules: from bidi.algorithm import get_display import matplotlib.pyplot as plt import arabic_reshaper reshaped_text = arabic_reshaper.reshape(u’لغةٌ عربيّة’) artext = get_display(reshaped_text) plt.text(0.25, 0.45, artext , name=”Times New Roman”,fontsize=50) plt.show()

Parsing through Arabic / RTL text from left to right

As your string currently stands, the word لطيفة is stored prior to the word اليوم; the fact that اليوم is displayed “first” (that is, further to the left), is just a (correct) result of the Unicode Bidirectional Algorithm in displaying the text. That is: the string you start with (“Test:لطيفة;اليوم;a;b”) is the result of the … Read more

Right-to-Left and Left-to-Right printed nicely

Put a Right-to-Left Embedding character, u’\u202B’, at the beginning of each Hebrew word, and a Pop Directional Formatting character, u’\u202C’, at the end of each word. This will set the Hebrew words apart as RTL sections in an otherwise LTR document. (Note that while this will produce the correct output, you’re also dependent on the … Read more

How to detect whether a character belongs to a Right To Left language?

Unicode characters have different properties associated with them. These properties cannot be derived from the code point; you need a table that tells you if a character has a certain property or not. You are interested in characters with bidirectional property “R” or “AL” (RandALCat). A RandALCat character is a character with unambiguously right-to-left directionality. … Read more

How to make the text direction from right to left

Another clever way which can be used in older versions of android and can be used anywhere in string so it’s handier even in latest version of android, is to include the right-to-left mark or even left-to-right mark in the string when it’s needed: left-to-right mark: ‎ or ‎ (U+200E) right-to-left mark: ‏ or ‏ … Read more

How to handle RTL languages on pre 4.2 versions of Android?

Sadly, I don’t think there’s a good solution (“good” meaning “does the job and is readily available”). For our own Android apps that support Hebrew, we use a custom rendering mechanism that we developed over many years. The rendering mechanism does everything: proprietary fonts; bidirectional (bidi) analysis; glyph placement; line break analysis; text flow; etc. … Read more