Store pointer to char_info in text_path instead of pointer to char_properties.
This commit is contained in:
parent
b5e1ebfac8
commit
4638b28c36
4 changed files with 31 additions and 34 deletions
|
@ -118,32 +118,32 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
typedef char_info const * char_info_ptr;
|
||||
|
||||
|
||||
/** List of all characters and their positions and formats for a placement. */
|
||||
class text_path : boost::noncopyable
|
||||
{
|
||||
struct character_node
|
||||
{
|
||||
int c;
|
||||
char_info_ptr c;
|
||||
pixel_position pos;
|
||||
double angle;
|
||||
char_properties *format;
|
||||
|
||||
character_node(int c_, double x_, double y_, double angle_, char_properties *format_)
|
||||
: c(c_), pos(x_, y_), angle(angle_), format(format_)
|
||||
character_node(char_info_ptr c_, double x_, double y_, double angle_)
|
||||
: c(c_), pos(x_, y_), angle(angle_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~character_node() {}
|
||||
|
||||
void vertex(int *c_, double *x_, double *y_, double *angle_, char_properties **format_)
|
||||
void vertex(char_info_ptr *c_, double *x_, double *y_, double *angle_)
|
||||
{
|
||||
*c_ = c;
|
||||
*x_ = pos.x;
|
||||
*y_ = pos.y;
|
||||
*angle_ = angle;
|
||||
*format_ = format;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -163,15 +163,15 @@ public:
|
|||
~text_path() {}
|
||||
|
||||
/** Adds a new char to the list. */
|
||||
void add_node(int c, double x, double y, double angle, char_properties *format)
|
||||
void add_node(char_info_ptr c, double x, double y, double angle)
|
||||
{
|
||||
nodes_.push_back(character_node(c, x, y, angle, format));
|
||||
nodes_.push_back(character_node(c, x, y, angle));
|
||||
}
|
||||
|
||||
/** Return node. Always returns a new node. Has no way to report that there are no more nodes. */
|
||||
void vertex(int *c, double *x, double *y, double *angle, char_properties **format)
|
||||
void vertex(char_info_ptr *c, double *x, double *y, double *angle)
|
||||
{
|
||||
nodes_[itr_++].vertex(c, x, y, angle, format);
|
||||
nodes_[itr_++].vertex(c, x, y, angle);
|
||||
}
|
||||
|
||||
/** Start again at first node. */
|
||||
|
|
|
@ -581,17 +581,16 @@ public:
|
|||
|
||||
for (int iii = 0; iii < path.num_nodes(); iii++)
|
||||
{
|
||||
int c;
|
||||
char_info_ptr c;
|
||||
double x, y, angle;
|
||||
char_properties *format;
|
||||
|
||||
path.vertex(&c, &x, &y, &angle, &format);
|
||||
path.vertex(&c, &x, &y, &angle);
|
||||
|
||||
face_set_ptr faces = font_manager.get_face_set(format->face_name, format->fontset);
|
||||
float text_size = format->text_size;
|
||||
face_set_ptr faces = font_manager.get_face_set(c->format->face_name, c->format->fontset);
|
||||
float text_size = c->format->text_size;
|
||||
faces->set_character_sizes(text_size);
|
||||
|
||||
glyph_ptr glyph = faces->get_glyph(c);
|
||||
glyph_ptr glyph = faces->get_glyph(c->c);
|
||||
|
||||
if (glyph)
|
||||
{
|
||||
|
@ -609,11 +608,11 @@ public:
|
|||
set_font_face(manager, glyph->get_face());
|
||||
|
||||
glyph_path(glyph->get_index(), sx + x, sy - y);
|
||||
set_line_width(format->halo_radius);
|
||||
set_line_width(c->format->halo_radius);
|
||||
set_line_join(ROUND_JOIN);
|
||||
set_color(format->halo_fill);
|
||||
set_color(c->format->halo_fill);
|
||||
stroke();
|
||||
set_color(format->fill);
|
||||
set_color(c->format->fill);
|
||||
show_glyph(glyph->get_index(), sx + x, sy - y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -313,11 +313,10 @@ box2d<double> text_renderer<T>::prepare_glyphs(text_path *path)
|
|||
|
||||
for (int i = 0; i < path->num_nodes(); i++)
|
||||
{
|
||||
int c;
|
||||
char_info_ptr c;
|
||||
double x, y, angle;
|
||||
char_properties *properties;
|
||||
|
||||
path->vertex(&c, &x, &y, &angle, &properties);
|
||||
path->vertex(&c, &x, &y, &angle);
|
||||
|
||||
#ifdef MAPNIK_DEBUG
|
||||
// TODO Enable when we have support for setting verbosity
|
||||
|
@ -331,10 +330,10 @@ box2d<double> text_renderer<T>::prepare_glyphs(text_path *path)
|
|||
pen.x = int(x * 64);
|
||||
pen.y = int(y * 64);
|
||||
|
||||
face_set_ptr faces = font_manager_.get_face_set(properties->face_name, properties->fontset);
|
||||
faces->set_character_sizes(properties->text_size);
|
||||
face_set_ptr faces = font_manager_.get_face_set(c->format->face_name, c->format->fontset);
|
||||
faces->set_character_sizes(c->format->text_size);
|
||||
|
||||
glyph_ptr glyph = faces->get_glyph(unsigned(c));
|
||||
glyph_ptr glyph = faces->get_glyph(unsigned(c->c));
|
||||
FT_Face face = glyph->get_face()->get_face();
|
||||
|
||||
matrix.xx = (FT_Fixed)( cos( angle ) * 0x10000L );
|
||||
|
@ -372,7 +371,7 @@ box2d<double> text_renderer<T>::prepare_glyphs(text_path *path)
|
|||
}
|
||||
|
||||
// take ownership of the glyph
|
||||
glyphs_.push_back(new glyph_t(image, properties));
|
||||
glyphs_.push_back(new glyph_t(image, c->format));
|
||||
}
|
||||
|
||||
return box2d<double>(bbox.xMin, bbox.yMin, bbox.xMax, bbox.yMax);
|
||||
|
|
|
@ -396,7 +396,6 @@ void placement_finder<DetectorT>::find_point_placement(double label_x, double la
|
|||
|
||||
double cwidth = ci.width + ci.format->character_spacing;
|
||||
|
||||
unsigned c = ci.c;
|
||||
if (i == index_to_wrap_at)
|
||||
{
|
||||
index_to_wrap_at = line_breaks_[++line_number];
|
||||
|
@ -420,7 +419,7 @@ void placement_finder<DetectorT>::find_point_placement(double label_x, double la
|
|||
double dx = x * cosa - y*sina;
|
||||
double dy = x * sina + y*cosa;
|
||||
|
||||
current_placement->add_node(c, dx, dy, rad, ci.format);
|
||||
current_placement->add_node(&ci, dx, dy, rad);
|
||||
|
||||
// compute the Bounding Box for each character and test for:
|
||||
// overlap, minimum distance or edge avoidance - exit if condition occurs
|
||||
|
@ -732,7 +731,6 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(const
|
|||
// grab the next character according to the orientation
|
||||
char_info const &ci = orientation > 0 ? info_.at(i) : info_.at(info_.num_characters() - i - 1);
|
||||
double cwidth = ci.width + ci.format->character_spacing;
|
||||
unsigned c = ci.c;
|
||||
|
||||
double last_character_angle = angle;
|
||||
|
||||
|
@ -826,9 +824,10 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(const
|
|||
render_y -= cwidth*sina + char_height*cosa;
|
||||
render_angle += M_PI;
|
||||
}
|
||||
current_placement->add_node(c,render_x - current_placement->center.x,
|
||||
current_placement->add_node(&ci,
|
||||
render_x - current_placement->center.x,
|
||||
-render_y + current_placement->center.y,
|
||||
render_angle, ci.format);
|
||||
render_angle);
|
||||
|
||||
//Normalise to 0 <= angle < 2PI
|
||||
while (render_angle >= 2*M_PI)
|
||||
|
@ -867,13 +866,13 @@ bool placement_finder<DetectorT>::test_placement(const std::auto_ptr<text_path>
|
|||
bool status = true;
|
||||
for (unsigned i = 0; i < info_.num_characters(); ++i)
|
||||
{
|
||||
//TODO: I think this can be simplified by taking the char_info from vertex() but this needs to be carefully tested!
|
||||
// grab the next character according to the orientation
|
||||
char_info const& ci = orientation > 0 ? info_.at(i) : info_.at(info_.num_characters() - i - 1);
|
||||
double cwidth = ci.width + ci.format->character_spacing;
|
||||
int c;
|
||||
char_info_ptr c;
|
||||
double x, y, angle;
|
||||
char_properties *properties;
|
||||
current_placement->vertex(&c, &x, &y, &angle, &properties);
|
||||
current_placement->vertex(&c, &x, &y, &angle);
|
||||
x = current_placement->center.x + x;
|
||||
y = current_placement->center.y - y;
|
||||
|
||||
|
|
Loading…
Reference in a new issue