Copy link to clipboard
Copied
Hi All,
My question is how to find and select all text elements with the same font in whole document ?
For example I want to find and select all words in Century font on given layer ?
From inside the program or by the script.
Thank you,
Hi, Try following
var temp = app.activeDocument.textFrames.add();
temp.contents = "Temp";
temp.textRange.textFont = app.textFonts.getByName('ArialMT'); // Replace ArialMT with your font name here
app.executeMenuCommand('Find Text Font Family menu item');
temp.remove();
This will select all textframes with font ArialMT.
Copy link to clipboard
Copied
Hi, Try following
var temp = app.activeDocument.textFrames.add();
temp.contents = "Temp";
temp.textRange.textFont = app.textFonts.getByName('ArialMT'); // Replace ArialMT with your font name here
app.executeMenuCommand('Find Text Font Family menu item');
temp.remove();
This will select all textframes with font ArialMT.
Copy link to clipboard
Copied
There can be different ways to select the textframe on a given layer. What I am following here is to locked all other layers and then select required textframes and then unlock the locked layers.
var _layerName = 'Layer 1'; // Use your layer name on which you want to select the textframes;
var doc = app.activeDocument;
for (var l = 0; l < doc.layers.length; l++) {
if (doc.layers[l].name != _layerName) {
doc.layers[l].locked = true;
}
}
var temp = doc.layers[_layerName].textFrames.add();
temp.contents = "Temp";
temp.textRange.textFont = app.textFonts.getByName('ArialMT'); // Replace ArialMT with your font name here
app.executeMenuCommand('Find Text Font Family menu item');
temp.remove();
for (var l = 0; l < doc.layers.length; l++) {
if (doc.layers[l].name != _layerName) {
doc.layers[l].locked = false;
}
}
Above script need more handling if in case some layers are alreday locked before running the script.
Copy link to clipboard
Copied
As @Charu Rajput already wrote in her good answer.
But I am afraid that this approach, as good as it may be, is not suitable for you because your question is too general, a more detailed explanation, screenshots and/or example file is completely missing.
Please give us more detailed information about the structure of your document, the paragraph and character style used, the layer hierarchy in the document and the hierarchy of elements in the layer. Should only characters or words or sentences or paragraphs or whole text frames be found? What should be done with the elements found (--> think forward)?
Your level of knowledge and whether you can write scripts yourself and need a little help or whether you need someone to write a script for you.
Copy link to clipboard
Copied
OK, so I will give some more info. Usually I insert as little information as possible to not make mess in question and thinking process.
The best will be file.
It is a map (well, one of many), and you see different text elements. Some connected with waters (blue), some with settlements (black) and so on.
I want select only blue (water elements). These are Century fonts.
And I doubt it is a text frame, because they are text on paths (?)
Thanks,
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Ok. Thank you for the example file.
Most of the (blue) fonts for the rivers are actually type on a path. The way described by @CarlosCanto works for the simultaneous selection of all fonts of the same type. That is why I have not tested the script from @Charu Rajput.
Copy link to clipboard
Copied
Ahh, AI 2022. So I have old Illustrator (2020). I was wondering what I was missing 🙂
Copy link to clipboard
Copied
EDIT: I see, AI Toolbox.
So it's done.
Thank you all for help 🙂