Important: Please read the Qt Code of Conduct -

Strange behavior of underline when scaling text (Windows)

  • Hello.
    I found a strange behavior of underline distance with respect to text base.
    In particular, when drawing with a QPainter a text with setUnderline(true), the distance of the underline with respect to the text base line changes a lot depending on the operating system even when using exactly the same font, and under Windows it also does not scale with the text pixel size, so that for large size it "sticks" to the text base line.
    This happens also when printing, for example during svg export.
    Here is a minimal example (apparently I did not have the permission to directly attach the zip file):
    and attached the images of the output svg files, when running the program with:

    • Windows 10, Qt 5.9.6, MinGW 32bit
    • Linux Mint 18, Qt 5.9.6, gcc 64bit
    • MacOS 13, Qt 5.9.6, clang 64bit
      Is it a (possibly known) bug of Qt, or I am doing something wrong?
      Is there a work-around?

    This is something I found while investigating the cuase of a bug found in MuseScore:

    Thank you for your help.

Log in to reply