28

Background

TextView always had issues with RTL (Right-To-Left) languages. Since I know only how to read Hebrew (in addition to English), I will talk about its issues:

  • Text alignment (and I'm not talking about gravity) . As an RTL language, Hebrew puts words from right to left (compared to English which is the opposite).

    For demonstrating how annoying it is, imagine that instead of showing "Hello world." you usually get ".Hello world" . This could be easily fixed if you had it in a single sentence, but it's harder when there are multiple punctuations characters.

  • Vowels positions. Hebrew doesn't require vowels in order to read text, but sometimes it's very hard to read without them (especially the bible). For vowels, Hebrew has what is called "NIKUD", which are actually like dots inside the letters. The problem in Android was that they were usually positioned in the wrong location .

    For demonstrating how annoying it is, imagine that instead of showing "Hello world." you usually get ".eHlol owrld" . Even if you try to fix it (put the vowels always one character after the current one), the position in the letter wasn't correct (imagine that the "e" in "Hello" would be like above the "H", for example) .

Only on version 4.2 (read here, under "Native RTL support") , Google has fixed all of the Hebrew related issues (or at least it seems so).

The problem

the problems with Hebrew has caused each Israeli carrier and each custom ROM maker have its own solution of how to fix the different issues, which makes it practically impossible to handle RTL text on pre 4.2 devices.

Things can get even more frustrating in case the text include both Hebrew and English letters.

What I've tried

I've read many websites talking about those problems, and I've tried many variants of the solutions, none has solved the problem on all devices:

The question

Is there a definite solution for this problem?

I would assume the best thing is that because Android 4.2 solves this, and Android is open source, we should have its TextView imported into a library that we can use, but Google hasn't provided such a library yet.

4

2 に答える 2

13

残念ながら、良い解決策はないと思います (「良い」とは、「仕事をこなし、すぐに利用できる」という意味です)。ヘブライ語をサポートする独自の Android アプリでは、長年にわたって開発したカスタム レンダリング メカニズムを使用しています。レンダリング メカニズムはすべてを行います。双方向 (双方向) 分析; グリフの配置; 改行分析; テキストの流れ; ネイティブの Android テキスト処理機能 (特に 4.2 より前) を使用しようとすると、次のような問題が発生します。

  1. 本当にくだらないフォント。ただし、非常に優れたDejaVuなどのサードパーティのフォントをパッケージ化することはできます。適切なフォントは、必要に応じて nekudot と te'amim 1の配置に驚くべき効果を発揮します。(正しいポインティングの配置がいかに重要であるかについては、あなたの意見に同意します。ヘブライ語のテキストを間違って配置された nekudot で読むことは、画面いっぱいのCAPTCHAを読むようなものです。)

  2. バギー入札分析。さらに悪いことに、バグは Android のバージョンごとに異なるようです。戦略的に配置された双方向書式設定コード (RTL マーク、LTR マークなど) を含むようにテキストを変更すると、これらのバグの多くを克服できます (ここでの議論を参照してください。これは Android に固有のものではありません)。ただし、これを行うのは面倒です。また、Android のバージョン間で一貫性がないため、フレームワークがどのような支援を必要とするかを事前に予測することは困難です。

  3. 右から左への問題に対するフレームワーク レベルの認識がない (またはよく考えられていない)。たとえば、ヘブライ語の TextView の左側にスクロール バーが表示されるように頑張ってください。私たちのアプリでは、スクロール バー システム全体を構築して、これを希望どおりに機能させる必要がありました。(Android はオープン ソースだと思います!)

  4. 行と単語の区切りの分析が不十分です。私たちがテストした Android の初期バージョンの少なくとも 1 つは、各 nikud マークが単語の境界であると考えていました。改行に関しては、多くの場合、システムは maqaf、gershayim、sof pasuk などのヘブライ語の句読点の処理方法を認識していません。

  5. 新しい Unicode 文字の一部 (HOLAM HASER FOR VAV—U+05BA—Unicode 5.0 の新機能) は、システムによってヘブライ文字として認識されません。

私が推奨するのは、完全なテキスト処理システムを自分で構築する準備ができていない限り、特に nekudot と te'amim をサポートする必要がある場合は、4.2 より前のバージョンの Android での高品質のテキスト表示をあきらめることです。 . また、上記の最初の 2 つのポイントで説明した手法を使用することを計画してください。

1聖書のカンティレーション マーク

于 2013-04-03T19:51:35.707 に答える
2

2013 年 8 月の時点で、Android はユーザーのニーズに合った双方向フォーマッターの API ドキュメントを公開しています。これは Android Support v4 ライブラリに含まれており、Android 4.2 より前のバージョンで動作するはずです。

参照: http://developer.android.com/reference/android/support/v4/text/BidiFormatter.html

于 2013-08-09T22:37:35.103 に答える