I’m having trouble finding out the simplest solution just by searching. Are there built-in fonts to choose from or do I need to always provide a font file?
Thanks!
I’m having trouble finding out the simplest solution just by searching. Are there built-in fonts to choose from or do I need to always provide a font file?
Thanks!
By default you can use any fonts that the system provides. If you need to know that list at runtime you can acquire the names using something like juce::Font::findAllTypefaceNames()
.
As for “changing the font of text” it kind of depends on the source of the text. If you’re drawing the text manually, you can set juce::Graphics::setFont()
.
If it’s text in a juce::Label
or similar you’d have to find the relevant way for changing the component’s font (e.g. juce::Label::setFont()
for labels, making a LookAndFeel
and overriding juce::ComboBox::LookAndFeel::getComboBoxFont()
, etc.)
You can also embed a font in your Binary Data and load it in as part of a LookAndFeel class.
You can add to your assets a font (in your binary) and use it in your LookAndFeel
Font myLookAndFeel::getBaseFont()
{
return Font(Typeface::createSystemTypefaceFor(BinaryData::MontserratLight_otf,
BinaryData::MontserratLight_otfSize));
}