FontOptions Question

Hi,
I’m new to Juce and going through the tutorials. I’m working on the ‘Label Class’ tutorial and see that the Font class is depricated. I’m trying to change the following piece of code from the tutorial

titleLabel.setFont (juce::Font (16.0f, juce::Font::bold));

to FontOptions. I cant use the juce::Font::bold option (depricated). I got stuck at:

titleLabel.setFont (FontOptions(16.0f, juce::Font::bold));

(Just substituting FontOptions for juce::Font)
How do I specify a bold font using FontOptions without using the Font::bold enum? Is there any tutorial or documention (aside from the class reference) which dives into the FontOptions class?

Thank you!

I’m not sure what your issue is. That line of code compiles for me.

Yes. It compiled for me too. The issue is that it uses the depricated Font class and may NOT compile in a future update. How should one create a bold font without using the Font class, and only use the FontOptions class?

The whole Font class is not deprecated - it’s just some of the constructors. I think what you have now is fine!

FontOptions is not a replacement for the Font Class. It’s another class that specifies certain options to be used for the font. As @chrhaase mentioned, it’s just the constructors that now require a FontOptions class to be passed. Also note that these two are equivalent:

titleLabel.setFont (FontOptions(16.0f, juce::Font::bold));
titleLabel.setFont (Font(FontOptions(16.0f, juce::Font::bold)));

because of “implicit conversions”. So what you have now is fine moving forwards in JUCE 8. See also:

Great! thank you all for your replies. I’m sure you’ll all be hearing more from me as I move forward into the other classes. :slight_smile: