Skip to content

Instantly share code, notes, and snippets.

@UskeS
Created December 4, 2023 04:45
Show Gist options
  • Save UskeS/f487701afa5d42527800a6b0b463b656 to your computer and use it in GitHub Desktop.
Save UskeS/f487701afa5d42527800a6b0b463b656 to your computer and use it in GitHub Desktop.
[InDesign] 特定のフォントファミリーの全ウェイトをドキュメント上にテキストとして作成する
// fill text with font families
var doc = app.documents.add();
var bnd = doc.pages[0].bounds;
var txf = doc.textFrames.add({
geometricBounds: bnd,
});
var fnt = app.fonts.everyItem();
var fln = fnt.fullNameNative;
for (var i = 0, len = fln.length; i < len; i++) {
if(!/ヒラギノ/i.test(fln[i])) { continue; }
txf.contents += fln[i] + "\r";
}
var prg = txf.paragraphs;
txf.textFramePreferences.textColumnCount = 3;
for (var i = 0, len = prg.length; i < len; i++) {
var wgt = prg[i].contents.match(/([^ ]+)$/)[1].replace(/[\r\n]/g, "");
var fml = prg[i].contents.replace(RegExp(" " + wgt + "[\r\n]?$"), "");
prg[i].appliedFont = fml + "\t" + wgt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment