Commit 60010479 authored by Emmanuel Pacaud's avatar Emmanuel Pacaud Committed by Emmanuel Pacaud

Implement letter-spacing property.

2007-02-21  Emmanuel Pacaud <emmanuel.pacaud@lapp.in2p3.fr>

	Implement letter-spacing property.
	http://bugzilla.gnome.org/show_bug.cgi?id=410509
	* rsvg-styles.c: parse and handle letter-spacing.
	* rsvg-text.c (rsvg_text_create_layout): set letter spacing attribute.


svn path=/trunk/; revision=1100
parent b9e7ecc2
2007-02-21 Emmanuel Pacaud <emmanuel.pacaud@lapp.in2p3.fr>
Implement letter-spacing property.
http://bugzilla.gnome.org/show_bug.cgi?id=410509
* rsvg-styles.c: parse and handle letter-spacing.
* rsvg-text.c (rsvg_text_create_layout): set letter spacing attribute.
2007-02-14 Dom Lachowicz <domlachowicz@gmail.com>
* tests/Makefile.am: Bug 407230 - make check fails when builddir
......
......@@ -83,6 +83,7 @@ rsvg_state_init (RsvgState * state)
state->text_dir = PANGO_DIRECTION_LTR;
state->unicode_bidi = UNICODE_BIDI_NORMAL;
state->text_anchor = TEXT_ANCHOR_START;
state->letter_spacing = _rsvg_css_parse_length ("0.0");
state->visible = TRUE;
state->cond_true = TRUE;
state->filter = NULL;
......@@ -120,6 +121,7 @@ rsvg_state_init (RsvgState * state)
state->has_text_dir = FALSE;
state->has_unicode_bidi = FALSE;
state->has_text_anchor = FALSE;
state->has_letter_spacing = FALSE;
state->has_startMarker = FALSE;
state->has_middleMarker = FALSE;
state->has_endMarker = FALSE;
......@@ -221,6 +223,8 @@ rsvg_state_inherit_run (RsvgState * dst, const RsvgState * src,
dst->unicode_bidi = src->unicode_bidi;
if (function (dst->has_text_anchor, src->has_text_anchor))
dst->text_anchor = src->text_anchor;
if (function (dst->has_letter_spacing, src->has_letter_spacing))
dst->letter_spacing = src->letter_spacing;
if (function (dst->has_startMarker, src->has_startMarker))
dst->startMarker = src->startMarker;
if (function (dst->has_middleMarker, src->has_middleMarker))
......@@ -612,6 +616,9 @@ rsvg_parse_style_arg (RsvgHandle * ctx, RsvgState * state, const char *str)
else if (strstr (str + arg_off, "end"))
state->text_anchor = TEXT_ANCHOR_END;
}
} else if (rsvg_css_param_match (str, "letter-spacing")) {
state->has_letter_spacing = TRUE;
state->letter_spacing = _rsvg_css_parse_length (str + arg_off);
} else if (rsvg_css_param_match (str, "stop-color")) {
if (strcmp (str + arg_off, "inherit")) {
state->stop_color = rsvg_css_parse_color (str + arg_off, &state->has_stop_color);
......@@ -745,6 +752,7 @@ rsvg_parse_style_pairs (RsvgHandle * ctx, RsvgState * state, RsvgPropertyBag * a
rsvg_lookup_parse_style_pair (ctx, state, "text-anchor", atts);
rsvg_lookup_parse_style_pair (ctx, state, "text-decoration", atts);
rsvg_lookup_parse_style_pair (ctx, state, "unicode-bidi", atts);
rsvg_lookup_parse_style_pair (ctx, state, "letter-spacing", atts);
rsvg_lookup_parse_style_pair (ctx, state, "visibility", atts);
rsvg_lookup_parse_style_pair (ctx, state, "writing-mode", atts);
rsvg_lookup_parse_style_pair (ctx, state, "xml:lang", atts);
......
......@@ -174,6 +174,8 @@ struct _RsvgState {
gboolean has_unicode_bidi;
TextAnchor text_anchor;
gboolean has_text_anchor;
RsvgLength letter_spacing;
gboolean has_letter_spacing;
guint text_offset;
......
......@@ -483,6 +483,8 @@ rsvg_text_create_layout (RsvgDrawingCtx * ctx,
{
PangoFontDescription *font_desc;
PangoLayout *layout;
PangoAttrList *attr_list;
PangoAttribute *attribute;
if (state->lang)
pango_context_set_language (context, pango_language_from_string (state->lang));
......@@ -508,6 +510,15 @@ rsvg_text_create_layout (RsvgDrawingCtx * ctx,
pango_layout_set_font_description (layout, font_desc);
pango_font_description_free (font_desc);
attr_list = pango_attr_list_new ();
attribute = pango_attr_letter_spacing_new ( _rsvg_css_normalize_length (&state->letter_spacing,
ctx, 'h') * PANGO_SCALE);
attribute->start_index = 0;
attribute->end_index = G_MAXINT;
pango_attr_list_insert (attr_list, attribute);
pango_layout_set_attributes (layout, attr_list);
pango_attr_list_unref (attr_list);
if (text)
pango_layout_set_text (layout, text, -1);
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment