Details
-
Suggestion
-
Resolution: Done
-
P3: Somewhat important
-
4.7.0
-
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
- is required for
-
QTBUG-14487 QTextObjectInterface - would be nice to make copy/paste work
- Reported
- replaces
-
QTBUG-18114 QTextCharFormat::AlignNormal does not take into account font descent while vertical
- Closed