bidi

How to get text direction in Android and change layout dynamically according to the direction?

℡╲_俬逩灬. 提交于 2019-11-27 20:39:56
I'm doing some research about feasibility of changing UI dynamically based on direction of a text. Although Google is supporting RTL languages (ref: Native RTL support in Android 4.2 ) but it doesn't cover a situation that application has mix of LTR and RTL contents. Google's solution is right if we have multilingual app and it has different sources of static data (such as menu items) in different languages. However, I didn't find any other document regard how to change layout dynamically based on direction of text content. Following image shows current design of my test app. List comes from

How to draw RTL text (Arabic) onto a Bitmap and have it ordered properly?

…衆ロ難τιáo~ 提交于 2019-11-27 07:13:16
问题 I'm trying to draw Arabic text onto a Bitmap for display: Bitmap img = Bitmap.createBitmap( (int) f+100, 300, Config.RGB_565); Canvas c = new Canvas(); c.setBitmap( img ); mFace = Typeface.createFromAsset(getAssets(),"DejaVuSansCondensed.ttf"); mPaint.setTypeface(mFace); content = "يجري"; content = ArabicUtilities.reshape( content ); System.out.println("Drawing text: " + content); c.drawText(content, 30, 30, mPaint); The ArabicUtilities class is a tool to reshape the unicode text so the

JavaScript: how to check if character is RTL?

爷,独闯天下 提交于 2019-11-27 05:29:39
问题 How can I programmatically check if the browser treats some character as RTL in JavaScript? Maybe creating some transparent DIV and looking at where text is placed? A bit of context. Unicode 5.2 added Avestan alphabet support. So, if the browser has Unicode 5.2 support, it treats characters like U+10B00 as RTL (currently only Firefox does). Otherwise, it treats these characters as LTR, because this is the default. How do I programmatically check this? I'm writing an Avestan input script and I

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

牧云@^-^@ 提交于 2019-11-27 00:33:10
What is a good way to tell whether a string contains text in a Right To Left language. I have found this question which suggests the following approach: public bool IsArabic(string strCompare) { char[] chars = strCompare.ToCharArray(); foreach (char ch in chars) if (ch >= '\u0627' && ch <= '\u0649') return true; return false; } While this may work for Arabic this doesn't seem to cover other RTL languages such as Hebrew. Is there a generic way to know that a particular character belongs to a RTL language? Unicode characters have different properties associated with them. These properties cannot

How to get text direction in Android and change layout dynamically according to the direction?

谁都会走 提交于 2019-11-26 22:54:18
问题 I'm doing some research about feasibility of changing UI dynamically based on direction of a text. Although Google is supporting RTL languages (ref: Native RTL support in Android 4.2) but it doesn't cover a situation that application has mix of LTR and RTL contents. Google's solution is right if we have multilingual app and it has different sources of static data (such as menu items) in different languages. However, I didn't find any other document regard how to change layout dynamically

NameError: global name 'unicode' is not defined - in Python 3

让人想犯罪 __ 提交于 2019-11-26 19:39:32
I am trying to use a Python package called bidi. In a module in this package (algorithm.py) there are some lines that give me error, although it is part of the package. Here are the lines: # utf-8 ? we need unicode if isinstance(unicode_or_str, unicode): text = unicode_or_str decoded = False else: text = unicode_or_str.decode(encoding) decoded = True and here is the error message: Traceback (most recent call last): File "<pyshell#25>", line 1, in <module> bidi_text = get_display(reshaped_text) File "C:\Python33\lib\site-packages\python_bidi-0.3.4-py3.3.egg\bidi\algorithm.py", line 602, in get

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

戏子无情 提交于 2019-11-26 09:25:59
问题 What is a good way to tell whether a string contains text in a Right To Left language. I have found this question which suggests the following approach: public bool IsArabic(string strCompare) { char[] chars = strCompare.ToCharArray(); foreach (char ch in chars) if (ch >= \'\\u0627\' && ch <= \'\\u0649\') return true; return false; } While this may work for Arabic this doesn\'t seem to cover other RTL languages such as Hebrew. Is there a generic way to know that a particular character belongs

NameError: global name &#39;unicode&#39; is not defined - in Python 3

你说的曾经没有我的故事 提交于 2019-11-26 06:19:19
问题 I am trying to use a Python package called bidi. In a module in this package (algorithm.py) there are some lines that give me error, although it is part of the package. Here are the lines: # utf-8 ? we need unicode if isinstance(unicode_or_str, unicode): text = unicode_or_str decoded = False else: text = unicode_or_str.decode(encoding) decoded = True and here is the error message: Traceback (most recent call last): File \"<pyshell#25>\", line 1, in <module> bidi_text = get_display(reshaped