在 Android 中使用 OpenType 字体支持复杂的文本布局 [英] Supporting complex text layout with OpenType fonts in Android

查看:34
本文介绍了在 Android 中使用 OpenType 字体支持复杂的文本布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的资产文件夹中放置一个 OpenType 字体,并使用 Typeface.createFromAsset 在我的 Android 应用程序中为使用 复杂文本布局 (CTL).

I would like to put an OpenType font in my assets folder and use Typeface.createFromAsset to render Unicode text in my Android application for a language that uses complex text layout (CTL).

我想为传统蒙古文字执行此操作,但这是同一个问题(所以我听说)其他语言,如泰语、阿拉伯语、印度语和许多少数民族语言.OpenType 字体 已经包含正确显示文本所需的信息.问题是并非所有软件都支持 OpenType 渲染.有些可以,但有些不行.据我所知,Android 不习惯,但现在可能吗?

I want to do this for traditional Mongolian script, but it is the same issue (so I hear) for other languages like Thai, Arabic, Indic languages, and many minority languages. An OpenType font already includes the information necessary to properly display the text. The problem is that not all software supports OpenType rendering. Some do, but others don't. From what I can gather, Android didn't used to, but maybe now does?

Android Lollipop 现已推出.Android 是否支持 OpenType 字体?

Android Lollipop is out now. Is there any support for OpenType fonts in Android?

如果仍然没有什么容易的,那么过程是什么?我听说过 Pango 和 Harfbuzz 之类的东西(声称适用于 Android)但我还没有找到任何关于如何实现它们的简单说明或教程.我发现的最接近的是 Indic text renderer,但它是远不容易理解.

If there is still nothing easy, then what is the process? I have heard of things like Pango and Harfbuzz (which claims to work with Android) but I haven't found any simple instructions or tutorials for how to implement them. The closest thing I have found is an Indic text renderer, but it is far from easy to understand.

这些问题表明大家对这个话题很感兴趣,但在我看来,这些问题并没有得到令人满意的回答.其中一些也已经过时.我想知道是否有当前的解决方案.

These questions show that there is interest in this topic, but in my opinion they haven't been satisfactorily answered. Some of them are also outdated. I want to know if there is a current solution.

我编写了自己的渲染引擎来显示传统的蒙古文 Unicode 文本.但是,如果已经有可用的 OpenType 字体,则为特定语言编写渲染引擎就是在重新发明轮子.此外,它不容易适应其他语言.

I have written my own rendering engine to display traditional Mongolian Unicode text. But writing a rendering engine for a specific language is reinventing the wheel if there are already OpenType fonts available. Also, it is not easily adaptable to other languages.

推荐答案

如果你想使用 Harfbuzz 来做到这一点,我已经写了一个使用 Harfbuzz 实现文本整形器的简单指南:http://www.simon-cozens.org/content/duffers-guide-fontconfig-and-harfbuzz

If you want to use Harfbuzz to do this, I have written a simple guide to implementing a text shaper using Harfbuzz: http://www.simon-cozens.org/content/duffers-guide-fontconfig-and-harfbuzz

这应该让您从字体选择到知道应该使用哪些字形以及将它们放在输出中的什么位置.

That should get you from font selection to knowing which glyphs should be used and where to put them in the output.

这篇关于在 Android 中使用 OpenType 字体支持复杂的文本布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