summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-01-22 11:53:15 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-01-22 11:53:15 +0100
commit98330dc9464729ea29d7e3624f1247094ca24de8 (patch)
tree3eed40435787df689ba25d1e89376783e2b428fd
parentce65f174e3569b35f09ea475f9ddad2aa8ebd360 (diff)
improve font handling
The vw_fontname and fw_fontname preferences are now used to define the CSS fontanmes "sans" and "monospace".
-rw-r--r--src/css.cc4
-rw-r--r--src/styleengine.cc12
2 files changed, 12 insertions, 4 deletions
diff --git a/src/css.cc b/src/css.cc
index 4a110161..b2e04877 100644
--- a/src/css.cc
+++ b/src/css.cc
@@ -347,7 +347,7 @@ void CssContext::addRule (CssRule *rule, CssPrimaryOrder order) {
void CssContext::buildUserAgentStyle () {
const char *cssBuf =
- "body {background-color: #dcd1ba; font-family: helvetica; color: black;"
+ "body {background-color: #dcd1ba; font-family: sans; color: black;"
" margin: 5px}"
"big {font-size: 1.17em}"
"blockquote, dd {margin-left: 40px; margin-right: 40px}"
@@ -382,7 +382,7 @@ void CssContext::buildUserAgentStyle () {
"td {border-style: inset; padding: 2px}"
"thead, tbody, tfoot { vertical-align: middle}"
"th { font-weight: bolder; text-align: center}"
- "code, tt, pre, samp, kbd {font-family: courier}";
+ "code, tt, pre, samp, kbd {font-family: monospace}";
a_Css_parse (this, cssBuf, strlen (cssBuf), 0, CSS_ORIGIN_USER_AGENT);
}
diff --git a/src/styleengine.cc b/src/styleengine.cc
index fbf9c8ee..d5089d71 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 = "helvetica";
+ font_attrs.name = prefs.vw_fontname;
font_attrs.size = (int) (14 * prefs.font_factor + 0.5);
font_attrs.weight = CssProperty::CSS_FONT_WEIGHT_NORMAL;
font_attrs.style = FONT_STYLE_NORMAL;
@@ -170,7 +170,15 @@ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) {
switch (p->name) {
case CssProperty::CSS_PROPERTY_FONT_FAMILY:
- fontAttrs.name = p->value.strVal;
+ // \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;
+ else if (strcmp (p->value.strVal, "monospace") == 0)
+ fontAttrs.name = prefs.fw_fontname;
+ else
+ fontAttrs.name = p->value.strVal;
break;
case CssProperty::CSS_PROPERTY_FONT_SIZE:
parentFont = stack->get (stack->size () - 2).style->font;