Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt/QML Mangling Text String



  • I'm attempting to display some static text with something like the following pseudo code:

    Import QtQuick 2.5
    Import QtQuick.Window 2.1
    
    Window{
      Text{
        text: "Something Is Not Connected"
      }
    }
    

    It is taking the "No" and converting it to the numero symbol "№", so it reads "Something Is №t Connected". It seems to be a combination of the font being used (Nimbus Sans L) and the Qt version (5.14). If I change either of these the issue goes away.

    Is there something I'm missing, or some way I can explicitly instruct Qt/QML not to mangle the string like this?


  • Lifetime Qt Champion

    Hi,

    Could it be that the o is a similar char but with a different utf8 number ?



  • This was kind of where my head was at, but I'm not sure how to prove this, or work around it. Also seems very odd the exact same code works on any other Font or version of Qt.



  • If there is no work around maybe you can use this:
    https://www.fileformat.info/info/unicode/char/200b/index.htm



  • I'm also using Qt 5.14 and purposely installed the nimbus font to my OS (windows 7) but am unable to reproduce your problem.

    Out of curiosity, if you write your text as all lowercase, does the problem persist?



  • No, it only happens when I use a combination of "No" ... like "Not" .."Nothing".. etc. Curious why it doesn't happen for you. Are you running on Windows 10?



  • @While_e said in Qt/QML Mangling Text String:

    No, it only happens when I use a combination of "No" ... like "Not" .."Nothing".. etc. Curious why it doesn't happen for you. Are you running on Windows 10?

    No, as stated previously, I'm using Windows 7



  • Apologies, read that too quickly.


  • Moderators

    @While_e ok 2 things you can try as well,

    first wrap the text in a translation unit:

    Window{
      Text{
        text: qsTr("Something Is Not Connected")
      }
    }
    

    2nd: Combine your o explicitly

    Window{
      Text{
        text: "Something Is N"+ "\u006F" + "t Connected"
      }
    }
    


  • I've tried both of these any they still fail. The only things that work are either insert a "Zero Width Space" between them, or the cleaner solution.. just remove the numero glyph from the font altogether.

    I was hoping this would be a known issue in some way, but these options will work for now. If I have more time I'll try to either investigate, or get enough info to open a bug report.

    Thank you for all the input.


Log in to reply