太くする
var activeFontWeight = app.activeDocument.activeLayer.textItem.font;
var fontFamily = app.fonts.getByName(activeFontWeight).family;
var fontWeights = [];
var nextFontWeight;
for (var i = 0; i < app.fonts.length; i++) {
if (app.fonts[i].family == fontFamily) {
fontWeights.push(app.fonts[i]);
}
}
for (var i = 0; i < fontWeights.length; i++) {
if (fontWeights[i].postScriptName == activeFontWeight) {
if (i == (fontWeights.length - 1)) {
nextFontWeight = fontWeights[i];
} else {
nextFontWeight = fontWeights[i + 1];
}
break;
}
}
app.activeDocument.activeLayer.textItem.font = nextFontWeight.postScriptName;
細くする
var activeFontWeight = app.activeDocument.activeLayer.textItem.font;
var fontFamily = app.fonts.getByName(activeFontWeight).family;
var fontWeights = [];
var nextFontWeight;
for (var i = 0; i < app.fonts.length; i++) {
if (app.fonts[i].family == fontFamily) {
fontWeights.push(app.fonts[i]);
}
}
for (var i = 0; i < fontWeights.length; i++) {
if (fontWeights[i].postScriptName == activeFontWeight) {
if (i == 0) {
nextFontWeight = fontWeights[i];
} else {
nextFontWeight = fontWeights[i - 1];
}
break;
}
}
app.activeDocument.activeLayer.textItem.font = nextFontWeight.postScriptName;