From 5c11bcf5c0dbe3975a50ec333b5fdac689a73ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 24 Mar 2014 17:15:54 +0100 Subject: [PATCH] don't treat negative values as placement failure --- include/llmr/text/types.hpp | 7 ++++++- src/text/placement.cpp | 5 ++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/llmr/text/types.hpp b/include/llmr/text/types.hpp index 2e363e102..91c4bbe28 100644 --- a/include/llmr/text/types.hpp +++ b/include/llmr/text/types.hpp @@ -99,7 +99,12 @@ struct PlacementProperty { explicit PlacementProperty(float zoom, const PlacementRange &rotationRange) : zoom(zoom), rotationRange(rotationRange) {} - float zoom = -1.0f; + inline operator bool() const { + return !isnan(zoom) && zoom != std::numeric_limits::infinity() && + rotationRange[0] != rotationRange[1]; + } + + float zoom = std::numeric_limits::infinity(); PlacementRange rotationRange = {{0.0f, 0.0f}}; }; diff --git a/src/text/placement.cpp b/src/text/placement.cpp index be329eda3..852236b71 100644 --- a/src/text/placement.cpp +++ b/src/text/placement.cpp @@ -305,10 +305,9 @@ void Placement::addFeature(TextBucket& bucket, PlacementProperty place = collision.place(glyphs, anchor, anchor.scale, maxPlacementScale, padding, horizontal); - - if (place.zoom >= 0.0f) { + if (place) { bucket.addGlyphs(glyphs, place.zoom, place.rotationRange, - zoom - zOffset); + zoom - zOffset); } } }