-
Notifications
You must be signed in to change notification settings - Fork 30
Fonts
fabiantheblind edited this page Nov 19, 2015
·
3 revisions
###fonts
/**
* Fonts can be a pain in the ***.
* You can call them by name, but then you have to be very precise
* by writing their name in the script.
* An easier way is to call them by number
* but there you will face problems when you activate or deactivate fonts
* because their numbers will change.
*
* This script writes a list of all available fonts
* on your system to the desktop.
* Have a look into new file.
* The weight is separated by a TAB.
* If you want to call a font by the name
* you have to write that TAB.
* Some IDEs translate the TAB character into four white spaces
* so be careful.
*
*/
main(); // main everything is in here
function main(){
var list = new Array(); // a list
// loop through the fonts and add their info in a list
for (var i = 0; i < app.fonts.length;i++){
list.push("app.fonts.item("+ String(i) +") --> " +app.fonts[i].name);
}; // end loop
// get the text file
var txtFile = File("~/Desktop/id_fontslist.txt");
if(!txtFile.exists){
// If the file does not exist create one.
txtFile = new File("~/Desktop/id_fontslist.txt");
}else{
// If it exists, ask the user if it should be overwritten.
var res = confirm ("The file already exists. Should I overwrite it?", true, "titleWINonly");
// If the user hits "no" stop the script.
if(res != true){
return;
};
};
var out; // Our output.
// We know already that the file exists
// but to be sure...
if( txtFile!='' ){
//Open the file for writing.
out = txtFile.open( 'e', undefined, undefined );
txtFile.encoding = "UTF-8";
txtFile.lineFeed = "Unix"; //convert to UNIX lineFeed
// txtFile.lineFeed = "Windows";
// txtFile.lineFeed = "Macintosh";
};
// got an output?
if( out != false ){
// loop the list and write each item to the file
for(var i in list){
txtFile.writeln(list[i]);
};
// always close files!
txtFile.close();
txtFile.execute();
};
// This is more the C or C++ style
// but it is good for the console.
// We know everything went fine.
return 0;
};This wiki is maintained by:
fabiantheblind
Thanks to:
- JohnDarnell for fixing lots of typos.
- jsp for fixing lots of typos.
- ltfschoen for fixing typos.
- wridgers for adding more links.
Thanks to the students from the seminar for asking all those questions and making me start this wiki.
- adinaradke
- AnitaMei
- ce0311
- coerv
- felixharle
- FerdinandP
- Flave
- marche
- monkian
- natael
- OliverMatelowski
- PDXIII
- praktischend
- schlompf
- skaim
You are awesome.
- Arrays
- Classes
- Comments
- Conditionals
- Functions
- Inspect Properties
- Loops
- Objects
- Output And Interaction
- Recursive Functions
- Inspect Properties
- Variables And Operations
- Extended JavaScript Guide
- Bridge Talk
- Create And Read Files
- ExtendScript Toolkit
- File
- Folder
- Includes JSX
- Object Watch
- Read In JSON From File And DONT Eval
- Storing Data In A Target Engine
- Target an application
- XML
- app
- Colorbrewer
- Colors And Swatches
- Delay And View
- Dialogs
- Documents
- Duplicate And Transform
- Event AfterSave
- Export IDML
- ExtendScript in InDesign Scripting DOM
- Fonts
- GeometricBounds and Coordinates
- Get named pageItems
- Graphic Lines
- Groups
- HSL Color Wheel
- Images
- Includes
- InsertionPoints
- Layers
- Line Feeds And Carrige Returns
- Masterspreads
- Matrix
- Objectstyles
- Outlines Groups Alignment
- Pages And Margins
- Pathfinder
- Placeholder Text
- Rectangles Ovals Polygons
- RulerOrigin
- Select words at insertionPoint
- Simple Find And Change Grep with FC Query
- Simple Find And Change Grep
- Simple Find And Change Text
- Spiro
- Styles
- Text Analysis ID FC
- Text Analysis
- Text Find Locations
- Text
- Transformation Matricies
- TransparencySettings
- XML creation and import