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

Font size increased after modify Arabic text conent by jsx?

Explorer ,
Nov 14, 2023 Nov 14, 2023

Copy link to clipboard

Copied

LoveYou6666_0-1699951306343.pngexpand image

LoveYou6666_2-1699951656975.pngexpand image

 

LoveYou6666_1-1699951602129.pngexpand image

 

 

I have a textframe and I want to replace the text content.

Here is my code 

var doc = app.open(new File("D:\\test.ai"));
var layers = doc.layers
layers[0].textFrames[0].contents = "عنب كرز"

previous font size is 12pt, after the operations, font size is 50pt, it's so strange!

test.ai 

font is HelveticaNeueLT Bold 

TOPICS
Bug , Scripting , SDK , Tools

Views

524
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

correct answers 1 Correct answer

Community Expert , Nov 14, 2023 Nov 14, 2023

@LoveYou阿逗逼6666, you could try something like this:

var doc = app.open(File(File($.fileName).parent + '/SUPPLIED/test.ai'));
var text = doc.layers[0].textFrames[0].textRange;

text.paragraphStyles[0].clear();
text.contents = "عنب كرز";

but it is actually altering the Paragraph Style and I think it might mess up your text. In my test, it changed the arabic—probably because of a setting needed in the style that I cleared. If you know the settings needed, we can set those with the script though.

 

...

Votes

Translate
Adobe
Guide ,
Nov 14, 2023 Nov 14, 2023

Copy link to clipboard

Copied

I can't replicate the problem, possibly because I don't have Arabic enabled.  Assuming it's a bug, you could just re-size.

var size = layers[0].textFrames[0].textRange.size;
layers[0].textFrames[0].contents = "عنب كرز";
layers[0].textFrames[0].textRange.size = size;

 

Votes

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
Community Expert ,
Nov 14, 2023 Nov 14, 2023

Copy link to clipboard

Copied

Hi @LoveYou阿逗逼6666, this is happening because of the interaction between your "Basic Paragraph" paragraph style and the way setting of "contents" works in scripting.

The quick answer is to redefine the "Basic Paragraph" style so it is 12pt (at the moment it is 50pt), or just change the text to NO style.

- Mark

Votes

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
Explorer ,
Nov 14, 2023 Nov 14, 2023

Copy link to clipboard

Copied

how to redefine the "Basic Paragraph" style?

Votes

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
Community Expert ,
Nov 14, 2023 Nov 14, 2023

Copy link to clipboard

Copied

You can choose (A) "Redefine Style" in the Paragraph Styles panel (choose the equivalent for your language, if not English) which will make the paragraph style match the curent selected text style:

Screenshot 2023-11-15 at 13.14.02.pngexpand image

- Mark

Votes

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
Explorer ,
Nov 14, 2023 Nov 14, 2023

Copy link to clipboard

Copied

I just want to change text content and avoid changing any text styles. how to keep the origin Paragraph Styles by jsx?

Votes

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
Community Expert ,
Nov 14, 2023 Nov 14, 2023

Copy link to clipboard

Copied

It seems that when we set the "contents" via a script, Illustrator inserts the new text using the non-overridden paragraph style, which is set to 50pt size.

Votes

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
Community Expert ,
Nov 14, 2023 Nov 14, 2023

Copy link to clipboard

Copied

LATEST

@LoveYou阿逗逼6666, you could try something like this:

var doc = app.open(File(File($.fileName).parent + '/SUPPLIED/test.ai'));
var text = doc.layers[0].textFrames[0].textRange;

text.paragraphStyles[0].clear();
text.contents = "عنب كرز";

but it is actually altering the Paragraph Style and I think it might mess up your text. In my test, it changed the arabic—probably because of a setting needed in the style that I cleared. If you know the settings needed, we can set those with the script though.

 

If that doesn't help, the final thing would be to have your script apply a correct paragraph style. It often becomes important to fixing bad paragraph styles because of these kinds of problems.

- Mark

Votes

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