Open harryhow opened 8 years ago
Left alignment and centered paragraphs work well using font.drawMultiLineColumn(
.
Maybe ofxFontStash2
allows right alignment easely.
BTW I found a workaround to draw a column paragraph right aligned here with ofxFontStash
.
What we have to do is to break the text lines adding \n
previously.
That can be done using the bbox getter without drawing,
and the to draw the new string text with font.drawmMultiLineColumn(
:
string _str = "dgsdfgsdg..."; // long text without using '\n' to break lines.
float _w = 500; // variable width with adaptative text lines
if (bRightAlign) // right aligned
{
// add '\n\ to _str
{
auto __bbox = font.drawMultiLineColumn(
_str, /*string*/
_size, /*size*/
_x, _y, /*where*/
MAX(10, _w), /*column width*/
_numLines, /*get back the number of lines*/
true, /* if true, we wont draw (just get bbox back) */
20, /* max number of lines to draw, crop after that */
true, /*get the final text formatting (by adding \n's) in the supplied string;
BE ARWARE that using TRUE in here will modify your supplied string! */
&_wordsWereCropped, /* this bool will b set to true if the box was to small to fit all text*/
false /*centered*/
);
}
// draw
auto _bbox = font.drawMultiLine(
_str, /*string*/
_size, /*size*/
_x, _y, /*where*/
OF_ALIGN_HORZ_RIGHT,
MAX(10, _w) /*column width*/
);
}
Hi,
Just wondering if there's any option to draw multiple line with alignment? (e.g. center, left, right )
It might be an useful feature.
Thanks!