From 3def606051550fbee11aa5dc92a5c5dced4585b3 Mon Sep 17 00:00:00 2001 From: Mike Wey Date: Tue, 15 Nov 2011 23:56:00 +0100 Subject: Also take the height into account when word wrapping. --- dmagick/Image.d | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dmagick/Image.d b/dmagick/Image.d index b9e727e..f407389 100644 --- a/dmagick/Image.d +++ b/dmagick/Image.d @@ -4293,6 +4293,9 @@ class Image size_t pos; string[] lines; + double lineHeight = getTypeMetrics([text[0]]).height; + size_t maxLines = cast(size_t)(boundingBox.height / lineHeight); + while ( !text.empty ) { for ( size_t i; i < text.length; i++ ) @@ -4322,6 +4325,9 @@ class Image lines ~= text[0 .. pos].strip(); text = text[min(pos+1, text.length) .. $]; pos = 0; + + if ( lines.length == maxLines ) + break; } return join(lines, "\n"); -- cgit v1.2.3