Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-16793

QTextDocument: Allow to access information about the left bearing of characters

    XMLWordPrintable

Details

    Description

      In libmeegotouch (http://meego.gitorious.org/meegotouch/libmeegotouch) the class MLabel uses QTextDocument internally for rendering rich-texts. No borders are used, hence it is required for having an unclipped text to return a sufficient preferred size-hint.

      But when using e.g. an italic font the methods QTextDocument::size() or QTextDocument::idealWidth() are not sufficient to calculate the preferred size-hint, because the left-bearing of characters like 'f' is not considered by those methods (see attached screenshot, where the red rectangle has the size of QTextDocument::size()).

      Of course it would be possible to manually iterate the QTextFragments and calculate the left-bearing for each line by QFontMetrics::boundingRect(), but this would have a bad impact on the performance and internally QTextDocument could do this more efficient.

      It would be useful if QTextDocument would offer a method like:
      QRectF boundingRect() const;
      where the upper-left from the returned rectangle contains the information about the left-bearing (like in QFontMetrics::boundingRect()) that is required to show all lines without clippling.

      Attached is a small sample application that shows the problem.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            ppenz Peter Penz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes