Is it possible that AttributedString ignores fonts being underlined and just draws it without the underline?
It is quite possible, I don't know offhand..
Well, I just checked it in the Demo solution.
This code produces no underlined font:
Font font (fonts [rowNumber]); font.setUnderline(true); //Added this line AttributedString s; s.setWordWrap (AttributedString::none); s.setJustification (Justification::centredLeft); s.append (font.getTypefaceName(), font.withPointHeight (height * 0.7f), Colours::black); s.append (" " + font.getTypefaceName(), Font (height * 0.5f, Font::italic), Colours::grey); s.draw (g, Rectangle<int> (width, height).expanded (-4, 50).toFloat());
Is this the intended behaviour for AttributedString?
No, it's not the intended behaviour, but the AttributedString does rely on OS functions to do that layout, and to tell it which font to use, and OS typefaces don't preserve the underline flag. Not sure how I could fix that without a lot of effort.
Any alternatives you recommend? Or just use Graphics::drawText?
That would certainly work. TextLayout/GlyphArrangement may also work.
I am having the same issue with underlining, however I am using a textlayout for this. Any clues on how to underline a range of text would be greatly appreciated.
Using the data after a createlayout I can get the glyph positions and just use this to "draw" an underline. If there is a more elegant solution I am all ears.