Copy link to clipboard
Copied
Hello, I am trying to make a tool: Create a Text font size based on comp size.
For example: comp is 540px = Font size: 105px. Not change the Scale property. Find the font size given the Width and Height of comp and length of the string.
I searched forums and found this script code, and it's working perfectly on the already created text layers.
I tried to make it with Automation Blocks, but it did not work correctly.
Can you help to make this happen?
Thank you
Copy link to clipboard
Copied
Hi Onder,
I just added a tool to the Community Library at
Comps/Comp Size/Change Comp Size and Scale Content.xml
which does this with each currently selected text layer of the active comp:
-measures the width of the text layer
- changes the font size such that the layer width is X% of the width of the comp. (where X can be entered in a dialog)
Copy link to clipboard
Copied
PS: manipulating text details is a bit tricky, but the tool contains some clever workarounds. In a nutshell, the keyframes blocks can give you a text in json format with all text attribute details. The tool includes
- a function which retrieves these text attributes
- a function which reads the font size from the text attributes
- a function which sets the font size of the text attribues
Those functions are probably also useful in other tools - and you should be able to write functions to get/set other text attributes in the same way.
For retrieving the text attribute json also see this tutorial.