Check if more than 50% of all characters are upside down. => Flip!

This commit is contained in:
Hermann Kraus 2012-08-05 15:09:33 +02:00
parent 6a27a2ae76
commit d866b7ef9d

View file

@ -300,9 +300,7 @@ bool placement_finder_ng::find_line_placements(T & path)
pp.forward(spacing/2.-layout_.width()/2.);
do
{
vertex_cache::state s = pp.save_state();
success = single_line_placement(pp, info_->properties.upright) || success;
pp.restore_state(s);
} while (pp.forward(spacing));
}
return success;
@ -311,6 +309,7 @@ bool placement_finder_ng::find_line_placements(T & path)
bool placement_finder_ng::single_line_placement(vertex_cache &pp, text_upright_e orientation)
{
vertex_cache::state s = pp.save_state();
/* IMPORTANT NOTE: See note about coordinate systems in find_point_placement()! */
text_upright_e real_orientation = orientation;
if (orientation == UPRIGHT_AUTO)
@ -360,6 +359,12 @@ bool placement_finder_ng::single_line_placement(vertex_cache &pp, text_upright_e
}
}
}
pp.restore_state(s);
if (orientation == UPRIGHT_AUTO && (upside_down_glyph_count > layout_.size()/2))
{
//Try again with oposite orienation
return single_line_placement(pp, real_orientation == UPRIGHT_RIGHT ? UPRIGHT_LEFT : UPRIGHT_RIGHT);
}
placements_.push_back(glyphs);
return true;
}