I have a juce::AttributedString
string that I want to draw on screen, JUCE 6.0.1. The string makes use of a single font but mixes different font weights, bold (with boldened()
) and normal specifically:
auto typeface = juce::Typeface::createSystemTypefaceFor (BinaryData::RobotoRegular_ttf, BinaryData::RobotoRegular_ttfSize);
const juce::Font font = juce::Font (typeface).withHeight (32.0f);
juce::AttributedString text;
text.append ("BOLDENED", font.boldened(), juce::Colours::white);
text.append (" NORMAL", font, juce::Colours::white);
text.setJustification (juce::Justification::centred);
text.draw (g, getBounds().toFloat());
The snipped above produces weird and inconsistent text depending on the OS and the font in use. For example, with Roboto:
Linux:
Windows:
macOS:
Linux renders the bold effect as a weird off-centered italic; Windows gets it almost right, macOS shows no bold at all.
Different fonts yield different results, so I suspect it could be a glitch in the font I’m using. However I would expect a “consistently wrong” behavior…