summaryrefslogtreecommitdiff
path: root/src/styleengine.cc
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-10-17 19:22:37 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-10-17 19:22:37 +0200
commitba30ecdf73f0633259a8c64ea2e3ef2e3cbcd65a (patch)
tree0c9a801112a7b6adab1ab9da10bb2a68893f9d32 /src/styleengine.cc
parent42b823675277e31dd2772a0d4bdb9bf1ff0b5df4 (diff)
add letter-spacing support to CSS subsystem
The implementation in the fltk backend is still missing.
Diffstat (limited to 'src/styleengine.cc')
-rw-r--r--src/styleengine.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/styleengine.cc b/src/styleengine.cc
index d97aba5c..e266b0d1 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -40,6 +40,7 @@ StyleEngine::StyleEngine (dw::core::Layout *layout) {
font_attrs.size = prefs.font_max_size;
font_attrs.weight = 400;
font_attrs.style = FONT_STYLE_NORMAL;
+ font_attrs.letterSpacing = 0;
style_attrs.initValues ();
style_attrs.font = Font::create (layout, &font_attrs);
@@ -202,7 +203,7 @@ void StyleEngine::endElement (int element) {
*/
void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) {
FontAttrs fontAttrs = *attrs->font;
- Font *parentFont;
+ Font *parentFont = stack->get (stack->size () - 2).style->font;
/* Determine font first so it can be used to resolve relative lenths.
* \todo Things should be rearranged so that just one pass is necessary.
@@ -227,7 +228,6 @@ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) {
fontAttrs.name = p->value.strVal;
break;
case CSS_PROPERTY_FONT_SIZE:
- parentFont = stack->get (stack->size () - 2).style->font;
if (p->type == CSS_TYPE_ENUM) {
switch (p->value.intVal) {
case CSS_FONT_SIZE_XX_SMALL:
@@ -307,6 +307,17 @@ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) {
fontAttrs.weight = 900;
break;
+ case CSS_PROPERTY_LETTER_SPACING:
+ if (p->type == CSS_TYPE_ENUM) {
+ if (p->value.intVal == CSS_LETTER_SPACING_NORMAL) {
+ fontAttrs.letterSpacing = 0;
+ }
+ } else {
+ computeValue (&fontAttrs.letterSpacing, p->value.intVal,
+ parentFont, parentFont->size);
+ }
+ // TODO
+ break;
default:
break;
}