diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-10-17 19:22:37 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-10-17 19:22:37 +0200 |
commit | ba30ecdf73f0633259a8c64ea2e3ef2e3cbcd65a (patch) | |
tree | 0c9a801112a7b6adab1ab9da10bb2a68893f9d32 /src | |
parent | 42b823675277e31dd2772a0d4bdb9bf1ff0b5df4 (diff) |
add letter-spacing support to CSS subsystem
The implementation in the fltk backend is still missing.
Diffstat (limited to 'src')
-rw-r--r-- | src/css.hh | 4 | ||||
-rw-r--r-- | src/cssparser.cc | 7 | ||||
-rw-r--r-- | src/styleengine.cc | 15 |
3 files changed, 23 insertions, 3 deletions
@@ -249,6 +249,10 @@ typedef enum { CSS_FONT_SIZE_X_SMALL, } CssFontSizeExtensions; +typedef enum { + CSS_LETTER_SPACING_NORMAL +} CssLetterSpacingExtensions; + /** * \brief This class holds a CSS property and value pair. diff --git a/src/cssparser.cc b/src/cssparser.cc index 377b290d..39643149 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -77,6 +77,10 @@ static const char *const Css_font_weight_enum_vals[] = { "bold", "bolder", "light", "lighter", "normal", NULL }; +static const char *const Css_letter_spacing_enum_vals[] = { + "normal", NULL +}; + static const char *const Css_list_style_type_enum_vals[] = { "disc", "circle", "square", "decimal", "decimal-leading-zero", "lower-roman", "upper-roman", "lower-greek", "lower-alpha", @@ -149,7 +153,8 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = { Css_font_weight_enum_vals}, {"height", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_UNUSED}, NULL}, {"left", {CSS_TYPE_UNUSED}, NULL}, - {"letter-spacing", {CSS_TYPE_UNUSED}, NULL}, + {"letter-spacing", {CSS_TYPE_ENUM, CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, + Css_letter_spacing_enum_vals}, {"line-height", {CSS_TYPE_UNUSED}, NULL}, {"list-style-image", {CSS_TYPE_UNUSED}, NULL}, {"list-style-position", {CSS_TYPE_UNUSED}, NULL}, 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; } |