I'm using a custom font in my Android project. For some reason when the text includes the letters IJ
together, it gives me the following glyph:
This appears to be the glyph located at \uE2C5
of the PUA region of the font.
The individual I
and J
glyphs both exist in the font and I can get them to appear if I set the text to I J
.
It's not an OpenType font (I don't think Android even supports OpenType rendering in custom fonts), so there shouldn't be anything like this happening. What is going on here?
The problem is reproducible with the following simple project:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView textView = (TextView) findViewById(R.id.textview);
Typeface tf = Typeface.createFromAsset(this.getAssets(), "MenksoftHawang.ttf");
textView.setTypeface(tf);
textView.setText("IJ");
}
}
The font can be downloaded from here. Put it in the assets folder in the project.
To access Edit view, you can either double click a glyph in Font view, or open a tab with View > Open Tab (Cmd-T). The selected glyphs are then opened in the Edit view, and the Text tool (T) is active.
When you type sample text in fontcloud, you will see it in every font you have uploaded there. Similar to using WordMarkIt for viewing your installed fonts on a computer. Scroll down and choose your glyph, just tap on it to copy, then scroll back up and press to paste.
Scroll through the display of characters until you see the glyph you want to insert. If you selected an OpenType font, you can display a pop‑up menu of alternate glyphs by clicking and holding the glyph box. Double-click the character you want to insert. The character appears at the text insertion point.
There appears to be three solutions to this problem:
You can disable the ligatures programmatically with setFontFeatureSettings
(as suggested here) or setLetterSpacing
(as suggested here). One disadvantage of both of these methods is that they are only available from API 21.
You can use font editing software to fix or delete the ligature errors in the font. See this Q&A for how to do it in FontForge. A potential problem here is that the font copyright owners may not allow third parties to edit their fonts.
Different fonts are often available and that is true in this case. The same company that had the problematic TrueType font in the question also has an OpenType version of that font. The OpenType version does not seem to have the ligature errors. A disadvantage, though, is that it is significantly larger in size, which will make that app download size larger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With