Skip to main content
BEGINNER_X
Legend
December 6, 2012
Question

Need Document Fonts in .TXT format

  • December 6, 2012
  • 2 replies
  • 1749 views

Hi All,

I am trying a script which is in "InDesignCS3_ScriptingGuide_JS" related to font list.

My requirement:

How can we get documents font list in .txt format.

Trying Code is below:

//To display font name (working fine)

var myDocument = app.activeDocument

var myDocumentFontNames = myDocument.fonts.everyItem().getElements();

for(var i = 0; i<myDocumentFontNames.length; i++){

alert(myDocumentFontNames.name);

}

//i think here is doubt


var myFileName = "~/Desktop/Test.txt";

myDocumentFontNames.exportFile(ExportFormat.taggedText, File(myFileName));

Can anyone give solution for me if you willing.

Thanks in advance

BEGINNER

This topic has been closed for replies.

2 replies

fabianmoronzirfas
Known Participant
December 7, 2012

Try modifying this script that exports all app.fonts into a .txt file

https://github.com/fabiantheblind/auto-typo-adbe-id/wiki/Fonts

get the raw code here

https://raw.github.com/fabiantheblind/auto-typo-adbe-id/master/fabiantheblind/fontslist.jsx

replace all

app.fonts

with

app.activeDocument.fonts

Cheers

:fabian

csm_phil
Legend
December 6, 2012

Hi BEGINNER,

Once again, you doing same wrong method. I am already instruct to you in the below web link.

http://forums.adobe.com/message/4882727#4882727

Now, also you doing same, Have you seen the export options export the font family names in the text file. Please try you manully it will works after you approach in script.

thx,

csm_phil

Inspiring
December 7, 2012

@beginner

Try this,

              

var myDocument = app.activeDocument

var fontList = []

var myDocumentFontNames = myDocument.fonts.everyItem().getElements();

for(var i = 0; i<myDocumentFontNames.length; i++){

fontList.push(myDocumentFontNames.name);

}

fontList = fontList.toString().replace(/,/g,"\n").replace(/\t/g," ")

var myFileName = File("~/Desktop/Test.txt")

myFileName.open("w")

myFileName.write(fontList)

myFileName.close();

BEGINNER_X
Legend
December 7, 2012

Hi Cenchen, fabion and csm_phil,

Thanks a lot. Its working fine.

Could you explain detailed where i highlighted in BOLD.

var myDocument = app.activeDocument

//What it is []

var fontList = []


var myDocumentFontNames = myDocument.fonts.everyItem().getElements();

for(var i = 0; i<myDocumentFontNames.length; i++){

fontList.push(myDocumentFontNames.name);

}

//Please explain this line very particularly

fontList = fontList.toString().replace(/,/g,"\n").replace(/\t/g," ")

var myFileName = File("~/Desktop/Test.txt")

myFileName.open("w")

myFileName.write(fontList)


myFileName.close();

Thanks in advance

BEGINNER