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 3 years have passed since last update.

Ae テキストレイヤーのフォントサイズ変更&more

Posted at

テキストレイヤーのフォントサイズ+アンカーポイントを真ん中に+位置を真ん中にする


//フォントを変更してアンカーポイント・位置を真ん中に
function anchorCenter(textLayerObj,fs){
        //フォントサイズの変更
        var cNTextTd = textLayerObj.property("ADBE Text Properties").property("ADBE Text Document").value; //テキストドキュメント
        cNTextTd.fontSize = fs;
        textLayerObj.property("ADBE Text Properties").property("ADBE Text Document").setValue(cNTextTd);
        
        //アンカーを真ん中に変更
        var curTime = app.project.activeItem.time;
        var myAnchor = textLayerObj.property("ADBE Transform Group").property("ADBE Anchor Point");
        var tl = textLayerObj.sourceRectAtTime(curTime, false).left; //テキストの左側の座標 l
        var tw =textLayerObj.sourceRectAtTime(curTime, false).width; //テキストの全体の幅 b
        var tt = textLayerObj.sourceRectAtTime(curTime, false).top;//テキスト上の座標 c
        var th = textLayerObj.sourceRectAtTime(curTime, false).height; //テキスト全体の高さ d
        var lv=myAnchor.value;
        var setX=roundFloat((tw/2)+tl);
        var setY=roundFloat((th/2)+tt);
        var setA = myAnchor.setValue([setX,setY]);  
        
        //位置を真ん中に
        px = div(myComp.width,2);
        py = div(myComp.height,2);
        textLayerObj.property("ADBE Transform Group").property("ADBE Position").setValue([px,py])

    function roundFloat(number) {
        var _pow = Math.pow( 10 , 4 );
        return Math.round( number * _pow ) / _pow;
    }
    
    function div(n,num){
            return n / num;
    }

}


app.beginUndoGroup("");

var myComp = app.project.activeItem;
var selLay = myComp.selectedLayers;
for (var i = 0 ;  i <selLay.length; i++ ){
    var myLay = selLay[i];
    if (myLay instanceof TextLayer ){
        anchorCenter(selLay[i],130)
    }
}

app.endUndoGroup();

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?