diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-11-15 22:44:31 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-11-15 22:44:31 +0100 |
commit | 817d21852cef6663f6e58cc4911412e3f80f9f2e (patch) | |
tree | 45f2b3630cbfdb1c29851c1adc861e69286ad152 | |
parent | c74ec3eacfb7474e72ab40ed79ea43ef1dbe273b (diff) |
support percentages in font-size definition
-rw-r--r-- | src/cssparser.cc | 2 | ||||
-rw-r--r-- | src/styleengine.cc | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/cssparser.cc b/src/cssparser.cc index 278f20d0..92ed78ac 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -99,7 +99,7 @@ CssPropertyInfo Css_property_info[CssProperty::CSS_PROPERTY_LAST] = { { "empty-cells", CSS_TYPE_UNUSED, NULL }, { "float", CSS_TYPE_UNUSED, NULL }, { "font-family", CSS_TYPE_SYMBOL, NULL }, - { "font-size", CSS_TYPE_LENGTH, NULL }, + { "font-size", CSS_TYPE_LENGTH_PERCENTAGE, NULL }, { "font-size-adjust", CSS_TYPE_UNUSED, NULL }, { "font-stretch", CSS_TYPE_UNUSED, NULL }, { "font-style", CSS_TYPE_ENUM, Css_font_style_enum_vals }, diff --git a/src/styleengine.cc b/src/styleengine.cc index 58bc910d..7b151469 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -130,6 +130,7 @@ void StyleEngine::endElement (int element) { */ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) { FontAttrs fontAttrs = *attrs->font; + Font *parentFont; /* Determine font first so it can be used to resolve relative lenths. * \todo Things should be rearranged so that just one pass is necessary. @@ -142,8 +143,12 @@ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) { fontAttrs.name = p->value.strVal; break; case CssProperty::CSS_PROPERTY_FONT_SIZE: - fontAttrs.size = computeValue (p->value.intVal, - stack->get (stack->size () - 2).style->font); + parentFont = stack->get (stack->size () - 2).style->font; + if (CSS_LENGTH_TYPE (p->value.intVal) == CSS_LENGTH_TYPE_PERCENTAGE) + fontAttrs.size = (int) (CSS_LENGTH_VALUE (p->value.intVal) * + parentFont->size); + else + fontAttrs.size = computeValue (p->value.intVal, parentFont); break; case CssProperty::CSS_PROPERTY_FONT_STYLE: fontAttrs.style = (FontStyle) p->value.intVal; |