Ligature problem


When rendering "Configuration", the fi is rendered as a ligature, which makes it look like a mess. Anyway to disable this ?



I guess it's CoreText that's substituting the ligature.. Not sure what could or should be done about that, but you could avoid CoreText and use the old layout functionality with GlyphArrangement instead?


CoreText ? That's iOS right ? The problem is related to Android...



Ah sorry, didn't notice the forum. Well, the android text layout classes then. Either way, the juce text stuff relies on the OS to take a string and produce a glyph layout from it, and that's what creates any ligatures. Not sure how you'd tell it not to!


Yes, quite. But I think I understand what the problem is, and it must be a bug in Paint.getTextWidths (Android). An "fi" ligature is a specific glyph in a typeface, and I would've expected that Roboto (which has this glyph) would return that glyph instead of the glyphs for "f" and i", but that is not what happens.

What I think happens is that Paint.getTextWidths sees "fi", finds the glyph and it's width, but ends up giving "f" the width of "fi", and still returning "f" + "i". That would explain the odd look of texts with "fi" in it...



Hmm, that's odd.

Is this actually a bug in the android SDK..? It vaguely rings a bell, I might have heard it mentioned before..


Yes, I've seen it mentioned too. Anyway, I resolved it by using FontForge to remove the fi ligature from the font, and using the font as an asset in the APK (via the code I sent you), and then I'm good.


I've been wondering about this fi rendering issue!  Any chance you might share the code you use to add the font as an asset, and perhaps even the modified Roboto?


Well I hope that once Jules has some spare time, he can add that code to JUCE :) Anyway, to get the font as an asset is simply by adding an "assets" folder in the Android build folder (where the manifest is). All files in that folder will be exported to the apk file, and will be accessible through the AssetsManager. The code in Java to get the Typeface is simple:

    public final Typeface getTypeFaceFromAsset (String assetName)
        return Typeface.createFromAsset(this.getResources().getAssets(), assetName);

and in juce_android_Fonts.cpp all that is needed is something like:

android.activity.callObjectMethod (JuceAppActivity.getTypeFaceFromAsset, javaString ("fonts/RobotoModified.ttf").get());

The font I use is not Roboto, but a proprietary one, so I cannot share it unfortunately. However, it is very easy to change it yourself: 

1. Download FontForge (

2. Open the font in FF and scroll to unicode 0xFB01 (which is the "fi" ligature)

3. Remove it, then "generate" your new font.



Added the font asset stuff earlier today :)


Thank you, Jules!