Skip to main content
casper_no
Known Participant
January 23, 2012
Question

Extending TLF to handle InDesign-like text wrapping, pointers?

  • January 23, 2012
  • 2 replies
  • 11770 views

Hi all,

We want to implement text wrap like you have in InDesign, ie. text wrap around an image that has a fixed position on page as opposed to floats that has a fix position in the text. I have a version that works fine as long as the objects to wrap around cover a whole column. If object to wrap around covers only part of the column, I create three containerControllers, one above, one to the side and one below. That also works. Almost. Line heights between those containers end up wrong as my containers have a fixed height and there can't be a conditional check if line fits or not. See attached image - the purple lines and fills show extents of containerControllers for debugging purposes.

I've started to dive into the source-code of TLF, and found that BaseCompose has a parcelList of Parcels that seems to be implemented with this in mind as a future expansion. From what I can work out, Parcels are sort of sub-parts of containerControlles to flow text into My idea is to somehow create my own parceList version instead of creating three containerControllers.

Anyone out there who has attempted the same? Is there future version of TLF that will include similar functionality?

This topic has been closed for replies.

2 replies

Participating Frequently
January 29, 2012

TLF will not support any float property except "left", "right" and "none". The reason for this is TLF is trying to follow W3C definition for html and CSS float. You can refer to the following document to find out how W3C define the float:http://www.w3.org/wiki/CSS/Training/floating. It makes no sense for Adobe to offer other properties for float.

Basically, if a client wanted a "text wrap". We would suggest them to use Multi-Container or re-write their own TLF -- Just like what you said. 

If you wanted to re-write your own TLF to support "text wrap". We would suggest you to take a look at BaseCompose::composeFloat and BaseCompose::calculateFloatBounds. We calculate the float knock-out rectangle there. Also, you need to take care of the Parcel::knockOut and Parcel::removeKnockOut.

We would suggest you to use a custom style to control your own knock out properties. This is how some of the Adobe internal team to implement the "text wrap" with TLF.

Hopefully, these information will be helpful.

casper_no
casper_noAuthor
Known Participant
January 31, 2012

The multi-container solution is what I've implemented already and that works quite well, but as shown above, it doesn't handle correct lineheight across containers. Which is a showstopper.

I've begun to explore the innards of TLF and found what you suggest - extending / rewriting BaseCompose to get to the Parcel class. It feels a bit shaky and I'm afraid that this solution could easily break if something changes in the next version of TLF. But quick hacks shows that Parcles can handle having knockOuts with static placement, so it looks like it might be possible to implement without having to write a Composer from scratch.

I agree that it doesn't make sense to offer more properites for "float", but I can't see that I've asked for it either.

Participating Frequently
February 2, 2012

I don't try your Multi-Container scenario. But I suggest you to try textFlowFormat.lineBreak = LineBreak.EXPLICIT.

Hope it will be helpful

casper_no
casper_noAuthor
Known Participant
January 24, 2012

I've dug into the source code some more. Floats in TLF 2.0 seems to be handled at low level by Parcel.knockOut() that looks like it defines a part of the parcel that text cannot be placed in and forces lines to be narrower. Perhaps that can be used to set similar knockOut areas for the fixed areas to wrap around?