Bug#268831: marked as done (librsvg2: x, y, dx, dy properties bogus on tspan element)

Debian Bug Tracking System owner@bugs.debian.org
Mon, 08 Nov 2004 16:48:13 -0800


Your message dated Mon, 08 Nov 2004 19:36:30 -0500
with message-id <4190110E.1070206@mxc.ca>
and subject line (no subject)
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 29 Aug 2004 12:07:01 +0000
>From nicholas@mxc.ca Sun Aug 29 05:07:01 2004
Return-path: <nicholas@mxc.ca>
Received: from cpe0080c82b6fe5-cm014250030215.cpe.net.cable.rogers.com (calvin) [65.50.150.14] 
	by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1C1OSa-0000w9-00; Sun, 29 Aug 2004 05:07:00 -0700
Received: by calvin (Postfix, from userid 10002)
	id DE110470032; Sun, 29 Aug 2004 08:06:59 -0400 (EDT)
Content-Type: multipart/mixed; boundary="===============1399983408=="
MIME-Version: 1.0
From: Nick Lewycky <nicholas@mxc.ca>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: librsvg2: x, y, dx, dy properties bogus on tspan element
X-Mailer: reportbug 2.64
Date: Sun, 29 Aug 2004 08:06:59 -0400
Message-Id: <20040829120659.DE110470032@calvin>
X-BadReturnPath: nicholas@calvin.calvin rewritten as nicholas@mxc.ca
  using "From" header
Delivered-To: submit@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2004_03_25 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-8.0 required=4.0 tests=BAYES_00,HAS_PACKAGE 
	autolearn=no version=2.60-bugs.debian.org_2004_03_25
X-Spam-Level: 

This is a multi-part MIME message sent by reportbug.

--===============1399983408==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Package: librsvg2
Severity: normal
Tags: patch

librsvg2 doesn't handle the following fragment:

    <text x="0" y="256">
        <tspan>H</tspan>
        <tspan y="261">2</tspan>
        <tspan>SO</tspan>
        <tspan dy="5">4</tspan>
    </text>

This should be rendered as if it were H_2SO_4 in TeX. Instead, the "2"
and "4" are displayed on the same line as the H and SO.

My attached patch, librsvg2-tspan.diff implements the correct
behaviour, but the patch was made against a tree with the patch from
bug 264484 already in it.

A unified patch, librsvg2-tspan+baseline.diff includes both changes.

-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.7
Locale: LANG=C, LC_CTYPE=C

--===============1399983408==
Content-Type: text/x-c; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="librsvg2-tspan.diff"

diff -u librsvg2-2.7.2/rsvg-text.c librsvg2-2.7.2/rsvg-text.c
--- librsvg2-2.7.2/rsvg-text.c
+++ librsvg2-2.7.2/rsvg-text.c
@@ -322,16 +322,19 @@
 
 			rsvg_parse_style_attrs (ctx, state, "tspan", klazz, id, atts);
 		}
-	
-	/* todo: transform() is illegal here */
-	x += dx ;
-	y += dy ;
-	
-	if (x > 0 && y > 0)
+
+	if (x || y)
 		{
 			art_affine_translate (affine, x, y);
-			art_affine_multiply (state->affine, affine, state->affine);
+			state->affine[5] = 0, state->affine[6] = 0;
+			art_affine_multiply (state->affine, state->affine, affine);
+		}
+
+	if (dx || dy)
+		{
+			art_affine_translate (affine, dx, dy);
+			art_affine_multiply (state->affine, state->affine, affine);
 		}
 }
 
diff -u librsvg2-2.7.2/debian/changelog librsvg2-2.7.2/debian/changelog
--- librsvg2-2.7.2/debian/changelog
+++ librsvg2-2.7.2/debian/changelog
@@ -1,4 +1,10 @@
+librsvg2 (2.7.2-5.2) unstable; urgency=low
+
+  * Fix bug with translations on tspan tag.
+
+ -- Nicholas Lewycky <nicholas@spi-inc.org>  Sun, 29 Aug 2004 00:51:42 -0400
+
 librsvg2 (2.7.2-5.1) unstable; urgency=low
 
   * Add support for baseline-shift.

