Last active
February 4, 2021 22:21
-
-
Save milligramme/7bb6f21036f45082eb6b6fa5a1e15f2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@target indesign | |
// 合成フォントを含むidmlをひらくと、すでにひらいているinddの同名合成フォント情報まで破壊する | |
app.documents.everyItem().close(SaveOptions.NO) | |
var indd_file = File(Folder.desktop + "/foo.indd") | |
var idml_file = File(Folder.desktop + "/foo.idml") | |
var doc = app.documents.add() | |
doc.save(indd_file) | |
var create_comp_font = function (doc) { | |
try { | |
var comp_font = doc.compositeFonts.add({name: Math.random().toString()}) | |
alert(comp_font+"を生成待ち..") | |
var comp_font_entries = comp_font.compositeFontEntries | |
with (comp_font_entries[0]){ | |
appliedFont = "小塚明朝 Pr6N" | |
fontStyle = "H" | |
relativeSize = 100 | |
baselineShift = 5 | |
verticalScale = 100 | |
horizontalScale = 100 | |
} | |
comp_font_entries[1].properties = comp_font_entries[0].properties | |
comp_font_entries[2].properties = comp_font_entries[0].properties | |
comp_font_entries[3].properties = comp_font_entries[0].properties | |
with (comp_font_entries[4]){ | |
appliedFont = "Myriad Pro" | |
fontStyle = "Bold" | |
relativeSize = 125 | |
baselineShift = 0 | |
verticalScale = 50 | |
horizontalScale = 75 | |
} | |
with (comp_font_entries[5]) { | |
appliedFont = "Myriad Pro" | |
fontStyle = "Bold" | |
relativeSize = 125 | |
baselineShift = 0 | |
verticalScale = 50 | |
horizontalScale = 75 | |
} | |
// 捨て設定 | |
// 一番下の CompositeFontEntries がこわれるぽいので | |
var _custom_comp_font_entries = comp_font.compositeFontEntries.add() | |
with (_custom_comp_font_entries) { | |
appliedFont = "小塚ゴシック Pr6N" | |
fontStyle = "H" | |
relativeSize = 125 | |
baselineShift = 0 | |
verticalScale = 50 | |
horizontalScale = 75 | |
customCharacters = "肉" | |
} | |
} | |
catch(x_x){} | |
return comp_font | |
} | |
var create_text = function (doc) { | |
var textframe = doc.textFrames.add({ | |
geometricBounds: [20,20,120,180], | |
contents: "肉(18,000)税込¥19,440" | |
}) | |
var text = textframe.parentStory.texts[0] | |
text.pointSize = "40pt" | |
return text | |
} | |
var cf = create_comp_font(doc) | |
var t_org = create_text(doc) | |
t_org.appliedFont = "小塚明朝 Pr6N\tH" | |
t_org.parentStory.characters.itemByRange(1,1).appliedFont = "小塚ゴシック Pr6N\tH" | |
t_org.parentStory.characters.itemByRange(2,7).appliedFont = "Myriad Pro\tBold" | |
t_org.parentStory.characters.itemByRange(11,-1).appliedFont = "Myriad Pro\tBold" | |
var t_comp = create_text(doc) | |
t_comp.parentTextFrames[0].move(undefined,[0,120]) | |
try { | |
t_comp.appliedFont = cf.name | |
} | |
catch(x_x){} | |
doc.exportFile(ExportFormat.INDESIGN_MARKUP, idml_file) | |
// foo.idmlを開くと、すでに開いているfoo.inddのほうも合成フォント情報がこわれる | |
app.open(idml_file) |
全てを一度とじて開き直すと表示はもどる
一番下の compositeFontEntries がこわれるので、ダミーでカスタム設定を追加すると回避できる
一応回避済みのデモになります
特例文字は破壊されない説がでたので「肉」を追加、やはり破壊される
肉が特例文字なので、破壊されるデモになります
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
idml以外に idmsやindlからの配置もだめ