Skip to content

Conversation

@fartinmartin
Copy link

Current layerRect() will calculate lineGap based on sourceText.style.leading and multiply by number of lines:

aefunctions/src/index.ts

Lines 300 to 307 in a6a7771

if (layer.text && xHeight) {
const { fontSize, leading, autoLeading } = layer.text.sourceText.style;
const lineGap = autoLeading ? fontSize * 1.2 : leading;
const textSize = fontSize / 2;
const numLines = textCount(layer.text.sourceText.value, 'line');
height = lineGap * (numLines - 1) + textSize;
topLeft = [left, -textSize];
}

But, if a text layer has per-character styles applied (via UI, or via expressions from something like style-parser) we'd need to calculate lineGap based on the styles at each line's starting character index value.

This PR introduces a new option consistentLeading that when set to false will calculate as described. (Open to a better option name/API here, haha!)

Additionally, the spaceBefore and spaceAfter paragraph props can affect the height of a given text layer. This PR adds the appropriate height given said paragraph spacing as well.

Here's an example project to check out: aefunctions-layerRect.zip

Note: In this PR, I no longer use textCount() to determine numLines. I found the regexp in this PR to be more consistent/expected—let me know if it breaks an edge case I haven't considered!

…` + `spaceBefore`/`spaceAfter` paragraph props
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant