aboutsummaryrefslogtreecommitdiff
path: root/src/styleengine.cc
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-01-26 21:09:52 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-01-26 21:09:52 +0100
commit307159fdc7edda9d12a174ebc7d3e0e5480aed4f (patch)
tree3d58b34d86c042ec916e4bc75d3689387d9b814b /src/styleengine.cc
parent954f1b5dea7b6dbdf8208b0ce6576228d121656c (diff)
adapt font-family preferences to match CSS
CSS 2.1 uses the following predefined font names: 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'. Add preferences so that the user can set real font names for these. Basically the new "font_sans_serif" option is what "vw_fontame" used to be and "font_monospace" is equivalent to "fw_fontname". The other two options are new.
Diffstat (limited to 'src/styleengine.cc')
-rw-r--r--src/styleengine.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/styleengine.cc b/src/styleengine.cc
index d5089d71..015f75be 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -30,7 +30,7 @@ StyleEngine::StyleEngine (dw::core::Layout *layout) {
Node *n = stack->getRef (stack->size () - 1);
/* Create a dummy font, attribute, and tag for the bottom of the stack. */
- font_attrs.name = prefs.vw_fontname;
+ font_attrs.name = prefs.font_sans_serif;
font_attrs.size = (int) (14 * prefs.font_factor + 0.5);
font_attrs.weight = CssProperty::CSS_FONT_WEIGHT_NORMAL;
font_attrs.style = FONT_STYLE_NORMAL;
@@ -172,11 +172,16 @@ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) {
case CssProperty::CSS_PROPERTY_FONT_FAMILY:
// \todo memory management of font name strings
// \todo handle comma separated lists of font names
- // \todo handle sans-serif, cursive, fantasy
- if (strcmp (p->value.strVal, "sans") == 0)
- fontAttrs.name = prefs.vw_fontname;
+ if (strcmp (p->value.strVal, "serif") == 0)
+ fontAttrs.name = prefs.font_serif;
+ else if (strcmp (p->value.strVal, "sans-serif") == 0)
+ fontAttrs.name = prefs.font_sans_serif;
+ else if (strcmp (p->value.strVal, "cursive") == 0)
+ fontAttrs.name = prefs.font_cursive;
+ else if (strcmp (p->value.strVal, "fantasy") == 0)
+ fontAttrs.name = prefs.font_fantasy;
else if (strcmp (p->value.strVal, "monospace") == 0)
- fontAttrs.name = prefs.fw_fontname;
+ fontAttrs.name = prefs.font_monospace;
else
fontAttrs.name = p->value.strVal;
break;