From 2896d64302c6fc490a3be7d2b9ba9d4c4f93259a Mon Sep 17 00:00:00 2001 From: David Eisner Date: Fri, 23 Nov 2012 18:05:09 +0000 Subject: [PATCH] cairo backend: MeasureString line wrap fix When doing a DrawString using bounds given by a prior call to MeasureString, the last line would not wrap if the second-to-last was the longest. The last wrap would cause MeasureString to give a too-small bounding rectangle. --- src/text-cairo.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/text-cairo.c b/src/text-cairo.c index 617cdf490..f13d807d8 100644 --- a/src/text-cairo.c +++ b/src/text-cairo.c @@ -397,6 +397,16 @@ MeasureString (GpGraphics *graphics, GDIPCONST WCHAR *stringUnicode, int *length #ifdef DRAWSTRING_DEBUG printf("[%3d] X: %3d, Y:%3d, '%c' | ", i, (int)CursorX, (int)CursorY, CleanString[i]>=32 ? CleanString[i] : '?'); #endif + CurrentDetail->PosX=CursorX; + CurrentDetail->PosY=CursorY; + + /* Advance cursor */ + CursorX+=CurrentDetail->Width; + if (MaxXformatFlags & StringFormatFlagsNoWrap)==0) && (CurrentDetail->Flags & STRING_DETAIL_BREAK)) { if (CleanString[i] == ' ') { @@ -420,16 +430,6 @@ MeasureString (GpGraphics *graphics, GDIPCONST WCHAR *stringUnicode, int *length WrapPoint=-1; } - CurrentDetail->PosX=CursorX; - CurrentDetail->PosY=CursorY; - - /* Advance cursor */ - CursorX+=CurrentDetail->Width; - if (MaxXFrameWidth) { if (WrapPoint!=-1) {