From d0f3acb581f7c0d5cf03e029e82ce38a4a9a4592 Mon Sep 17 00:00:00 2001 From: Hermann Kraus Date: Sat, 4 Aug 2012 02:22:05 +0200 Subject: [PATCH] Implement minimum-padding and avoid-edges. --- src/text/placement_finder_ng.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/text/placement_finder_ng.cpp b/src/text/placement_finder_ng.cpp index 9d99416ef..15aae463b 100644 --- a/src/text/placement_finder_ng.cpp +++ b/src/text/placement_finder_ng.cpp @@ -183,12 +183,20 @@ bool placement_finder_ng::find_point_placement(pixel_position pos) rotated_box2d(bbox, sina_, cosa_, layout_.width(), layout_.height()); bbox.re_center(glyphs->get_base_point().x, glyphs->get_base_point().y); - if (!detector_.extent().intersects(bbox) || + if (!detector_.extent().intersects(bbox) + || + (info_->properties.avoid_edges && !extent_.contains(bbox)) + || + (info_->properties.minimum_padding > 0 && + !extent_.contains(bbox + (scale_factor_ * info_->properties.minimum_padding))) + || (!info_->properties.allow_overlap && - !detector_.has_point_placement(bbox, info_->properties.minimum_distance * scale_factor_))) + !detector_.has_point_placement(bbox, info_->properties.minimum_distance * scale_factor_)) + ) { - return false; //Not enough space for this text + return false; } + detector_.insert(bbox, layout_.get_text()); /* IMPORTANT NOTE: