Merge branch 'master' of github.com:mapnik/mapnik

This commit is contained in:
Dane Springmeyer 2013-02-26 12:07:53 -05:00
commit 054cb13231
10 changed files with 403 additions and 43 deletions

View file

@ -20,15 +20,16 @@
*
*****************************************************************************/
#ifndef CHAR_INFO_HPP
#define CHAR_INFO_HPP
#ifndef MAPNIK_CHAR_INFO_HPP
#define MAPNIK_CHAR_INFO_HPP
#include <boost/shared_ptr.hpp>
namespace mapnik {
struct char_properties;
class char_info {
class char_info
{
public:
char_info(unsigned c_, double width_, double ymax_, double ymin_, double line_height_)
: c(c_),
@ -36,7 +37,7 @@ public:
line_height(line_height_),
ymin(ymin_),
ymax(ymax_),
avg_height(ymax_-ymin_),
avg_height(ymax - ymin),
format()
{
}
@ -52,6 +53,8 @@ public:
{
}
double height() const { return ymax-ymin; }
unsigned c;
double width;
double line_height;
@ -59,7 +62,8 @@ public:
double ymax;
double avg_height;
char_properties *format;
double height() const { return ymax-ymin; }
};
}
#endif
#endif //MAPNIK_CHAR_INFO_HPP

View file

@ -98,12 +98,12 @@ public:
font_face(FT_Face face)
: face_(face) {}
std::string family_name() const
std::string family_name() const
{
return std::string(face_->family_name);
}
std::string style_name() const
std::string style_name() const
{
return std::string(face_->style_name);
}
@ -312,9 +312,9 @@ public:
{
std::vector<std::string> const& names = fset.get_face_names();
face_set_ptr face_set = boost::make_shared<font_face_set>();
for (std::vector<std::string>::const_iterator name = names.begin(); name != names.end(); ++name)
BOOST_FOREACH( std::string const& name, names)
{
face_ptr face = get_face(*name);
face_ptr face = get_face(name);
if (face)
{
face_set->add(face);
@ -323,7 +323,7 @@ public:
else
{
MAPNIK_LOG_DEBUG(font_engine_freetype)
<< "Failed to find face '" << *name
<< "Failed to find face '" << name
<< "' in font set '" << fset.get_name() << "'\n";
}
#endif
@ -375,11 +375,11 @@ struct text_renderer : private mapnik::noncopyable
composite_mode_e comp_op = src_over,
double scale_factor=1.0);
box2d<double> prepare_glyphs(text_path const& path);
void render(pixel_position pos);
void render_id(int feature_id, pixel_position pos, double min_radius=1.0);
void render(pixel_position const& pos);
void render_id(int feature_id, pixel_position const& pos, double min_radius=1.0);
private:
void render_bitmap(FT_Bitmap *bitmap, unsigned rgba, int x, int y, double opacity)
{
int x_max=x+bitmap->width;

View file

@ -22,7 +22,7 @@
#ifndef MAPNIK_PIXEL_POSITION_HPP
#define MAPNIK_PIXEL_POSITION_HPP
/** Store a pixel position. */
// Store a pixel position.
struct pixel_position
{
double x;

View file

@ -99,7 +99,7 @@ public:
return at(i);
}
UnicodeString const& get_string() const
UnicodeString const& get_string() const
{
return text_;
}
@ -110,10 +110,10 @@ public:
return (text_.indexOf(break_char) >= 0);
}
/** Resets object to initial state. */
void clear(void)
// Resets object to initial state.
void clear()
{
text_ = "";
text_.remove();
characters_.clear();
}
};
@ -121,7 +121,7 @@ public:
typedef char_info const * char_info_ptr;
/** List of all characters and their positions and formats for a placement. */
// List of all characters and their positions and formats for a placement.
class text_path : mapnik::noncopyable
{
struct character_node
@ -140,12 +140,12 @@ class text_path : mapnik::noncopyable
~character_node() {}
void vertex(char_info_ptr *c_, double *x_, double *y_, double *angle_) const
void vertex(char_info_ptr & c_, double & x_, double & y_, double & angle_) const
{
*c_ = c;
*x_ = pos.x;
*y_ = pos.y;
*angle_ = angle;
c_ = c;
x_ = pos.x;
y_ = pos.y;
angle_ = angle;
}
};
@ -172,7 +172,7 @@ public:
}
/** Return node. Always returns a new node. Has no way to report that there are no more nodes. */
void vertex(char_info_ptr *c, double *x, double *y, double *angle) const
void vertex(char_info_ptr & c, double & x, double & y, double & angle) const
{
nodes_[itr_++].vertex(c, x, y, angle);
}

View file

@ -252,10 +252,10 @@ occi_datasource::occi_datasource(parameters const& params)
case oracle::occi::OCCIBFLOAT:
case oracle::occi::OCCIDOUBLE:
case oracle::occi::OCCIBDOUBLE:
desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Double));
break;
case oracle::occi::OCCINUMBER:
case oracle::occi::OCCI_SQLT_NUM:
desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Double));
break;
case oracle::occi::OCCICHAR:
case oracle::occi::OCCISTRING:
case oracle::occi::OCCI_SQLT_AFC:

