=== modified file 'librsvg.def'
--- librsvg.def	2006-11-03 01:32:16 +0000
+++ librsvg.def	2008-10-07 12:25:27 +0000
@@ -15,6 +15,7 @@
 rsvg_handle_get_base_uri
 rsvg_handle_set_base_uri
 rsvg_handle_get_dimensions
+rsvg_handle_get_dimensions_sub
 rsvg_handle_get_title
 rsvg_handle_get_desc
 rsvg_handle_get_metadata

=== modified file 'rsvg-base.c'
--- rsvg-base.c	2008-08-26 16:51:17 +0000
+++ rsvg-base.c	2008-10-09 14:10:06 +0000
@@ -1329,6 +1329,43 @@
     return output;
 }
 
+static RsvgBbox
+_rsvg_find_bbox_sub (RsvgHandle * handle, RsvgNode * node)
+{
+    RsvgDrawingCtx *ctx = g_new (RsvgDrawingCtx, 1);
+    RsvgBbox output;
+    RsvgBboxRender *render = rsvg_bbox_render_new ();
+    ctx->drawsub_stack = NULL;
+    ctx->render = (RsvgRender *) render;
+
+    ctx->state = NULL;
+
+    ctx->defs = handle->priv->defs;
+    ctx->base_uri = g_strdup (handle->priv->base_uri);
+    ctx->dpi_x = handle->priv->dpi_x;
+    ctx->dpi_y = handle->priv->dpi_y;
+    ctx->vb.w = 512;
+    ctx->vb.h = 512;
+    ctx->pango_context = NULL;
+
+    rsvg_state_push (ctx);
+    _rsvg_affine_identity (rsvg_state_current (ctx)->affine);
+    
+    if (node->children->len > 0 && g_strcmp0 (node->type->str, "text")) {
+	printf ("Children in <%s>! %d\n", node->type->str, node->children->len);
+	_rsvg_node_draw_children (node, ctx, 0);
+    }
+    else
+	rsvg_node_draw (node, ctx, 0);
+
+    rsvg_state_pop (ctx);
+
+    output = render->bbox;
+    rsvg_render_free (ctx->render);
+    g_free (ctx);
+    return output;
+}
+
 /**
  * rsvg_handle_get_dimensions
  * @handle: A #RsvgHandle
@@ -1364,6 +1401,8 @@
             bbox = _rsvg_find_bbox (handle);
     }
 
+    printf("Bbox %f %f\n", bbox.w, bbox.h);
+
     dimension_data->width = (int) (_rsvg_css_hand_normalize_length (&sself->w, handle->priv->dpi_x,
                                                                     bbox.w + bbox.x * 2, 12) + 0.5);
     dimension_data->height = (int) (_rsvg_css_hand_normalize_length (&sself->h, handle->priv->dpi_y,
@@ -1378,6 +1417,57 @@
                                     handle->priv->user_data);
 }
 
+gboolean
+rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimension_data, const char *id)
+{
+    RsvgNodeSvg *root = NULL;
+    RsvgNode *sself = NULL;
+    RsvgBbox bbox;
+
+    g_return_val_if_fail (handle, FALSE);
+    g_return_val_if_fail (dimension_data, FALSE);
+
+    memset (dimension_data, 0, sizeof (RsvgDimensionData));
+
+    if (id && *id)
+	sself = (RsvgNode *) rsvg_defs_lookup (handle->priv->defs, id);
+
+    if (!sself)
+        return FALSE;
+
+    root = (RsvgNodeSvg *) handle->priv->treebase;
+
+    if (!root)
+	return FALSE;
+
+    printf("Type %s\n", sself->type->str);
+
+    bbox.x = bbox.y = 0;
+    bbox.w = bbox.h = 1;
+
+    bbox = _rsvg_find_bbox_sub (handle, sself);
+
+    printf("Bbox New x: %f y: %f \n \tw: %f h: %f\n\n", bbox.x, bbox.y, bbox.w, bbox.h);
+
+    dimension_data->width = (int) (_rsvg_css_hand_normalize_length_sub (&root->w, bbox.w, handle->priv->dpi_x,
+                                                                    bbox.w + bbox.x * 2, 12) + 0.5);
+    dimension_data->height = (int) (_rsvg_css_hand_normalize_length_sub (&root->h, bbox.h, handle->priv->dpi_y,
+                                                                     bbox.h + bbox.y * 2,
+                                                                     12) + 0.5);
+
+    printf("Dimension width: %d height: %d\n\n", dimension_data->width, dimension_data->height);
+
+    dimension_data->em = dimension_data->width;
+    dimension_data->ex = dimension_data->height;
+
+    if (handle->priv->size_func)
+        (*handle->priv->size_func) (&dimension_data->width, &dimension_data->height,
+                                    handle->priv->user_data);
+
+    return FALSE;
+}
+
+
 /** 
  * rsvg_set_default_dpi
  * @dpi: Dots Per Inch (aka Pixels Per Inch)

=== modified file 'rsvg-css.c'
--- rsvg-css.c	2008-04-25 14:27:44 +0000
+++ rsvg-css.c	2008-10-09 09:10:58 +0000
@@ -252,6 +252,28 @@
     return 0;
 }
 
+double
+_rsvg_css_hand_normalize_length_sub (const RsvgLength * in, gdouble length, 
+				     gdouble pixels_per_inch, gdouble width_or_height, 
+				     gdouble font_size)
+{
+
+    printf("Bbox length: %f\n\n", length);
+
+    if (in->factor == '\0')
+        return length;
+    else if (in->factor == 'p')
+        return length * width_or_height;
+    else if (in->factor == 'm')
+        return length * font_size;
+    else if (in->factor == 'x')
+        return length * font_size / 2.;
+    else if (in->factor == 'i')
+        return length * pixels_per_inch;
+
+    return 0;
+}
+
 gboolean
 rsvg_css_param_match (const char *str, const char *param_name)
 {

=== modified file 'rsvg-private.h'
--- rsvg-private.h	2008-08-26 16:51:17 +0000
+++ rsvg-private.h	2008-10-09 09:21:21 +0000
@@ -344,6 +344,9 @@
 double _rsvg_css_normalize_length	(const RsvgLength * in, RsvgDrawingCtx * ctx, char dir);
 double _rsvg_css_hand_normalize_length	(const RsvgLength * in, gdouble pixels_per_inch,
 					 gdouble width_or_height, gdouble font_size);
+double _rsvg_css_hand_normalize_length_sub	(const RsvgLength * in, gdouble length,
+						 gdouble pixels_per_inch, gdouble width_or_height, 
+						 gdouble font_size);
 
 RsvgLength _rsvg_css_parse_length (const char *str);
 

=== modified file 'rsvg.h'
--- rsvg.h	2007-01-13 15:22:25 +0000
+++ rsvg.h	2008-10-09 14:05:11 +0000
@@ -118,6 +118,8 @@
 
 void rsvg_handle_get_dimensions (RsvgHandle * handle, RsvgDimensionData * dimension_data);
 
+gboolean rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimension_data, const char *id);
+
 /* Accessibility API */
 
 G_CONST_RETURN char *rsvg_handle_get_title	(RsvgHandle * handle);

