Adding a typeface

Hi, I’m trying to embed a custom typeface. I have the ttf file, turned it into a binary resource and am using the following call to load it:

auto p_typeface = Typeface::createSystemTypefaceFor( BinaryData::NunitoRegular_ttf, BinaryData::NunitoRegular_ttfSize );

This seems to work and I get a valid ptr and all looks good, but if I then make a call to Font::findAllTypefaceNames() it doesn’t appear. Are there any other steps I need to perform?


I don’t know for sure but I’d guess Font::findAllTypefaceNames() returns a list of typefaces on the system (on windows Control Panel > Appearance and Personalization > Fonts) but not any that are currently held in memory.

findAllTypefaceNames() returns a StringArray so you’d have to add any extra ones manually:

auto tfs = Font::findAllTypefaceNames();
auto myFont = Font(Typeface::createSystemTypefaceFor(...));

// might also want to sort after for UX:

ah, ok. I was only using it to verify that things had loaded correctly - I’m not really bothered about the list.

just that calling setDefaultSansSerifTypefaceName() on my look and feel had no effect.