Add option for selecting which text should be upright.

This commit is contained in:
Hermann Kraus 2012-08-05 01:51:42 +02:00
parent 6a7387f95e
commit 0b1c983d40
2 changed files with 32 additions and 13 deletions

View file

@ -119,6 +119,16 @@ enum justify_alignment
DEFINE_ENUM(justify_alignment_e, justify_alignment);
enum text_upright
{
UPRIGHT_AUTO,
UPRIGHT_LEFT,
UPRIGHT_RIGHT,
text_upright_MAX
};
DEFINE_ENUM(text_upright_e, text_upright);
class text_layout;
@ -169,6 +179,7 @@ struct text_symbolizer_properties
unsigned text_ratio;
unsigned wrap_width;
bool rotate_displacement;
text_upright_e upright;
/** Default values for char_properties. */
char_properties_ptr format;
private:

View file

@ -43,8 +43,6 @@ static const char * label_placement_strings[] = {
"interior",
""
};
IMPLEMENT_ENUM(label_placement_e, label_placement_strings)
static const char * vertical_alignment_strings[] = {
@ -54,8 +52,6 @@ static const char * vertical_alignment_strings[] = {
"auto",
""
};
IMPLEMENT_ENUM(vertical_alignment_e, vertical_alignment_strings)
static const char * horizontal_alignment_strings[] = {
@ -65,8 +61,6 @@ static const char * horizontal_alignment_strings[] = {
"auto",
""
};
IMPLEMENT_ENUM(horizontal_alignment_e, horizontal_alignment_strings)
static const char * justify_alignment_strings[] = {
@ -76,8 +70,6 @@ static const char * justify_alignment_strings[] = {
"auto",
""
};
IMPLEMENT_ENUM(justify_alignment_e, justify_alignment_strings)
static const char * text_transform_strings[] = {
@ -87,10 +79,19 @@ static const char * text_transform_strings[] = {
"capitalize",
""
};
IMPLEMENT_ENUM(text_transform_e, text_transform_strings)
static const char * text_upright_strings[] = {
"auto",
"left",
"right",
"capitalize",
""
};
IMPLEMENT_ENUM(text_upright_e, text_upright_strings)
text_symbolizer_properties::text_symbolizer_properties() :
orientation(),
displacement(0,0),
@ -111,6 +112,7 @@ text_symbolizer_properties::text_symbolizer_properties() :
text_ratio(0),
wrap_width(0),
rotate_displacement(false),
upright(UPRIGHT_AUTO),
format(boost::make_shared<char_properties>()),
tree_()
{
@ -171,6 +173,8 @@ void text_symbolizer_properties::from_xml(xml_node const &sym, fontset_map const
if (orientation_) orientation = *orientation_;
optional<boolean> rotate_displacement_ = sym.get_opt_attr<boolean>("rotate-displacement");
if (rotate_displacement_) rotate_displacement = *rotate_displacement_;
optional<text_upright_e> upright_ = sym.get_opt_attr<text_upright_e>("upright");
if (upright_) upright = *upright_;
optional<double> dx = sym.get_opt_attr<double>("dx");
if (dx) displacement.x = *dx;
optional<double> dy = sym.get_opt_attr<double>("dy");
@ -279,6 +283,10 @@ void text_symbolizer_properties::to_xml(boost::property_tree::ptree &node,
{
set_attr(node, "rotate-displacement", rotate_displacement);
}
if (upright != dfl.upright || explicit_defaults)
{
set_attr(node, "upright", upright);
}
format->to_xml(node, explicit_defaults, *(dfl.format));
if (tree_) tree_->to_xml(node);
}