ofxTextSuite - Text wrapping and aligning

Gday. Nothing too exciting here, just a quick addon to assist in managing text blocks. Hopefully it will save someone some time.

Code: http://github.com/lukemalcolm/ofxTextSuite
Doc: http://wiki.github.com/lukemalcolm/ofxTextSuite/

Features:

* Text wrapping:

  • Area wrap and resize (fit to area)
  • Horiztonal Wrapping
  • Forced number of lines of wrap

* Text drawing alignment:

  • Left
  • Right
  • Center
  • Justified

* Independent word colouring.
* Word level access to text.

You can see it in use here:
http://blog.neonplayground.cc/vegas-visitor-book-for-the-production-company

I’ve used this mainly for displaying SMSes on screen from ofxSMS: http://forum.openframeworks.cc/t/ofxsms—an-sms-interface-for-gnokii/2954/0

This code is likely to evolve over the next little while to manage multiple fonts/styles.

Cheers,

Luke

[updated: Now moved to Github - links updated].

1 Like

That’s very useful, Luke. Thanks a lot!

GPL? ewwww.

http://www.linuxjournal.com/article/5935

Thanks for the addon, the different text wrapping is super useful!
" \n " or \r for new lines doesn’t work with the addon for me, is there a solution to create new line?

Thank you for your addon, I’m trying to use it to draw a set of 500 names.
I have two questions:

  1. The documentation say “Individual word colors can be changed by accessing the words vector directly.” What method calls that vector or how can I color and individual word inside a block?

Update 1:
I’ve tried this and the vector color seems to change, but the words are not coloured:
ofColor c;
for (int i = 0; i < 255; i++) {
c.set(i, ofRandom(255), 0, i);
myText.words[i].color.set©;
cout << myText.words[i].color << “\n”;
}

Update 2
I’ve solved the problem, the setText method was after the colouring. I changed before the individual colour changes and now it works.

Thank you

Just another question: Once I set a string to an ofxTextBlock, is there any way to locate a specific word, not just for colouring but also to retrieve that sub-string?

Thank you.

Bug: https://github.com/lukemalcolm/ofxTextSuite/issues/7

I know this is pretty old already but the link to the documentation seems to be outdated and the add-on seems to be still relevant! Would be super nice if someone could guide me to the documentation or update the link. :slight_smile:

I know this is pretty old already but the link to the documentation seems to be outdated and the add-on seems to be still relevant! Would be super nice if someone could guide me to the documentation or update the link. :slight_smile:

it appears that the project has been transferred to someone else. The repository link still works though and redirects to https://github.com/Furkanzmc/ofxTextSuite

The wiki link is broken, but you can just get there from the repository