Paragraph spacing option

I really appreciate all the great text formatting options — thanks! One option I'd love to see added is paragraph spacing. This could be passed as an optional argument to and friends, and/or set via e.g. This would manifest as extra space (increased leading) before the next line following a hard-coded \n within the provided text.

This would make it convenient to manage small blocks of stylized text without needing to manually account for the size of each line/paragraph they contain. Some examples:

  1. Longer form text, with multiple paragraphs of prose
  2. Short lists, to add extra space between list items
  3. Title + description blocks, where the title might be bolded, followed by a small gap, followed by one or more lines of wrapped text

I've already hacked together a small change to _layoutTextInRect in CoreLibs/graphics.lua which achieves the effect, which I can share if helpful. It's quite straightforward since the inner loop already iterates over each hard-broken line — just add the appropriate paragraphSpacing at the very end of each loop. However, since I couldn't set a property on the font object itself, I cheated and just set in order to get the desired value into that function cheaply. Would be great to have official support!

As far as parameterizing it, I'm not sure which approach to specifying paragraph spacing makes the most sense, but I'd accept any of:

  1. An additive value (added to leading)
  2. An override value (used instead of standard leading)
  3. A multiplier (e.g. 1.5 would yield space equal to lineHeight * 1.5 between paragraphs)


1 Like

I've also needed this.