Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
4.7.1
-
None
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.