i want to draw colour underlines to text (ie in a different colour to the text).
I’m using the GlyphArrangement' directly, but these is no way i can find. Also
Graphics’ is const around here…
i want to draw colour underlines to text (ie in a different colour to the text).
I’m using the GlyphArrangement' directly, but these is no way i can find. Also
Graphics’ is const around here…
Not possible as things currently stand! You might be able to hack together your own version of GlyphArrangement::drawGlyphUnderline though?
If it’s just a small piece of text you could first draw the text underlined with your underline color and then another time not underlined with your normal text color.
Could work.
[quote=“gekkie100”]If it’s just a small piece of text you could first draw the text underlined with your underline color and then another time not underlined with your normal text color.
Could work.[/quote]
No - you’d get some nasty anti-aliasing artifacts if you did that.
No problem. i’m quite happy to make my own local changes.
currently, im doing this, which is qute horrible because i const cast away and change the state.
[code]inline void GlyphArrangement::drawGlyphUnderline (const Graphics& g, const PositionedGlyph& pg,
const int i, const AffineTransform& transform, const Colour& ulCol) const
{
…
Path p;
p.addRectangle (pg.x, pg.y + lineThickness * 2.0f, nextX - pg.x, lineThickness);
// XXX HACK
Graphics& gm = const_cast<Graphics&>(g);
gm.saveState();
gm.setColour(ulCol);
g.fillPath (p, transform);
gm.restoreState();
}[/code]
I’ve had to do a saveState' and
restoreState’ here because there is no getColour' on
Graphics’ otherwise i could get the old colour, change it, use it and set it back.
I’m hoping there’s not too much overhead here. is there a better way without too much juce changing. I prefer to keep my juce changes as local as possible.
thanks,
Personally, I’d probably leave the juce code alone, and draw a non-underlined GlyphArrangement, and then write my own external version of drawGlyphUnderline that iterates the glyph arrangement to draw the lines.
thank you!
I hadn’t noticed you can get all the information out of a GlyphArrangement and a `PositionedGlyph’ but you can. This is by far the best way. I’ve reverted my hacks and written my own draw for each glyph.
Also, later on i want to draw different kinds of underlines not just different colours. so this fixes that too.
– hugh.