Unity’s capabilities often hit a bump when it comes to advanced typographic features, particularly its lack of support for OpenType fonts and languages that use ligatures, such as Arabic, Persian or Kannada. This article explores the nature of OpenType, the challenges with ligatures in Unity, and practical solutions to navigate these limitations.
What is OpenType?
OpenType is a font format developed jointly by Adobe and Microsoft, supporting a wide array of languages and typographic features. It allows for advanced typesetting capabilities, including ligatures, alternative characters, and more, within a single font file. These features are crucial for languages like Arabic, where characters change form depending on their position in a word or sentence.
The Challenge with Ligatures in Unity
Unity does not currently support OpenType’s advanced typographic features (And as of today, there are no official plans to add this feature to the engine). This becomes particularly problematic for languages that rely on ligatures—two or more letters combined into a single glyph to form a correct character representation. For example, in Persian, the word “نه” (no) is a combination of the two letters “ن” (Noon) and “ه” (He) forming a single ligature. Without proper ligature support, Persian text appears disjointed and is often unreadable in Unity applications.
Existing Solutions and Developing Our Own
While we await native support from Unity for OpenType and ligatures, there are two main approaches to address this issue:
-
Third-Party Plugins: Several plugins are available on the Unity Asset Store that provide support for OpenType and correct ligature handling. These plugins process the text and render it correctly, offering a straightforward solution albeit sometimes at an additional cost.
-
Creating Custom Fonts and Handling Ligatures Manually:
Example of Manual Handling
Suppose we have an Arabic word “لا” (no) that includes a common ligature. This word includes “ل” (Unicode U+0644) and “ا” (Unicode U+0627). We can handle it as follows:
-
Custom Font Setup: Ensure your custom font has a glyph for the ligature “لا” at a specific Unicode, say U+FEFB.
-
Unity Script Adjustment:
In this script, every occurrence of the Arabic letters “لا” is replaced by the Unicode representation of the custom ligature glyph, ensuring the text renders correctly in Unity. Meaning that everytime we see Unicodes U+0644 and U+0627 in the text, we will replace it by U+FEFB.
Conclusion
While Unity’s lack of native support for OpenType and ligatures presents challenges, particularly for developers working with complex scripts, the community has devised innovative solutions. Whether through third-party tools or custom font handling, these strategies ensure that games and apps can still provide a rich, culturally inclusive user experience. By understanding and implementing these workarounds, you can effectively bridge the gap until Unity offers native support.