textbox size in layout

Hello,

I have alot of text which i wish to place in a layout (that I'm going to output to a pdf file) stored in various textwaves. I am trying to arrange the values in a consistent manner on a layout. Unfortunately, one of the text waves contains very long sentences and needs to be word wrapped. I have looked at the code that was posted here in 2009 http://www.igorexchange.com/node/981

However this code isnt' working for me and I think i may have found the reason but have no idea how to fix it. I'm trying to make the textboxes with size 16 font. The textbox containing the large sentences however, is being compacted to fit within the layout area. As a result of this, I think that the word wrapping code is misinterpreting the size of the text (in pixels) and therefore not placing the carraige returns in the proper places.

I'm attaching images for a test layout before and after the text wrapping is suppose to happen. While you can see that some of the text is wrapped to the following lines, the text is not the correct size (either before or after text wrapping).

Any thoughts on this? I think that if the original text box had letters of the correct size, the text wrapping might work.
Quote:
The textbox containing the large sentences however, is being compacted to fit within the layout area.


This is correct. If a textbox would overflow the page area of the layout, Igor shrinks it so it will fit.

This is a result of a decision that I made in 1989 in order to prevent a runaway textbox from causing a crash by consuming a very large (for the time) amount of memory. All layout objects (in the layout layer) are backed by offscreen bitmaps. If the object becomes very large, the offscreen bitmap can take a very large amount of memory.

In retrospect, this was a bad decision and I should have found another way to deal with the possibility of excessive memory use.

Because some people may rely on this behavior, changing it could create problems. However, we will consider changing it for Igor7.

There are two ways to fix the textbook size. Manually you can press the option or Alt key while double-clicking the textbook. Igor then sets it to 100% size.

The second way is to execute "ModifyGraph width" and "ModifyGraph height" to set the width and height to what it would be if the textbox were not shrunk. But determining the nominal width and height is not a simple matter.

A workaround is to insert carriage returns in your original textbox so that it does not overflow the page area from the start. This will prevent Igor from shrinking the textbox.

One problem with this workaround is that the WordWrapTextBox does not insert a space when it removes a carriage return. This causes words separated by a carriage return to collide when it is wrapped. I'm not sure if this is a bug in WordWrapTextBox or if it is the intended behavior.

I have attached an experiment that I used to investigate the question you raised.

It seems to me that the WordWrapTextBox function is doing the right thing. If I create a textbox, wrap it to a given width (say 300), manually shrink it, and wrap it again to the same width, the wrapping remains unchanged.

I'm not sure why, when I tell WordWrapTextBox to use a wrapWidth of 300, I wind up with a 243 point wide textbox. If I wound up with a 300 point wide textbox then the shrinking could be undone by executing:
ModifyLayout width(text0)=300



Here is a possible fix for the problem of words colliding when a carriage return is removed. I'm not sure if the fix has bad side effects though:
    #if 1
        // This is the original code
        // Kill old carriage returns.  
        textStr=ReplaceString("\r",textStr,"")
    #else
        // This fixes the problem of words colliding where a carriage return was removed
        // Replace old carriage return with a space
        textStr=ReplaceString("\r",textStr," ")
    #endif


Change "#if 1" to "#if 0" to try my fix.
[quote=hrodstein][quote]
ModifyLayout width(text0)=300



For the moment, I have implemented a fix like that you've indicated above. Unfortunately, this causes a stretched textbox in the rare (but not uncommon event) that the original text box was the correct size (say if instead of a large sentence, only a few words are present). So for the short term, I will just impliment the modifyLayout width fix to the mass majority, manually fixing those that didn't work.

I will try your recommendation for adding, then removing, carriage returns next week.

Thanks alot for your response