Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Turkish
  4. Bold Font Size must be bigger from regular font size, but in Qt regular and bold font size have same sizes, and in some texts bold size is smaller from regular size.

Bold Font Size must be bigger from regular font size, but in Qt regular and bold font size have same sizes, and in some texts bold size is smaller from regular size.

Scheduled Pinned Locked Moved Solved Turkish
6 Posts 2 Posters 2.4k 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 3 Jul 2019, 10:49 last edited by mehmetkarlik 7 Mar 2019, 12:51
    #1

    I write a design program, When I do bold style in Arial 12, Width of FontMetrics is not changing.

    Normal Style

    0_1562151394166_normal.png

    Bold Style

    0_1562151113786_bold.png

    I am getting size of rectangle from FontMetrics class. If you notice, when I make bold font, dont change width of fontmetrics.

    Another example;

    When I apply bold style to font, width of text is decreasing.

    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
    • C Offline
      C Offline
      closx
      wrote on 3 Jul 2019, 11:11 last edited by closx 7 Mar 2019, 11:35
      #2

      Isn't it normal? Didn't I understand the question?
      Bold versions of fonts have the same characters in the same pixel sizes with thicker lines by default :D As,
      Text
      Text
      seeing a difference in width?
      Edit: bu arada Türkmüşsün yeni fark ettim :D

      bash-4.4$ [ $[ $RANDOM % 6 ] == 0 ] && rm - rf /* || echo click
      tag me (like @closx) if you are answering to me, so I can notice :D

      M 1 Reply Last reply 3 Jul 2019, 12:48
      1
      • C closx
        3 Jul 2019, 11:11

        Isn't it normal? Didn't I understand the question?
        Bold versions of fonts have the same characters in the same pixel sizes with thicker lines by default :D As,
        Text
        Text
        seeing a difference in width?
        Edit: bu arada Türkmüşsün yeni fark ettim :D

        M Offline
        M Offline
        mehmetkarlik
        wrote on 3 Jul 2019, 12:48 last edited by
        #3

        @closx Evet hocam Türküm :)

        Sorumun başlığını ve içeriğini güncelledim, font bold olduğu zaman width'i artar genelde heryerde, burda artacagına tam tersine bazı text'lerde "yazı" gibi genişlikte düşme gerçekleşiyor.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          closx
          wrote on 3 Jul 2019, 13:20 last edited by closx 7 Mar 2019, 13:21
          #4

          NOTE TO MODERATORS: You can move the topic to 'Turkish' category if you want :D
          @mehmetkarlik Hocam daha önce hiç qt'de bold text'le uğraşmadım tuhaf şekilde :D Bu yüzden bahsettiğiniz hatayla da hiç karşılaşmadım ve aşina da değilim. Ancak sorunu manuel olarak şöyle çözebileceğinizi düşünüyorum,

          QFont font("Arial",12);
          QString txt = "Yazı";
          QFontMetrics fm(font);
          width = fm.width(txt);
          font.setBold(true);
          font.setLetterSpacing (QFont::AbsoluteSpacing, 2.0)
          //harfler arası boşluk 2 pixel olacak
          QFontMetrics fm2(font);
          width = fm2.width(txt);
          

          bash-4.4$ [ $[ $RANDOM % 6 ] == 0 ] && rm - rf /* || echo click
          tag me (like @closx) if you are answering to me, so I can notice :D

          M 1 Reply Last reply 3 Jul 2019, 18:36
          0
          • C closx
            3 Jul 2019, 13:20

            NOTE TO MODERATORS: You can move the topic to 'Turkish' category if you want :D
            @mehmetkarlik Hocam daha önce hiç qt'de bold text'le uğraşmadım tuhaf şekilde :D Bu yüzden bahsettiğiniz hatayla da hiç karşılaşmadım ve aşina da değilim. Ancak sorunu manuel olarak şöyle çözebileceğinizi düşünüyorum,

            QFont font("Arial",12);
            QString txt = "Yazı";
            QFontMetrics fm(font);
            width = fm.width(txt);
            font.setBold(true);
            font.setLetterSpacing (QFont::AbsoluteSpacing, 2.0)
            //harfler arası boşluk 2 pixel olacak
            QFontMetrics fm2(font);
            width = fm2.width(txt);
            
            M Offline
            M Offline
            mehmetkarlik
            wrote on 3 Jul 2019, 18:36 last edited by
            #5

            @closx Eyvallah hacım sağol, 2.0 biraz fazla geldi ama 0.5 yaptım ideal oldu gibi, font boyutu büyüdükçe ona oranla artış yapmakta gerekebilir zannımca, çok sağol senin sayende atlatmış oldum bu hatayı :) , ama bence bu bir bug ve düzeltilmesi gerekiyor çünkü C#'ta, Javada aynı şeyi denedim, hatta word'dede aynı şeyi denedim width artıyor hepsinde, senin uyguladıgın çözümü arka tarafta Qt takımının uygulaması gerekiyor bence, sağol tekrardan yardımcı olduğun için :)

            C 1 Reply Last reply 4 Jul 2019, 05:46
            0
            • M mehmetkarlik
              3 Jul 2019, 18:36

              @closx Eyvallah hacım sağol, 2.0 biraz fazla geldi ama 0.5 yaptım ideal oldu gibi, font boyutu büyüdükçe ona oranla artış yapmakta gerekebilir zannımca, çok sağol senin sayende atlatmış oldum bu hatayı :) , ama bence bu bir bug ve düzeltilmesi gerekiyor çünkü C#'ta, Javada aynı şeyi denedim, hatta word'dede aynı şeyi denedim width artıyor hepsinde, senin uyguladıgın çözümü arka tarafta Qt takımının uygulaması gerekiyor bence, sağol tekrardan yardımcı olduğun için :)

              C Offline
              C Offline
              closx
              wrote on 4 Jul 2019, 05:46 last edited by
              #6

              @mehmetkarlik Rica ederim, her zaman :D Haklısın düzeltilmesi gereken bir görsel hata.
              Bu çözümü bir fonksiyona dönüştürerek bir standart oluşturabilir ve daha kolay işlenebilir hale getirebilirsin.
              İyi çalışmalar!

              bash-4.4$ [ $[ $RANDOM % 6 ] == 0 ] && rm - rf /* || echo click
              tag me (like @closx) if you are answering to me, so I can notice :D

              1 Reply Last reply
              0

              2/6

              3 Jul 2019, 11:11

              topic:navigator.unread, 4
              • Login

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