We are about to switch to a new forum software. Until then we have removed the registration on this forum.
In processing, there is a line spacing function, why there is no word spacing function, so how to change the font spacing of processing font? The picture is for reference only, haha, look forward to your reply.thank you.
Are you trying to scale the spaces -- like changing kerning -- or are you trying to create a particular effect, like full justified text?
If you don't need pixel-level control, you could replace single spaces between words with double or triple spaces, etc. -- like so:
String unspaced, spaced; void setup() { size(200, 200); unspaced = "This is a test string."; spaced = stringSpace(unspaced, 3); } void draw() { background(0); text(stringSpace(unspaced, 1), 20, 40); text(stringSpace(unspaced, 2), 20, 60); text(spaced, 20, 100); text(stringSpace(unspaced, (millis()/1000)%5), 20, 140); } String stringSpace(String s, int times) { String spaces = new String(new char[times]).replace("\0", " "); return s.replaceAll(" ", spaces); }
Thanks for your reply, this is what I need.
Answers
Are you trying to scale the spaces -- like changing kerning -- or are you trying to create a particular effect, like full justified text?
If you don't need pixel-level control, you could replace single spaces between words with double or triple spaces, etc. -- like so:
Thanks for your reply, this is what I need.