aboutsummaryrefslogtreecommitdiff
path: root/dw/textblock.cc
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2013-11-02 20:50:11 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2013-11-02 20:50:11 +0100
commit9b068e74be8c7935e12b63181b8726b9595cf152 (patch)
treeeaa695473ad8d67430a7189383d45812014b7699 /dw/textblock.cc
parent3587360b6f134a763aa005ba3c4e8e71cc73ebe9 (diff)
for VALIGN_SUB and VALIGN_SUPER only increase line-height if necessary
For cases like <div style="line-height:1.7"> dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo <sup>dillo</sup> dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo <sub>dillo</sub> dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo dillo </div> this gives equally spaced lines and also seems to replicate firefox behaviour.
Diffstat (limited to 'dw/textblock.cc')
-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);
+ }
}
/**