Copy link to clipboard
Copied
I'm trying to access a font via jsx, passing a string.
If I pass a system font, such as "Helvetica", it works fine. If I pass "Augustine", it fails.
Getting .name of app.textFonts shows "Helvetica-Regular" and "AugustineRegular". I wonder if that hyphen is an issue.
Below is the function I'm using: Anyone have any thoughts? Thanks.
var appFont = app.textFonts.getByName(fontString);
Yes, your new font name is "AugustineRegular" so try passing that in.
Copy link to clipboard
Copied
Hi brianp311,
Could you try this little test? First select a text frame object and run this script.
// 1. get the name of the font from the selected text frame.
var textFrame = app.activeDocument.selection[0];
if (textFrame.typename == 'TextFrame') {
var actualFontName = textFrame.textRange.characterAttributes.textFont.name;
try {
// 2. now try to getByName, using that name
var theFont = app.textFonts.getByName(actualFontName);
alert('Getting the font "' + theFont.name + '" worked!');
} catch (error) {
alert('Getting the font "' + actualFontName + '" failed!' + error);
}
}
Let me know how you go.
- Mark
Copy link to clipboard
Copied
It was happening on a client's machine. It seems the naming was just a bit off for some of the user-installed files. I wrote him a script to get the exact names for what he needs to pass via csv. Thanks for the help.
Copy link to clipboard
Copied
Oops, sorry I realise I misunderstood your question. 🙂
Copy link to clipboard
Copied
Yes, your new font name is "AugustineRegular" so try passing that in.
Copy link to clipboard
Copied
That did it. Thanks.