Copy link to clipboard
Copied
I have installed the font programmatically and I can see the font in Windows Font directory, however, when I try to get the font via:
var fontName = app.textFonts.getByName("SourceHanSansCN-Bold")
Copy link to clipboard
Copied
That expression should get you the font object (although still not null). This should get you the font name:
var fontName = app.textFonts.getByName("SourceHanSansCN-Bold").name;
Copy link to clipboard
Copied
Did you install the font "For all users"?
Copy link to clipboard
Copied
yeah, I put the font to the "C:\windows\Font" directory.
Copy link to clipboard
Copied
can you see the font in the Illustrator UI?
Copy link to clipboard
Copied
If ExtendScript can't access the font object, you would have gotten an error ("no such element found" or something to that effect). If you're really getting "null", there is more to this than we are being told.