Exemplo n.º 1
0
void layout_node::apply(evaluated_format_properties_ptr const& p, feature_impl const& feature, attributes const& vars, text_layout & parent) const
{
    text_layout_properties new_properties(parent.get_layout_properties());
    if (dx) new_properties.dx = *dx;
    if (dy) new_properties.dy = *dy;
    if (text_ratio) new_properties.text_ratio = *text_ratio;
    if (wrap_width) new_properties.wrap_width = *wrap_width;
    if (wrap_char) new_properties.wrap_char = *wrap_char;
    if (wrap_before) new_properties.wrap_before = *wrap_before;
    if (repeat_wrap_char) new_properties.repeat_wrap_char = *repeat_wrap_char;
    if (rotate_displacement) new_properties.rotate_displacement = *rotate_displacement;
    if (orientation) new_properties.orientation = *orientation;
    if (halign) new_properties.halign = *halign;
    if (valign) new_properties.valign = *valign;
    if (jalign) new_properties.jalign = *jalign;

    // starting a new offset child with the new displacement value
    // we pass a null format tree since this is not the parent but a child
    text_layout_ptr child_layout = std::make_unique<text_layout>(parent.get_font_manager(),
                                                                 feature,
                                                                 vars,
                                                                 parent.get_scale_factor(),
                                                                 parent.get_default_text_properties(),
                                                                 new_properties,
                                                                 formatting::node_ptr());
    // process contained format tree into the child node
    if (child_)
    {
        child_->apply(p, feature, vars, *child_layout);
    }
    else
    {
        MAPNIK_LOG_WARN(format) << "Useless layout node: Contains no text";
    }
    parent.add_child(std::move(child_layout));
}