diff --git a/src/mbgl/text/collision_feature.cpp b/src/mbgl/text/collision_feature.cpp index 181875139..2a61e0b10 100644 --- a/src/mbgl/text/collision_feature.cpp +++ b/src/mbgl/text/collision_feature.cpp @@ -45,7 +45,7 @@ void CollisionFeature::bboxifyLabel(const std::vector &line, float anchorDistance = firstBoxOffset; // move backwards along the line to the first segment the label appears on - while (anchorDistance > -labelLength / 2) { + do { index--; // there isn't enough room for the label after the beginning of the line @@ -54,7 +54,7 @@ void CollisionFeature::bboxifyLabel(const std::vector &line, anchorDistance -= util::dist(line[index], p); p = line[index]; - } + } while (anchorDistance > -labelLength / 2); float segmentLength = util::dist(line[index], line[index + 1]);