gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat
-rw-r--r--agg-plot/text-shape.h 5
-rw-r--r--agg-plot/text_label.h 34
2 files changed, 20 insertions, 19 deletions
diff --git a/agg-plot/text-shape.h b/agg-plot/text-shape.h
index 96a610ff..53d1999c 100644
--- a/agg-plot/text-shape.h
+++ b/agg-plot/text-shape.h
@@ -10,7 +10,7 @@ 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_x(x), m_y(y), m_size(_size)
+ m_text_label(text, round(_size)), m_x(x), m_y(y), m_font_size(_size), m_size(_size)
{
m_matrix.tx = m_x;
m_matrix.ty = round(m_y);
@@ -66,7 +66,7 @@ namespace draw {
virtual void apply_transform(const agg::trans_affine& m, double as)
{
- m_text_label.scale_font(m.sx, m.sy);
+ m_text_label.font_size(m.sx * m_font_size, round(m.sy * m_font_size));
double x = m_x, y = m_y;
m.transform(&x, &y);
@@ -79,6 +79,7 @@ namespace draw {
private:
text_label m_text_label;
double m_x, m_y;
+ double m_font_size;
agg::trans_affine m_matrix;
double m_size;
agg::rect_base<double> m_bbox;
diff --git a/agg-plot/text_label.h b/agg-plot/text_label.h
index 209876ba..0221077a 100644
--- a/agg-plot/text_label.h
+++ b/agg-plot/text_label.h
@@ -20,9 +20,8 @@ class text_label
str m_text_buf;
double m_width;
- double m_height;
-
- double m_scale_x, m_scale_y;
+ double m_font_height;
+ double m_font_width;
unsigned m_pos;
double m_x, m_y;
@@ -38,27 +37,21 @@ class text_label
public:
text_label(const char* text, double size):
- m_text_buf(text), m_height(size), m_scale_x(1), m_scale_y(1), m_pos(0),
+ m_text_buf(text), m_font_height(size), m_font_width(size),
m_font_eng(gslshell::font_engine()), m_font_man(gslshell::font_manager()),
m_model_mtx(&identity_matrix),
m_text_curve(m_font_man.path_adaptor()), m_text_trans(m_text_curve, m_text_mtx)
{
- set_font_size();
+ update_font_size();
m_width = get_text_width();
}
void model_mtx(const agg::trans_affine& m) { m_model_mtx = &m; }
- void set_font_size()
- {
- m_font_eng.height(m_scale_y * m_height);
- m_font_eng.width(m_scale_x * m_height * scale_x);
- }
-
- void scale_font(double f_scale_x, double f_scale_y)
+ void font_size(double height, double width)
{
- m_scale_x = f_scale_x;
- m_scale_y = f_scale_y;
+ m_font_height = height;
+ m_font_width = width;
}
const str& text() const { return m_text_buf; }
@@ -94,7 +87,7 @@ class text_label
void rewind(double hjustif, double vjustif)
{
m_x = scale_x * (- hjustif * m_width);
- m_y = round(- 0.86 * vjustif * m_height);
+ m_y = round(- 0.86 * vjustif * m_font_height);
m_advance_x = 0;
m_advance_y = 0;
m_pos = 0;
@@ -103,7 +96,7 @@ class text_label
agg::trans_affine_scaling scale_mtx(1.0 / double(scale_x), 1.0);
trans_affine_compose (m_text_mtx, scale_mtx);
- set_font_size();
+ update_font_size();
load_glyph();
}
@@ -124,7 +117,7 @@ class text_label
void approximation_scale(double as) { m_text_curve.approximation_scale(as); }
- double get_text_height() const { return m_height; }
+ double get_text_height() const { return m_font_height; }
double get_text_width()
{
@@ -145,6 +138,13 @@ class text_label
return x / double(scale_x);
}
+
+private:
+ void update_font_size()
+ {
+ m_font_eng.height(m_font_height);
+ m_font_eng.width(m_font_width * scale_x);
+ }
};
#endif
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月28日 13:21:35 +0000

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