Skip navigation
libarth1212
Currently Being Moderated

text overflow + postFix

Mar 18, 2011 8:11 AM

Hi,

 

Is there a way to select textframes containing text that overflows and to resize the frame to stop the overflow?

 

What is the use of the postFix parameter in the areaText and pathText method ?

 

Regards,

Lionel Barth

 
Replies
  • Currently Being Moderated
    Mar 21, 2011 5:29 PM   in reply to libarth1212

    first, I wrote below code. It is really you wanted, but I think you can reference it.

    var slct = app.activeDocument.textFrames[0];
    var plen = slct.paragraphs[0].length;
    var hlen = slct.story.lines[0].length;
    var hscale = paragraphs[0].scaling;
    var step = 0.01;
    while (plen != hlen) {
        slct.paragraphs[0].scaling = [hscale,1];
        hlen = slct4.story.lines[0].length;
        hscale -= step;
        }

     

    We can detect overflows, comparing lines and paragraphs properties.

    linesandparagraphs.png


    second,
    We can make threaded textFrames, use baseFrame property. And normally, add to after baseFrames.
    When we set postFix to true, areaText add to after baseFrame. See below.

     


    var bf = app.activeDocument.selection[0];
    var a=app.activeDocument.pathItems.rectangle (-100,100,100,100);
    var b = app.activeDocument.textFrames.areaText(
        a,
        TextOrientation.HORIZONTAL,
        baseFrame=bf ,
        postFix=true
        );

     

    addafter.png

    *upper frame is baseFrame.

     

     

     

    var bf = app.activeDocument.selection[0];
    var a=app.activeDocument.pathItems.rectangle (-100,100,100,100);
    var b = app.activeDocument.textFrames.areaText(
        a,
        TextOrientation.HORIZONTAL,
        baseFrame=bf ,
        postFix=false
        );

     

    false mean preFix, like below image.

    addbefore.png

    *upper frame is baseFrame.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 27, 2011 8:47 PM   in reply to libarth1212

    OK Lionel, check below script.

     

    //overflow control.
    var counter = 0;
    slct = app.activeDocument.selection[0];
    cntsLength = getChars(slct);
    visibleChar =getVisible(slct);
    var vscale = 1.0;
    stepNum = 0.02;
    while (cntsLength != visibleChar) {
        scalingWidth(slct, [vscale,1]);
        visibleChar =getVisible(slct);
        vscale = vscale-stepNum;
        }

     


    function getVisible(txObj){
        var result=0;
        for (var i=0;i<txObj.lines.length;i++){
            result += txObj.lines[i].characters.length;
            }
        return result;
        }

     

    function getChars(txObj){
        var result=0;
        for (var i=0;i<txObj.paragraphs.length;i++){
            result += txObj.paragraphs[i].characters.length;
            }
        return result;
        }

     

    function scalingWidth(txObj,wscl){
        for (var i=0;i<txObj.paragraphs.length;i++){
            txObj.paragraphs[i].scaling = wscl;
            redraw();
            }
        }

     


    This time we fit contents to textFrame, press contents width.

     


    scaling property is an array. It contain horizontalScale and verticalScale.

     

    scaling = [horisontalScale, verticalScale] (0 to 1)

     

    If you want set to 100% width and height...

     

    scaling = [1, 1];

     


    Illustrators OMV sometimes do not written I really wanted to. So I try to check properties myself.

     

    Ten wrote.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 28, 2011 11:16 AM   in reply to libarth1212

    Excellent script been looking for exactly this  for a while now. Well done mate.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 7, 2011 8:56 AM   in reply to MadMich

    Can this script be modified to prevent the text from Horizontally scaling below 70%?. And maybe continue scaling both vertical and horizontally to fit box?

    Then as a warning I could highlight the field with a unique colour if this is possible.

     

    Thanks in advance

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points