• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Scripting: New and updated APIs for Font Management

Adobe Employee ,
Mar 22, 2024 Mar 22, 2024

Copy link to clipboard

Copied

Hi everyone,

 

Starting with AE 24.4.0.24 beta, we have introduced a number of miscellaneous Font management APIs which we hope will be super interesting to some of you who have more refined workflows around Fonts - we created them to help our internal testing, and decided to expose them to Beta following your feedback.

 

As always, we have updated the Scripting Documentation, where you will find more detailed information about these new APIs. Here is a quick overview of the new APIs:

 

app.fonts.fontsDuplicateByPostScriptName
Having more than one Font instance which has the same PostScript name can lead to surprises when the Font instance you thought you were going to get was not the one the FontServer handed back. Earlier releases of After Effects were prone to crash in this state and one of the focuses of the last year of FontServer work was to make this situation work.

 

Simply use the TextDocument.font API to select a Font by PostScript name is problematic when there is more than one Font instance with the same PostScript name - did the FontServer select the one you wanted?

 

app.fonts.mruFontFamilyList
app.fonts.favoriteFontFamilyList
Access to Most Recently Used (MRU), and Favorites font lists anywhere you can choose fonts from these lists. Ever wanted to clear these lists? Just pass in an empty array.
Want to define your own Favorites programmatically rather than clicking in the UI? Here is the way.

 

app.fonts.freezeSyncSubstitutedFonts
By default when After Effects opens a Project, and it finds that it has a Font reference which does not exactly match an installed Font, it will attempt to activate an Adobe Font with the same PostScript name if it can find one there. Not all workflows want this to happen - a popular reason being server workflows where they never want to use Adobe Fonts and so the automatic install just makes the Font environment more complicated for them. This API will disable the automatic activation from Adobe Fonts.

 

app.fonts.substitutedFontReplacementMatchPolicy
When After Effects has a missing Font reference when opening a Project, which appears in the UI as a bracket font name at the bottom of the Character Panels, it will automatically look in the Font environment to find a candidate Font to replace it with.

 

Consider the case where a Project file was saved using Courier on Windows, and then opened on the Mac. If the two installed Font instances do not share the same Font properties that After Effects requires, it will be treated as a missing Font reference when opened on the Mac.
It is longstanding behavior in After Effects to silently allow this sort of quiet substitution, and so by default when evaluating a missing Font reference we only require that we find another Font instance that has the same PostScript name to replace it.

 

All this happens automatically but do be aware that the Project IS changed by the replacement of the original referenced Font with the replacement Font. If this Project was saved and brought back to Windows the same thing would happen again in reverse.

 

Some workflows do not want this loose behavior at all - a close substitute, merely by PostScript name, is not acceptable to them. It is better to realize the Font is missing and go find it than have the composition change in a silent and potentially undesired way.

 

Other workflows do not want any replacement at all - a popular assumption being that all the Fonts should have been already installed so why is anything missing at all?
This API provides these two additional policies over the default PostScript-name-only one.

 

app.fonts.pollForAndPushNonSystemFontFoldersChanges
Finally, erver-based workflows which need to add and remove their own Font instances through scripting without resorting to using the OS tools, have a challenge in getting After Effects to notice that the Font environment has changed through their actions.

 

Fonts that are changed through the OS tools, and by Adobe Fonts activation, are automatically detected but Fonts that are changed in the Application Support Fonts folder (and the equivalent on Windows) are not detected until After Effects restarts or the Font environment changes in folders which are automatically detected. This experimental API allows the scripter to give the Font environment a little push to recognize if the Font environment has changed outside of the System Font folders, and it has it will schedule an update to the Font environment to process it.


It has been requested that we expose the ability to dynamically add additional Font search folders - it is something we are considering.

 

As always we are interested in hearing about the successful use of these APIs and feedback on how they might be made better for your workflow.

 

Douglas Waterfall, John Colombo & Sébastien Périer
After Effects Engineering

TOPICS
Feature request

Views

323

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

I've been using app.fonts.mruFontFamilyList and app.fonts.favoriteFontFamilyList and they're working great! I'd only really considered syncing favorites but now I've played with mru it's equally useful.

 

A slight issue is the Character/Properties panels needs a bump (like collapsing/uncollapsing the panel or selecting a text layer) before the font list updates after receiving new string arrays, which will give users an initial impression that it hasn't changed.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

Hi @Paul Tuersley , glad you found this.

 

The CharPanel updates itself on the idle task so a change to the font environment does not instantly trigger an update there.

 

