Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt fonts don't work right

Qt fonts don't work right

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 808 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mehmetkarlik
    wrote on last edited by mehmetkarlik
    #1

    Code:

    QFont font("Arial",12);
    QString txt = "Yazı";

    qDebug()<<"################";

    QFontMetrics fm(font);
    width = fm.width(txt);
    qDebug()<<"Normal Width: "<<width;

    font.setBold(true);

    QFontMetrics fm2(font);
    width = fm2.width(txt);
    qDebug()<<"Bold Width: "<<width;

    qDebug()<<"################";

    Output:

    ################
    Normal Width: 26
    Bold Width: 25
    ################

    1 Reply Last reply
    0
    • O Offline
      O Offline
      ollarch
      wrote on last edited by
      #2

      Hi,

      Reading QFontMetrics width method:
      "Returns the width in pixels of the first len characters of text."

      Setting a font bold changes the character stroke but not the width of the text.

      M 1 Reply Last reply
      2
      • O ollarch

        Hi,

        Reading QFontMetrics width method:
        "Returns the width in pixels of the first len characters of text."

        Setting a font bold changes the character stroke but not the width of the text.

        M Offline
        M Offline
        mehmetkarlik
        wrote on last edited by
        #3

        @ollarch Please try with word or other programs, you will see word's width is increasing, Qt is decreasing width of words when you do bold style, you can see normal style width is 26 but bold style is 25, I am actually senior C# developer , I am working with Qt 2 years, if you try that in C# or Java (Netbeans or Eclipse), you will see that width is increasing. or you can try that with any text editor. It is bug and Qt team must fix this problem.

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @mehmetkarlik said in Qt fonts don't work right:

          It is bug and Qt team must fix this problem.

          So did you file a bug report about this already? Please post the url here for reference.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          M 1 Reply Last reply
          1
          • O Offline
            O Offline
            ollarch
            wrote on last edited by ollarch
            #5

            Hi,

            Have you tryied using a QPaintDevice in the QFontMetrics constructor? Also you could try QFontMetricsF if you get different result.

            Congrats to be a senior C# developer. We are trying to help you but if you don't want our help don't ask the forum. As an experienced developer you can debug Qt fonts ans see how QFontMetrics does this calculus.

            M 1 Reply Last reply
            0
            • O ollarch

              Hi,

              Have you tryied using a QPaintDevice in the QFontMetrics constructor? Also you could try QFontMetricsF if you get different result.

              Congrats to be a senior C# developer. We are trying to help you but if you don't want our help don't ask the forum. As an experienced developer you can debug Qt fonts ans see how QFontMetrics does this calculus.

              M Offline
              M Offline
              mehmetkarlik
              wrote on last edited by mehmetkarlik
              #6

              @ollarch I am senior at C# not C++ and Qt, firstly read beautifully, after do a comment.

              @ollarch And before give advice please firstly try it, after advice it.

              O 1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                @mehmetkarlik said in Qt fonts don't work right:

                It is bug and Qt team must fix this problem.

                So did you file a bug report about this already? Please post the url here for reference.

                M Offline
                M Offline
                mehmetkarlik
                wrote on last edited by
                #7

                @Christian-Ehrlicher Ok, I created a bug report.

                https://bugreports.qt.io/browse/QTBUG-76908

                1 Reply Last reply
                3
                • M mehmetkarlik

                  @ollarch I am senior at C# not C++ and Qt, firstly read beautifully, after do a comment.

                  @ollarch And before give advice please firstly try it, after advice it.

                  O Offline
                  O Offline
                  ollarch
                  wrote on last edited by
                  #8

                  @mehmetkarlik Ok.

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved