Last insertion point of a line is ignored. Why?

I am writing a script that takes a multiline paragraph and can scale down the pointSize to fit all the text on a line that corresponds to the width of the text block.

Screen Shot 2013-08-27 at 12.33.55 PM.png

Here's how to calculate.

-J' add the length of each line to get the total width.

-calculate the percentage of scaling by dipping the width of text to the total width frame.

-several current point size with are.

Pretty simple stuff.

The issue I'm facing is that indesign makes the last character as the last point of insertion of each line. SHE IGNORES the SPACE AFTER IT. What shoul be technically the last point inseriton. So given that space cannot be calculated, it shake my whole scaling.

Screen Shot 2013-08-27 at 12.34.09 PM.png

I'm doing something wrong. Any help would be appreciated.

my code:

var frameWidth = app.selection[0].geometricBounds[3] - app.selection[0].geometricBounds[1];
var numOfLines = app.selection[0].lines.length;
var totalWidth = 0;


for (var j = numOfLines - 1; j>-1; j--) {
      if(j == numOfLines-1) {
            totalWidth = totalWidth + (app.selection[0].lines[j].insertionPoints[-1].horizontalOffset - app.selection[0].lines[j].insertionPoints[0].horizontalOffset);
      } else {
            totalWidth = totalWidth + (app.selection[0].lines[j].characters[-1].horizontalOffset - app.selection[0].lines[j].characters[0].horizontalOffset);
      }
}


var percentage = frameWidth / totalWidth;


app.selection[0].paragraphs[0].pointSize = app.selection[0].paragraphs[0].pointSize * percentage + "pt";

Use the endHorizontalOffset property.

One of the problems with text objects (which can be a blessing or a curse depending on what you happen to want to at some point) is a principle that I call "the last shall be first." This is because the last insertion of any particular text object is the same insertion point as the first of the next similar text element.

Thus, for example,.

nextPara = .paragraphs thisPara.insertionPoint [-1] [0]

One consequence of this is that the last PointInsertion of a line has two different positions, the end of a line and the beginning of the next.

Even the user interface is confused by the present. Click at the end of a story that ends with a paragraph mark and place an image. You will see that the cursor marker remains at the same insertion point, but before placing them, it is to the left of the line to which you added the image now is at the end of the previous line.

It's very odd behavior which panicked me for more than a decade now.

Dave

Tags: InDesign

