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

script for finding the font indices

Community Beginner ,
Jun 03, 2020 Jun 03, 2020

Copy link to clipboard

Copied

fonts of a text frame are associated with the index or something like position of text. the problem is that when i replace a frame with another text the other text takes the same font as the original text in text frame(because fonts are assigned on the basis of locaation).how can i keep a track that this font is there in this bound and how can i retain the font of replaced text instead of default assignment to the font of original text.actulally i want to ask is that how can i get the area range of given font so that i can do some manipulations or hiow can i maintain the font of replaced text.

TOPICS
Scripting

Views

701

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 , Jun 04, 2020 Jun 04, 2020

Not sure I quite understand the question, but you can capture the applied font of text objects with obj.appliedFont, ie: 

var currFont = app.activeDocument.textFrames[0].texts[0].appliedFont;

You can also use app.findGrep() to find all sets of text with a particular font and replace it with a different font: 

 

app.findTextPreferences = NothingEnum.NOTHING; 
app.findTextPreferences.appliedFont = "Font to find"; 
var myFinds = app.findText(); //returns an array of Text objects that match the font.

 

So

...

Votes

Translate

Translate
Community Expert ,
Jun 04, 2020 Jun 04, 2020

Copy link to clipboard

Copied

Not sure I quite understand the question, but you can capture the applied font of text objects with obj.appliedFont, ie: 

var currFont = app.activeDocument.textFrames[0].texts[0].appliedFont;

You can also use app.findGrep() to find all sets of text with a particular font and replace it with a different font: 

 

app.findTextPreferences = NothingEnum.NOTHING; 
app.findTextPreferences.appliedFont = "Font to find"; 
var myFinds = app.findText(); //returns an array of Text objects that match the font.

 

So, you can store the existing font in a variable, change some text, then apply the stored font to the changed text. Of course, using Paragraph and Character Styles is much more flexible and powerful, and the better way to go. 

Votes

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 Beginner ,
Jun 05, 2020 Jun 05, 2020

Copy link to clipboard

Copied

var currFont = app.activeDocument.textFrames[0].texts[0].appliedFont;
this line is giving currFont value as [object Font] but how to find exact font that is applied on text?

Votes

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 Beginner ,
Jun 05, 2020 Jun 05, 2020

Copy link to clipboard

Copied

sorry got the answer...thank you so much 

Votes

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 ,
Jun 06, 2020 Jun 06, 2020

Copy link to clipboard

Copied

LATEST

You should read about textstyleranges and insertionpoints. See an example where its discussed how to change formatting in a section of text. This shows the use of the insertionPoints collection

https://community.adobe.com/t5/indesign/lt-indesign-gt-script-to-change-font-partly-with-javascript/...

textStyleRanges can be considered as a continous block of text that has the same formatting, so a paragraph can have multiple textStyleRanges or a single, depending upon if it has style overrides or has character styles applied over its text.

 

-Manan

 

Votes

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