Tuesday, July 24, 2007


Get the Lead out!

The question was asked in the U2U forum: what does it mean in the InDesign CS3 Object Model Viewer (available from ESTK 2's Help menu) when a property is described as having the value "any"?

Well, the answer to that specific question is that "any" is a poor choice of terminology. "Varies" or "various" would be better choices.

Generally speaking, when a property is described as having a value of type "any", what it means is that you can set the value with any of a set of variable types, but what you'll get when you query the value is usually always the same type of variable; that variable type that most closely matches the property's nature.

And that led me to recall a function I've used countless times to get the leading of a text object (more precisely, the leading of the first character the text object -- unless the object is a single insertionPoint, in which case you get its leading), where two different kinds of value can be returned by the property:
function getLeading(text) {
  var leading = text.leading;
  if (leading == Leading.auto) {
    leading = text.pointSize * text.autoLeading/100;
  return leading
Actually, this can be used to get the leading of paragraph styles, too.

For character styles, you have to be a tad careful because you could have a paragraph style where either the leading or the pointSize (or both) are set to be ignored (in which case you get the value NothingEnum.nothing), so you could use this function for character styles, but you'd be better off constructing one that addresses these other possibilities.

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?