View file

@ -155,10 +155,10 @@ feature_ptr occi_featureset::next()
break;
case oracle::occi::OCCIDOUBLE:
case oracle::occi::OCCIBDOUBLE:
feature->put(fld_name, rs_->getDouble(i + 1));
break;
case oracle::occi::OCCINUMBER:
case oracle::occi::OCCI_SQLT_NUM:
feature->put(fld_name, rs_->getDouble(i + 1));
break;
case oracle::occi::OCCICHAR:
case oracle::occi::OCCISTRING:
case oracle::occi::OCCI_SQLT_AFC:

View file

@ -417,7 +417,7 @@ void cairo_context::add_text(text_path const& path,
char_info_ptr c;
double x, y, angle;
path.vertex(&c, &x, &y, &angle);
path.vertex(c, x, y, angle);
face_set_ptr faces = font_manager.get_face_set(c->format->face_name, c->format->fontset);
double text_size = c->format->text_size * scale_factor;

View file

@ -231,12 +231,13 @@ stroker_ptr freetype_engine::create_stroker()
return stroker_ptr();
}
char_info font_face_set::character_dimensions(const unsigned c)
char_info font_face_set::character_dimensions(unsigned int c)
{
//Check if char is already in cache
std::map<unsigned, char_info>::const_iterator itr;
itr = dimension_cache_.find(c);
if (itr != dimension_cache_.end()) {
if (itr != dimension_cache_.end())
{
return itr->second;
}
@ -351,12 +352,12 @@ box2d<double> text_renderer<T>::prepare_glyphs(text_path const& path)
bbox.xMin = bbox.yMin = 32000; // Initialize these so we can tell if we
bbox.xMax = bbox.yMax = -32000; // properly grew the bbox later
for (int i = 0; i < path.num_nodes(); i++)
for (int i = 0; i < path.num_nodes(); ++i)
{
char_info_ptr c;
double x, y, angle;
path.vertex(&c, &x, &y, &angle);
path.vertex(c, x, y, angle);
// TODO Enable when we have support for setting verbosity
// MAPNIK_LOG_DEBUG(font_engine_freetype) << "text_renderer: prepare_glyphs="
@ -436,7 +437,7 @@ void composite_bitmap(T & pixmap, FT_Bitmap *bitmap, unsigned rgba, int x, int y
}
template <typename T>
void text_renderer<T>::render(pixel_position pos)
void text_renderer<T>::render(pixel_position const& pos)
{
FT_Error error;
FT_Vector start;
@ -466,7 +467,7 @@ void text_renderer<T>::render(pixel_position pos)
FT_BitmapGlyph bit = (FT_BitmapGlyph)g;
composite_bitmap(pixmap_, &bit->bitmap, itr->properties->halo_fill.rgba(),
bit->left,
height - bit->top,
height - bit->top,
itr->properties->text_opacity,
comp_op_
);
@ -488,10 +489,10 @@ void text_renderer<T>::render(pixel_position pos)
//render_bitmap(&bit->bitmap, itr->properties->fill.rgba(),
// bit->left,
// height - bit->top, itr->properties->text_opacity);
composite_bitmap(pixmap_, &bit->bitmap, itr->properties->fill.rgba(),
bit->left,
height - bit->top,
height - bit->top,
itr->properties->text_opacity,
comp_op_
);
@ -501,7 +502,7 @@ void text_renderer<T>::render(pixel_position pos)
template <typename T>
void text_renderer<T>::render_id(int feature_id, pixel_position pos, double min_radius)
void text_renderer<T>::render_id(int feature_id, pixel_position const& pos, double min_radius)
{
FT_Error error;
FT_Vector start;
@ -540,11 +541,11 @@ void text_renderer<T>::render_id(int feature_id, pixel_position pos, double min_
boost::mutex freetype_engine::mutex_;
#endif
std::map<std::string,std::pair<int,std::string> > freetype_engine::name2file_;
template void text_renderer<image_32>::render(pixel_position);
template void text_renderer<image_32>::render(pixel_position const&);
template text_renderer<image_32>::text_renderer(image_32&, face_manager<freetype_engine>&, stroker&, composite_mode_e, double);
template box2d<double>text_renderer<image_32>::prepare_glyphs(text_path const&);
template void text_renderer<grid>::render_id(int, pixel_position, double );
template void text_renderer<grid>::render_id(int, pixel_position const& , double );
template text_renderer<grid>::text_renderer(grid&, face_manager<freetype_engine>&, stroker&, composite_mode_e, double);
template box2d<double>text_renderer<grid>::prepare_glyphs(text_path const& );
}

View file

@ -919,7 +919,7 @@ bool placement_finder<DetectorT>::test_placement(std::auto_ptr<text_path> const&
double cwidth = ci.width + ci.format->character_spacing;
char_info_ptr c;
double x, y, angle;
current_placement->vertex(&c, &x, &y, &angle);
current_placement->vertex(c, x, y, angle);
x = current_placement->center.x + x;
y = current_placement->center.y - y;

File diff suppressed because it is too large Load diff