Copy link to clipboard
Copied
uppercase
I need to read that option from TextFrame. Is there a way?
There's FontCapsOption in CharacterAttributes, but it seems it does different thing..
Thanks in advance.
1 Correct answer
What you're looking for is the capitalization attribute.
alert(app.activeDocument.textFrames[0].textRange.characterAttributes.capitalization)
app.activeDocument.textFrames[0].textRange.characterAttributes.capitalization = FontCapsOption.ALLCAPS
alert(app.activeDocument.textFrames[0].textRange.characterAttributes.capitalization)
on a blank document, this sample code just targets the first text frame and changes the capitalization setting to all caps. All of the Font Cap options you mentioned ar
...Explore related tutorials & articles
Copy link to clipboard
Copied
Thanks for your answer and sorry for being unclear, I have updated the description now - but I need it in Illustrator...
Unfortuantely, illustrator's CharacterAttributes does not seem to to have this key.
Copy link to clipboard
Copied
Unfortunately, the last reply appears to be from an Ai bot. They've been flooding the forum lately with only marginally correct (but generally incorrect) answers.
Back to the topic:
What exactly do you want to find (capitalise letters or words or sentences or whole paragraphs? and what exactly do you want to do with the result?
Personally, I usually use REGEX (regular expressions) in Javascript for such cases. However, to set up a suitable rule for REGEX, you need to know exactly what you want to search for (and ideally also what you want to do with the result afterwards).
Copy link to clipboard
Copied
thank you, and yes that would be an approach to detect these changes.
I had wrong impression these menu commands set a setting to capitalization.. when in fact they modify actual contents.
Copy link to clipboard
Copied
What you're looking for is the capitalization attribute.
alert(app.activeDocument.textFrames[0].textRange.characterAttributes.capitalization)
app.activeDocument.textFrames[0].textRange.characterAttributes.capitalization = FontCapsOption.ALLCAPS
alert(app.activeDocument.textFrames[0].textRange.characterAttributes.capitalization)
on a blank document, this sample code just targets the first text frame and changes the capitalization setting to all caps. All of the Font Cap options you mentioned are what are used here
FontCapsOption.ALLCAPS | All Caps |
FontCapsOption.ALLSMALLCAPS | All Smallcaps |
FontCapsOption.NORMALCAPS | Normal Caps |
FontCapsOption.SMALLCAPS | Small Caps |
EDIT:
Wanted to also add. The above is a display change to the text. The text may internally be set as "Lorem Ipsum" but changed to display setting as All Caps would display as "LOREM IPSUM" while maintaining the internal text as "Lorem Ipsum". To access the Change case functionality you can either do a heavier coding approach to change the text contents or use the executeMenuCommand to access those commands.
https://ten-artai.com/illustrator-ccver-22-menu-commands-list/
app.executeMenuCommand("UpperCase Change Case Item")
app.executeMenuCommand("LowerCase Change Case Item")
app.executeMenuCommand("Title Case Change Case Item")
app.executeMenuCommand("Sentence case Change Case Item")
Copy link to clipboard
Copied

