aboutsummaryrefslogtreecommitdiff
path: root/dw/textblock.cc
diff options
context:
space:
mode:
Diffstat (limited to 'dw/textblock.cc')
-rw-r--r--dw/textblock.cc30
1 files changed, 18 insertions, 12 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc
index a79462e1..a45b3da5 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -909,8 +909,8 @@ void Textblock::calcWidgetSize (core::Widget *widget, core::Requisition *size)
size->width = core::style::absLengthVal (wstyle->width)
+ wstyle->boxDiffWidth ();
else
- size->width = (int) (core::style::perLengthVal (wstyle->width)
- * availWidth);
+ size->width =
+ core::style::multiplyWithPerLength (availWidth, wstyle->width);
if (wstyle->height == core::style::LENGTH_AUTO) {
size->ascent = requisition.ascent;
@@ -922,9 +922,10 @@ void Textblock::calcWidgetSize (core::Widget *widget, core::Requisition *size)
+ wstyle->boxDiffHeight ();
size->descent = 0;
} else {
- double len = core::style::perLengthVal (wstyle->height);
- size->ascent = (int) (len * availAscent);
- size->descent = (int) (len * availDescent);
+ size->ascent =
+ core::style::multiplyWithPerLength (wstyle->height, availAscent);
+ size->descent =
+ core::style::multiplyWithPerLength (wstyle->height, availDescent);
}
}
@@ -1619,6 +1620,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;
@@ -1645,9 +1648,9 @@ void Textblock::calcTextSize (const char *text, size_t len,
if (core::style::isAbsLength (style->lineHeight))
height = core::style::absLengthVal(style->lineHeight);
else
- height = lout::misc::roundInt (
- core::style::perLengthVal(style->lineHeight) *
- style->font->size);
+ height =
+ core::style::multiplyWithPerLengthRounded (style->font->size,
+ style->lineHeight);
leading = height - style->font->size;
size->ascent += leading / 2;
@@ -1657,10 +1660,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);
+ }
}
/**