Copy link to clipboard
Copied
Does anyone know of a script to do this? I imagine the script will have to take the height of the text-box and divide it by two. However, the size of the text will probably have to be taken into consideration as well.

Copy link to clipboard
Copied
The script would have to calculate something such as a baseline shift, and you would need to let us know what you want to do about ascenders and descender.
Might be better to post here, or I can move your post for you
There are ways to do this without scripting, of which will add a separate reply.
Copy link to clipboard
Copied
I have a hard time believing there isn't a script that auto-adjusts the baseline shift in the Character menu.
Copy link to clipboard
Copied
matthews63743827 schrieb
I have a hard time believing there isn't a script that auto-adjusts the baseline shift in the Character menu.
I have a hard time believe …
… that you completely ignored the questions and advices of MikeGondek
Please see that screenshot. In your opinion - where (or what) is the best alignment???

What kind of alignment do you prefer?
Do you have some examples with a detailed explanation (or at the best an: example.ai) for us?
Copy link to clipboard
Copied
Please no insults.
And then: again read my contribution, think meticulously and then answer.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
...a vertical align script is likely possible, and probably fairly simple, especially since InDesign has a vertical align option.
Illustrator and InDesign use entirely different text engines. Illustrator (lamely) shares the one in Photoshop, not the one in InDesign.
I wonder how they made that work? Oh yes! Code.
Just because two programs (ex:, InDesign and Illustrator) can be scripted does not mean that the same things can be done in them with a script. What can be done via scripting in either program is entirely dependent upon what objects, methods, and properties are defined in the scripting API for that program.
Vertically-centering text is a built-in feature of an InDesign textFrame object. So (although I haven't checked) the textFrame object in InDesign's scripting API probably has a property for vertical centering whereas Illustrator's API does not. So in InD scripting, vertically centering text probably just involves setting a textFrame's property. But doing it in AI scripting, would require devising a considerably more tedious and elaborate workaround for the absence of that property, which is why people are trying to get you to understand that "centering" text vertically is an ambiguous requirement because "height" of text is typeface-specific.
The problem is very much the same as the common complaint that software text is not actually scaled to the visible "height" of the characters. People in the sign trade, for example, are often required by customers (who don't understand typography) to create text at a specific measured "height." In order to state that problem in terms of "code," you have to exactly specify what "height" means to you. (The height of an italic glyph's flourish? The X height? The Cap Height?)
Years ago, I wrote an Illustrator script which "sets" type to what most users with that complaint usually want: the CapHeight. It works, but the "behind-the-scene" workaround involved was rather ridiculous: It obtained the size attribute from a character in the selected textFrame, created a temporary textFrame object at the page origin, set its content to a single X character, converted it to paths in order to obtain the height of the path, deleted the path, and then used that height as a scaling factor for the text size of the selected textFrame.
So yeah, someone could write an AI script to do what you want using some similarly silly workaround, if you specifically detail your expectations. But I wouldn't bother doing it because I quit expending time and energy on scripts for Adobe applications the day Adobe decided I had to rent its software, and because there is a commonly used workaround for vertically centering text in a box anyway:
JET
Copy link to clipboard
Copied
Hi JETalmage,
well spoken.
JETalmage wrote:
… Years ago, I wrote an Illustrator script which "sets" type to what most users with that complaint usually want: the CapHeight. It works …
Funny, I did the same, but for Photoshop only (years ago).
![]()
JETalmage wrote:
… workaround for vertically centering text in a box anyway:
- Create a PathType object.
- In the Appearance Palette, give it an additional Fill.
- Position the second Fill below the Characters listing.
- Apply the Convert To Shape Effect to the second Fill and set its Extra Space value as desired.
- Save the whole construct somewhere (as a Symbol, for example) so it can be re-used elsewhere.
…
Exactly.
This is, how the yellow boxes in my post #5 was created.
![]()
Copy link to clipboard
Copied
If you goal is to get the type in the center of the text box, that is not possibly in Illustraro as in InDesign.
You can have the align palette to do this, but you need to do 2 things

The reason the align palette does not by default center text, is that it is centering upon the font (including the space above and below the ascenders and descenders, coded into the font.
Not sure if this helps you, but please clarify or provide an example with more detail of what your end result you are looking to do.
Copy link to clipboard
Copied
Or you may be content with double clicking here

to trim excess unused height from your text container. I added a descender so you can see how important this is to consider.

Find more inspiration, events, and resources on the new Adobe Community
Explore Now