Added face_name parameter to text and shield symbolizers,

which specifies the font face to be used for rendering.
New constructor is: text_symbolizer(name, face_name, size, ...)
This commit is contained in:
vspader 2006-10-19 17:11:45 +00:00
parent 7cae55f73f
commit 118e8f0d52
8 changed files with 30 additions and 9 deletions

View file

@ -32,7 +32,7 @@ void export_shield_symbolizer()
class_<shield_symbolizer>("ShieldSymbolizer",
init<>("Default Shield Symbolizer - 4x4 black square"))
.def (init< std::string const&, unsigned, mapnik::Color const&,
.def (init< std::string const&, std::string const&, unsigned, mapnik::Color const&,
std::string const&, std::string const&,unsigned,unsigned>("TODO"))
;

View file

@ -38,7 +38,7 @@ void export_text_symbolizer()
;
class_<text_symbolizer>("TextSymbolizer",
init<std::string const&,unsigned,Color const&>())
init<std::string const&,std::string const&, unsigned,Color const&>())
.add_property("halo_fill",make_function(
&text_symbolizer::get_halo_fill,
return_value_policy<copy_const_reference>()),

View file

@ -34,6 +34,7 @@ namespace mapnik
{
explicit shield_symbolizer();
shield_symbolizer(std::string const& name,
std::string const& face_name,
unsigned size,
Color const& fill,
std::string const& file,
@ -44,6 +45,7 @@ namespace mapnik
boost::shared_ptr<ImageData32> const& get_data() const;
std::string const& get_name() const;
std::string const& get_face_name() const;
unsigned get_text_size() const;
Color const& get_fill() const;
@ -53,6 +55,7 @@ namespace mapnik
private:
std::string name_;
std::string face_name_;
unsigned size_;
Color fill_;
boost::shared_ptr<ImageData32> symbol_;

View file

@ -38,11 +38,12 @@ namespace mapnik
struct MAPNIK_DECL text_symbolizer
{
text_symbolizer(std::string const& name,unsigned size,Color const& fill);
text_symbolizer(std::string const& name,std::string const& face_name, unsigned size,Color const& fill);
text_symbolizer(text_symbolizer const& rhs);
text_symbolizer& operator=(text_symbolizer const& rhs);
std::string const& get_name() const;
unsigned get_text_size() const;
std::string const& get_face_name() const;
Color const& get_fill() const;
void set_halo_fill(Color const& fill);
Color const& get_halo_fill() const;
@ -56,6 +57,7 @@ namespace mapnik
position const& get_displacement() const;
private:
std::string name_;
std::string face_name_;
unsigned size_;
Color fill_;
Color halo_fill_;

View file

@ -331,7 +331,7 @@ namespace mapnik
if (text.length() > 0 && data)
{
face_ptr face = font_manager_.get_face("Bitstream Vera Sans Roman");//TODO
face_ptr face = font_manager_.get_face(sym.get_face_name());
if (face)
{
int w = data->width();
@ -488,8 +488,7 @@ namespace mapnik
{
Color const& fill = sym.get_fill();
face_ptr face = font_manager_.get_face("Bitstream Vera Sans Roman");//TODO
//face_ptr face = font_manager_.get_face("Times New Roman Regular");//TODO
face_ptr face = font_manager_.get_face(sym.get_face_name());
if (face)
{
text_renderer<mapnik::Image32> ren(pixmap_,face);

View file

@ -131,13 +131,15 @@ namespace mapnik
{
std::string name =
sym.second.get<std::string>("<xmlattr>.name");
std::string face_name =
sym.second.get<std::string>("<xmlattr>.face_name");
unsigned size =
sym.second.get<unsigned>("<xmlattr>.size",10);
std::string color_str =
sym.second.get<std::string>("<xmlattr>.fill","black");
Color c = color_factory::from_string(color_str.c_str());
text_symbolizer text_symbol(name,size,c);
text_symbolizer text_symbol(name,face_name, size,c);
std::string placement_str =
sym.second.get<std::string>("<xmlattr>.placement","point");

View file

@ -44,12 +44,13 @@ namespace mapnik
shield_symbolizer::shield_symbolizer(
std::string const& name,
std::string const& face_name,
unsigned size,
Color const& fill,
std::string const& file,
std::string const& type,
unsigned width,unsigned height)
: name_(name), size_(size), fill_(fill), symbol_(new ImageData32(width,height))
: name_(name), face_name_(face_name), size_(size), fill_(fill), symbol_(new ImageData32(width,height))
{
try
{
@ -67,6 +68,7 @@ namespace mapnik
shield_symbolizer::shield_symbolizer(shield_symbolizer const& rhs)
: name_(rhs.name_),
face_name_(rhs.face_name_),
size_(rhs.size_),
fill_(rhs.fill_),
symbol_(rhs.symbol_),
@ -88,6 +90,11 @@ namespace mapnik
return name_;
}
std::string const& shield_symbolizer::get_face_name() const
{
return face_name_;
}
void shield_symbolizer::set_allow_overlap(bool overlap)
{
overlap_ = overlap;

View file

@ -26,8 +26,9 @@
namespace mapnik
{
text_symbolizer::text_symbolizer(std::string const& name,unsigned size,Color const& fill)
text_symbolizer::text_symbolizer(std::string const& name, std::string const& face_name, unsigned size,Color const& fill)
: name_(name),
face_name_(face_name),
size_(size),
fill_(fill),
halo_fill_(Color(255,255,255)),
@ -38,6 +39,7 @@ namespace mapnik
text_symbolizer::text_symbolizer(text_symbolizer const& rhs)
: name_(rhs.name_),
face_name_(rhs.face_name_),
size_(rhs.size_),
fill_(rhs.fill_),
halo_fill_(rhs.halo_fill_),
@ -51,6 +53,7 @@ namespace mapnik
if (this == &other)
return *this;
name_ = other.name_;
face_name_ = other.face_name_;
size_ = other.size_;
fill_ = other.fill_;
halo_fill_ = other.halo_fill_;
@ -65,6 +68,11 @@ namespace mapnik
return name_;
}
std::string const& text_symbolizer::get_face_name() const
{
return face_name_;
}
unsigned text_symbolizer::get_text_size() const
{
return size_;