• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Unification of textFrame style

Explorer ,
Oct 21, 2022 Oct 21, 2022

Copy link to clipboard

Copied

Hi,
I have multiple linked frames, these are the last ones - textFrame82, textFrame92.
I can't find how to set a uniform font with script, the style is carried over from previous frames.
The upper frames are already disconnected, so these lower ones don't affect it anymore.
So this doesn't work, clear style ap, i can't find.

 

textFrame82.texts[0].properties =
{
appliedFont : fonts ,
justification : Justification.FULLY_JUSTIFIED ,
pointSize : 18 ,
fillColor : doc.colors.itemByName("black") ,
lending : 20
};

 

Directions?

Thank you

Jirka

jirik79416729_0-1666387477697.png

 

TOPICS
Scripting

Views

180

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 21, 2022 Oct 21, 2022

Hi @jirik79416729, in addition to what @Robert Tkaczyk has suggested, please have a look at this script. It will give you some ideas. The key is the clearOverrides method of many text objects. You can clear paragraph style overrides or character style overrides or both.

- Mark

 

function main() {

    var doc = app.activeDocument;

    /* Example 1:
         clear overrides in selection
         (first select one or more text frames or some text)
    */
    clearTextOverridesInItems(doc.selectio
...

Likes

Translate

Translate
Advisor ,
Oct 21, 2022 Oct 21, 2022

Copy link to clipboard

Copied

AdobeScripts_0-1666391274238.png

I think it should be leading ... not sure if that will fix your problem.

 

And how about using ObjectStyle with ParaStyle ??? then you won't need to set-up so many params 😉 just one command 😉

 

Can automate anything - as long as it doesn't require A.I.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 22, 2022 Oct 22, 2022

Copy link to clipboard

Copied

Hi
If you know how to do it and how to work with it, it's easy.
I want to take the output "fonts" and make them a little bit neater after all these years.
I originally wanted to program this in Delphi, to load the font from folders. Maybe even inactive/uninstalled ones, to make it clearer where which ones are.
But I found I don't know how to start 😉 and I wonder even with things I've programmed before how I did it.
Well, the years go by and the head can't wonder anymore, what was common is no longer.
So I looked at InDesign, which I used to work in, and tried a script, unfortunately only with fonts installed, but that can be solved retrospectively, though more laboriously. (Do you have a tip for loading from a folder with uninstalled fonts?)
First, I made a page with text frames as I wanted it to look. That is, each frame has a set style, and then I had the idea of linking the frames so that the text follows. Just kind of a neat little thing, but I'm interested in the technical side of it.
Unfortunately, I don't know the details of Indesign scripting, so sometimes I ask a primitive question after a long search.
Now it was probably better to start over rather than "drive a wedge". But I found it easiest to make the last text "active" and overwrite with style.
You can't do that via textbox, parts of the text remain with the original styles.
I didn't learn Indesign scripting and couldn't find simple examples anywhere.
Thanks for the tip, but it doesn't solve anything with converting the last frames/texts to another style.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 22, 2022 Oct 22, 2022

Copy link to clipboard

Copied

So what EXACTLY is your goal? Samples of fonts? Or what?

 

Because you are another person asking "how can I get from point A to B" without giving more details 😞 what is the location of points A & B? Are you alone? Truckload of bananas? Etc. 

Can automate anything - as long as it doesn't require A.I.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 22, 2022 Oct 22, 2022

Copy link to clipboard

Copied

Yes, a sample of the fonts. So I can customize it as needed.
It would be nice if it could from folders with fonts that are not active/installed.

I was already happy with it, except for the last two boxes.
The procedure was, I filled the linked textFrames (from the first one on top), copied/divided and re-linked the last three textFrames, set the new style and copied/divided again. The split is so that when the style changes, the text doesn't get affected and bleed over into the previous textFrame. At first it worked, but the bottom two did not. I set the font there to 10b and 18b

I'm now looking at the scripting manual for InDesign ExtendScript to understand the definition of objects. But English is not my first language and it's slow going. I'm bad at it, so I prefer to translate it, writing it down for "future reference".

jirik79416729_0-1666441158242.png

jirik79416729_1-1666441189288.png

 

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 22, 2022 Oct 22, 2022

Copy link to clipboard

Copied

Wouldn't be much better - instead of linking TextFrames - keep them separated - but with more text they can fit - to always have the same text as a sample - so you can see how the same text looks like with a different font / formatting applied ? Yes, you'll have oversets but who cares?

Then - as I think you have one font style per page - just duplicate the page and re-apply formatting? You'd have to use labels to be able to "find" TFs you need to reformat - but then you'll get rid of the headache of text shifting between TFs...

You could even make your life easier - by re-formatting the same objects on the 1st page, then duplicate that page to the end of your document and then start over - this way you won't have to "find" TFs on the new page. 

Can automate anything - as long as it doesn't require A.I.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 22, 2022 Oct 22, 2022

Copy link to clipboard

Copied

Hi,
I wrote that the separate textboxes I had were fine. Then I thought of the textFrame linking, but I encountered this problem. So I'm solving it, I'm interested in it.
This automatic loading of the installed 188 fonts takes about, a minute, so this way it's cool,

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 23, 2022 Oct 23, 2022

Copy link to clipboard

Copied

I suspect that your problem may be the fact that when you increase the size of the text in a text frame, some of it will overflow into the next text frame, or if you decrease the size then some text from next text frame in the wrong size will come into this text frame. Therefore your code will have to consider this and handle it. You must imagine what each change will do to the text and the flow-on or flow-back effects.

 

In my script I had to be careful with my DOM specifiers that they referenced characters in a story (as opposed to texts in a text frame) and that the text frames were processed in correct order. I'm sorry this topic is complicated.

- Mark

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 24, 2022 Oct 24, 2022

Copy link to clipboard

Copied

Yes, it is, but this behavior is fine.
I solved this by "duplicating" the text frames, which disconnects them, deleting the original.
This leaves the frames filled with text, as they should be, and they don't affect each other.
Then I link only the ones where I want the change, and so it repeats to the last linked text frame.
However, I am failing at a simple thing and it is simple. Active box -> ALT+A and change the style of the active text box.

textFrame93.select();
textFrame93.texts[0].select();

Despite the script which is below, it still remembers different styles.
Even though "stepping" the debugger will do the job and unify the text. The next time the style is changed, everything is back, scattered.
My script is a mess right now, I'll try to understand and tweak it more over time. For now I solved it by activating the frame, shrinking the text to 1b, ?? sometimes twice and changing the style I want. It works, but it's not very nice on the code side ;-).
While directly in inDesign, just ALT+A and change the style on the active frame even with text that is outside the frame (overflows, overlaps).
Anyway, thanks for the code below, I'm still learning even if harder now. But technically I'm interested in the solution, as everything works. 😉

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 24, 2022 Oct 24, 2022

Copy link to clipboard

Copied

LATEST

@jirik79416729, you don't need to select objects to access them. In fact, IMO it is better if you don't. When you select a text frame and choose Select All (cmd-A or ctrl-A) you are selecting the parent story of the text frame, which includes all text in the text frame as well as previous or next threaded text frames, and even if the text is overset. In my script I showed this in my 2nd example with: doc.selection[0].parentStory.

 

It sounds like you are making terrific progress already, but if think of something that may help I will post it.

- Mark

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 21, 2022 Oct 21, 2022

Copy link to clipboard

Copied

Hi @jirik79416729, in addition to what @Robert Tkaczyk has suggested, please have a look at this script. It will give you some ideas. The key is the clearOverrides method of many text objects. You can clear paragraph style overrides or character style overrides or both.

- Mark

 

function main() {

    var doc = app.activeDocument;

    /* Example 1:
         clear overrides in selection
         (first select one or more text frames or some text)
    */
    clearTextOverridesInItems(doc.selection);

    /* Example 2:
       clear overrides in whole story
       (first select a text frame)
    */
    // clearTextOverridesInItems(doc.selection[0].parentStory);


    /**
     * Clears style overrides from text
     * or textFrame(s) or story.
     * @author m1b
     * @version 2022-10-22
     * @param {PageItems} items - any indesign objects with 'texts' property.
     */
    function clearTextOverridesInItems(items) {

        if (!items.hasOwnProperty('0'))
            items = [items];

        var texts = [];

        for (var i = 0; i < items.length; i++)
            if (
                items[i].hasOwnProperty('texts')
                && items[i].texts[0].isValid
            )
                // note we want hard references here, because
                // the text may reflow after clearing overrides
                texts.push(resolve(items[i].texts[0].toSpecifier()));

        for (var i = 0; i < texts.length; i++)
            texts[i].clearOverrides(OverrideType.ALL);

    };

} // end main

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Clear text overrides');

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines