Clipping text in a shape - Wrapping text

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
Zryip TheSlug
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 163
Joined: Tue Jan 26, 2010 10:15 pm
Contact:

Clipping text in a shape - Wrapping text

Post by Zryip TheSlug » Sun Mar 29, 2015 7:23 pm

I've tried to clip a text in a rectangle and I would have expected the text would have wrapped inside the rectangle.
I do not seen a command for creating a text behaving like the svg "textarea" element.

Maybe I missed something in the documentation. If not, is there any plan to support this behavior in a future version?
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: Clipping text in a shape - Wrapping text

Post by LCMark » Mon Mar 30, 2015 9:02 am

You have a good point - the current 'fill text' syntax could do with some refinement. How about this:

To fill a text string without implicitly breaking the text into lines at a given point use:

Code: Select all

fill text <expr> [ with ( ascent | descent | baseline ) ] at <point>
By default 'point' is taken to be the left-side baseline anchor of the text. 'ascent' makes it the left-side ascent anchor (i.e. ascent above the baseline); and similarly for 'descent'.

To fill a text string with implicit breaking and alignment within a rectangle use:

Code: Select all

fill text <expr> at <alignment> of <rect>
The text will be broken into lines using the width of the rect as the layout widget. The logical size of the text, after being broken into lines, will be taken and then positioned within the rectangle with the given alignment. (Note that there is no clipping down here, the rect is just used for alignment - if you want to clip to the rect, an explicit command will be needed to set the clip).

Zryip TheSlug
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 163
Joined: Tue Jan 26, 2010 10:15 pm
Contact:

Re: Clipping text in a shape - Wrapping text

Post by Zryip TheSlug » Wed Apr 01, 2015 11:49 pm

@LCMark

Sounds great, thanks.

Btw, any chance to have the "text path" implemented?
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: Clipping text in a shape - Wrapping text

Post by monte » Thu Apr 02, 2015 1:54 am

@LCMark is there any possibility to have both vertical and horizontal alignment options when filling text within a rectangle? So <alignment> would be:

Code: Select all

 [ (top | middle | bottom) ] [( left | center | right)]
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: Clipping text in a shape - Wrapping text

Post by LCMark » Thu Apr 02, 2015 10:25 am

@monte: Hmmm - you can do 'top right', 'top left', 'bottom right', 'bottom left', 'left', 'right', 'center' - but not 'middle' it would appear. I think the 'middle' combinations are an oversight. Filed as http://quality.runrev.com/show_bug.cgi?id=15144.

Post Reply

Return to “LiveCode Builder”