アップデート
結局、縦書きのスクリプトMongolTextView
をゼロから開発することになりました。の一部として利用できますmongol-library
。

以下の解決策の問題点は、ミラー化されたフォント (特に中国語) に含まれていない文字が後方に表示されることです。
古い答え
モンゴル語フォントはすべて、グリフの向きが英語と同じ方向、つまり左から右になるように作られています。これにより、モンゴル語の単語を英語、中国語、またはキリル文字のテキストに追加できます (唯一の問題は、単語が「立っている」のではなく「横になっている」ことです)。
TextView を時計回りに 90 度回転すると垂直になりますが、ラインラップは間違った方向になります (回転後に左から右ではなく右から左になります)。行折り返し方向の問題は、TextView を水平方向に反転またはミラーリングすることで解決できますが、すべてのグリフがミラーリングされます。この最後の問題は、垂直ミラー フォント ( FontForgeなどのオープン ソース ソフトウェアを使用して既存のフォントを編集することで作成できるもの) から始めることで解決できます。次の図は、プロセスを示しています。

回転と反転は、TextView を拡張し、メソッドonDraw()
とonMeasure()
メソッドをオーバーライドすることで実行できます。
public class MongolTextView extends TextView {
private TextPaint textPaint;
// Constructors
public MongolTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public MongolTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public MongolTextView(Context context) {
super(context);
init();
}
// This class requires the mirrored Mongolian font to be in the assets/fonts folder
private void init() {
Typeface tf = Typeface.createFromAsset(getContext().getAssets(),
"fonts/MongolFontMirrored.ttf");
setTypeface(tf);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// swap the height and width
super.onMeasure(heightMeasureSpec, widthMeasureSpec);
setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
}
@Override
protected void onDraw(Canvas canvas) {
textPaint = getPaint();
textPaint.setColor(getCurrentTextColor());
textPaint.drawableState = getDrawableState();
canvas.save();
// flip and rotate the canvas
canvas.translate(getWidth(), 0);
canvas.rotate(90);
canvas.translate(0, getWidth());
canvas.scale(1, -1);
canvas.translate(getCompoundPaddingLeft(), getExtendedPaddingTop());
getLayout().draw(canvas);
canvas.restore();
}
}
xml レイアウトでは、拡張された TextView の完全な名前を使用します。
<com.example.MongolTextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="@string/title_string" />
既知の問題点:
layout_margin
ローテーションをlayout_gravity
意識すればうまくいくがpadding
、gravity
行動がおかしい。そのため、 andを使用して使用wrap_content
しないようにするのが最もうまくいくようです。MongolTextView を FrameLayout に配置し、 と を使用することで、同じ効果を得ることができます。padding
gravity
layout_margin
layout_gravity
- このソリューションは、Unicode テキストのレンダリングを扱いません。非 Unicode テキストを使用する必要があるか (非推奨)、アプリにレンダリング エンジンを含める必要があります。(現時点では、Android は OpenType スマートフォント レンダリングをサポートしていません。これが将来変更されることを願っています。比較すると、iOS は複雑なテキスト レンダリング フォントをサポートしています。) Unicode モンゴル語レンダリング エンジンの例については、このリンクを参照してください。