Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ExtendScript: cache in app.textFonts?

Explorer ,
Apr 22, 2022 Apr 22, 2022

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")
fontName always get null, Is there cache in the app.textFonts? Any advise?
TOPICS
Performance , Scripting , SDK
412
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Guide ,
Apr 22, 2022 Apr 22, 2022

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;

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 23, 2022 Apr 23, 2022

Did you install the font "For all users"?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 26, 2022 Apr 26, 2022

yeah, I put the font to the "C:\windows\Font" directory.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 23, 2022 Apr 23, 2022

can you see the font in the Illustrator UI?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 26, 2022 Apr 26, 2022
LATEST

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.  

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines