TextFonts
TextFonts
Section titled “TextFonts”app.textFonts
Description
Section titled “Description”A collection of TextFont objects.
Properties
Section titled “Properties”TextFonts.length
Section titled “TextFonts.length”app.textFonts.length
Description
Section titled “Description”The number of elements in the collection.
Number; read-only.
TextFonts.parent
Section titled “TextFonts.parent”app.textFonts.parent
Description
Section titled “Description”The object’s container.
Object; read-only.
TextFonts.typename
Section titled “TextFonts.typename”app.textFonts.typename
Description
Section titled “Description”The class name of the referenced object.
String; read-only.
Methods
Section titled “Methods”TextFonts.getByName()
Section titled “TextFonts.getByName()”app.textFonts.getByName(name)
Description
Section titled “Description”Get the first element in the collection with the provided name.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
name | String | Name of element to get |
Returns
Section titled “Returns”TextFonts.index()
Section titled “TextFonts.index()”app.textFonts.index(itemKey)
Description
Section titled “Description”Gets an element from the collection.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
itemKey | String, Number | String or number key |
Returns
Section titled “Returns”Example
Section titled “Example”Finding fonts
Section titled “Finding fonts”// Creates a new A3 sized document and display a list of available fonts until the document is full.
var edgeSpacing = 10;var columnSpacing = 230;var docPreset = new DocumentPreset;docPreset.width = 1191.0;docPreset.height = 842.0
var docRef = documents.addDocument(DocumentColorSpace.CMYK, docPreset);var sFontNames = "";var x = edgeSpacing;var y = (docRef.height - edgeSpacing);
var iCount = textFonts.length;
for (var i=0; i<iCount; i++) { sFontName = textFonts[i].name; sFontName += " "; sFontNames = sFontName + textFonts[i].style;
var textRef = docRef.textFrames.add(); textRef.textRange.characterAttributes.size = 10; textRef.contents = sFontNames; textRef.top = y; textRef.left = x;
// check wether the text frame will go off the edge of the document if ((x + textRef.width)> docRef.width) { textRef.remove(); iCount = i; break; } else { // display text frame textRef.textRange.characterAttributes.textFont = textFonts.getByName(textFonts[i].name); redraw();
if ((y-=(textRef.height)) <= 20) { y = (docRef.height - edgeSpacing); x += columnSpacing; } }}