I am away from my work computer for a while so I cannot remind myself what the code does when these lists change.

 

You might try to $.sleep(1000) to see if I thought ahead on this.

 

Changing the sort order, Show English Names, does handle this properly but I do not remember if that was exposed to scripting.

 

Adding or removing a font will trigger recognition as well - even if only a custom variable one.

 

Douglas Waterfall

After Effects Engineering 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

$.sleep(1000) doesn't seem to do it, and I don't think sort order or Show English Names are exposed.

 

Is this likely something that can be addressed without needing some workaround? I'm not in any hurry for a solution.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

It should be automatic without any workarounds but I missed it - you were my target customer.

 

I will fix this when I return to the office.

 

You might try Favorites after syncing Source Code Pro from Adobe Fonts - these are partial duplicates with what is in the App package. I had to do something weird and obscure to get the old UI code to show them both - append space(s) to the duplicate family instances when it is registered with the UI.

 

Not sure there is a better solution, though I suppose I could expose an API on the Font to return the FavoritesFamilyName.  Yuck.

 

Douglas Waterfall

After Effects Engineering

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

Just using family names did strike me as curious against the backdrop of previous talk we've had on edge cases, but I've not sourced a suitable selection of problem fonts to get into testing the horrors of duplicates yet.

 

I did just enable Source Code through Adobe fonts. It didn't show up until I relaunched AE (which I thought wasn't necessary). But on relaunch a second 'Source Code Pro' allFonts entry did appear with the new styles. And they do show as separate entries in AE's font menu. I'm not seeing anything with appended spaces.

 

Adding or removing 'Source Code Pro' to MRU or favourites does apply it to both instances, which I guess is what you were getting at with familyNames being an imperfect solution. I like the simplicity of the current solution, but yes it does mean a round trip from and to AE's font menu will munge that information with regard to duplicates.

 

I guess there could be cases where someone has duplicates and purposefully favourites the specific ones they want, that wouldn't be best pleased when my script instantly wrecks their careful organisation, or fills their 14 MRU slots with duplicates. Another 'how important are edge cases?' situation.

 

On a separate note, there seems to be some crazy bug in the big Adobe 'font with samples' menu currently where styles multiply every time you look at them. So that's fun! And I also learnt that the Preview Size in the Type prefs does in fact work, you just need to restart for that to change. I only even found that because I was looking for the MRU max pref, neither of which are in the Character panel side menu where you might expect them.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

Another quick thought. I don't know what your 'yuck!' alternate entry point for reading/writing mru/favorites accurately was, but maybe an alternate would be to supply an array of fontIDs instead of family names? 

 

Is the first fontID on any allFonts instance a fixed point in a single AE session that could identify the family? I'm already storing my own version of allFonts and would think I could supply or reconcile an array of fontIDs. 

 

Even better, AE supplies me an array of both [familyName, one of the fontIDs] for an easy lookup and I can supply AE just an array of fontIDs.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

Alas, the UI only wants a Family Name and so ALL the styles/faces are considered to be part of the favorite.

 

Source Code Pro should automatically show up without relaunching. Did you close and reopen the Char Panel?

 

As for trailing spaces in the Favorite Family Name - you would not see it in the UI (it is a space) but I expect the the Favorities will have one. Select them both and read back the list - the second one in sort order ought to have one I think.

 

Douglas Waterfall

After Effects Engineering

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 26, 2024 Mar 26, 2024

Copy link to clipboard

Copied

Alas, the UI only wants a Family Name and so ALL the styles/faces are considered to be part of the favorite.

 

I realise we're only talking about identifying family instances not styles, but just thought that might be a way to actually identify a specific family instance. But if there's no way to even interact with the font UI with anything more accurate than family name then I guess we just accept the round trip duplicate issue when syncing. Maybe we could even have figured it out with an array of menu indexes if they tallied in a consistent way with allFonts at that moment.

 

I tried having only one Source Code Pro favorited in the font menu and found on restart they both were so I see that issue is built-in. It doesn't seem to get confused by preserving MRU without duplicates though.

 

for trailing spaces in the Favorite Family Name - you would not see it in the UI (it is a space) but I expect the the Favorities will have one. Select them both and read back the list - the second one in sort order ought to have one I think.

 

This is what I get back from AE after I've manually used the Character panel to get the dupe fonts into the top slots.
favs = *Source Code Pro*Source Code Pro*
mru = *Source Code Pro *Source Code Pro*

 

There's no extra space in favourites but there is in MRU. Is that why MRU preserves itself on relaunch but Favorites doesn't?

 

