From a5a5e9f3599ede4cc234daf5ba20ec9f3317a034 Mon Sep 17 00:00:00 2001 From: Jakub Valtar Date: Sun, 30 Aug 2015 23:49:58 -0400 Subject: [PATCH 1/2] Render text starting with space properly This block seems to be out of place. It is entered when the current word has zero length. It's not possible to tell whether the string fits on the line or not at this place. Besides, the same condition is already handled below. --- core/src/processing/core/PGraphics.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index 971f255e5..9ae69dcc7 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -4708,9 +4708,6 @@ public class PGraphics extends PImage implements PConstants { // boundary of a word or end of this sentence if ((buffer[index] == ' ') || (index == stop)) { // System.out.println((index == stop) + " " + wordStart + " " + index); - if (start != stop && wordStart == index) { // end of line, nothing is fitting - return false; - } float wordWidth = textWidthImpl(buffer, wordStart, index); if (runningX + wordWidth >= boxWidth) { From 840724c16ca0b33ac947a3b5f9698a734dc64c18 Mon Sep 17 00:00:00 2001 From: Jakub Valtar Date: Mon, 31 Aug 2015 00:13:48 -0400 Subject: [PATCH 2/2] Prevent exception when measuring empty string --- core/src/processing/core/PGraphics.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index 9ae69dcc7..720ff3e17 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -4708,7 +4708,11 @@ public class PGraphics extends PImage implements PConstants { // boundary of a word or end of this sentence if ((buffer[index] == ' ') || (index == stop)) { // System.out.println((index == stop) + " " + wordStart + " " + index); - float wordWidth = textWidthImpl(buffer, wordStart, index); + float wordWidth = 0; + if (index > wordStart) { + // we have a non-empty word, measure it + wordWidth = textWidthImpl(buffer, wordStart, index); + } if (runningX + wordWidth >= boxWidth) { if (runningX != 0) {