TextLayout underlining text not working on macOS

Some of my users have requested a strikethrough text formatting option so I have just added that and while testing I noticed that it works in most components but not in one where I’m using TextLayout to draw the text.

I noticed that in this case the already implemented underlining also isn’t working.
It just doesn’t underline the text when using the TextLayout::createNativeLayout function. It does work with TextLayout::createStandardLayout which is however only used if the native layout fails (which isn’t the case here).

In CoreTextTypeLayout::createLayout and the functions called from there the underline attribute is never accessed. It kinda makes sense as the underline attribute doesn’t change the text layout per se. But as the createLayout function also sets the font to the TextLayout runs, it makes sense that it’s also not drawn when TextLayout::draw is called.

Any ideas how to make TextLayout also draw underlined text and in turn also my added strikethrough option which I’m of course happy to share with the community as a format patch?

Thanks!

Anyone from the JUCE team @ed95 @reuk @t0m?

Does anyone have any insight as to why this isn’t working and if it’s possible to make it work easily? I just rolled back from JUCE 6.0.1 to version 5.4.5 and it’s also not working there.

It looks like font underlining was never added for native CoreText layouts. We’ve added it in 4ddcc7b so underlining should work as expected now.

1 Like