Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Change font weight in scripting?

  • Change font weight in scripting?

    Posted by Ben Christie on November 9, 2015 at 10:13 pm

    Hi guys! (this is repost but was told it would be better received in this forum)

    I’m hoping this is something pretty simple I am overlooking, but I am trying to find how to set the font weight via script.

    Currently I have my font set up like this. But I need to choose Helvetica Neue Medium instead. Thoughts?

    fpoControl.resetCharStyle();
    fpoControl.fontSize = 51;
    fpoControl.fillColor = [0, 0, 0];
    fpoControl.font = "Helvetica Neue";
    fpoControl.text = myString;
    fpoControl.justification = ParagraphJustification.CENTER_JUSTIFY;
    fpoDocument.setValue(fpoControl);

    Syed Iqbal replied 7 years, 9 months ago 3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    November 9, 2015 at 10:50 pm

    You may need to set the style, but the first thing to do is make sure you know the names that AE is using. Create a comp with a text layer (Layer 1) with the desired font and try this:

    var myComp = app.project.activeItem;
    var myTextLayer = myComp.layer(1);
    var mySourceText = myTextLayer.property(“ADBE Text Properties”).property(“ADBE Text Document”);
    var myTextDoc = mySourceText.value;
    alert(myTextDoc.font + ” / ” + myTextDoc.fontStyle);

    Dan

  • Ben Christie

    December 3, 2015 at 7:19 pm

    Thanks Dan!

    This worked perfectly, I was actually just using the wrong name like you thought. Sometimes it’s best to start with what you know.

    Thanks again!

    Ben

  • Syed Iqbal

    July 25, 2018 at 9:39 am

    Hi
    I just want to understand how to I write a very small script which could make the active layer’s font style property to bold. I want to assign a keyboard shortcut to my script file later on so that I can save tons of time of doing it through mouse.

    From one of Dan’s code, I tried to manipulate fontStyle property by using setValue method but it does not work.

    var myComp = app.project.activeItem;
    var myTextLayer = myComp.layer(1);
    var mySourceText = myTextLayer.property(“ADBE Text Properties”).property(“ADBE Text Document”);
    var myTextDoc = mySourceText.value;
    myTextDoc.fontStyle = myTextDoc.fontStyle.setValue(“Bold”);

    Again what I am trying is to set the font weight of text layer from Regular to Bold. Any help would be much appreciated.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy