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

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
rabit
Posts: 40
Joined: Wed May 31, 2006 8:30 am

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

Post by rabit » Thu Apr 07, 2016 3:49 pm

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

peter-b
Posts: 182
Joined: Thu Nov 20, 2014 2:14 pm
Location: LiveCode Ltd.

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

Post by peter-b » Fri Apr 08, 2016 10:09 am

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!
LiveCode Open Source Team — @PeterTBBrett — peter.brett@livecode.com

rabit
Posts: 40
Joined: Wed May 31, 2006 8:30 am

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

Post by rabit » Fri Apr 08, 2016 10:50 am

@Peter thanks very much for the info, this helps.

Ralf

Post Reply

Return to “LiveCode Builder”