Text alignment with line breaks?


I’m not sure if this already exists or if it would be an extension. Is there a way to align an OfTrueTypeFont that works with line breaks? I’ve done a lot of searching for this but haven’t found any solutions. There are a number of addons that have some sort of alignment but don’t work with line breaks. I even made my own addon but that broke a few months ago after some changes in the OF core.

Please let me know if there’s a way to do this. Thanks

Hi, i have this little code for make “Line breaks” (left side align based) using a width as limiter
“font_regular” is an ofTrueType.

string AgendaView::format_text_for(string _text,float _width) { string f_text = ""; string line = ""; vector<string> parts = ofSplitString(_text, " "); for(int i=0;i<parts.size();i++){ string part = parts.at(i); line = line+part; float w = font_regular.stringWidth(line); if(w < _width) { f_text+=part + " "; }else{ f_text+="\r\n" + part + " "; line = ""; } } return f_text; }

I dont know if that you are needing.