Copy link to clipboard
Copied
Hello!
I'd like to mix the script that choose font weights plus the script that choose font family.
Script to choose Font Weight:
var fontWeights = [
'Regular',
'Bold',
];
family = thisProperty.style.font;
family = family.split('-');
select = Math.round(clamp(effect("Select Weight")("Slider"), 0, fontWeights.length - 1));
createStyle().setFont(family[0] + '-' + fontWeights[select]);
Script to choose Font Family:
var fontArray = [
"Arial",
"Trebuchet MS",
"Times New Roman"
];
v = Math.round(effect("Select Font")("Slider"));
style.setFont(fontArray[v]);
Can you help me?
There doesn't seem to be a good algorithm for turning a font name into the bold version of that font name, so I think something like this is probably as close as you can get:
fonts = ["ArialMT","TrebuchetMS","TimesNewRomanPSMT"];
boldFonts = ["Arial-BoldMT","TrebuchetMS-Bold","TimesNewRomanPS-BoldMT"];
fontSelect = clamp(Math.round(effect("Select Font")("Slider")),0,fonts.length-1);
weightSelect = clamp(Math.round(effect("Select Weight")("Slider")),0,1);
fontName = weightSelect > 0 ? boldFonts
...
Copy link to clipboard
Copied
Anyone can help me? Please!
Copy link to clipboard
Copied
There doesn't seem to be a good algorithm for turning a font name into the bold version of that font name, so I think something like this is probably as close as you can get:
fonts = ["ArialMT","TrebuchetMS","TimesNewRomanPSMT"];
boldFonts = ["Arial-BoldMT","TrebuchetMS-Bold","TimesNewRomanPS-BoldMT"];
fontSelect = clamp(Math.round(effect("Select Font")("Slider")),0,fonts.length-1);
weightSelect = clamp(Math.round(effect("Select Weight")("Slider")),0,1);
fontName = weightSelect > 0 ? boldFonts[fontSelect] : fonts[fontSelect];
style.setFont(fontName)
Copy link to clipboard
Copied
@Dan Ebberts is correct - fonts are not generically structured in the way that you are trying to use them.
In the end of course with font property you have to select the PostScript name you desire, and at the time you wrote this that was not easy to figure out.
However, now with app.fonts in 24.0 you can browse all the fonts installed on your system and identify the families and faces available in each of them.
You can read about that here: https://ae-scripting.docsforadobe.dev/other/fontsobject.html
Douglas Waterfall
After Effects Engineering