aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/textblock.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 1d486083..cd301871 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -1447,6 +1447,8 @@ void Textblock::calcTextSize (const char *text, size_t len,
core::style::Style *style,
core::Requisition *size, bool isStart, bool isEnd)
{
+ int requiredAscent, requiredDescent;
+
size->width = textWidth (text, 0, len, style, isStart, isEnd);
size->ascent = style->font->ascent;
size->descent = style->font->descent;
@@ -1485,10 +1487,13 @@ void Textblock::calcTextSize (const char *text, size_t len,
/* In case of a sub or super script we increase the word's height and
* potentially the line's height.
*/
- if (style->valign == core::style::VALIGN_SUB)
- size->descent += (style->font->ascent / 3);
- else if (style->valign == core::style::VALIGN_SUPER)
- size->ascent += (style->font->ascent / 2);
+ if (style->valign == core::style::VALIGN_SUB) {
+ requiredDescent = style->font->descent + style->font->ascent / 3;
+ size->descent = misc::max (size->descent, requiredDescent);
+ } else if (style->valign == core::style::VALIGN_SUPER) {
+ requiredAscent = style->font->ascent + style->font->ascent / 2;
+ size->ascent = misc::max (size->ascent, requiredAscent);
+ }
}
/**