There is quite a lot to unpack in this expression. So, let’s star from beginning.
First, we are defining all the sources, which we will use throughout this expression and then variables. Then we are defining starting X and Y positions, based on main Name Text layer.
Then I’m running to match functions on text string, with defined search parameters. Once this is done, I’m running 2x if statements. First to check if there are any descenders and second to check if there are any punctuation markers. If yes, we will use value to offset position. If no, we will simply use 0.
You can put if statement in a variable in the following way:
variableHere = (condition) ? ifTrue : ifFalse;
Last step is to figure out if there are descenders or punctuation markers. Since descenders like j and g are bigger than punctuation markers, we want to use them for offset. If there are no descenders present, but there are punctuation markers, we want to use smaller offset.
This is where the previous offset code and sliders come in. At this stage, we are running 2 last if statements in new variables. If there are punctuation markers, but no descenders – use punctuation markers. If this is false, use descenders. If both are true, which means we have descenders and punctuation markers, then we use the first result, which means we are offsetting text by bigger amount (descenders offset).
This code is not pretty. It is segmented and we are running multiple if statements for pretty simple check. I think there is better solution with, for loop way? If you know of better solution, please do get in touch and I will make new tutorial.