We are using QT 5.9.1 build, QMinimal plugin, with fontconfig support for fonts. From what I know the same QFontDatabase is used for XCB plugin, so it can be reproduced with it as well.
In the application we would like to draw text, which consists of multiple languages, for example, Chinese and English. This text can be underlined.
What we discovered - that when we have a string that contains both chinese and english - underline is rendered incorrectly.
1. Ensure you have at least two fonts set up in the system - one is to render latin characters, and one is to render Chinese. For example, we are using "Noto Sans" as primary font. It doesn't support Chinese characters, so we use "PingFang" as fallback. If you run this fontconfig command, you will find which ones are fallback for your primary font:
fc-match -s "Noto Sans"
See screenshot  for output.
2. Please use following code snippet to reproduce it:
3. Observe that 2 underlines are rendered. Looks like those underlines should be rendered for 2 substrings - LOGO and #\u611B\u5FC3. But it seems like offset is wrong. I'm also not sure if width of those underlines is correct.
Please see screenshot  to check how it looks.
Alternative way to repro
The issue happens when you use QTextLayout, and apply underline formatting there.
We found a very hacky workaround, based on the code here:
When text formatting has an outline, then underline is rendered in the different code branch. So by adding transparent outline:
we were able to fix the problem, because in this branch of code underline is rendered correctly.