aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-11-08 15:23:21 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-11-08 15:23:21 +0100
commit79a3a198352597ceda154ce3a5c93373967ab5bf (patch)
tree09a307efda9ae672f0336b17caff4fe7892bbd96 /src
parent8ab7dd2af3b0230112fbdd552f9461dda6371cea (diff)
support CSS_FONT_WEIGHT_LIGHTER and CSS_FONT_WEIGHT_BOLDER
Diffstat (limited to 'src')
-rw-r--r--src/css.cc2
-rw-r--r--src/css.hh12
-rw-r--r--src/styleengine.cc15
3 files changed, 27 insertions, 2 deletions
diff --git a/src/css.cc b/src/css.cc
index 3f036f5e..b28f1d03 100644
--- a/src/css.cc
+++ b/src/css.cc
@@ -114,7 +114,7 @@ CssStyleSheet * CssContext::buildUserAgentStyle () {
// <b>
props = new CssPropertyList ();
- props->set (CssProperty::CSS_PROPERTY_FONT_WEIGHT, 700);
+ props->set (CssProperty::CSS_PROPERTY_FONT_WEIGHT, CssProperty::CSS_FONT_WEIGHT_BOLDER);
s->addRule (new CssSelector(a_Html_tag_index("b"), NULL, NULL), props);
// <i>
diff --git a/src/css.hh b/src/css.hh
index 84eba13a..c98a3850 100644
--- a/src/css.hh
+++ b/src/css.hh
@@ -101,6 +101,18 @@ class CssProperty {
CSS_PROPERTY_LAST
} Name;
+ typedef enum {
+ CSS_FONT_WEIGHT_LIGHTER = -1,
+ CSS_FONT_WEIGHT_BOLDER = -2,
+ CSS_FONT_WEIGHT_STEP = 300,
+ /* Some special font weights. */
+ CSS_FONT_WEIGHT_LIGHT = 100,
+ CSS_FONT_WEIGHT_NORMAL = 400,
+ CSS_FONT_WEIGHT_BOLD = 700,
+ CSS_FONT_WEIGHT_MIN = 100,
+ CSS_FONT_WEIGHT_MAX = 900,
+ } CssFontWeightExtensions;
+
Name name;
Value value;
};
diff --git a/src/styleengine.cc b/src/styleengine.cc
index 9123007e..c1b4f718 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -120,7 +120,20 @@ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) {
fontAttrs.style = (FontStyle) p->value.intVal;
break;
case CssProperty::CSS_PROPERTY_FONT_WEIGHT:
- fontAttrs.weight = p->value.intVal;
+ switch (p->value.intVal) {
+ case CssProperty::CSS_FONT_WEIGHT_LIGHTER:
+ fontAttrs.weight -= CssProperty::CSS_FONT_WEIGHT_STEP;
+ break;
+ case CssProperty::CSS_FONT_WEIGHT_BOLDER:
+ fontAttrs.weight += CssProperty::CSS_FONT_WEIGHT_STEP;
+ break;
+ default:
+ fontAttrs.weight = p->value.intVal;
+ }
+ if (fontAttrs.weight < CssProperty::CSS_FONT_WEIGHT_MIN)
+ fontAttrs.weight = CssProperty::CSS_FONT_WEIGHT_MIN;
+ if (fontAttrs.weight > CssProperty::CSS_FONT_WEIGHT_MAX)
+ fontAttrs.weight = CssProperty::CSS_FONT_WEIGHT_MAX;
break;
case CssProperty::CSS_PROPERTY_LIST_STYLE_TYPE:
attrs->listStyleType = (ListStyleType) p->value.intVal;