Implement scaling in text_shape to preserve font hinting - 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年08月07日 18:53:31 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年08月07日 18:53:31 +0200
commitaf0ad999cddb57b70547806d309c60cca5893e7e (patch)
tree34046e750fb21ddbb6d24c6458f984da5e746d15 /agg-plot/text-shape.h
parent5d5237a6688d733c645a1df04471545036f94c7a (diff)
downloadgsl-shell-af0ad999cddb57b70547806d309c60cca5893e7e.tar.gz
Implement scaling in text_shape to preserve font hinting
Diffstat (limited to 'agg-plot/text-shape.h')
-rw-r--r--agg-plot/text-shape.h 26
1 files changed, 12 insertions, 14 deletions
diff --git a/agg-plot/text-shape.h b/agg-plot/text-shape.h
index aadbe147..96a610ff 100644
--- a/agg-plot/text-shape.h
+++ b/agg-plot/text-shape.h
@@ -10,10 +10,10 @@ namespace draw {
public:
text_shape(double x, double y, const char* text,
double _size = 10.0, double hjustif = 0.0, double vjustif = 0.0):
- m_text_label(text, _size), m_scaling(0), m_size(_size)
+ m_text_label(text, _size), m_x(x), m_y(y), m_size(_size)
{
- m_matrix.tx = x;
- m_matrix.ty = y;
+ m_matrix.tx = m_x;
+ m_matrix.ty = round(m_y);
m_text_label.model_mtx(m_matrix);
compute_bounding_box();
}
@@ -25,10 +25,7 @@ namespace draw {
virtual unsigned vertex(double* x, double* y)
{
- unsigned cmd = m_text_label.vertex(x, y);
- if (m_scaling && agg::is_vertex(cmd))
- m_scaling->transform(x, y);
- return cmd;
+ return m_text_label.vertex(x, y);
}
virtual void bounding_box(double *x1, double *y1, double *x2, double *y2)
@@ -57,11 +54,6 @@ namespace draw {
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\">" \
@@ -74,14 +66,20 @@ namespace draw {
virtual void apply_transform(const agg::trans_affine& m, double as)
{
- m_scaling = &m;
+ m_text_label.scale_font(m.sx, m.sy);
+
+ double x = m_x, y = m_y;
+ m.transform(&x, &y);
+ m_matrix.tx = x;
+ m_matrix.ty = round(y);
+
m_text_label.approximation_scale(m.scale());
}
private:
text_label m_text_label;
+ double m_x, m_y;
agg::trans_affine m_matrix;
- const agg::trans_affine* m_scaling;
double m_size;
agg::rect_base<double> m_bbox;
};
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月27日 21:02:16 +0000

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