Skip to content

Instantly share code, notes, and snippets.

@kkotaro0111
Forked from partynight12th/illstrator_fontlist.jsx
Last active December 16, 2015 03:30
Show Gist options
  • Save kkotaro0111/5370761 to your computer and use it in GitHub Desktop.
Save kkotaro0111/5370761 to your computer and use it in GitHub Desktop.
任意の文字列を、そのマシーンにインストールされてる全てのフォントで書きだすExtend Script for Illustrator。 キャンパス上に設置したテキストオブジェクトを1つ選択した状態で、このJSXをドラッグ・アンド・ドロップすれば、書き出される。 ただし、フォントがたくさん入っていると、超絶時間とマシンリソースを消費するので、気をつけること。
var textFrame = activeDocument.selection[0];
if(textFrame && textFrame.characters && textFrame.characters.length > 0){
var textContent = textFrame.contents;
var fonts = app.textFonts;
var len = fonts.length;
var width = 270;
var height = 24;
var setnum = len / (width / (height / 2));
var numset = Math.sqrt(setnum) << 0;
var numtextframe = ((numset * width) / height) << 0;
for(var i = 0; i < len; i++){
var x = ((i / numtextframe) << 0) * width;
var y = (i % numtextframe) * -height * 2 -height;
textObj = activeDocument.textFrames.add();
textObj.contents = textContent + "\n" + fonts[i].name;
textObj.textRange.characterAttributes.textFont = fonts[i];
textObj.textRange.characterAttributes.size = height;
textObj.textRange.characterAttributes.autoLeading = false;
textObj.textRange.characterAttributes.leading = height;
for(var j = textContent.length; j < textObj.contents.length; j++){
textObj.textRanges[j].characterAttributes.size = height /2;
}
textObj.translate(x, y);
var g = textObj.createOutline();
g.name = fonts[i].name;
}
}else{
alert("Please select the text frame.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment