I'm trying on Windows XP with the last version of JUCE to write some text which is both bold and italic, but I have not found any way to make it work. I get plain text instead each time. Nevertheless, when I choose only the Font::bold, or the Font::italic attribute, they are considered and I get the expected result. I have tried several things like that :
// Everything here is working fine
void paint(Graphics &g)
{
g.setFont (Font("Arial", 12, Font::bold));
g.drawSingleLineText ("Sample Text", 0, 0);
g.setFont (Font("Arial", 12, Font::italic));
g.drawSingleLineText ("Sample Text", 0, 0);
g.setFont (Font("Arial", 12, Font::plain).withTypefaceStyle("Bold"));
g.drawSingleLineText ("Sample Text", 0, 0);
g.setFont (Font("Arial", 12, Font::plain).withTypefaceStyle("Italic"));
g.drawSingleLineText ("Sample Text", 0, 0);
}
// Everything here is not working as expected and rendered plain
void paint(Graphics &g)
{
g.setFont (Font("Arial", 12, Font::bold + Font::italic));
g.drawSingleLineText ("Sample Text", 0, 0);
g.setFont (Font("Arial", 12, Font::plain).withTypefaceStyle("Bold Italic"));
g.drawSingleLineText ("Sample Text", 0, 0);
}
Any idea ? Am I doing something wrong, of is there something wrong with Juce ?
I have just seen in the Juce Demo that the style "Bold Italic" exists for Arial and that the bug is there too. I can display Arial Bold, Arial Italic, but I can't display Arial Bold Italic.
And... I have the same problem with all the other fonts I have on my computer :(
In this case it probably works anyway, because Font::Bold (1) + Font::Italic (2) == 3, which is the same result if you had to OR (1 | 2 == 3) them.. but any other constant it wouldn't necessarily work.
All that those “bold” and “italic” flags do is make it look for fonts whose style contains the word “bold” or “italic”. Unless you have a font that contains both those keywords, then it won’t find it.
Fonts should be referred to by the name of their style instead - that’s much more reliable, as typefaces have all kinds of style names.