Ok so I have found a solution by overriding the getFont() functions in LookAndFeel to return a Font with a custom font name. Then in my default LookAndFeel getTypefaceForFont() override I have an if statement that tests the name of which font to use. A bit hacky but it seems to work:
class Tab1LookAndFeel : public LookAndFeel_V4
{
public:
Font getLabelFont(Label &label) override;
Font getTextButtonFont (TextButton&, int buttonHeight) override;
}
Font Tab1LookAndFeel::getLabelFont(Label &label)
{
return Font (“Tab1Font”, label.getFont().getHeight(), Font::plain);
}
Font Tab1LookAndFeel::getTextButtonFont (TextButton&, int buttonHeight)
{
return Font (“Tab1Font”, jmin (15.0f, buttonHeight * 0.5f), Font::plain);
}
class DefaultLookAndFeel : public LookAndFeel_V4
{
public:
virtual Typeface::Ptr getTypefaceForFont (const Font&) override;
private:
Typeface::Ptr tab1Tf;
Typeface::Ptr defaulTf;
}
DefaultLookAndFeel::DefaultLookAndFeel()
{
tab1Tf = Typeface::createSystemTypefaceFor(BinaryData::tabfont_ttf,
BinaryData::tabfont_ttfSize);
defaultTf = Typeface::createSystemTypefaceFor(BinaryData::defaultfont_ttf,
BinaryData:: defaultfont_ttfSize);
}
Typeface::Ptr DefaultLookAndFeel::getTypefaceForFont (const Font& font)
{
if (font.getTypefaceName() == “Tab1Font”)
{
return tab1Tf;
}
else
{
return defaultTf;
}
}
Does anybody know why the font used is always the default LookAndFeel’s font and not the current one?