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

QTextDocumentLayout - add support for the vertical alignment QTextCharFormat::AlignDescent

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P3: Somewhat important
    • 4.8.0
    • 4.7.0
    • GUI: Text handling
    • None
    • ee9455ed2a83084692d969c398ecb91bcd4fc33a

    Description

      This is very handy when inserting text object with QTextObjectInterface so they can be aligned with the descent line (currently they can only be aligned on the baseline or centered)

      patch suggested:

      diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
      index bbe5fd7..4b6008a 100644
      --- a/src/gui/text/qtextdocumentlayout.cpp
      +++ b/src/gui/text/qtextdocumentlayout.cpp
      @@ -2974,6 +2974,10 @@ void QTextDocumentLayout::resizeInlineObject(QTextInlineObject item, int posInDo
           if (f.verticalAlignment() == QTextCharFormat::AlignMiddle) {
               item.setDescent(inlineSize.height() / 2);
               item.setAscent(inlineSize.height() / 2 - 1);
      +    } else if(f.verticalAlignment() == QTextCharFormat::AlignDescent) {
      +          QFontMetricsF fm(f.font());
      +          item.setDescent(fm.descent());
      +          item.setAscent(inlineSize.height() -fm.descent() - 1);
           } else {
               item.setDescent(0);
               item.setAscent(inlineSize.height() - 1);
      diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h
      index a86451c..9cb9786 100644
      --- a/src/gui/text/qtextformat.h
      +++ b/src/gui/text/qtextformat.h
      @@ -373,7 +373,8 @@ public:
               AlignSubScript,
               AlignMiddle,
               AlignTop,
      -        AlignBottom
      +        AlignBottom,
      +        AlignDescent
           };
           enum UnderlineStyle { // keep in sync with Qt::PenStyle!
               NoUnderline,
      
      

      Attachments

        Issue Links

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

          Activity

            People

              esabraha Eskil Abrahamsen Blomfeldt
              sanonymous Nokia Qt Support (Inactive)
              Votes:
              11 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes