16 Replies Latest reply on Oct 2, 2008 10:17 PM by Thomas B. Nielsen

    SCRIPT alerting me about excessive tracking of text ??

    Level 1
      hello iam working on a 600 pages book

      and to squeeze all the text onto specific pages i had to do some crazy tracking of the text like +/- 25 now i would like to review the most tracked paragraphs if i can do some manual tweaking of them etc.

      I know i can highlight "custom tracking/kerning" paragraphs in preferences but iam only interested about extreme cases of tracked paragraphs...

      is there script that would tell me anyhow which paragraphs are tracked "more than +/- 8" for example so i can concentrate only on the worst cases with tracking bigger than +/- 8
        • 1. Re: SCRIPT alerting me about excessive tracking of text ??
          Level 1
          Hello Rosta,

          I have made a script that should do the requested.

          Please have the following in mind:
          - The script DELETES any XML data you may have in your document!
          - The script marks each paragraph with tracking above 8 or below -8, with a XMLelement
          - I'm no pro at scripting :-) - but i would love to learn, so please everyone feel free to comment on the script
          - so do not run the script on your original document at first ;-)

          The script can be found here:
          http://www.nobrainer.dk/marker-store-spatierings-vaerdier/
          Just click the script icon or the filename.

          Hope this will help you in some way.
          • 2. Re: SCRIPT alerting me about excessive tracking of text ??
            Level 1
            A W E S O M E

            exactlly what i needed

            very elegant way too

            THANKS
            • 3. Re: SCRIPT alerting me about excessive tracking of text ??
              Thomas B. Nielsen Level 3
              Thx Rosta :-),

              Glad you could use the script.
              • 4. Re: SCRIPT alerting me about excessive tracking of text ??
                Level 1
                IT HELPED ME IMMENSELY

                one thing though that could be improved (every script can be improved :D) is this:

                when i uniformlly track a paragrpah +/- 8 it highlights that paragraph... cool

                but when i track only a single line of the praragraph +/- 8 the paragraph doesnt get spotted / highlited...

                nevertheless it did the job PERFECTLLY and i improved my project on several pages which i spoted with this script

                THANKS AGAIN
                • 5. Re: SCRIPT alerting me about excessive tracking of text ??
                  Thomas B. Nielsen Level 3
                  I know that the script is "limited" to paragraphs, it's easy to change though, both for lines, words and so on - BUT that would also mean a significant increse in xmlElements you will have to go through.

                  Perhaps it's possible to compare tracking for all words in a paragraph, if tracking is the same for all words/chars mark the paragraph else if they differ, then mark each words/set of characters that has +/-8 in tracking?
                  • 6. Re: SCRIPT alerting me about excessive tracking of text ??
                    Level 1
                    could you make a modifcation that would track down words with +/- 8 tracking ?

                    I could not program it myself but iam still working on the book and would really appreciate this extra level of check... down to words

                    I would than use both script the paragraph level first than the word level modification
                    • 7. Re: SCRIPT alerting me about excessive tracking of text ??
                      Level 1
                      Hi Rosta,

                      The below script will mark all words with tracking > +/-8.

                      http://www.nobrainer.dk/marker-store-spatierings-tracking-vaerdier-paa-ord/

                      Note: That means a lot of tags! I know it's possible to do this smarter (combining the two scripts) I just need to figure out how :-) will look at it.
                      In the meantime, you should be able to use the above.
                      • 8. Re: SCRIPT alerting me about excessive tracking of text ??
                        Level 1
                        A combined version
                        http://www.nobrainer.dk/kombineret-spatierings-tracking-markering/

                        Marks all paragraphs with +/-8 tracking, and searches all other paragraphs for words with +/-8 tracking and marks them if any.

                        Would love to see how this would be done by a pro - thinking there most be some way of marking the section of a text that has an equal tracking above +/-8, instead of having to mark each word individually.
                        • 9. Re: SCRIPT alerting me about excessive tracking of text ??
                          [Jongware] Most Valuable Participant
                          Well, although I'd hardly call me-self a "pro", how about using textStyleRanges? I'm wondering how using XML to mark stuff works, I'm used to putting stuff in color -- see the "Overtracked" swatch this one creates. When done checking tracking, or when sufficiently bored with it, delete the "Overtracked" swatch and replace with Black. (Obviously, if Text Color is an important element of your layout, you should not use this!)<br /><br />Click in a story and run the script. It may take a while, as in a long story there may be thousands of textstyleranges.<br /><br /><pre>theTextR = app.selection[0].parentStory.textStyleRanges;<br /><br />app.activeDocument.colors.add ({name:"Overtracked",space:ColorSpace.RGB,colorValue:[255,0,0]});<br /><br />var i=0;<br /><br />while (i<theTextR.length)<br /><br />{<br /><br />   if (theTextR[i].tracking < -8 || theTextR[i].tracking > 8 )<br /><br />   {<br /><br />      while (i<theTextR.length && (theTextR[i].tracking < -8 || theTextR[i].tracking > 8 ))<br /><br />      {<br /><br />         theTextR[i].fillColor = "Overtracked";<br /><br />         i++;<br /><br />      }<br /><br />   } else<br /><br />      i++;<br /><br />}</pre>
                          • 10. Re: SCRIPT alerting me about excessive tracking of text ??
                            Thomas B. Nielsen Level 3
                            Thanx jongware,

                            textStyleRanges was what i knew i needed, but didn't know where to find ;-)
                            I have made a comibined script, that:
                            - Uses the "textStyleRanges" method to identify texts that have "overtracking".
                            - marks every text that is "overtracked" with a XMLelement

                            The script can be downloaded here:
                            http://www.nobrainer.dk/marker-store-spatierings-vaerdier/

                            That should do exectly what you need Rosta.
                            • 11. Re: SCRIPT alerting me about excessive tracking of text ??
                              [Jongware] Most Valuable Participant
                              Ah -- Thomas, you didn't catch a small 'improvement' -- which I implemented because I wanted to <br />i see <br />the selection.<br /><br /><pre>while (i<theTextR.length && (theTextR[i].tracking < minValue || theTextR[i].tracking > maxValue )) { <br />   //theTextR[i].fillColor = "Overtracked"; <br />     myXMLElement = myStoryElement.xmlElements.add(myXMLTag, theTextR[i]);<br />   i++;<br />} else<br />  i++;</pre><br /><br />The idea of this was to select the range <br />i and then<br />all following ones with the same over/undertracking into a single selected string. It wasn't necessary using fillColor, it was much easier to just<br /><br /><pre>if (i<theTextR.length && (theTextR[i].tracking < minValue || theTextR[i].tracking > maxValue ))<br />   theTextR[i].fillColor = "Overtracked"; <br />i++;</pre><br /><br />If you want consecutive runs of 'bad' tracking concatenated into a single XML run, you can use the 'while' construction and then use itemByRange (or something similar).<br /><br />I'm very pleased with my version, as now I'm <br />i finally <br />able to easily search for "not" text; for example, just now I needed to check which Word imported text had a baseline shift, i.e.,  "theTextR[i].baselineshift != 0". It doesn't run eye-blinking fast, but it catches them all.
                              • 12. Re: SCRIPT alerting me about excessive tracking of text ??
                                Thomas B. Nielsen Level 3
                                Hello jongware,

                                Thank you for taking you time to explain this to me.

                                >Ah -- Thomas, you didn't catch a small 'improvement' -- which I implemented because I wanted to see the selection.

                                I'm not sure i understand this, by "I wanted to see the selection" are you referring to me out commenting the "theTextR[i].fillColor = "Overtracked";" ? I just choose another "path", to use XMlelements which, when clicked, takes you to the text and selects it. (Unubstructive mark up)

                                >If you want consecutive runs of 'bad' tracking concatenated into a single XML run, you can use the 'while' construction and then use itemByRange (or something similar).

                                Could you make me a small example? I would really appriciate to learn new (and properbly more correct) ways of scripting.
                                • 13. Re: SCRIPT alerting me about excessive tracking of text ??
                                  [Jongware] Most Valuable Participant
                                  Nonono, not needed for fillColor. I wanted to see the stuff <br />i selected.<br />That's easy enough for a single TextStyleRange (just do "theTextR[i].select()"), but the text with bad tracking may consist of multiple text runs -- for example, a word inside may be italic, or you may have a run of text with tracking -10, then with tracking +10. The following selects <br />b all<br />of the bad stuff, no matter what lies inbetween, as a single selection.<br /><br /><pre>theTextR = app.selection[0].parentStory.textStyleRanges;<br /><br />var i=0;<br /><br />while (i<theTextR.length)<br /><br />{<br /><br />   if (theTextR[i].tracking < -8 || theTextR[i].tracking > 8 )<br /><br />   {<br /><br />      theTextR[i].select(SelectionOptions.REPLACE_WITH);<br /><br />      i++;<br /><br />      while (theTextR[i].tracking < -8 || theTextR[i].tracking > 8 )<br /><br />      {<br /><br />         theTextR[i].select(SelectionOptions.ADD_TO);<br /><br />         i++;<br /><br />      }<br /><br />      break;<br /><br />   } else<br /><br />      i++;<br /><br />}</pre><br /><br />(Note the "break" that exits the main loop. This sample will only find and select the first occurrence.)<br /><br />With your code, every time some other attribute than tracking is changed (or even when the tracking value itself is changed), it'll create a new XML element. You can't use the 'select' function for that, but you can "convert" the runs to a single object ready for marking using<br /><br /><pre>   start = i;<br />   i++;<br />   while (theTextR[i].tracking < -8 || theTextR[i].tracking > 8 )<br />      i++;<br />   (yourStuff) = theTextR[start].parent.textStyleRanges.itemByRange (theTextR[start].index, theTextR[i].index);</pre><br /><br />-- which probably could be written a bit more clearly :-) That last line selects the parent of a text style range (a Story), then its TextStyleRanges, then any Range inside of that from "start" to "i".
                                  • 14. Re: SCRIPT alerting me about excessive tracking of text ??
                                    Thomas B. Nielsen Level 3
                                    Once again thank you for explaining jongware.

                                    Updated my script at http://www.nobrainer.dk/marker-store-spatierings-vaerdier/ to put textStyleranges with +/-8 tracking in same xmlElement.
                                    • 15. Re: SCRIPT alerting me about excessive tracking of text ??
                                      [Jongware] Most Valuable Participant
                                      Excellent!
                                      This is a great way to search for "not" text attributes (such as baseline shift != 0", font size != 10), or for "inbetween values", such as the tracking values it checks now. It only needs a very minor adjustment in the code to check for other types and/or values (i.e., "pointSize").

                                      A couple o'questions back: why use XML? Don't you use that in your documents? (I do, I don't want to add. Hence my using fillColor. Besides, you can
                                      i search
                                      for the fillColor, and remove all marks by just deleting the swatch.)

                                      And, what's that "TO DO"? Only Danish I know is the one you eat ;-)
                                      • 16. Re: SCRIPT alerting me about excessive tracking of text ??
                                        Thomas B. Nielsen Level 3
                                        >This is a great way to search for "not" text attributes (such as baseline shift != 0", font size != 10), or for "in between values", such as the tracking values it checks now. It only needs a very minor adjustment in the code to check for other types and/or values (i.e., "pointSize").

                                        >A couple o'questions back: why use XML? Don't you use that in your documents? (I do, I don't want to add. Hence my using fillColor. Besides, you can search for the fillColor, and remove all marks by just deleting the swatch.)

                                        No mostly we don't use XML, but for some of my tasks I do. But my main concern is not to add changes to the actual content.
                                        But I do agree with you, in many cases the fillColor method is a better way.

                                        >And, what's that "TO DO"? Only Danish I know is the one you eat

                                        The to do in English: Add a userinterface/dialog to choose other search values and other "searches" than for tracking (ie fontSize).
                                        So actually the same as you have been thinking :-)
                                        I think I will also make it possible to choose the markup method (fillColor/XML/scriptLabel or some other unobstructive way of marking)

                                        BTW: I really appriciate the help getting better at this Indesign Scripting, think it's greeeeaaaaattt but i'm no real "scripter" just a graphic designer :-)