Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

Where exactly on canvas is textFrame's "top"?

$
0
0

I have a script putting some elements on screen — a rectangle and a couple of text items.

 

While the top and left position of the rectangle falls exactly where it's supposed to, I can't quite figure out what top value of a textFrame item means. See the code and corresponding result — the text items' baselines are slightly below the top of the rectangle. Why and how can I precisely control the placement of text items, specifically the "top" value as it seems not to correspond to anything?

 

// For loop

// Box
var dayBox = docRef.pathItems.rectangle( dayTop, dayLeft, dayWidth, dayHeight );
dayBox.filled = false;
dayBox.stroked = true;
dayBox.strokeColor = newColor;
dayBox.strokeWidth = sDay;

// Text
var dayNameText = docRef.textFrames.add();
var k = new Date(year, m, d);
var dayName = k.getDayNameShort(ypLang);
dayNameText.contents = dayName;
dayNameText.top = dayTop; // "top" of what?
dayNameText.left = dayLeft;
dayNameParaStyle.applyTo(dayNameText.textRange);
dayNameCharStyle.applyTo(dayNameText.textRange);

var dayNumberText = docRef.textFrames.add();
dayNumberText.contents = d + 1;
dayNumberText.top = dayTop; // ?
dayNumberText.left = dayRight;
dayNumberParaStyle.applyTo(dayNumberText.textRange);
dayNumberCharStyle.applyTo(dayNumberText.textRange);

 

Screen Shot 2015-11-09 at 10.47.03.png


Viewing all articles
Browse latest Browse all 12845

Trending Articles



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