Page 1 of 1

How to wrap a string at the edge of a rectangle?

Posted: Thu Apr 07, 2016 3:49 pm
by rabit
Implicit breaking a string into lines filling a text string seems to fail.

I used version 8.0.0-dp-16 and tried:

Code: Select all

fill text mText at top left of rectangle [0, 0, 50, 200] on this canvas
Think this is what Mark Waddingham suggested in another thread. Though the result
is that all words of a string are drawn in one line without wrapping at the edge.

For what it's worth even enforcing a multiline string by adding a new line like:

Code: Select all

put "Foo" into mText
put newline after mText
put "Bar" after mText

fill text mText at center of rectangle [0, 0, 50, 200] on this canvas
does not work as expected. The result is "Foo Bar" in one line.

Ralf

Re: How to wrap a string at the edge of a rectangle?

Posted: Fri Apr 08, 2016 10:09 am
by peter-b
The bad news is that, currently, you need to do multiline text rendering totally manually in LCB:

- Break into runs
- Draw each run using a separate call

The good news is that in the future, we'll add an API to access more high-level text layout (and text editing) capability!

Re: How to wrap a string at the edge of a rectangle?

Posted: Fri Apr 08, 2016 10:50 am
by rabit
@Peter thanks very much for the info, this helps.

Ralf