FixedLineSpace

From Director Online Wiki
Jump to: navigation, search

Here's some code to get the default fixed line space (fixedLineSpace) of a text member at the insertion point. The reason for it is because if the fixedLineSpace has not been changed to a custom value then when trying to get the value when it's the default value will return a big, fat ZERO.

Here's the code:

on getFixedLineSpace (theMem, theChar)
  theField = new(#field)
  if theChar = 0 then
     theChar = 1
  end if
  theField.text = theMem.char[theChar]
  theField.font = theMem.char[theChar].font
  theField.fontSize = theMem.char[theChar].fontSize
  theLineHeight = theField.lineHeight - 1
  theField.erase()
  return theLineHeight
end

Example on how to use:

theChar = member("text").selection
member("output").text = string(getFixedLineSpace (member("text"), theChar[1]))