Last active
February 2, 2017 00:43
-
-
Save milligramme/ee69d796c45456176e4eea0d7b12876e to your computer and use it in GitHub Desktop.
InDesign TextPreferences.insetSpacing bug test
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
/* | |
フレーム内マージンが設定されたテキストフレーム | |
のアンカーの位置を操作するとマージン分余計に動いてしまう | |
*/ | |
var test = function (doc, opts) { | |
var textframe = doc.textFrames.add({ | |
geometricBounds: opts['frame_bon'] | |
}); | |
// フレーム内マージン!!! | |
textframe.textFramePreferences.insetSpacing = opts['inset_space']; | |
var pathpoints = textframe.paths[0].pathPoints | |
for (var i=0, len=pathpoints.length; i < len ; i++) { | |
if (pathpoints[i].anchor[0] > opts['frame_bon'][3] - 2) { | |
pathpoints[i].anchor = [ | |
pathpoints[i].anchor[0] + opts['add_to'], | |
pathpoints[i].anchor[1] | |
]; | |
} | |
}; | |
$.writeln("//expect " + opts['expect'] ); | |
$.writeln("//actually " + textframe.geometricBounds); | |
} | |
var doc = app.documents.add(); | |
var opts; | |
$.writeln('\ninset spacing is not set to a textframe'); | |
opts = { | |
frame_bon: [150,80,160,120], | |
inset_space: [0,0,0,0], | |
add_to: 10, | |
expect: [150,80,160,130], | |
} | |
test(doc, opts); | |
$.writeln('\ninset spacing is set to left&right of a textframe'); | |
opts = { | |
frame_bon: [150,80,160,120], | |
inset_space: [0,0.4,0,0.1], | |
add_to: 10, | |
expect: [150,80,160,130], | |
} | |
// rightとleftの和が増える | |
test(doc, opts); | |
$.writeln('\ninset spacing is set to top&bottom of a textframe'); | |
opts = { | |
frame_bon: [150,80,160,120], | |
inset_space: [0.3,0,1.2,0], | |
add_to: 10, | |
expect: [150,80,160,130], | |
} | |
// bottomは影響しない??で topの2倍が減る | |
test(doc, opts); | |
$.writeln('\ninset spacing is set to all of a textframe'); | |
opts = { | |
frame_bon: [150,80,160,120], | |
inset_space: [0.3,0.1,1.2,0.2], | |
add_to: 10, | |
expect: [150,80,160,130], | |
} | |
// topの2倍が減る + rightとleftの和が増える | |
test(doc, opts); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🤒
inset spacing is not set to a textframe
//expect 150,80,160,130
//actually 150,80,160,130
🤕
inset spacing is set to left&right of a textframe
//expect 150,80,160,130
//actually 150,80,160,130.5
inset spacing is set to top&bottom of a textframe
//expect 150,80,160,130
//actually 150,80,160,129.4
inset spacing is set to all of a textframe
//expect 150,80,160,130
//actually 150,80,160,129.7