If the lack of it on Favorites is an error, and this will actually be consistently present for duplicate family entries, could we deduce which specific family instance is meant based on how many spaces are added and even feed that back to AE with spaces intact and understood?

 

Even if the order wasn't guarantee to be the current allFonts order, perhaps the fontID ranges inside each instance would reveal the original order the family instances were created and so which one would have x number of spaces?

 

Source Code Pro should automatically show up without relaunching. Did you close and reopen the Char Panel?

 

I tried using CC to remove Source Code Pro, then collapsed/uncollapsed the Character panel and it still showed two entries. I tried creating a comp and text layer to see what it'd do with this potentially unknown now missing font and got an endlessly repeating After Effects (Beta) warning: Unknown Exception that required a force quit.

 

I relaunched, tried also removing Source Sans Pro using CC and that did seem to disappear without prompting. I then used CC to enable Source Sans Pro but closing and reopening the Character panel didn't cause it to appear. I relaunched and it was now in the font list.

Tried removing again using CC, it was still in font list this time, selected it, clicked with Text tool in comp and got repeating Unknown Exception error.

 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Mar 26, 2024 Mar 26, 2024

Copy link to clipboard

Copied

Thanks for pursuing this - it will save me a bit of time when I return to my desk.

 

Unfortunately the only thing which is persisted IS the string, no other data. 

 

The old UI code is not prepared to have duplicate Families and the trailing space is just a dodge so it will allow it, but you see the limitations with the mru/fav.

 

Favorites is kind of crude, imho, because one might not want the whole font, and with some fonts having many styles it can still be a tall list.

 

As for Source Code Pro, as I mentioned AE ships with a special instance of this to support the expressions editor. It is a different font the. Adobe Fonts has, but they share the same PostScript name - thus the duplication. So you should never be able to remove all references to Source Code Pro.

 

Sounds like there are issues with transitioning these - it should not be crashing and I will look into that.

 

Douglas Waterfall

After Effects Engineering

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 26, 2024 Mar 26, 2024

Copy link to clipboard

Copied

I don't mind favorites being family only. I feel having to manage style favorites would be too fine grained and probably lead to confusion.

 

For favorites and MRUs, if all duplicate families did have spaces at the end, and each subsequent duplicate gets +1 additional space, then I can't help but think that might be the extra info I need to identify specific family instances and preserve them in a roundtrip to and from AE. It just depends how consistent that extra space hack is and whether AE will recognise them when given back inside the same session.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Mar 26, 2024 Mar 26, 2024

Copy link to clipboard

Copied

Duplicates are a hassle, but probably not that common - but it is worth it to think about it.

 

The UI is built based on the sort order so duplicates in terms of Family Name is determined by the order the UI  finds the families. First duplicate gets one trailing space, second gets two, etc.

 

The favorites list is a just loaded into the UI and matched against these entries - so there is no guarantee that it always points to the same family instance.

 

Now, if you are going to manage your own list, you could figure out what family is being referenced by the favorite and gather some more information with which to identify it - technology and writingScripts[0] would be good ideas. Then you remember that, and when it comes time to build the favorites from your list you go find the fonts in the big list and then see what nTh duplicate it is. With that, you know how many trailing spaces to add.

 

Yuck.

 

Douglas Waterfall

After Effects Engineering

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

LATEST

Yuck indeed. It's the kind of thing I might do in my code, but not what I'd expect from an AE scripting API! I guess a side effect of dealing with an Adobe wide technology in the font menu. And being an undocumented quirk I imagine the danger of it changing in future releases is quite high.

 

- I've been able to successfully identify the specific duplicate family instances using the spaces at the end after grabbing the app.fonts.mruFontFamilyList array.

 

- AE does not correctly add MRU to those duplicate instances when you write back to mruFontFamilyList. It fails to do anything with the array item with the space on the end. It's impossible to tell AE to MRU a duplicate family instance currently. A basic example, the following script will remove any duplicate families from the current MRU:
app.fonts.mruFontFamilyList = app.fonts.mruFontFamilyList;


- app.fonts.favoriteFontFamilyList doesn't currently even supply duplicates with spaces. You just get multiple copies of the family name without any spaces.

 

It seems you're relying on this between AE launches too, as it suffers all the same issues. An AE restart will lose any MRU entries that were duplicates because it's unable to recognise its own system of added spaces. And for favorites, if even one of a duplicate family was favorited then on relaunch all will be favorited because it has no concept of spaces at all. At least this is what seems to be going on.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources