Hello everyone,
I’m encountering a peculiar issue with AttributedString
where the last text I append is not drawn under the following conditions:
- Previously appended text is wrapped
- the box I draw in is smaller than the text height (even by just half a pixel).
Here’s the code to reproduce the problem:
void MainComponent::paint (juce::Graphics& g)
{
g.fillAll(juce::Colours::white);
juce::AttributedString attributedString;
attributedString.append("Here's a potentially multiline text (make your window smaller if needed)\n");
attributedString.append("=>> Watch this text disappear <<=");
juce::TextLayout layout;
layout.createLayout(attributedString, getWidth());
attributedString.draw(g, juce::Rectangle<float>(0, 0, getWidth(), layout.getHeight()-0.5));
DBG(layout.getHeight());
}
Is this a bug or a feature? Does it only affect MacOS/iOS (I can’t test it currently on other platforms)?
This issue has caused headings to disappear in my markup display class. I’ll publish a fix for my code soon.