diff options
author | Sebastian Geerken <devnull@localhost> | 2013-11-18 00:51:11 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2013-11-18 00:51:11 +0100 |
commit | 69afabf89b19f1c57cb7de966b1a9e4b50645ded (patch) | |
tree | 182ce86cd5b58ac80b6cccd250a1a34994968e5c /dw/textblock.cc | |
parent | 1346a5fa9aa365e24724586adcb39746588712bf (diff) | |
parent | 0ff5581158180cde9d49c507aacd5d1a4e1a5b53 (diff) |
Merge with main repo.
Diffstat (limited to 'dw/textblock.cc')
-rw-r--r-- | dw/textblock.cc | 30 |
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); + } } /** |