[Bug report] lineSpacing

Issue

Text.lineSpacing returns 0 when using the default lineSpacing (24). It correctly returns after changing lineSpacing.

My code :

const { Text } = require(‘scenegraph’) ;

const textNode = selection.items[0] ;
console.log(textNode.lineSpacing) ;

Expected Behavior

24

Actual Behavior

0

@sttk3

Are you still seeing this issue? I’m unable to replicate this any more.

1 Like

Returning 0 for default is the expected behavior. See the docs: https://adobexdplatform.com/plugin-docs/reference/scenegraph.html#Text-lineSpacing.

It sounds like you might be interested in an API to get the overall font metrics of a Text object. Please upvote this request if so: Get font metrics.

1 Like

Thank you for contacting. I know that now.

lineSpacing was this rule.

  • If lineSpacing is 0 then it is AutoLeading
  • autoLeadingValue = Math.ceil(characterSize * 1.7)
  • If the line is blank, narrow spacing by half of character size

I’m not sure if it’s always going to be a * 1.7 multiplier by default… that might depend on each font’s individual metrics.

1 Like

It is a pity.
If the plugin can see graphicContent.agc directly, I can use the position and range of text.

I think line spacing is returning values now if it didn’t in the past.

1 Like

Thank you.

I’m sorry I made you spend time and effort.
To close the question, I need to flag the correct answer.

Hi,

I am experiencing the same issue. Getting line-spacing as 0 from the plugin but on my xd document, when I inspect, I see line-spacing value there. I don’t explicitly set a value for line-spacing but I want to get the default value.

Could you please help me getting default line spacing value?

I don’t know how to get the default value for line spacing, but the actual line spacing can be obtained as follows.

  1. Export the target text as svg
  2. Calculate the difference between the y attribute of the tspan tag

You can find the corresponding source code in Split Rows.