--===============1399983408==
Content-Type: text/x-c; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="librsvg2-tspan+baseline.diff"

diff -u librsvg2-2.7.2/debian/changelog librsvg2-2.7.2/debian/changelog
--- librsvg2-2.7.2/debian/changelog
+++ librsvg2-2.7.2/debian/changelog
@@ -1,3 +1,15 @@
+librsvg2 (2.7.2-5.2) unstable; urgency=low
+
+  * Fix bug with translations on tspan tag.
+
+ -- Nicholas Lewycky <nicholas@spi-inc.org>  Sun, 29 Aug 2004 00:51:42 -0400
+
+librsvg2 (2.7.2-5.1) unstable; urgency=low
+
+  * Add support for baseline-shift.
+
+ -- Nicholas Lewycky <nicholas@spi-inc.org>  Sun,  8 Aug 2004 20:20:06 -0500
+
 librsvg2 (2.7.2-5) unstable; urgency=medium
 
   * Rebuild with libgnutls11 (closes: #263682).
only in patch2:
unchanged:
--- librsvg2-2.7.2.orig/rsvg-css.c
+++ librsvg2-2.7.2/rsvg-css.c
@@ -693,6 +693,26 @@
 		return str;
 }
 
+gint
+rsvg_css_parse_baseline_shift (const char * str, gdouble pixels_per_inch,
+                               gdouble width_or_height, gdouble font_size,
+                               gint inherit)
+{
+	if (!str)
+		return 0;
+	else if (!strcmp (str, "inherit"))
+		return inherit;
+	else if (!strcmp (str, "baseline"))
+		return 0;
+	else if (!strcmp (str, "sub"))
+		return font_size * -0.54;        /* not quite spec */
+	else if (!strcmp (str, "super"))
+		return font_size * 0.54;
+	else
+		return rsvg_css_parse_normalized_length (str, pixels_per_inch,
+												 width_or_height, font_size);
+}
+
 #if !defined(HAVE_STRTOK_R) && !GLIB_CHECK_VERSION(2, 3, 2)
 
 static char *
only in patch2:
unchanged:
--- librsvg2-2.7.2.orig/rsvg-styles.c
+++ librsvg2-2.7.2/rsvg-styles.c
@@ -51,6 +51,20 @@
 	return 0;
 }
 
+static gint
+rsvg_state_baseline_shift (RsvgState * cur_state, RsvgState * parent_state)
+{
+	if (cur_state)
+		{
+			if (cur_state->has_baseline_shift)
+				return cur_state->baseline_shift;
+			else if (parent_state)
+				return parent_state->baseline_shift;
+		}
+	
+	return 0;
+}
+
 gdouble
 rsvg_viewport_percentage (gdouble width, gdouble height)
 {
@@ -645,6 +659,13 @@
 						}
 				}
 		}
+	else if (rsvg_css_param_match (str, "baseline-shift"))
+		{
+			gint current_baseline_shift = rsvg_state_baseline_shift (state, parent_state);
+			state->has_baseline_shift = TRUE;
+			state->baseline_shift = rsvg_css_parse_baseline_shift (str + arg_off, ctx->dpi,
+																   (gdouble)ctx->height, state->font_size, current_baseline_shift);
+		}
 }
 
 void rsvg_parse_style_pair (RsvgHandle *ctx, RsvgState *state, 
only in patch2:
unchanged:
--- librsvg2-2.7.2.orig/rsvg-styles.h
+++ librsvg2-2.7.2/rsvg-styles.h
@@ -125,6 +125,9 @@
 	guint32 current_color;
 	gboolean has_current_color;
 
+	gint baseline_shift;
+	gboolean has_baseline_shift;
+
 	GdkPixbuf *save_pixbuf;
 };
 
only in patch2:
unchanged:
--- librsvg2-2.7.2.orig/rsvg-text.c
+++ librsvg2-2.7.2/rsvg-text.c
@@ -156,7 +156,10 @@
 		line_ink_rect = ink_rect; /* nothing to draw anyway */
 	else
 		pango_layout_line_get_pixel_extents (line, &line_ink_rect, NULL);
-	
+
+	if (state->has_baseline_shift)
+		line_ink_rect.y -= state->baseline_shift;
+
 	bitmap.rows       = ink_rect.height;
 	bitmap.width      = ink_rect.width;
 	bitmap.pitch      = bitmap.width;
@@ -211,7 +214,7 @@
 	gradctx.y1 = line_ink_rect.y + logical_rect.height;
 	for (i = 0; i < 6; i++)
 		gradctx.affine[i] = state->affine[i];
-	
+
 	rsvg_render_paint_server (render, state->fill, &gradctx);
 
 	opacity = state->fill_opacity * state->opacity;
@@ -319,15 +322,18 @@
 
 			rsvg_parse_style_attrs (ctx, state, "tspan", klazz, id, atts);
 		}
-	
-	/* todo: transform() is illegal here */
-	x += dx ;
-	y += dy ;
-	
-	if (x > 0 && y > 0)
+
+	if (x || y)
 		{
 			art_affine_translate (affine, x, y);
-			art_affine_multiply (state->affine, affine, state->affine);
+			state->affine[5] = 0, state->affine[6] = 0;
+			art_affine_multiply (state->affine, state->affine, affine);
+		}
+
+	if (dx || dy)
+		{
+			art_affine_translate (affine, dx, dy);
+			art_affine_multiply (state->affine, state->affine, affine);
 		}
 }
 
only in patch2:
unchanged:
--- librsvg2-2.7.2.orig/rsvg-text-vectors.c
+++ librsvg2-2.7.2/rsvg-text-vectors.c
@@ -135,7 +135,7 @@
 {
 	RsvgTextLayout * layout;
 	PangoFontDescription *font_desc;
-	
+
 	if (ctx->pango_context == NULL)
 		ctx->pango_context = rsvg_text_get_pango_context (ctx);
 	
@@ -506,11 +506,16 @@
 			PangoRectangle   rect;
 			PangoLayoutLine *line;
 			gint             baseline;
+			RsvgState       *state;
 			
 			line = pango_layout_iter_get_line (iter);
 			
 			pango_layout_iter_get_line_extents (iter, NULL, &rect);
 			baseline = pango_layout_iter_get_baseline (iter);
+
+			state = rsvg_state_current(layout->ctx);
+			if (state && state->has_baseline_shift)
+				baseline -= state->baseline_shift;
 			
 			rsvg_text_layout_render_line (layout, line,
 										  render_func,

--===============1399983408==--

---------------------------------------
Received: (at 268831-close) by bugs.debian.org; 9 Nov 2004 00:37:10 +0000
>From nicholas@mxc.ca Mon Nov 08 16:37:10 2004
Return-path: <nicholas@mxc.ca>
Received: from smtp104.rog.mail.re2.yahoo.com [206.190.36.82] 
	by spohr.debian.org with smtp (Exim 3.35 1 (Debian))
	id 1CRK0U-0003vT-00; Mon, 08 Nov 2004 16:37:10 -0800
Received: from unknown (HELO wagon) (p.lewycky@65.50.150.14 with login)
  by smtp104.rog.mail.re2.yahoo.com with SMTP; 9 Nov 2004 00:36:32 -0000
Received: from [10.1.1.2] (calvin [10.1.1.2])
	by wagon (Postfix) with ESMTP
	id B01CF197B02; Mon,  8 Nov 2004 19:36:35 -0500 (EST)
Message-ID: <4190110E.1070206@mxc.ca>
Date: Mon, 08 Nov 2004 19:36:30 -0500
From: Nick Lewycky <nicholas@mxc.ca>
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041007 Debian/1.7.3-5
X-Accept-Language: en-us
MIME-Version: 1.0
To: 264484-close@bugs.debian.org, 268831-close@bugs.debian.org
Subject: (no subject)
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Delivered-To: 268831-close@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2004_03_25 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-3.0 required=4.0 tests=BAYES_00 autolearn=no 
	version=2.60-bugs.debian.org_2004_03_25
X-Spam-Level: 
X-CrossAssassin-Score: 2

These two patches are obsolete. Upstream has since written their own
independent implementation.

Nick Lewycky