0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【photoshop】選択中のフォントファミリーの太さを一段変える

Posted at

太くする

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;
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?