Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

cairo backend: MeasureString line wrap fix #5

Open
wants to merge 1 commit into
base: mono-2-10
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/text-cairo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 (MaxX<CursorX) {
MaxX=CursorX;
MaxXatY=CursorY;
}

/* Remember where to wrap next, but only if wrapping allowed */
if (((format->formatFlags & StringFormatFlagsNoWrap)==0) && (CurrentDetail->Flags & STRING_DETAIL_BREAK)) {
if (CleanString[i] == ' ') {
Expand All @@ -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 (MaxX<CursorX) {
MaxX=CursorX;
MaxXatY=CursorY;
}

/* Time for a new line? Go back to last WrapPoint and wrap */
if (FrameWidth && CursorX>FrameWidth) {
if (WrapPoint!=-1) {
Expand Down