Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 83883

addBoxText() long creation time

$
0
0

I haven't much experience with long box texts and ran into this problem that i had never noticed before for short texts:

 

The addBoxText() method can have two arguments 1: the box size and 2: the text.

It appears that if :

- the text is specified in the constructor,

- the textDocument is retrieved to edit it (says the font, fontSize ,etc) and the value set

then time to create the text layer can be huge for long strings.

The problem disappears if the text argument is omitted in the constructor.

 

Below is a sample test to illustrate.

It creates a temp comp (deleted after), add three text layers with different creation scenarios

I get these times (approx - on both CC2014 and CS6) :

1 : 0.05 sec

2 : 6.12 sec

3 : 0.04 sec

 

I have "fixed" the problem by taking option 3, but i'd like to know if it can be reproduced, and what is the best/standard way to do.

 

Xavier.

 

// create some long string (at most 2000 chars)
var text = " hello.";
while (text.length<100) text += text;
text += "\r\r";
while (text.length<1000) text += text;

var comp =  app.project.items.addComp("test", 1920, 1080, 1, 1, 25);
var layer, p, t;
var timers = [];

$.hiresTimer;

// create a boxText, specify the text in the constructor, but do nothing else
layer = comp.layers.addBoxText([1920, 1080], text);
timers.push("1 -  text specified - no edit : " + ($.hiresTimer/1e6).toFixed(2) + " sec");

// create a boxText, specify the text in the constructor, retrieve the text doc to edit it (no edit is done!!!!!), and set the value =========> L-O-N-G
layer = comp.layers.addBoxText([1920, 1080], text);
p =layer.text.sourceText;
t = p.value;
// edit : t.font = "Ebrima", t.fontSize = 50; etc
p.setValue(t);
timers.push("2 -  text specified - with retrieve/set : " + ($.hiresTimer/1e6).toFixed(2) + " sec");

// same as 2, but dont specify the text in the constructor =========> OK
layer = comp.layers.addBoxText([1920, 1080]);
p =layer.text.sourceText;
t = p.value;
// edit : t.font = "Ebrima", t.fontSize = 50; etc
t.text = text;
p.setValue(t);
timers.push("3 -  text NOT specified - with retrieve/set : " + ($.hiresTimer/1e6).toFixed(2) + " sec");

comp.remove();

alert(timers.join("\r\r"));

Viewing all articles
Browse latest Browse all 83883

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>