Skip to main content
Adirai Maji
Inspiring
September 10, 2023

[Scripting Bug] in V24 Build 44 usedFonts Property doesn't work, When text layer is duplicated.

  • September 10, 2023
  • 9 replies
  • 1089 views

app.project.usedFonts doesn't work Properly, If we duplicate a text layer and change the font of either one of the layers, It won't detect the old font used in the original layer. Even if we remove the layer which have the new font. It always shows us the removed font (second font). Not the font that remain in the project.

This topic has been closed for replies.

9 replies

Adobe Employee
June 24, 2024

FYI: usedFonts / replaceFont has been (finally) released in 24.5

 

Thank you @Adirai Maji for assisting us in this effort - your report was vital to this outcome.

 

Douglas Waterfall

After Effects Engineering

Adobe Employee
May 13, 2024

Hello...again. The good news is that moving to Release has never been closer!

 

The less good news is that we just made one more last little breaking change to the JSON while in Beta, available on or after 24.5.0 (34).

 

Back in March we had held this back from 24.3 and 24.4 releases because there was a difference of understanding about what timeD really meant as it did not behave as timeD in other layers behaved.

 

 

This has now been resolved with our understanding that for Text Layers only, the timeD one passes to valueAtTime() is actually Text Layer local/relative time and not Comp Time like other properties. Thus usedFonts also returns it as Text Layer local/relative as well.

 

The breaking change was to modify the JSON to make this naming more explicit. with the new API name changing timeD to be layerTimeD.

 

Nothing else changes, and we will be updating the docs shortly. We do think this is the last blocking issue.

 

Douglas Waterfall

After Effects Engineering

Adobe Employee
March 15, 2024

Uh oh.

 

We have hit a snag with usedFonts which is going to force us to hold it back even longer in Beta than we had planned.

 

The issue is what usedAt.timeD actually represents? Our design was that one could do this:

var timeD = usedAt[j].timeD;
var layer = app.project.layerByID(layerID);
var td = layer.property("Source Text").valueAtTime(timeD, true/*preExpressionB*/);

...and you would get back the correct TextLayer.

 

@JohnColombo17100380 has found some arrangements of Layers which suggests that we have got this wrong somewhere, so we are scratching our heads trying to untangle why it works so well in a lot of cases but seemingly not all?

 

We will keep you updated.

 

Douglas Waterfall

After Effects Engineering

Adobe Employee
March 1, 2024

This has been finally been addressed as part of some related work involving font replacement - it will be available in beta build after 24.4.0/2.

 

The need to fix this, and its entanglement in other work is what has held up its progress towards full release. Please let us know if there are any remaining incorrect behaviors which you see.

 

Note that there has been breaking change in the JSON which is returned from usedFonts by the addition of a time field.

 

Previous:

{
    font: <Font Object>,
    layerIDs: [
        layerID0,
        layerID1,
        ...
    ],
}

 

New:

{
    font: <Font Object>,
    usedAt: [
        {
            layerID: <layerID0>,
            timeD: <time0>
        },
        {
            layerID: <layerID1>,
            timeD: <time1>
        },
    ]
}

 

To retrieve the TextDocument instance simply use the property method valueAtTime() instead of the traditional value().

 

The docs will be updated when the build appears.

 

Here is a little demo script:

(function () {

    var usedFontsV = app.project.usedFonts;

    var str = "UsedFonts:" + usedFontsV.length + "\n";

    for (var i = 0; i < usedFontsV.length; i++) {
        var font = usedFontsV[i].font;

        str += "[" + font.postScriptName + "]: [\n";

        var usedAt = usedFontsV[i].usedAt;

        for (var j = 0; j < usedAt.length; j++) {
            var layerID = usedAt[j].layerID;
            var timeD = usedAt[j].timeD;

            var layer = app.project.layerByID(layerID);
            var td = layer.property("Source Text").valueAtTime(timeD, true/*preExpressionB*/);
            var text = td.toString();

            str += "(" + layerID + "," + timeD + "):" + text + "\n";
        }

        str += "]\n";
    }

    alert(str);

    return usedFontsV.length;
})();

 

Douglas Waterfall

After Effects Engineering

 

Adobe Employee
January 26, 2024

Hi @Adirai Maji 

 

I am still actively working on this, it will not make it for the upcoming 24.2 release.

 

Douglas Waterfall

After Effects Engineering

Adobe Employee
December 11, 2023

Hi @Adirai Maji

 

Sorry for the long delay in getting back to this - the per-character styling in TextDocument interfered.

 

Based on your report, I had to go re-derive the situation and discovered that I had some bad assumptions about using certain data.

 

I have a fix which is looking pretty promising but which is entangled in some other font bug fixes so I will get it all out as soon as I am confident it is stable and can update the docs.

 

Douglas Waterfall

After Effects Engineering

JohnColombo17100380
Community Manager
Community Manager
September 19, 2023

Thank you, @Adirai Maji! I've added this scenario to our internal ticket on this issue.

 

Cheers,

- John, After Effects Engineering Team 

Adirai Maji
Inspiring
September 18, 2023

Hi @JohnColombo17100380 ,
Thank you for investigating the issue. I just want to add one more note to the issue, I've also found that if we duplicate a composition and change the font of text layers in either of the composition, usedFonts property doesn't detect old font.

JohnColombo17100380
Community Manager
Community Manager
September 11, 2023

Hi @Adirai Maji,

Thank you for reporting this issue. We are able to reproduce it as well and will be investigating a fix. Thanks for reporting this issue while the feature is still in Beta!

 

Cheers,

- John, After Effects Engineering Team