From 88131e4ccfe176fc1c967b2d7635573246ecea8b Mon Sep 17 00:00:00 2001 From: Akarshit Wal Date: Mon, 2 Feb 2015 22:40:02 +0530 Subject: [PATCH] textAlign Right print correctly --- core/src/processing/core/PGraphics.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index ab5137a86..83db7bddb 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -4549,13 +4549,12 @@ public class PGraphics extends PImage implements PConstants { if ((buffer[index] == ' ') || (index == stop)) { float wordWidth = textWidthImpl(buffer, wordStart, index); - if (runningX + wordWidth > boxWidth) { + if (runningX + wordWidth >= boxWidth) { if (runningX != 0) { // Next word is too big, output the current line and advance index = wordStart; textSentenceBreak(lineStart, index); - // Eat whitespace because multiple spaces don't count for s* - // when they're at the end of a line. + // Eat whitespace before the first word on the next line. while ((index < stop) && (buffer[index] == ' ')) { index++; } @@ -4588,8 +4587,8 @@ public class PGraphics extends PImage implements PConstants { index++; } else { // this word will fit, just add it to the line - runningX += wordWidth + spaceWidth; - wordStart = index + 1; // move on to the next word + runningX += wordWidth; + wordStart = index ; // move on to the next word including the space before the word index++; } } else { // not a space or the last character