AlertWindow custom font not working


#1

I’m using a custom LookAndFeel object to have a custom AlertWindow’s font on iOS (so the font is not the standard Helvetica…)

The problem is that the AlertWindow seems to ignore my font setting defaulting to Helvetica.

After some stepping through the AlertWindow and TextLayout code, I discovered that the font setting gets lost when the AlertWindow creates/updates its own textLayout member.

The TextLayout member function below calls createNativeLayout first and defaults to createStandardLayout.
If I comment out the first call like you see here, then the font setting is kept in account.

[code]void TextLayout::createLayout (const AttributedString& text, float maxWidth)
{
lines.clear();
width = maxWidth;
justification = text.getJustification();

// if (! createNativeLayout (text))
createStandardLayout (text);

recalculateWidth();

}
[/code]

Any way to fix createNativeLayout?

Alf


#2

TextLayout can only work with fonts that are in the system font collection. This means that it won’t work with embedded Juce fonts. If you want to use a custom font, you need to add the actual font file (ttf/otf) to the system font collection and then use it normally via AttributedString. It is possible to do this on iOS.