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.
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
...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.
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?
Copy link to clipboard
Copied
sorry got the answer...thank you so much
Copy link to clipboard
Copied
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
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