Copy link to clipboard
Copied
Hello,
I'm doing a specimen and I need to write out all of the styles of one font.
I have Sans Regular, Italic, Bold, Medium etc. and I need to write them and then individually select them and change them to the style its refering to.
Is there any other way to do this? For example like selecting the font and "Write out and style the family of selected font" option?
It's taking way too long...
Thanks!
1 Correct answer
In conclusion:
If you wanted to try this, this is the script from https://yourscriptdoctor.com/displaying-font-family-members/ but put in javascript. You can make your own script from this and it works wonders!
How to install texts scripts here:
https://creativepro.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-post/
try {
var userFont = getFontName();
var doc = app.activeDocument;
var defaultStyle = doc.textDefaults.appliedParagraphStyle;
defaultStyle.po
...
Copy link to clipboard
Copied
There are websites that list all styles of a font family.
Copy link to clipboard
Copied
Yes, I copied the names of the styles. But I want them to be in the style they're named.
Now i'm selecting each text and making it the style it's named. But The font has 43 styles and it's taking too long.
Copy link to clipboard
Copied
So you want to have a "sample style sheet"?
Copy link to clipboard
Copied
I'm not sure... but thank you.
I'm sending an example of what i need:
First picture is when i copy the names of styles. It's all in one style.
Second picture is the result of what I'm doing.
It's like if you wanted to see all the styles of the one font family, how it looks like.
Copy link to clipboard
Copied
Right, so you have styles NAMED - but now you want them to by styled this way?
Or those are just texts?
Copy link to clipboard
Copied
Yes! Exactly.
Copy link to clipboard
Copied
Yes! Exactly.
By Le Kozis
For now, I've only found Mac version of the script:
https://yourscriptdoctor.com/displaying-font-family-members/
Copy link to clipboard
Copied
That's it! I'm gonna try this. Thank you!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
It's like if you wanted to see how the individual styles of the font family look like. But listed with the name of the style.
Copy link to clipboard
Copied
It's not the font you're looking for - just how it previews:
https://fonts.adobe.com/fonts/ten-oldstyle#fonts-section
But it's here:
https://www.stormtype.com/families/anselm-serif
Copy link to clipboard
Copied
In conclusion:
If you wanted to try this, this is the script from https://yourscriptdoctor.com/displaying-font-family-members/ but put in javascript. You can make your own script from this and it works wonders!
How to install texts scripts here:
https://creativepro.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-post/
try {
var userFont = getFontName();
var doc = app.activeDocument;
var defaultStyle = doc.textDefaults.appliedParagraphStyle;
defaultStyle.pointSize = 10;
defaultStyle.leading = 16;
// Find fonts matching input
var fontList = [];
var fonts = app.fonts.everyItem().getElements();
for (var i = 0; i < fonts.length; i++) {
if (fonts[i].name.toLowerCase().indexOf(userFont.toLowerCase()) !== -1) {
fontList.push(fonts[i].name);
}
}
if (fontList.length === 0) {
throw "No fonts found containing \"" + userFont + "\"";
}
if (app.selection.length === 0 || !(app.selection[0] instanceof TextFrame)) {
throw "Requires text frame selection in InDesign document";
}
var selItem = app.selection[0];
var str = "";
for (var i = 0; i < fontList.length; i++) {
str += fontList[i] + "\r";
}
selItem.contents = str;
var paras = selItem.paragraphs;
for (var i = 0; i < paras.length; i++) {
var fontName = paras[i].contents.replace(/\r$/, ""); // remove line break
try {
paras[i].appliedFont = fontName;
paras[i].pointSize = 16;
} catch (e) {
// Fallback: skip applying font if not available
$.writeln("Could not apply font: " + fontName);
}
}
} catch (err) {
alert("Error: " + err);
}
// Prompt user for font name
function getFontName() {
var w = new Window("dialog", "Enter font name");
w.orientation = "column";
w.alignChildren = "fill";
var input = w.add("edittext", undefined, "");
input.characters = 30;
var btnGroup = w.add("group");
btnGroup.alignment = "right";
var okBtn = btnGroup.add("button", undefined, "OK");
var cancelBtn = btnGroup.add("button", undefined, "Cancel");
okBtn.onClick = function () {
if (input.text === "") {
alert("Requires font name");
return;
}
w.close(1);
};
cancelBtn.onClick = function () {
w.close(0);
};
if (w.show() === 1) {
return input.text;
} else {
throw "User cancelled input.";
}
}
Copy link to clipboard
Copied
I was looking at this all day - finaly got it working
var sel = app.selection[0];
if (!sel || !sel.hasOwnProperty("paragraphs")) {
alert("Please select text that lists font styles like 'Regular', 'Bold', etc.");
} else {
var paras = sel.paragraphs;
var notFound = [];
// Function to apply the font style
function applyFontStyle(styleName, fontFamily) {
try {
// Create the font name by combining family and style
var fontKey = fontFamily + "\t" + styleName;
var fontObj = app.fonts.itemByName(fontKey);
// Check if the font is valid and apply
if (fontObj.isValid) {
return fontObj;
} else {
return null;
}
} catch (e) {
return null;
}
}
// List of font style names (expand this list with all known style names)
var fontStyles = [
"Regular", "Bold", "Italic", "Medium", "Light", "ExtraBold", "SemiBold",
"Display", "Caption", "Condensed", "Subhead", "Bold Condensed", "Italic Caption",
"Medium Italic", "SemiBold Caption", "Bold Italic", "Medium Display", "Italic Subhead"
];
// Loop through the selected paragraphs and apply fonts
for (var i = 0; i < paras.length; i++) {
var paraText = paras[i].contents; // Get the text content of the paragraph
// Check if the content is one of the known font styles
var styleName = null;
for (var j = 0; j < fontStyles.length; j++) {
if (paraText.indexOf(fontStyles[j]) !== -1) {
styleName = fontStyles[j];
break; // If a match is found, stop checking further
}
}
// Apply the font if a style was found
if (styleName) {
var fontFamily = paras[i].appliedFont.fontFamily; // Get the font family of the paragraph
var appliedFont = applyFontStyle(styleName, fontFamily); // Get the font object for the style
if (appliedFont) {
paras[i].appliedFont = appliedFont; // Apply the font to the text
} else {
notFound.push(styleName); // Track styles not found
}
} else {
notFound.push("No style match for: " + paraText); // Track paragraphs without a style match
}
}
// Feedback for any styles that couldn't be applied
if (notFound.length > 0) {
alert("Couldn't apply these styles or matches:\n" + notFound.join("\n"));
} else {
alert("All styles applied successfully!");
}
}
Copy link to clipboard
Copied
As you're writing out the text anyway - you just need to apply the font style to the list - and it should work.
Once you have the main ones setup it should be automated enough.
I'm working on automating the style list based on the selection but gotta go work on something else.
Copy link to clipboard
Copied
Wow! Really cool, thank you! Tried it and it works!
But I think we've found a better way though. Chceck the "correct answer" in this disscusion and you'll see. There's a script that generates the names of the styles in the styles directly.
As you're writing out the text anyway - you just need to apply the font style to the list - and it should work.
Once you have the main ones setup it should be automated enough.
I'm working on automating the style list based on the selection but gotta go work on something else.
By Eugene Tyson
Copy link to clipboard
Copied
Sorry didn't see it was posted until I posted as I didn't refresh before posting excitedly.
I will take at it tomorrow - no time right now.
Is it working the way you want - or do you want me to try integrate the correct answer with my method - haven't delved into it really - just asking if there's anything else you might need.
Copy link to clipboard
Copied
I understand.
Nevertheless, I have the script you've made. I think it can come in handy. It's a closed case!
Thanks for your work.
Sorry didn't see it was posted until I posted as I didn't refresh before posting excitedly.
I will take at it tomorrow - no time right now.
Is it working the way you want - or do you want me to try integrate the correct answer with my method - haven't delved into it really - just asking if there's anything else you might need.
By Eugene Tyson
Copy link to clipboard
Copied
Yeh no bother, trying to learn this scripting stuff, so it's great to see the correct answer - I'll keep trying to make it more automated, see if I can get it to work, for my own knowledge, this is great for my collection of code snippets.
Need anything else let us know.
Copy link to clipboard
Copied
Have you coded it yourself? Or used ChatGPT?
Unfortunately, this forum is broken and I can't upvote your post.
Copy link to clipboard
Copied
I used this script from this site which you sended https://yourscriptdoctor.com/displaying-font-family-members/
and then yes, I asked ChatGPT to make it into javascript to make it work on windows. Then made some small changes to make it work the way I wanted.
Is that okay?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks for your help. Wouldn't have done it without it.
Copy link to clipboard
Copied
Thanks for your help. Wouldn't have done it without it.
By Le Kozis
You're welcome 🙂
Please check notifications / private messages - top right corner.

