Highlighted

changing font size and text width does not update -- am I missing something?

Explorer ,
Jun 05, 2020

Copy link to clipboard

Copied

I change the font size of a point text, but text width stays the same.  What am I doing wrong?  Being new to this, I am baffled.

here is the code,

 

/*** font size update problem ***/
var doc = app.documents.add();
var t = doc.textFrames.add();
t.position = [200,200];
t.contents = "Hello World!";
size = t.textRange.characterAttributes.size;
$.writeln('kind=', t.kind);
$.writeln('contents=', t.contents);
$.writeln('character size=', size);
$.writeln('text width=', t.width);
size -= 5
$.writeln('character size=', size);
$.writeln('text width=', t.width);

 

and this is console record

 

contents=Hello World!
character size=12
text width=60.875
character size=7
text width=60.875
Result: undefined
kind=TextType.POINTTEXT
contents=Hello World!
character size=12
text width=60.875
character size=7
text width=60.875
Result: undefined

 

I have also attached the screen shot after the execution of the above code.  Thank you!

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Change the statement size -= 5 to the following

t.textRange.characterAttributes.size -= 5

 

-Manan

Topics

How to, Scripting, Type

Views

383

Likes

Translate

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

changing font size and text width does not update -- am I missing something?

Explorer ,
Jun 05, 2020

Copy link to clipboard

Copied

I change the font size of a point text, but text width stays the same.  What am I doing wrong?  Being new to this, I am baffled.

here is the code,

 

/*** font size update problem ***/
var doc = app.documents.add();
var t = doc.textFrames.add();
t.position = [200,200];
t.contents = "Hello World!";
size = t.textRange.characterAttributes.size;
$.writeln('kind=', t.kind);
$.writeln('contents=', t.contents);
$.writeln('character size=', size);
$.writeln('text width=', t.width);
size -= 5
$.writeln('character size=', size);
$.writeln('text width=', t.width);

 

and this is console record

 

contents=Hello World!
character size=12
text width=60.875
character size=7
text width=60.875
Result: undefined
kind=TextType.POINTTEXT
contents=Hello World!
character size=12
text width=60.875
character size=7
text width=60.875
Result: undefined

 

I have also attached the screen shot after the execution of the above code.  Thank you!

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Change the statement size -= 5 to the following

t.textRange.characterAttributes.size -= 5

 

-Manan

Topics

How to, Scripting, Type

Views

384

Likes

Translate

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
Jun 05, 2020 0
Adobe Community Professional ,
Jun 05, 2020

Copy link to clipboard

Copied

Change the statement size -= 5 to the following

t.textRange.characterAttributes.size -= 5

 

-Manan

Likes

Translate

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
Reply
Loading...
Jun 05, 2020 0
Explorer ,
Jun 05, 2020

Copy link to clipboard

Copied

Thank you, Manan Joshi!  It worked as you suggested.

 

The problem is  that t.textRange.characterAttributes.size is a string, not an object.  Most properties are objects, and therefore are 'call by reference'.  But strings are always 'call by value,'  I think.

In the above code, t = doc.textFrames.add(); is call by reference, so, any changes to t result in changes to the original property.  But, size is call by value, so changes to size will have no effects on the original property.

Likes

Translate

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
Reply
Loading...
Jun 05, 2020 0
Adobe Community Professional ,
Jun 05, 2020

Copy link to clipboard

Copied

"the problem is that...."

 

do you still have questions about this? 

Likes

Translate

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
Reply
Loading...
Jun 05, 2020 0