Similar Questions

  • Just updated to Sierra and updated Pages at the same time. Now when I try to select a line of text I find myself with an insertion point where I stopped by selecting

    Today, I updated for Sierra and updated to the latest version of the Pages. Now I find that I am more able to select a line of text. When I try to do, I find myself with an insertion point where I stopped by selecting, but nothing is selected. This is a bug in the new version of pages or get my wrong settings?

    You use a Wacom tablet by chance?

    Solution: Press the shift key, just before stop selection. And Yes, that sounds like trouble in the Sierra.

  • Size of the text cursor (insertion point)?

    How can I control the size of the text cursor (insertion point)? The Windows setting in Accessability Options of the Panel seems to ignore Firefox.

    Try to create these two integer prefs:

    ui.caretWidth
    ui.caretBlinkTime (milliseconds;use 0 to disable blink)
    

    To open the topic: config page, type Subject: config in the address bar (address) and press the 'Enter' key, as you type the url of a Web site to open a Web site.

    If you see a warning then you can confirm that you want to access this page.

    • Use the filter at the top bar of the on: page config to more easily spot a preference.
    • Preferences that have changed also show "BOLD" (user set).
    • Preferences can be reset to the default value using the context menu if they are set of users
    • Preferences can be changed via the context menu: Edit (string or integer) or toggle (Boolean)
  • Satellite C655 - text insert point is erratic, wandering and deletes

    I'm having an erratic text insertion point.
    When you use MS Word, WordPress or other trying to hit, the text insertion point jumps around while typing.
    The result is;

    (1) what I'm typing is inserted in the text that is already written,
    (2) text is placed elsewhere in the page, or
    (3) written text is deleted - this may be a word or a whole paragraph.
    Type it is like playing a game - type you and watch where the words are placed or erasure and always complete a sentence.

    I use a Satellite C655 which I bought through BJ, Word 7, Internet Explorer and Word Starter 2010.
    I don't like this version of Word, but my drive for Word 2003 does not install because of a "missing file" - go figure.
    It installed on my new Windows 7 desktop computer.

    Any suggestions? Is it a problem that I would return to my laptop for Toshiba?
    Since I'm a writer, this problem is serious for me.

    Dave
    [email protected]

    Hello

    If your laptop uses an older version of BIOS, please update the BIOS to the latest status.
    In addition, you must disable the touchpad while typing.
    In my case, I touched the touchpad accidentally area while typing and so my cursor jumped on another line

    Welcome them

  • [JS] [CS3] Insertion point

    Hi all

    I need to get my hands on an insertion point between the 2 characters and add a few negative kerning to share characters, and on the other.

    I tried:

    myInsertion = .insertionPoints myPara.characters-[3];

    and many variations of this line, but no joy.

    Can someone help me here please?

    See you soon (as always)
    Roy

    This will set the kerning on each side of this character to a specific value:

    myPara.characters-[3].insertionPoints.everyItem () .kerningValue = - 25;

    If you want to use different values, then:

    myPara.characters-[3] .insertionPoints [0] .kerningValue = leftKern;

    myPara.characters-[3] .insertionPoints [1] .kerningValue = rightKern;

    where leftKern and rightKern contain the values you want.

    Dave

  • Insert point to appear in firefox, how can I remove it?

    Recently, I noticed that I had an insertion point to appear anywhere that I click on the browser, ill post a picture to show what he looks like, how do I get it returned?

    Try to hit the F7 key.

  • Keynote not remember last insert location

    Good day to all,

    When you insert a picture from the Photos App in Keynote (MBP), I need to access the album OK/etc to select the required photo. However, when adding additional photos or the replacement of an existing photo, taken from the album even in the Photos, I have to re-navigatre to the same album in the Photos App. Is there anyway I can get Keynote to remember the last insert/import location that I used. Re-sail again and again so is your time.

    Concerning

    Kevin

    Keynote 6.6.1 to Yosemite always shows the last used folder. If Photos, music or movies.

    Annoyingly, only a single image at a time can be imported.

  • insertion point to jump when entering

    I just bought a new hp pavilion dm4 laptop (model dm4-2180us, windows 7). whenever I type, the insertion point jumps.  I am very careful not to make any contact with the touchpad, and again he jumps.  It seems to happen whenever I type, regardless of the program.  the only change I made since I bought the laptop in Device Manager, I've restored the mouse on ps2.  I did this because the touchpad kept gel, and this is the solution recommended for this problem.  It worked, but now I have a problem with the insertion point.  I appreciate any help you can give.  Thank you!

    Please follow the steps in the order

    1. Install the latest version of the BIOS from here
    2. Go to control panel > programs and features and uninstall the Alps touchpad driver, restart the computer and install drivers touchpad update from here
  • How to move the insertion point from editText ScriptUI?

    Hello.

    How to move the insertion point from editText ScriptUI?

    Please tell me the JS code.

    Thank you.

    I don't think you can. You can control the selection of text in an editText widget, but not the position of the insertion point.

  • When I change the thickness (in points) of text/lines/etc by using the arrow icons the thickness of the line jumps instantly to 1000 pts. Why?

    ILLUSTRATOR - when I change the thickness (outline/stroke) (in points) of text/lines/etc by using the icons of arrow (upwards or downwards), the thickness of the line jumps instantly to 1000 pts. How can I adjust the settings to make this feature work, because I really need in many situations. Thanks in advance!

    1.JPG

    3.png

    koenk,

    The current pastor of the corrupt file bug/preferences units seems to be:

    (1) delete your preferences HERE (close HAVE and press Ctrl + Alt + Shift / Cmd + Option + shift during startup).

    (2) ensure that the parameters English (United States) system locale and the decimal point is. (dot/full stop, no, (comma) when the machine is restarted,)

    (3) launch HAVE again and see if the subject is cured.

    You can see a long discussion here:

    https://forums.Adobe.com/thread/1871389?q=units%20bug

  • Set/get an Insertion Point in a table cell

    I'm an iteration through the cells in a table to a series of calls to ITableCommands::SetCellText (). This written properly in cells, but I also need to set the insertion point to the first character in the cell somehow. I have the GridAddress - is - it possible to get the selection of who? (I was able to select the entire cell, but I want to get the text of her selection. Does anyone know how? Thank you.

    Bob

    I had the TextIndex of the cell using ITextStoryThread::GetTextStart.

  • Any ideas how can I insert a pdf into word, by using the option object to insert. However, the pdf file that I want to insert text and annotated lines, but once inserted comments do not appear?  any help would be greatly appreciated.

    Any ideas how can I insert a pdf into word, by using the option object to insert. However, the pdf file that I want to insert text and annotated lines, but once inserted comments do not appear?  any help would be greatly appreciated.

    You will need to find a forum for MS Word, since it is the software you are trying to manipulate in the present.  If you think that the treatment/creation of the PDF file plays a role, then you should ask in the forum for the software that you use to create the PDF file.

    This forum is for a question about downloading and installing Adobe products test, so in all circumstances, your question does not fit in this forum.

  • FOR FM10: add text at the insertion point

    Hello comrades,.

    What is the code for the current insertion point (where the cursor is placed currently?)

    I've seen code to add text at the beginning/end of FMP, but not at the current insertion point.

    Thank you in advance!

    Try using textLoc instead of TextLoc for your variable. TextLoc with this spelling is a reserved word.

  • How can I insert the insertion point in each first paragraph

    Hi all

    Please find the script, below this script will place the insertion point to the end of each paragraph, but I need to place the insertion point in the first letter of each paragraph. Help, please.

    var myDoc = app.documents.item (0)

    var myLib = app.libraries.item (0)

    app.findTextPreferences = null;

    app.changeTextPreferences = null;

    app.findChangeTextOptions.caseSensitive = false;

    app.findChangeTextOptions.includeFootnotes = false;

    app.findTextPreferences.appliedParagraphStyle = "TX"

    app.findTextPreferences.findWhat = "" ^ p ""

    var myFinds = myDoc.findText)

    for (i = 0; i < myFinds.length; i ++)

    {

    var myIcon = myLib.assets.item ("Para").placeAsset(myFinds[i].insertionPoints[0]) [0]

    myIcon.appliedObjectStyle = myDoc.objectStyles.item ("Para No")

    }

    Thanks and greetings

    Nithin

    Hi Nithin,

    Try this,

    var doc = app.activeDocument,
        myLib=app.libraries.item(0),
        _paragraphs = doc.stories.everyItem().paragraphs.everyItem().getElements(), i;
    
    for(i =_paragraphs.length-1;i>=0;i--)
    {
            if(_paragraphs[i].appliedParagraphStyle.name == "TX")
            {
                    var myIcon=myLib.assets.item("Para").placeAsset(_paragraphs[i].insertionPoints[0])[0];
                    myIcon.appliedObjectStyle=doc.objectStyles.item("Para No")
                }
        }
    

    Kind regards

    Cognet

  • Inclination of the points on a line

    Is there a way to bias points on a line so that there is a heavier concentration of points on one end and one lighter concentration on the other in InDesign?   I want the points to all be the same size.  I also want to integrate a gradient so that the end with the heaviest concentration is of a darker color than the opposite end.  I can't think anything short of creation of the oblique line of points myself in Illustrator and saving it as a brush... I feel just like there must be a way more simple than that.

    What you seem to want is a kind of logarithmic spacing coupled with a gradient background. I guess this could be scriptable, but spacing is nothing of what is available for the dotted out of the box.

Maybe you are looking for