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. [Solved] Problems getting the correct width of BOLD text from QFontMetrics
Forum Updated to NodeBB v4.3 + New Features

[Solved] Problems getting the correct width of BOLD text from QFontMetrics

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.0k Views 1 Watching
  • 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.
  • K Offline
    K Offline
    kenchan
    wrote on last edited by
    #1

    I am using Qt5.2.0 on Windows and Mac OSX 10.9.1 (Mavericks).

    I want to get the width of any given string of Bold text in any given font. I have Tried both QFontMetrics and QFontMetricsF. I have tried set the height of the font in points and pixels.

    I have tried all variation of these functions:

    width()
    boundingRect()
    tightBoundingRect()
    size()

    However they all give a width that is shorter than the actual displayed width of the text when BOLD text or BOLD italic text is used. This works OK for normal text and normal italic text in the fonts I have tried so far.

    I have seen many past posts relating to various problems with the getting the correct width of text but I cannot glean the status of the current version in this respect.

    Like, is it all supposed to be working now???
    Or, has BOLD text just been forgotten in all the bug fixing work over the years???

    Can any on please offer me some advice about this issue.

    My thanks to all who offer help.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you getting errors for every font ? Or only specific ones ? On both platforms ?

      Did you check the "bug report system":http://bugreports.qt-project.org to see if there already something talking about it ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kenchan
        wrote on last edited by
        #3

        Hello again SGaist, thank you for your interest in my post.

        Actually I am working with a legacy application that was originally using the Windows api for text and it does its text thing in a rather complex way.

        I did some tests with a simple app and found that I actually can get a reasonable box using those function. Once one understands the meaning of the various font metrics...

        So my conclusion is now that the legacy app is messing things up somehow.

        I have no time to test this on all fonts but I am very pleased to know that Qt is doing the font stuff right.

        Many thanks to all concerned.

        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