Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bidi behavior inconsistent; possibility to enable/disable bidi in termux settings? #296

Open
zelhar opened this issue Apr 6, 2017 · 7 comments

Comments

@zelhar
Copy link

zelhar commented Apr 6, 2017

In termux the bidi functionality seems to depend on which font is chosen from the termux style. for example when selecting gnu free font Hebrew is displayed right-to-left (although with bugs when typing or editing it), while when chosing default font or inconsolata font bidi is disabled and the text is displayed ltr.

The bidi support in any terminal is not perfect and sometime it is desirable to simply disable it. some of the linux consoles like Konsol and gnome terminal allow the user to choose whether to enable or disable bidi support, is that possible to be done in termux as well?

I think it would be useful to be able to completely disable bidi in termux because that thing never behaves in a predictable way and especially when editing and inserting text I find it easier to just work ltr.

@fornwall
Copy link
Member

fornwall commented Apr 6, 2017

Termux already sets android:supportsRtl="false" in the AndroidManifest.xml, I'm not sure how to disable bidi functionality when using the GNU FreeFont (if possible).

Would really appreciate help from anyone more knowledgeable with bidirectional text on Android here.

@zelhar
Copy link
Author

zelhar commented Apr 7, 2017

perhaps it needs to be included in the manifest of termux-styling as well? namely in that file:
https://github.com/termux/termux-styling/blob/master/app/src/main/AndroidManifest.xml

@alsho-alsho
Copy link

I don't believe that this is a bug. This is a must-have feature for showing correctly texts in persian or arabic. If one wants to cat a file in persian or edit it in nano, it is absolutely necessary.
Please do not disable this feature. For someone like me it is vital.

@zelhar
Copy link
Author

zelhar commented Sep 10, 2017

does anyone know or can refer me to a source that show how does the font system in termux work?

@zelhar
Copy link
Author

zelhar commented Sep 20, 2017

From the tests I've made it seems that the reason why Termux behaves differently with different fonts depends on whether or not the font contains the right-to-left charset. Because Gnu FreeFont contains Hebrew, Arabic, Hindi and so forth right to left charsets, Termux displays them right to left, but when the cursor is on a line with such scripts it gets completely messed up.

When I use a font without Hebrew glyphs, Termux displays everything left-to-right. The Hebrew letters to my understanding, are displayed from whatever supplamental font is defined by the OS, which I think is NotoSansHeb or something, and it looks terrible on the screen. However in programs with built-in bidi support, namely emacs, the bidi support works (except for the font looking terrible) when the fonts with the missing hebrew script is used. when Liberation mono or freefont is used, the text still gets all messed up in emacs.

@zelhar
Copy link
Author

zelhar commented Sep 20, 2017

@fornwall I think that I have an idea of what might be going on in the code. in "TerminalRenderer.java" there is an object "mTextPaint" which to my understanding reders the text on the screen. I think that the method "setTextDirection" should be set to 'anyRtl' (=2):
mTextPaint.setTextDirection(2) or to disable rtl completely in case this doesn't work set the value to 'ltr'.

for reference:
https://developer.android.com/reference/android/view/View.html#attr_android:textDirection
https://developer.android.com/reference/android/view/View.html#setTextDirection(int)

@fornwall
Copy link
Member

@zelhar Hm, mTextPaint is an instance of the android.graphics.Paint class, so doesn't have a setTextDirection method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants