Fix method to generate SVG output for text_shape objects - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot/text-shape.h
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2012年07月19日 23:56:04 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年07月19日 23:56:04 +0200
commit6a5aa48d30b5ba557361d8b85a32fe3085cf04e2 (patch)
treeda7eece6bcf6e71a56764a14534e1a8537c0fe59 /agg-plot/text-shape.h
parent60f4afc1da907037867b9501fd9f781948efe649 (diff)
downloadgsl-shell-6a5aa48d30b5ba557361d8b85a32fe3085cf04e2.tar.gz
Fix method to generate SVG output for text_shape objects
Diffstat (limited to 'agg-plot/text-shape.h')
-rw-r--r--agg-plot/text-shape.h 38
1 files changed, 16 insertions, 22 deletions
diff --git a/agg-plot/text-shape.h b/agg-plot/text-shape.h
index 77afb0af..38abf892 100644
--- a/agg-plot/text-shape.h
+++ b/agg-plot/text-shape.h
@@ -43,28 +43,22 @@ namespace draw {
virtual str write_svg(int id, agg::rgba8 c, double h)
{
const str& text = m_text_label.text();
- int txt_size = m_size;
-
- const agg::trans_affine* m = m_scaling;
-
- double x = m_matrix.tx, y = -m_matrix.ty;
- const double dx = (m ? m->tx : 0.0), dy = svg_y_coord(m ? m->ty : 0.0, h);
-
- x += dx;
- y += dy;
-
- str svgtext = str::print("<text x=\"%g\" y=\"%g\" id=\"text%i\"" \
- " style=\"font-size:%i\">" \
- " <tspan id=\"tspan%i\">%s</tspan>" \
- "</text>",
- x, y, id, txt_size, id, text.cstr());
-
- str s;
- if (!m || is_unit_matrix(*m))
- s = svgtext;
- else
- s = str::print("<g transform=\"matrix(%g,%g,%g,%g,%g,%g)\">%s</g>",
- m->sx, m->shx, m->shy, m->sy, dx, dy, svgtext.cstr());
+ double txt_size = m_size;
+
+ const agg::trans_affine& m = m_matrix;
+
+ double x = m.tx, y = m.ty;
+ if (m_scaling)
+ {
+ m_scaling->transform(&x, &y);
+ txt_size *= m_scaling->sy;
+ }
+
+ str s = str::print("<text x=\"%g\" y=\"%g\" id=\"text%i\"" \
+ " style=\"font-size:%i\">" \
+ " <tspan id=\"tspan%i\">%s</tspan>" \
+ "</text>",
+ x, svg_y_coord(y, h), id, int(txt_size), id, text.cstr());
return s;
}
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月25日 09:20:15 +0000

AltStyle によって変換されたページ (->オリジナル) /