aboutsummaryrefslogtreecommitdiff
path: root/src/styleengine.cc
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-02-06 20:59:22 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-02-06 20:59:22 +0100
commit448efdf236c5224047250af97238279f8f29a2aa (patch)
treeae23b2ca721972bc89904da3fe13abfb96e221d3 /src/styleengine.cc
parentc34bff4996a888b92e6d546b82a388f787325470 (diff)
switch font-weight handling to new multi type system
Diffstat (limited to 'src/styleengine.cc')
-rw-r--r--src/styleengine.cc46
1 files changed, 31 insertions, 15 deletions
diff --git a/src/styleengine.cc b/src/styleengine.cc
index 264406bb..badacbae 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -32,7 +32,7 @@ StyleEngine::StyleEngine (dw::core::Layout *layout) {
/* Create a dummy font, attribute, and tag for the bottom of the stack. */
font_attrs.name = prefs.font_sans_serif;
font_attrs.size = (int) (14 * prefs.font_factor + 0.5);
- font_attrs.weight = CSS_FONT_WEIGHT_NORMAL;
+ font_attrs.weight = 400;
font_attrs.style = FONT_STYLE_NORMAL;
style_attrs.initValues ();
@@ -193,21 +193,37 @@ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) {
fontAttrs.style = (FontStyle) p->value.intVal;
break;
case CSS_PROPERTY_FONT_WEIGHT:
- switch (p->value.intVal) {
- case CSS_FONT_WEIGHT_LIGHTER:
- fontAttrs.weight -= CSS_FONT_WEIGHT_STEP;
- break;
- case CSS_FONT_WEIGHT_BOLDER:
- fontAttrs.weight += CSS_FONT_WEIGHT_STEP;
- break;
- default:
- fontAttrs.weight = p->value.intVal;
- break;
+
+ if (p->type == CSS_TYPE_ENUM) {
+ switch (p->value.intVal) {
+ case CSS_FONT_WEIGHT_BOLD:
+ fontAttrs.weight = 700;
+ break;
+ case CSS_FONT_WEIGHT_BOLDER:
+ fontAttrs.weight += 300;
+ break;
+ case CSS_FONT_WEIGHT_LIGHT:
+ fontAttrs.weight = 100;
+ break;
+ case CSS_FONT_WEIGHT_LIGHTER:
+ fontAttrs.weight -= 300;
+ break;
+ case CSS_FONT_WEIGHT_NORMAL:
+ fontAttrs.weight = 400;
+ break;
+ default:
+ assert(false); // invalid font weight value
+ break;
+ }
+ } else {
+ fontAttrs.weight = p->value.intVal;
}
- if (fontAttrs.weight < CSS_FONT_WEIGHT_MIN)
- fontAttrs.weight = CSS_FONT_WEIGHT_MIN;
- if (fontAttrs.weight > CSS_FONT_WEIGHT_MAX)
- fontAttrs.weight = CSS_FONT_WEIGHT_MAX;
+
+ if (fontAttrs.weight < 100)
+ fontAttrs.weight = 100;
+ if (fontAttrs.weight > 900)
+ fontAttrs.weight = 900;
+
break;
default:
break;