Skip to content

Conversation

@iTutFadU
Copy link
Contributor

start can be non-zero since the method is public. Otherwise it counts newlines before the start of the actual text in range.

@Stefterv
Copy link
Contributor

Stefterv commented Sep 29, 2025

Hi @iTutFadU could you show through screenshots what this change would entail?

@iTutFadU
Copy link
Contributor Author

The text will show up at the correct height (here green) instead of counting newlines preceding it before the range (here red).

The example code:

String text = "Some\n\ntext\nwith\nnewlines";
char[] chars;
float textWidth;

void setup() {
    size(500, 500, P2D);
    textFont(createFont("Arial", 50));
    textAlign(LEFT, TOP);
    chars = text.toCharArray();
    textWidth = textWidth(text.substring(6, text.length()));
}

void draw() {
    background(20);
    
    fill(#FF5555);
    text(chars, 6, text.length(), 0, 0);
    
    fill(#55FF55);
    text(text.substring(6, text.length()), width / 2, 0);
}

@Stefterv Stefterv added this to the 4.4.11 milestone Oct 14, 2025
@Stefterv
Copy link
Contributor

Stefterv commented Feb 9, 2026

@catilac

@catilac catilac merged commit 21c2466 into processing:main Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants